Skip to content

Commit

Permalink
Merge pull request #41 from Eoxia/2.2.0
Browse files Browse the repository at this point in the history
2.2.0
  • Loading branch information
nicolas-eoxia authored Oct 2, 2020
2 parents a28a2f9 + 30fb6e6 commit 9d542eb
Show file tree
Hide file tree
Showing 24 changed files with 335 additions and 106 deletions.
2 changes: 1 addition & 1 deletion core/asset/js/backend.min.js

Large diffs are not rendered by default.

Binary file modified core/asset/language/wpshop-fr_FR.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions core/asset/language/wpshop-fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: wpshop\n"
"POT-Creation-Date: 2020-09-03 17:12+0200\n"
"PO-Revision-Date: 2020-09-03 17:21+0200\n"
"PO-Revision-Date: 2020-10-02 16:26+0200\n"
"Last-Translator: \n"
"Language-Team: Eoxia\n"
"Language: fr_FR\n"
Expand Down Expand Up @@ -948,7 +948,7 @@ msgstr "Déjà payé"
#: modules/dolibarr/doli-statut/class/class-doli-statut.php:82
#: modules/dolibarr/doli-statut/class/class-doli-statut.php:100
msgid "Billed"
msgstr "Payé"
msgstr "Facturé"

#: modules/dolibarr/doli-order/view/metabox-order-payment.view.php:68
msgid "Remaining unpaid"
Expand Down
4 changes: 4 additions & 0 deletions modules/dashboard/view/metaboxes/metabox-invoice.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
foreach ( $invoices as $invoice ) : ?>
<div class="table-row">
<div class="table-cell"><a href="<?php echo esc_attr( $dolibarr_url . '/compta/facture/card.php?facid=' . $invoice->data['external_id'] ); ?>"><?php echo esc_html( $invoice->data['title'] ); ?></a></div>
<?php if ( ! empty( $invoice->data['third_party']->data['id'] ) ): ?>
<div class="table-cell break-word"><a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-third-party&id=' . $invoice->data['third_party']->data['id'] ) ); ?>"><?php echo esc_html( $invoice->data['third_party']->data['title'] ); ?></a></div>
<?php else : ?>
<div class="table-cell"><?php esc_html_e('unknown', 'wpshop' ); ?></div>
<?php endif; ?>
<div class="table-cell"><?php echo esc_html( number_format( $invoice->data['total_ttc'], 2, ',', '' ) ); ?>€</div>
<div class="table-cell"><?php echo esc_html( date( 'd/m/Y H:i', strtotime( $invoice->data['datec'] ) ) ); ?></div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions modules/dashboard/view/metaboxes/metabox-order.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
foreach ( $orders as $order ) : ?>
<div class="table-row">
<div class="table-cell"><a href="<?php echo esc_attr( $dolibarr_url . '/commande/card.php?id=' . $order->data['external_id'] ); ?>"><?php echo esc_html( $order->data['title'] ); ?></a></div>
<?php if ( ! empty( $order->data['third_party']->data['id'] ) ): ?>
<div class="table-cell"><a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-third-party&id=' . $order->data['third_party']->data['id'] ) ); ?>"><?php echo esc_html( $order->data['third_party']->data['title'] ); ?></a></div>
<?php else : ?>
<div class="table-cell"><?php esc_html_e('unknown', 'wpshop' ); ?></div>
<?php endif; ?>
<div class="table-cell"><?php echo esc_html( number_format( $order->data['total_ttc'], 2, ',', '' ) ); ?>€</div>
<div class="table-cell"><?php echo esc_html( date( 'd/m/Y H:i', strtotime( $order->data['datec'] ) ) ); ?></div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions modules/dashboard/view/metaboxes/metabox-proposal.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
foreach ( $proposals as $proposal ) : ?>
<div class="table-row">
<div class="table-cell"><a href="<?php echo esc_attr( $dolibarr_url . '/comm/propal/card.php?id=' . $proposal->data['external_id'] ); ?>"><?php echo esc_html( $proposal->data['title'] ); ?></a></div>
<?php if ( ! empty( $proposal->data['third_party']->data['id'] ) ): ?>
<div class="table-cell"><a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-third-party&id=' . $proposal->data['third_party']->data['id'] ) ); ?>"><?php echo esc_html( $proposal->data['third_party']->data['title'] ); ?></a></div>
<?php else : ?>
<div class="table-cell"><?php esc_html_e('unknown', 'wpshop' ); ?></div>
<?php endif; ?>
<div class="table-cell"><?php echo esc_html( number_format( $proposal->data['total_ttc'], 2, ',', '' ) ); ?>€</div>
<div class="table-cell"><?php echo esc_html( date( 'd/m/Y H:i', strtotime( $proposal->data['datec'] ) ) ); ?></div>
</div>
Expand Down
35 changes: 24 additions & 11 deletions modules/dolibarr/doli-categories/class/class-doli-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public function display() {
global $wpdb;
$dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings );
$per_page = get_user_meta( get_current_user_id(), Doli_Category::g()->option_per_page, true );

if ( empty( $per_page ) || 1 > $per_page ) {
$per_page = Doli_Category::g()->limit;
}

$current_page = isset( $_GET['current_page'] ) ? (int) $_GET['current_page'] : 1;

$s = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
Expand All @@ -117,7 +117,7 @@ public function display() {
// La route de dolibarr ne fonctionne pas avec des caractères en base10
$route .= '&sqlfilters=(t.ref%3Alike%3A\'%25' . $s . '%25\')';
}

$wp_categories = Doli_Category::g()->get();

if ( ! empty($wp_categories)) {
Expand All @@ -127,7 +127,7 @@ public function display() {
}
}
}

View_Util::exec( 'wpshop', 'doli-categories', 'list', array(
'categories' => $wp_categories,
'doli_url' => $dolibarr_option['dolibarr_url'],
Expand Down Expand Up @@ -161,7 +161,7 @@ public function display_item( $category, $doli_url = '' ) {
*/
public function convert_to_wp_category_format( $doli_categories ) {
$wp_categories = array();

if ( ! empty( $doli_categories ) ) {
foreach ( $doli_categories as $doli_category ) {
$wp_category = $this->get( array( 'schema' => true ), true );
Expand Down Expand Up @@ -190,26 +190,26 @@ public function doli_to_wp( $doli_category, $wp_category, $save = true, &$notice
) ) {
$category = null;
$doli_category = Request_Util::get( 'categories/' . $doli_category->id ); // Charges par la route single des factures pour avoir accès à linkedObjectsIds->commande.

$wp_category->data['external_id'] = (int) $doli_category->id;

$wp_category->data['name'] = $doli_category->label;
if ( ! empty($doli_category->array_options->options__wps_slug) ) {
$wp_category->data['slug'] = $doli_category->array_options->options__wps_slug;
}
if ( ! empty($doli_category->array_options->options__wps_id) ) {
$wp_category->data['id'] = (int) $doli_category->array_options->options__wps_id;
}

$wp_category = Doli_Category::g()->update( $wp_category->data );

if ( $save ) {
$data_sha = array();
$data_sha = array();
$data_sha['doli_id'] = (int) $wp_category->data['external_id'];
$data_sha['wp_id'] = $wp_category->data['id'];
$data_sha['name'] = $wp_category->data['name'];
$data_sha['slug'] = $wp_category->data['slug'];

$wp_category->data['sync_sha_256'] = hash( 'sha256', implode( ',', $data_sha ) );
//@todo save_post utilisé ?
Expand Down Expand Up @@ -248,6 +248,19 @@ public function search( $s = '', $default_args = array(), $count = false ) {
return 0;
}
}

public function get_related_categories( $object ) {
$related_categories = array();
$related_terms = get_the_terms( $object->data['id'],'wps-product-cat' );
if ( ! empty( $related_terms ) ) {
foreach ( $related_terms as $related_term ) {
$related_categories[] = $related_term->name;
}
}

return $related_categories;

}
}

Doli_Category::g();
3 changes: 2 additions & 1 deletion modules/dolibarr/doli-categories/view/item.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<li><i class="fas fa-hashtag"></i>Doli : <?php echo esc_html( $category->data['external_id'] ); ?></li>
<?php endif; ?>
<li><i class="fas fa-calendar-alt"></i> <?php echo esc_html( $category->data['datec']['rendered']['date_time'] ); ?></li>
</ul>
</ul>
<ul class="reference-title ">
<?php if ( ! empty( $category->data['name'] ) ) : ?>
<?php echo esc_html( $category->data['name'] ); ?>
Expand All @@ -41,6 +41,7 @@
<?php if ( ! empty( $category->data['external_id'] ) ) : ?>
<li><a href="<?php echo esc_attr( $doli_url ); ?>/categories/viewcat.php?id=<?php echo $category->data['external_id']; ?>&type=product" target="_blank"><?php esc_html_e( 'See in Dolibarr', 'wpshop' ); ?></a></li>
<?php endif; ?>
<li><a href="<?php echo esc_attr( home_url() . '/' . $category->data['type'] . '/' . $category->data['slug'] ); ?>" target="_blank"><?php esc_html_e( 'See', 'wpshop' ); ?></a></li>
</ul>
</div>
<div class="table-cell table-300">
Expand Down
20 changes: 12 additions & 8 deletions modules/dolibarr/doli-order/view/item.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@
</ul>
</div>
<div class="table-cell table-200">
<div>
<a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-third-party&id=' . $order->data['tier']->data['id'] ) ); ?>">
<strong><?php echo esc_html( $order->data['tier']->data['title'] ); ?></strong>
</a>
</div>
<div><?php echo esc_html( $order->data['tier']->data['address'] ); ?></div>
<div><?php echo esc_html( $order->data['tier']->data['zip'] ) . ' ' . esc_html( $order->data['tier']->data['country'] ); ?></div>
<div><?php echo esc_html( $order->data['tier']->data['phone'] ); ?></div>
<?php if ( ! empty( $order->data['tier'] ) ) : ?>
<div>
<a href="<?php echo esc_attr( admin_url( 'admin.php?page=wps-third-party&id=' . $order->data['tier']->data['id'] ) ); ?>">
<strong><?php echo esc_html( $order->data['tier']->data['title'] ); ?></strong>
</a>
</div>
<div><?php echo esc_html( $order->data['tier']->data['address'] ); ?></div>
<div><?php echo esc_html( $order->data['tier']->data['zip'] ) . ' ' . esc_html( $order->data['tier']->data['country'] ); ?></div>
<div><?php echo esc_html( $order->data['tier']->data['phone'] ); ?></div>
<?php else : ?>
<div><?php esc_html_e( 'unknown', 'wpshop' ); ?></div>
<?php endif; ?>
</div>
<div class="table-cell table-150"><?php echo Doli_Statut::g()->display_status( $order ); ?></div>
<div class="table-cell table-100"><?php echo esc_html( Payment::g()->get_payment_title( $order->data['payment_method'] ) ); ?></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@
<h4 class="metabox-list-title"><i class="fas fa-building"></i> <?php esc_html_e( 'Informations', 'wpshop' ); ?></h4>
<ul class="metabox-list">
<li><span><?php esc_html_e( 'Date', 'wpshop' ); ?></span> <?php echo esc_html( $order->data['datec']['date_time'] ); ?></li>
<li><span><?php esc_html_e( 'Customer', 'wpshop' ); ?></span> <a href="<?php echo admin_url( 'admin.php?page=wps-third-party&id=' . $third_party->data['id'] ); ?>"><?php echo esc_html( $third_party->data['title'] ); ?></a></li>
<li><span><?php esc_html_e( 'Phone', 'wpshop' ); ?></span> <?php echo esc_html( $third_party->data['phone'] ); ?></li>
<?php if ( ! empty( $third_party->data['id'] ) ): ?>
<li><span><?php esc_html_e( 'Customer', 'wpshop' ); ?></span> <a href="<?php echo admin_url( 'admin.php?page=wps-third-party&id=' . $third_party->data['id'] ); ?>"><?php echo esc_html( $third_party->data['title'] ); ?></a></li>
<li><span><?php esc_html_e( 'Phone', 'wpshop' ); ?></span> <?php echo esc_html( $third_party->data['phone'] ); ?></li>
<?php else : ?>
<li><span><?php esc_html_e('Customer', 'wpshop' ); ?></span> <?php esc_html_e('unknown', 'wpshop' ); ?></li>
<li><span><?php esc_html_e('Phone', 'wpshop' ); ?></span> <?php esc_html_e('unknown', 'wpshop' ); ?></li>
<?php endif; ?>
<li><span><?php esc_html_e( 'Order status', 'wpshop' ); ?></span> <?php echo Doli_Statut::g()->display_status( $order ); ?></li>
<li><span><?php esc_html_e( 'Payment method', 'wpshop' ); ?></span> <?php echo esc_html( Payment::g()->get_payment_title( $order->data['payment_method'] ) ); ?></li>
</ul>
Expand Down
10 changes: 5 additions & 5 deletions modules/dolibarr/doli-sync/action/class-doli-sync-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ public function sync() {
*/
public function sync_entry() {
check_ajax_referer( 'sync_entry' );

$dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings );

$wp_id = ! empty( $_POST['wp_id'] ) ? (int) $_POST['wp_id'] : 0;
$entry_id = ! empty( $_POST['entry_id'] ) ? (int) $_POST['entry_id'] : 0;
$type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '';
$wp_id = ! empty( $_POST['wp_id'] ) ? (int) $_POST['wp_id'] : 0;
$entry_id = ! empty( $_POST['entry_id'] ) ? (int) $_POST['entry_id'] : 0;
$type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '';

$sync_status = Doli_Sync::g()->sync( $wp_id, $entry_id, $type );
$sync_info = Doli_Sync::g()->get_sync_infos( $type );
Expand Down
Loading

0 comments on commit 9d542eb

Please sign in to comment.