From a3a105d83f8c6d8898687e860a9490d8a85361b0 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 5 Aug 2020 12:14:28 +0200 Subject: [PATCH 01/13] Add : Add button for split product --- .../settings/action/class-settings-action.php | 12 +++++------ modules/settings/class/class-settings.php | 21 +++++++++++++++++-- modules/settings/view/general.view.php | 7 +++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/modules/settings/action/class-settings-action.php b/modules/settings/action/class-settings-action.php index 5ecfbf2..c030e2d 100644 --- a/modules/settings/action/class-settings-action.php +++ b/modules/settings/action/class-settings-action.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -118,7 +118,7 @@ public function callback_load_tab() { * Met à jour les options général. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ public function callback_update_general_settings() { check_admin_referer( 'callback_update_general_settings' ); @@ -133,15 +133,15 @@ public function callback_update_general_settings() { $thumbnail_size['width'] = ! empty( $thumbnail_size['width'] ) ? (int) $thumbnail_size['width'] : 0; $thumbnail_size['height'] = ! empty( $thumbnail_size['height'] ) ? (int) $thumbnail_size['height'] : 0; $use_quotation = isset( $_POST['use_quotation'] ) && 'on' == $_POST['use_quotation'] ? true : false; + $split_product = isset( $_POST['split_product'] ) && 'on' == $_POST['split_product'] ? true : false; $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); - $dolibarr_option['shop_email'] = $shop_email; - + $dolibarr_option['shop_email'] = $shop_email; $dolibarr_option['thumbnail_size']['width'] = $thumbnail_size['width']; $dolibarr_option['thumbnail_size']['height'] = $thumbnail_size['height']; - - $dolibarr_option['use_quotation'] = $use_quotation; + $dolibarr_option['use_quotation'] = $use_quotation; + $dolibarr_option['split_product'] = $split_product; update_option( 'wps_dolibarr', $dolibarr_option ); diff --git a/modules/settings/class/class-settings.php b/modules/settings/class/class-settings.php index 51bd1e6..dc0a6da 100644 --- a/modules/settings/class/class-settings.php +++ b/modules/settings/class/class-settings.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -45,7 +45,7 @@ class Settings extends Singleton_Util { * Le constructeur. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ protected function construct() { $this->default_settings = array( @@ -59,6 +59,7 @@ protected function construct() { 'height' => 460, ), 'use_quotation' => true, + 'split_product' => true, 'notice' => array( 'error_erp' => true, 'activate_erp' => true, @@ -285,6 +286,22 @@ public function use_quotation() { return $dolibarr_option['use_quotation']; } + + /** + * Vérifie si la séparation des produits est activé. + * + * @todo a revoir + * + * @since 2.1.0 + * @version 2.1.0 + * + * @return boolean true ou false. + */ + public function split_product() { + $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); + + return $dolibarr_option['split_product']; + } } Settings::g(); diff --git a/modules/settings/view/general.view.php b/modules/settings/view/general.view.php index d0bae64..dfa1285 100644 --- a/modules/settings/view/general.view.php +++ b/modules/settings/view/general.view.php @@ -57,6 +57,13 @@ +
+ +
+
From 1438219f3fa37ff9292bf5fc9834a68c6cad9776 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 5 Aug 2020 12:15:22 +0200 Subject: [PATCH 02/13] Add : Add function split product and description in product --- modules/cart/action/class-cart-action.php | 7 ++++--- modules/cart/class/class-cart.php | 10 ++++++---- modules/cart/view/frontend/cart.php | 11 +++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/cart/action/class-cart-action.php b/modules/cart/action/class-cart-action.php index 24d329a..043e9ea 100644 --- a/modules/cart/action/class-cart-action.php +++ b/modules/cart/action/class-cart-action.php @@ -84,8 +84,9 @@ public function callback_calculate_totals() { public function callback_add_to_cart() { check_ajax_referer( 'add_to_cart' ); - $id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; - $qty = ! empty( $_POST['qty'] ) ? (int) $_POST['qty'] : 1; + $id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; + $qty = ! empty( $_POST['qty'] ) ? (int) $_POST['qty'] : 1; + $desc = ! empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : ''; if ( empty( $id ) ) { wp_send_json_error(); @@ -93,7 +94,7 @@ public function callback_add_to_cart() { $product = Product::g()->get( array( 'id' => $id ), true ); - $added = Cart::g()->add_to_cart( $product, $qty ); + $added = Cart::g()->add_to_cart( $product, $qty, $desc ); ob_start(); include( Template_Util::get_template_part( 'cart', 'link-cart' ) ); diff --git a/modules/cart/class/class-cart.php b/modules/cart/class/class-cart.php index 43dd69e..9f527ac 100644 --- a/modules/cart/class/class-cart.php +++ b/modules/cart/class/class-cart.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -48,14 +48,14 @@ public function can_add_product() { * Ajoute un produit dans le panier. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 * * @param Product $product Les données du produit. * @param integer $qty La quantité à ajouter. * * @return boolean True si tout s'est bien passé. */ - public function add_to_cart( $product, $qty = 1 ) { + public function add_to_cart( $product, $qty = 1, $desc = '' ) { if ( ! $this->can_add_product() ) { return; } @@ -69,9 +69,11 @@ public function add_to_cart( $product, $qty = 1 ) { $index = -1; + if ( ! empty( Cart_Session::g()->cart_contents ) ) { foreach ( Cart_Session::g()->cart_contents as $key => $line ) { - if ( $line['id'] === $product->data['id'] ) { + $data['content'] = $line['content'] . $desc; + if ( $line['id'] === $product->data['id'] && Settings::g()->split_product() == false ) { $data['qty'] = $line['qty'] + $qty; $index = $key; break; diff --git a/modules/cart/view/frontend/cart.php b/modules/cart/view/frontend/cart.php index 70ef63d..a3e668d 100644 --- a/modules/cart/view/frontend/cart.php +++ b/modules/cart/view/frontend/cart.php @@ -16,8 +16,9 @@ /** * Documentation des variables utilisées dans la vue. * -* @var array $cart_contents Les données du panier. -* @var Product $product La donnée d'un produit. +* @var array $cart_contents Le tableau contenant toutes les données du panier. + *@var integer $key Le produit. +* @var Product $product Les données d'un produit. * @var array $shipping_cost_option Les données de frais de livraison. * @var integer $total_price_no_shipping Prix total sans frais de livraison. * @var integer $tva_amount Montant de la TVA. @@ -33,15 +34,13 @@
- $product ) : if ( $shipping_cost_option['shipping_product_id'] !== $product['id'] ) : include( Template_Util::get_template_part( 'products', 'wps-product-list-edit' ) ); endif; endforeach; - endif; - ?> + endif; ?>
From b5564280000255c43bee1042c170494971657925 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 5 Aug 2020 19:47:34 +0200 Subject: [PATCH 03/13] fix : Add desc for first product --- modules/cart/class/class-cart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cart/class/class-cart.php b/modules/cart/class/class-cart.php index 9f527ac..6266709 100644 --- a/modules/cart/class/class-cart.php +++ b/modules/cart/class/class-cart.php @@ -69,10 +69,9 @@ public function add_to_cart( $product, $qty = 1, $desc = '' ) { $index = -1; - if ( ! empty( Cart_Session::g()->cart_contents ) ) { foreach ( Cart_Session::g()->cart_contents as $key => $line ) { - $data['content'] = $line['content'] . $desc; + $data['content'] = $desc; if ( $line['id'] === $product->data['id'] && Settings::g()->split_product() == false ) { $data['qty'] = $line['qty'] + $qty; $index = $key; @@ -85,6 +84,7 @@ public function add_to_cart( $product, $qty = 1, $desc = '' ) { if ( $can_add ) { if ( -1 === $index ) { + $data['content'] = $desc; Cart_Session::g()->add_product( $data ); } else { Cart_Session::g()->update_product( $index, $data ); From 3e1bc2572b6091e3ed2fbc9326e508a3577ae1ea Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 5 Aug 2020 19:48:35 +0200 Subject: [PATCH 04/13] Add : Add language paramater in all document --- modules/checkout/action/class-checkout-action.php | 7 +++++-- .../doli-invoice/action/class-doli-invoice-action.php | 7 +++++-- .../dolibarr/doli-order/action/class-doli-order-action.php | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/checkout/action/class-checkout-action.php b/modules/checkout/action/class-checkout-action.php index ce8da97..9c50ccd 100644 --- a/modules/checkout/action/class-checkout-action.php +++ b/modules/checkout/action/class-checkout-action.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -408,7 +408,9 @@ public function callback_checkout_proposal( $third_party, $contact ) { * Créer la proposition commerciale lors du tunnel de vente. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 + * + * @todo mettre la langue de l'user API pour la génération du doc * * @param Third_Party $third_party Les données du tier. * @param User $contact Les données du contact. @@ -461,6 +463,7 @@ public function callback_checkout_doli_proposal( $third_party, $contact ) { Request_Util::put( 'documents/builddoc', array( 'modulepart' => 'propal', 'original_file' => $doli_proposal->ref . '/' . $doli_proposal->ref . '.pdf', + 'langcode' => 'fr_FR', ) ); Cart_Session::g()->add_external_data( 'doli_proposal_id', $doli_proposal_id ); diff --git a/modules/dolibarr/doli-invoice/action/class-doli-invoice-action.php b/modules/dolibarr/doli-invoice/action/class-doli-invoice-action.php index b5bab85..e94bdb5 100644 --- a/modules/dolibarr/doli-invoice/action/class-doli-invoice-action.php +++ b/modules/dolibarr/doli-invoice/action/class-doli-invoice-action.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -238,7 +238,9 @@ public function meta_box_product( $invoice ) { * Créer la facture si la commande est payé. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 + * + * @todo mettre la langue de l'user API pour la génération du doc * * @param array $data Data from PayPal. */ @@ -287,6 +289,7 @@ public function create_invoice( $data ) { Request_Util::put( 'documents/builddoc', array( 'modulepart' => 'invoice', 'original_file' => $doli_invoice->ref . '/' . $doli_invoice->ref . '.pdf', + 'langcode' => 'fr_FR', ) ); $invoice_file = Request_Util::get( 'documents/download?modulepart=facture&original_file=' . $doli_invoice->ref . '/' . $doli_invoice->ref . '.pdf' ); diff --git a/modules/dolibarr/doli-order/action/class-doli-order-action.php b/modules/dolibarr/doli-order/action/class-doli-order-action.php index 45a1071..0ec4e93 100644 --- a/modules/dolibarr/doli-order/action/class-doli-order-action.php +++ b/modules/dolibarr/doli-order/action/class-doli-order-action.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -373,7 +373,9 @@ public function metabox_order_related_object( $order ) { * Création d'une commande lors du tunnel de vente. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 + * + * @todo mettre la langue de l'user API pour la génération du doc * * @param stdClass $proposal Les données d'une proposition commerciale. * @@ -394,6 +396,7 @@ public function create_order( $proposal ) { Request_Util::put( 'documents/builddoc', array( 'modulepart' => 'order', 'original_file' => $doli_order->ref . '/' . $doli_order->ref . '.pdf', + 'langcode' => 'fr_FR', ) ); $current_user = wp_get_current_user(); From 87396cde50e78c845d04ac63dfaa8740baf97f3f Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 24 Aug 2020 07:18:27 +0200 Subject: [PATCH 05/13] New : Feature on sync media --- core/asset/js/backend.min.js | 2 +- .../asset/doli-documents.backend.js | 74 ++++++ .../class/class-doli-documents.php | 233 ++++++++++++++++++ .../dolibarr/doli-documents/class/index.php | 2 + .../doli-documents/doli-documents.config.json | 12 + modules/dolibarr/doli-documents/index.php | 2 + .../model/class-doli-documents-model.php | 110 +++++++++ .../dolibarr/doli-documents/model/index.php | 2 + .../doli-sync/class/class-doli-sync.php | 8 + modules/products/class/class-product.php | 90 +++++++ .../products/view/metabox/gallery.view.php | 95 +++++++ wpshop.config.json | 3 +- 12 files changed, 631 insertions(+), 2 deletions(-) create mode 100644 modules/dolibarr/doli-documents/asset/doli-documents.backend.js create mode 100644 modules/dolibarr/doli-documents/class/class-doli-documents.php create mode 100644 modules/dolibarr/doli-documents/class/index.php create mode 100644 modules/dolibarr/doli-documents/doli-documents.config.json create mode 100644 modules/dolibarr/doli-documents/index.php create mode 100644 modules/dolibarr/doli-documents/model/class-doli-documents-model.php create mode 100644 modules/dolibarr/doli-documents/model/index.php create mode 100644 modules/products/view/metabox/gallery.view.php diff --git a/core/asset/js/backend.min.js b/core/asset/js/backend.min.js index e888f9b..f2334f5 100644 --- a/core/asset/js/backend.min.js +++ b/core/asset/js/backend.min.js @@ -1 +1 @@ -window.eoxiaJS.wpshop={},window.eoxiaJS.wpshopFrontend={},window.eoxiaJS.wpshop.init=function(){jQuery(".wps-sync").length&&jQuery(".wps-sync").each(function(){var e={action:"check_sync_status",wp_id:jQuery(this).find(".button-synchro").data("wp-id"),type:jQuery(this).find(".button-synchro").data("type")};window.eoxiaJS.loader.display(jQuery(this));var o=jQuery(this);jQuery.post(ajaxurl,e,function(e){window.eoxiaJS.loader.remove(o),o.replaceWith(e.data.view),e.data.status&&"0x1"==e.data.status.status_code&&jQuery('.table-row[data-id="'+e.data.id+'"] .reference-id li:last').remove()}).fail(function(){window.eoxiaJS.loader.remove(o),o.find(".statut").attr("aria-label","500 (Internal Server Error)"),o.find(".statut").addClass("statut-red")})});var e={action:"check_erp_statut",_wpnonce:scriptParams.check_erp_statut_nonce};jQuery.post(ajaxurl,e,function(e){!e.data.statut&&e.data.view&&jQuery("body").append(e.data.view)})},window.eoxiaJS.wpshop.API={},window.eoxiaJS.wpshop.API.init=function(){},window.eoxiaJS.wpshop.API.generatedAPIKey=function(e,o){e.closest(".wpshop-fields").replaceWith(o.data.view)},window.eoxiaJS.wpshop.thirdParties={},window.eoxiaJS.wpshop.thirdParties.init=function(){window.eoxiaJS.wpshop.thirdParties.event()},window.eoxiaJS.wpshop.thirdParties.event=function(){jQuery(document).on("click","#wps-third-party-contact .add-contact",window.eoxiaJS.wpshop.thirdParties.toggleContactFormNew),jQuery(document).on("click",".wpeo-autocomplete.search-contact .autocomplete-search-list .autocomplete-result",window.eoxiaJS.wpshop.thirdParties.putContactID)},window.eoxiaJS.wpshop.thirdParties.toggleContactFormNew=function(){jQuery("#wps-third-party-contact .row.new").toggle()},window.eoxiaJS.wpshop.thirdParties.putContactID=function(){jQuery(this).closest(".wpeo-autocomplete").find(".button-associate-contact").attr("data-contact-id",jQuery(this).data("id")),jQuery(this).closest(".wpeo-autocomplete").find("input#search-contact").val(jQuery(this).data("result"))},window.eoxiaJS.wpshop.thirdParties.loaddedTitleEdit=function(e,o){e.closest("h2").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.savedThird=function(e,o){e.closest("h2").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.loaddedBillingAddressSuccess=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.savedBillingAddressSuccess=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.loaddedContactSuccess=function(e,o){e.closest("tr").replaceWith(o.data.view)},window.eoxiaJS.wpshop.thirdParties.savedContact=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.associatedContactSuccess=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.tools={},window.eoxiaJS.wpshop.tools.init=function(){jQuery(document).on("click",".import-third-party .wpeo-button.button-primary",window.eoxiaJS.wpshop.tools.importThirdParty),jQuery(document).on("click",".import-product .wpeo-button.button-primary",window.eoxiaJS.wpshop.tools.importProduct)},window.eoxiaJS.wpshop.tools.importThirdParty=function(e){var o=new FormData;e.preventDefault(),o.append("file",jQuery(".import-third-party input[type=file]")[0].files[0]),o.append("action","import_third_party"),o.append("_wpnonce",jQuery(this).closest("form").find('input[name="_wpnonce"]').val()),o.append("index_element",0),window.eoxiaJS.wpshop.tools.requestImportThirdParty(o)},window.eoxiaJS.wpshop.tools.importProduct=function(e){var o=new FormData;e.preventDefault(),o.append("file",jQuery(".import-product input[type=file]")[0].files[0]),o.append("action","import_third_party"),o.append("_wpnonce",jQuery(this).closest("form").find('input[name="_wpnonce"]').val()),o.append("index_element",0),window.eoxiaJS.wpshop.tools.requestImportProduct(o)},window.eoxiaJS.wpshop.tools.requestImportThirdParty=function(e){jQuery.ajax({url:ajaxurl,data:e,processData:!1,contentType:!1,type:"POST",beforeSend:function(){window.eoxiaJS.loader.display(jQuery(".import-third-party .wpeo-button")),jQuery(".import-details").html("In progress")},success:function(e){var o=new FormData;e.success&&(jQuery(".import-third-party progress").attr("max",e.data.count_element),jQuery(".import-third-party progress").val(e.data.index_element/e.data.count_element*e.data.count_element),e.data.end?(jQuery(".import-detail").html("Importation terminé"),window.eoxiaJS.loader.remove(jQuery(".import-third-party .wpeo-button"))):(o.append("action","import_third_party"),o.append("_wpnonce",jQuery(".import-third-party").find('input[name="_wpnonce"]').val()),o.append("path_to_json",e.data.path_to_json),o.append("index_element",e.data.index_element),o.append("count_element",e.data.count_element),jQuery(".import-detail").html("Progress"),window.eoxiaJS.wpshop.tools.requestImport(o)))}})},window.eoxiaJS.wpshop.tools.requestImportProduct=function(e){jQuery.ajax({url:ajaxurl,data:e,processData:!1,contentType:!1,type:"POST",beforeSend:function(){window.eoxiaJS.loader.display(jQuery(".import-product .wpeo-button")),jQuery(".import-details").html("In progress")},success:function(e){var o=new FormData;e.success&&(jQuery(".import-product progress").attr("max",e.data.count_element),jQuery(".import-product progress").val(e.data.index_element/e.data.count_element*e.data.count_element),e.data.end?(jQuery(".import-detail").html("Importation terminé"),window.eoxiaJS.loader.remove(jQuery(".import-product .wpeo-button"))):(o.append("action","import_product"),o.append("_wpnonce",jQuery(".import-product").find('input[name="_wpnonce"]').val()),o.append("path_to_json",e.data.path_to_json),o.append("index_element",e.data.index_element),o.append("count_element",e.data.count_element),jQuery(".import-detail").html("Progress"),window.eoxiaJS.wpshop.tools.requestImportProduct(o)))}})},window.eoxiaJS.wpshop.product={},window.eoxiaJS.wpshop.product.init=function(){window.eoxiaJS.wpshop.product.event()},window.eoxiaJS.wpshop.product.event=function(){jQuery(document).on("wps-change-toggle",".stock-field .toggle",window.eoxiaJS.wpshop.product.displayBlockStock),jQuery(document).on("click",'.wps-list-product .table-header input[type="checkbox"]',window.eoxiaJS.wpshop.product.checkAll),jQuery(document).on("click",".button-apply",window.eoxiaJS.wpshop.product.apply),jQuery(document).ready(window.eoxiaJS.wpshop.product.autoSynchro),jQuery(".similar-product").select2({ajax:{url:scriptParams.url+"/wp-json/wpshop/v2/product/search",data:function(e){return{s:e.term}},processResults:function(e){var o=[];for(var t in e){var i={id:e[t].id,text:e[t].title};o.push(i)}return{results:o}},cache:!0},minimumInputLength:1})},window.eoxiaJS.wpshop.product.displayBlockStock=function(e,o){o?jQuery(".stock-block").fadeIn():jQuery(".stock-block").fadeOut()},window.eoxiaJS.wpshop.product.checkAll=function(){jQuery(this).is(":checked")?jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!0):jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!1)},window.eoxiaJS.wpshop.product.apply=function(){"quick-edit"===jQuery(".select-apply").val()&&jQuery(".wps-list-product .table-row:not(.table-header)").each(function(){jQuery(this).find('input[type="checkbox"]').is(":checked")&&jQuery(this).find('.action-attribute[data-action="change_mode"]').click()})},window.eoxiaJS.wpshop.product.autoSynchro=function(e){jQuery(this).find('.button-synchro[data-entry-id="1"]')},window.eoxiaJS.wpshop.product.changeMode=function(e,o){jQuery(e).closest("div.table-row").replaceWith(o.data.view)},window.eoxiaJS.wpshop.settings={},window.eoxiaJS.wpshop.settings.init=function(){},window.eoxiaJS.wpshop.settings.dismiss=function(e,o){jQuery(".notice-erp").fadeOut()},window.eoxiaJS.wpshop.doliAssociate={},window.eoxiaJS.wpshop.doliAssociate.init=function(){jQuery(document).on("keyup",".synchro-single .filter-entry",window.eoxiaJS.wpshop.doliAssociate.filter),jQuery(document).on("click",".synchro-single li",window.eoxiaJS.wpshop.doliAssociate.clickEntry)},window.eoxiaJS.wpshop.doliAssociate.filter=function(e){var o=jQuery(".synchro-single ul.select li");o.show();for(var t=jQuery(this).val().toLowerCase(),i=0;i'),d.val(e.id)}),o.open()}),a.on("click",function(e){e.preventDefault(),n.html(""),i.removeClass("hidden"),a.addClass("hidden"),d.val("")})}),window.eoxiaJS.wpshop.product={},window.eoxiaJS.wpshop.product.init=function(){window.eoxiaJS.wpshop.product.event()},window.eoxiaJS.wpshop.product.event=function(){jQuery(document).on("wps-change-toggle",".stock-field .toggle",window.eoxiaJS.wpshop.product.displayBlockStock),jQuery(document).on("click",'.wps-list-product .table-header input[type="checkbox"]',window.eoxiaJS.wpshop.product.checkAll),jQuery(document).on("click",".button-apply",window.eoxiaJS.wpshop.product.apply),jQuery(document).ready(window.eoxiaJS.wpshop.product.autoSynchro),jQuery(".similar-product").select2({ajax:{url:scriptParams.url+"/wp-json/wpshop/v2/product/search",data:function(e){return{s:e.term}},processResults:function(e){var o=[];for(var t in e){var i={id:e[t].id,text:e[t].title};o.push(i)}return{results:o}},cache:!0},minimumInputLength:1})},window.eoxiaJS.wpshop.product.displayBlockStock=function(e,o){o?jQuery(".stock-block").fadeIn():jQuery(".stock-block").fadeOut()},window.eoxiaJS.wpshop.product.checkAll=function(){jQuery(this).is(":checked")?jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!0):jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!1)},window.eoxiaJS.wpshop.product.apply=function(){"quick-edit"===jQuery(".select-apply").val()&&jQuery(".wps-list-product .table-row:not(.table-header)").each(function(){jQuery(this).find('input[type="checkbox"]').is(":checked")&&jQuery(this).find('.action-attribute[data-action="change_mode"]').click()})},window.eoxiaJS.wpshop.product.autoSynchro=function(e){jQuery(this).find('.button-synchro[data-entry-id="1"]')},window.eoxiaJS.wpshop.product.changeMode=function(e,o){jQuery(e).closest("div.table-row").replaceWith(o.data.view)},window.eoxiaJS.wpshop.settings={},window.eoxiaJS.wpshop.settings.init=function(){},window.eoxiaJS.wpshop.settings.dismiss=function(e,o){jQuery(".notice-erp").fadeOut()},window.eoxiaJS.wpshop.doliAssociate={},window.eoxiaJS.wpshop.doliAssociate.init=function(){jQuery(document).on("keyup",".synchro-single .filter-entry",window.eoxiaJS.wpshop.doliAssociate.filter),jQuery(document).on("click",".synchro-single li",window.eoxiaJS.wpshop.doliAssociate.clickEntry)},window.eoxiaJS.wpshop.doliAssociate.filter=function(e){var o=jQuery(".synchro-single ul.select li");o.show();for(var t=jQuery(this).val().toLowerCase(),i=0;i' ); + + // Send the attachment id to our hidden input + imgIdInput.val( attachment.id ); + + // Hide the add image link + //addImgLink.addClass( 'hidden' ); + + // Unhide the remove image link + //delImgLink.removeClass( 'hidden' ); + }); + + // Finally, open the modal on click + frame.open(); + }); + + // DELETE IMAGE LINK + delImgLink.on( 'click', function( event ){ + + event.preventDefault(); + + // Clear out the preview image + imgContainer.html( '' ); + + // Un-hide the add image link + addImgLink.removeClass( 'hidden' ); + + // Hide the delete image link + delImgLink.addClass( 'hidden' ); + + // Delete the image id from the hidden input + imgIdInput.val( '' ); + + }); + +}); diff --git a/modules/dolibarr/doli-documents/class/class-doli-documents.php b/modules/dolibarr/doli-documents/class/class-doli-documents.php new file mode 100644 index 0000000..8f743dc --- /dev/null +++ b/modules/dolibarr/doli-documents/class/class-doli-documents.php @@ -0,0 +1,233 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +use eoxia\Post_Class; +use stdClass; + +defined( 'ABSPATH' ) || exit; + +/** + * Doli Documents Class. + */ +class Doli_Documents extends Post_Class { + + /** + * Le nom du modèle. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @var string + */ + protected $model_name = '\wpshop\Doli_Documents_Model'; + + /** + * Le post type. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @var string + */ + protected $type = 'wps-documents'; + + /** + * La clé principale du modèle. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @var string + */ + protected $meta_key = 'documents'; + + /** + * La route pour accéder à l'objet dans la rest API. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @var string + */ + protected $base = 'documents'; + + /** + * Le nom du post type. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @var string + */ + protected $post_type_name = 'documents'; + + /** + * Appel la vue "list" du module "doli-order". + * + * @since 2.0.0 + * @version 2.0.0 + */ + public function display() { + $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); + $per_page = get_user_meta( get_current_user_id(), Doli_Order::g()->option_per_page, true ); + + if ( empty( $per_page ) || 1 > $per_page ) { + $per_page = Doli_Order::g()->limit; + } + + $current_page = isset( $_GET['current_page'] ) ? (int) $_GET['current_page'] : 1; + + $s = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; + + $route = 'orders?sortfield=t.rowid&sortorder=DESC&limit=' . $per_page . '&page=' . ( $current_page - 1 ); + + if ( ! empty( $s ) ) { + // La route de dolibarr ne fonctionne pas avec des caractères en base10 + $route .= '&sqlfilters=(t.ref%3Alike%3A\'%25' . $s . '%25\')'; + } + + $doli_orders = Request_Util::get( $route ); + $orders = $this->convert_to_wp_order_format( $doli_orders ); + + if ( ! empty( $orders ) ) { + foreach ( $orders as &$element ) { + $element->data['tier'] = Third_Party::g()->get( array( 'id' => $element->data['parent_id'] ), true ); + $element->data['datec'] = \eoxia\Date_Util::g()->fill_date( $element->data['datec'] ); + } + } + + View_Util::exec( 'wpshop', 'doli-order', 'list', array( + 'orders' => $orders, + 'doli_url' => $dolibarr_option['dolibarr_url'], + ) ); + } + + /** + * Appel la vue "item" d'une commande. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @param Doli_Order $order Les données d'une commande. + * @param string $doli_url L'url de Dolibarr. + */ + public function display_item( $order, $doli_url = '' ) { + if ( empty( $order->data['tier'] ) ) { + $order->data['tier'] = Third_Party::g()->get( array( 'id' => $order->data['parent_id'] ), true ); + } + View_Util::exec( 'wpshop', 'doli-order', 'item', array( + 'order' => $order, + 'doli_url' => $doli_url, + ) ); + } + + /** + * Convertit un tableau Documents Object provenant de Dolibarr vers un format Documents Object WPshop afin de normisé pour l'affichage. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @param stdClass $doli_documents Le tableau contenant toutes les données des documents provenant de Dolibarr. + * + * @return Doli_Documents Le tableau contenant toutes les données des documents convertis depuis le format de Dolibarr. + */ + public function convert_to_wp_documents_format( $doli_documents ) { + $wp_documents = array(); + + if ( ! empty( $doli_documents ) ) { + foreach ( $doli_documents as $doli_document ) { + $wp_document = $this->get( array( 'schema' => true ), true ); + $wp_documents[] = $this->doli_to_wp( $doli_document, $wp_document, true ); + } + } + + return $wp_documents; + } + + /** + * Synchronisation depuis Dolibarr vers WP. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @param stdClass $doli_document Les données d'un document Dolibarr. + * @param Doli_Documents $wp_document Les données d'un document WordPress. + * @param boolean $only_convert Only Convert Dolibarr Object to WP. Don't save the WP Object on the database. + * + * @return Doli_Documents Les données d'un document WordPress avec ceux de Dolibarr. + */ + public function doli_to_wp( $doli_document, $wp_document, $only_convert = false ) { + if ( is_object( $wp_document ) ) { + //$wp_document->data['external_id'] = (int) $doli_document->id; + $wp_document->data['name'] = $doli_document->name; + $wp_document->data['path'] = $doli_document->path; + $wp_document->data['fullpath'] = $doli_document->fullname; + $time = get_date_from_gmt ( date( 'Y-m-d H:i:s', $doli_document->date ) ); + $wp_document->data['date'] = $time; + $wp_document->data['size'] = (int) $doli_document->size; + $wp_document->data['dolibarr_type'] = $doli_document->type; + //$wp_document->data['parent_id'] = Doli_Products::g()->get_wp_id_by_doli_id( $doli_document->socid ); + + $wp_document->data['linked_objects_ids'] = array(); + + // @todo: Répéter dans toutes les méthode doli_to_wp. Mettre dans CommonObject. + if ( ! empty( $doli_document->linkedObjectsIds ) ) { + foreach ( $doli_document->linkedObjectsIds as $key => $values ) { + $values = (array) $values; + $wp_document->data['linked_objects_ids'][ $key ] = array(); + + if ( ! empty( $values ) ) { + foreach ( $values as $value ) { + $wp_document->data['linked_objects_ids'][ $key ][] = (int) $value; + } + } + } + } + + if ( ! $only_convert ) { + $wp_document = $this->update( $wp_document->data ); + } + } + return $wp_document; + } + + /** + * Fonction de recherche. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @param string $s Le terme de la recherche. + * @param array $default_args Les arguments par défaut. + * @param boolean $count Si true compte le nombre d'élement, sinon renvoies l'ID des éléments trouvés. + * + * @return array|integer Les ID des éléments trouvés ou le nombre d'éléments trouvés. + */ + public function search( $s = '', $default_args = array(), $count = false ) { + $route = 'orders?sortfield=t.rowid&sortorder=DESC'; + + if ( ! empty( $s ) ) { + $route .= '&sqlfilters=(t.ref%3Alike%3A\'%25' . $s . '%25\')'; + } + + $doli_orders = Request_Util::get( $route ); + + if ( $count && ! empty( $doli_orders ) ) { + return count( $doli_orders ); + } else { + return 0; + } + } +} + +Doli_Documents::g(); diff --git a/modules/dolibarr/doli-documents/class/index.php b/modules/dolibarr/doli-documents/class/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/modules/dolibarr/doli-documents/class/index.php @@ -0,0 +1,2 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +use eoxia\Post_Model; + +defined( 'ABSPATH' ) || exit; + +/** + * Doli Documents Model Class. + */ +class Doli_Documents_Model extends Post_Model { + + /** + * Le constructeur. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param Doli_Order $object Les données de l'objet. + * @param string $req_method La méthode de la requête. + */ + public function __construct( $object, $req_method = null ) { + + $this->schema['external_id'] = array( + 'type' => 'integer', + 'meta_type' => 'single', + 'field' => '_external_id', + 'since' => '2.0.0', + 'version' => '2.0.0', + 'description' => 'L\'ID du customer (dolibarr). Relation avec dolibarr.', + ); + + $this->schema['name'] = array( + 'type' => 'string', + 'meta_type' => 'single', + 'field' => 'name', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Le nom du document.', + ); + + $this->schema['path'] = array( + 'type' => 'string', + 'meta_type' => 'single', + 'field' => 'path', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Le chemin d\'accès au document.', + ); + + $this->schema['fullpath'] = array( + 'type' => 'string', + 'meta_type' => 'single', + 'field' => 'guid', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Le chemin d\'acces total au document.', + ); + + $this->schema['date'] = array( + 'type' => 'wpeo_date', + 'meta_type' => 'single', + 'field' => 'date', + 'context' => array( 'GET' ), + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Date de création du document. Relation avec dolibarr', + ); + + $this->schema['size'] = array( + 'type' => 'integer', + 'meta_type' => 'single', + 'field' => 'size', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'La taille du document en Ko.', + ); + + $this->schema['dolibarr_type'] = array( + 'type' => 'string', + 'meta_type' => 'single', + 'field' => 'type', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Le type de document.', + ); + + $this->schema['linked_objects_ids'] = array( + 'type' => 'array', + 'meta_type' => 'single', + 'field' => '_linked_objects_ids', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'L\'id des objets liés.', + 'default' => null, + ); + + parent::__construct( $object, $req_method ); + } +} diff --git a/modules/dolibarr/doli-documents/model/index.php b/modules/dolibarr/doli-documents/model/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/modules/dolibarr/doli-documents/model/index.php @@ -0,0 +1,2 @@ +get( array( 'id' => $wp_id ), true ); + + Doli_Proposals::g()->doli_to_wp( $doli_documents, $wp_proposal ); + + $wp_object = $wp_proposal; + break;*/ default: break; } diff --git a/modules/products/class/class-product.php b/modules/products/class/class-product.php index 39e5b6c..7499720 100644 --- a/modules/products/class/class-product.php +++ b/modules/products/class/class-product.php @@ -192,6 +192,14 @@ public function callback_register_meta_box() { array( $this, 'callback_add_meta_box' ), 'wps-product' ); + + add_meta_box( + 'wps_product_gallery', + __( 'Product Gallery', 'wpshop'), + array( $this, 'callback_add_meta_box_gallery' ), + 'wps-product', + 'side' + ); } /** @@ -231,6 +239,88 @@ public function callback_add_meta_box( $post ) { ) ); } + /** + * La vue de la metabox pour configurer le produit. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param WP_Post $post Le produit. + */ + public function callback_add_meta_box_gallery( $post ) { + $product = $this->get( array( 'id' => $post->ID ), true ); + + if ( empty( $product ) ) { + $product = $this->get( array( 'schema' => true ), true ); + } + + if ( ! empty( $product->data['fk_product_parent'] ) ) { + $parent_post = get_post( Doli_Products::g()->get_wp_id_by_doli_id( $product->data['fk_product_parent'] ) ); + + $product->data['parent_post'] = $parent_post; + } + + $wp_upload_dir = wp_upload_dir(); + + $doli_documents = Request_Util::get( 'documents?modulepart=product&id=' . $product->data['external_id'] ); + $wp_documents = Doli_Documents::g()->convert_to_wp_documents_format( $doli_documents ); + if ( ! empty ( $wp_documents ) ) { + $attachments = get_children( array( 'post_parent' => $product->data['external_id'], 'post_type' => 'attachment' ) ); + if ( empty ( $attachments ) ) { + foreach ( $wp_documents as $key => $wp_document ) { + + $uploadfile = $wp_upload_dir['path'] . '/' . $wp_document->data['name']; + + $contents = file_get_contents( $wp_document->data['fullpath'] ); + $savefile = fopen( $uploadfile, 'w' ); + fwrite( $savefile, $contents ); + fclose( $savefile ); + + $filetype = wp_check_filetype( basename( $wp_document->data['fullpath'] ), null ); + + $args = array( + 'post_name' => $wp_document->data['name'], + 'post_mime_type' => $filetype['type'], + 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $wp_document->data['fullpath'] ) ), + 'meta_input' => array( + 'path' => $wp_document->data['path'], + 'fullpath' => $wp_document->data['fullpath'], + 'date' => $wp_document->data['date'], + 'size' => $wp_document->data['size'], + 'dolibarr_type' => $wp_document->data['dolibarr_type'], + ), + ); + $attachment_id = wp_insert_attachment( $args, $uploadfile, $product->data['external_id'] ); + require_once( ABSPATH . 'wp-admin/includes/image.php' ); + $attached_file = get_post_meta( $attachment_id , '_wp_attached_file', true ); + $attach_data = wp_generate_attachment_metadata( $attachment_id,$wp_upload_dir['baseurl'] . '/' . $attached_file ); + wp_update_attachment_metadata( $attachment_id, $attach_data ); + } + } + } + + $attachment = array(); + foreach ( $attachments as $key => $attachment_object ) { + foreach ( $attachment_object as $key => $attachment_data ) { + $attachment[$key] = $attachment_data; + $attachment['fullpath'] = get_post_meta( $attachment_object->ID , 'fullpath', true ); + $attachment['size'] = get_post_meta( $attachment_object->ID , 'size', true ); + $attachment['attached_file'] = get_post_meta( $attachment_object->ID , '_wp_attached_file', true ); + } + $attachments[$attachment_object->ID] = $attachment; + } + + $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); + View_Util::exec( 'wpshop', 'products', 'metabox/gallery', array( + 'id' => ! empty( $product->data['id'] ) ? $product->data['id'] : $post->ID, + 'wp_upload_dir' => $wp_upload_dir, + 'attachments' => $attachments, + 'product' => $product, + 'doli_url' => $dolibarr_option['dolibarr_url'], + 'sync_status' => false, + ) ); + } + /** * Fonction de recherche. * diff --git a/modules/products/view/metabox/gallery.view.php b/modules/products/view/metabox/gallery.view.php new file mode 100644 index 0000000..6181583 --- /dev/null +++ b/modules/products/view/metabox/gallery.view.php @@ -0,0 +1,95 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.0.0 + * @version 2.0.0 + */ + +namespace wpshop; + +defined( 'ABSPATH' ) || exit; + +/** + * Documentation des variables utilisées dans la vue. + * + * @var Product $product Les données d'un produit. + * @var string $sync_status True si on affiche le statut de la synchronisation. + * @var string $doli_url L'url de Dolibarr. + * @var boolean $has_selected True si le produit est selectionné. + * @var array $tva Les types de TVA. + * @var string $selected L'attribut HTML "selected". + * @var array $similar_products Le tableau contenant toutes les données des produits similaires. + * @var Product $similar_product Les données d'un produit similaire. + */ +?> + + + + + + +'; print_r($attachment); echo ''; exit; ?> + + + + + + + + + + + + +ID ) ); + +// See if there's a media id already saved as post meta +$your_img_id = get_post_meta( $post->ID, '_thumbnail_id', true ); + +// Get the image src +$your_img_src = wp_get_attachment_image_src( $your_img_id, 'full' ); + +// For convenience, see if the array is valid +$you_have_img = is_array( $your_img_src ); +?> + + +
+
    --> + + '; print_r($attachment); echo ''; exit; ?> +
  • + +
  • + + +
+ + + +
+ + +

+ + + + + + +

+ + + diff --git a/wpshop.config.json b/wpshop.config.json index 9f1e035..6f31ae4 100644 --- a/wpshop.config.json +++ b/wpshop.config.json @@ -45,7 +45,8 @@ "modules/dolibarr/doli-payment/doli-payment.config.json", "modules/dolibarr/doli-products/doli-products.config.json", "modules/dolibarr/doli-sync/doli-sync.config.json", - "modules/dolibarr/doli-associate/doli-associate.config.json" + "modules/dolibarr/doli-associate/doli-associate.config.json", + "modules/dolibarr/doli-documents/doli-documents.config.json" ], "use_global_sync": true } From adb568aa3c160e89f463ec7f31383c2f9705bcb5 Mon Sep 17 00:00:00 2001 From: nicolas-eoxia Date: Mon, 24 Aug 2020 17:56:53 +0200 Subject: [PATCH 06/13] New : feature Media --- core/asset/js/backend.min.js | 2 +- .../asset/doli-documents.backend.js | 26 +++++- .../class/class-doli-documents.php | 92 +------------------ .../model/class-doli-documents-model.php | 8 +- .../filter/class-doli-sync-filter.php | 28 ++++++ modules/products/class/class-product.php | 63 +++++++------ .../products/view/metabox/gallery.view.php | 2 +- 7 files changed, 96 insertions(+), 125 deletions(-) diff --git a/core/asset/js/backend.min.js b/core/asset/js/backend.min.js index f2334f5..0f13bed 100644 --- a/core/asset/js/backend.min.js +++ b/core/asset/js/backend.min.js @@ -1 +1 @@ -window.eoxiaJS.wpshop={},window.eoxiaJS.wpshopFrontend={},window.eoxiaJS.wpshop.init=function(){jQuery(".wps-sync").length&&jQuery(".wps-sync").each(function(){var e={action:"check_sync_status",wp_id:jQuery(this).find(".button-synchro").data("wp-id"),type:jQuery(this).find(".button-synchro").data("type")};window.eoxiaJS.loader.display(jQuery(this));var o=jQuery(this);jQuery.post(ajaxurl,e,function(e){window.eoxiaJS.loader.remove(o),o.replaceWith(e.data.view),e.data.status&&"0x1"==e.data.status.status_code&&jQuery('.table-row[data-id="'+e.data.id+'"] .reference-id li:last').remove()}).fail(function(){window.eoxiaJS.loader.remove(o),o.find(".statut").attr("aria-label","500 (Internal Server Error)"),o.find(".statut").addClass("statut-red")})});var e={action:"check_erp_statut",_wpnonce:scriptParams.check_erp_statut_nonce};jQuery.post(ajaxurl,e,function(e){!e.data.statut&&e.data.view&&jQuery("body").append(e.data.view)})},window.eoxiaJS.wpshop.API={},window.eoxiaJS.wpshop.API.init=function(){},window.eoxiaJS.wpshop.API.generatedAPIKey=function(e,o){e.closest(".wpshop-fields").replaceWith(o.data.view)},window.eoxiaJS.wpshop.thirdParties={},window.eoxiaJS.wpshop.thirdParties.init=function(){window.eoxiaJS.wpshop.thirdParties.event()},window.eoxiaJS.wpshop.thirdParties.event=function(){jQuery(document).on("click","#wps-third-party-contact .add-contact",window.eoxiaJS.wpshop.thirdParties.toggleContactFormNew),jQuery(document).on("click",".wpeo-autocomplete.search-contact .autocomplete-search-list .autocomplete-result",window.eoxiaJS.wpshop.thirdParties.putContactID)},window.eoxiaJS.wpshop.thirdParties.toggleContactFormNew=function(){jQuery("#wps-third-party-contact .row.new").toggle()},window.eoxiaJS.wpshop.thirdParties.putContactID=function(){jQuery(this).closest(".wpeo-autocomplete").find(".button-associate-contact").attr("data-contact-id",jQuery(this).data("id")),jQuery(this).closest(".wpeo-autocomplete").find("input#search-contact").val(jQuery(this).data("result"))},window.eoxiaJS.wpshop.thirdParties.loaddedTitleEdit=function(e,o){e.closest("h2").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.savedThird=function(e,o){e.closest("h2").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.loaddedBillingAddressSuccess=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.savedBillingAddressSuccess=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.loaddedContactSuccess=function(e,o){e.closest("tr").replaceWith(o.data.view)},window.eoxiaJS.wpshop.thirdParties.savedContact=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.thirdParties.associatedContactSuccess=function(e,o){e.closest(".inside").html(o.data.view)},window.eoxiaJS.wpshop.tools={},window.eoxiaJS.wpshop.tools.init=function(){jQuery(document).on("click",".import-third-party .wpeo-button.button-primary",window.eoxiaJS.wpshop.tools.importThirdParty),jQuery(document).on("click",".import-product .wpeo-button.button-primary",window.eoxiaJS.wpshop.tools.importProduct)},window.eoxiaJS.wpshop.tools.importThirdParty=function(e){var o=new FormData;e.preventDefault(),o.append("file",jQuery(".import-third-party input[type=file]")[0].files[0]),o.append("action","import_third_party"),o.append("_wpnonce",jQuery(this).closest("form").find('input[name="_wpnonce"]').val()),o.append("index_element",0),window.eoxiaJS.wpshop.tools.requestImportThirdParty(o)},window.eoxiaJS.wpshop.tools.importProduct=function(e){var o=new FormData;e.preventDefault(),o.append("file",jQuery(".import-product input[type=file]")[0].files[0]),o.append("action","import_third_party"),o.append("_wpnonce",jQuery(this).closest("form").find('input[name="_wpnonce"]').val()),o.append("index_element",0),window.eoxiaJS.wpshop.tools.requestImportProduct(o)},window.eoxiaJS.wpshop.tools.requestImportThirdParty=function(e){jQuery.ajax({url:ajaxurl,data:e,processData:!1,contentType:!1,type:"POST",beforeSend:function(){window.eoxiaJS.loader.display(jQuery(".import-third-party .wpeo-button")),jQuery(".import-details").html("In progress")},success:function(e){var o=new FormData;e.success&&(jQuery(".import-third-party progress").attr("max",e.data.count_element),jQuery(".import-third-party progress").val(e.data.index_element/e.data.count_element*e.data.count_element),e.data.end?(jQuery(".import-detail").html("Importation terminé"),window.eoxiaJS.loader.remove(jQuery(".import-third-party .wpeo-button"))):(o.append("action","import_third_party"),o.append("_wpnonce",jQuery(".import-third-party").find('input[name="_wpnonce"]').val()),o.append("path_to_json",e.data.path_to_json),o.append("index_element",e.data.index_element),o.append("count_element",e.data.count_element),jQuery(".import-detail").html("Progress"),window.eoxiaJS.wpshop.tools.requestImport(o)))}})},window.eoxiaJS.wpshop.tools.requestImportProduct=function(e){jQuery.ajax({url:ajaxurl,data:e,processData:!1,contentType:!1,type:"POST",beforeSend:function(){window.eoxiaJS.loader.display(jQuery(".import-product .wpeo-button")),jQuery(".import-details").html("In progress")},success:function(e){var o=new FormData;e.success&&(jQuery(".import-product progress").attr("max",e.data.count_element),jQuery(".import-product progress").val(e.data.index_element/e.data.count_element*e.data.count_element),e.data.end?(jQuery(".import-detail").html("Importation terminé"),window.eoxiaJS.loader.remove(jQuery(".import-product .wpeo-button"))):(o.append("action","import_product"),o.append("_wpnonce",jQuery(".import-product").find('input[name="_wpnonce"]').val()),o.append("path_to_json",e.data.path_to_json),o.append("index_element",e.data.index_element),o.append("count_element",e.data.count_element),jQuery(".import-detail").html("Progress"),window.eoxiaJS.wpshop.tools.requestImportProduct(o)))}})},jQuery(function(e){var o,t=e("#wps_product_gallery.postbox"),i=t.find(".upload-custom-img"),a=t.find(".delete-custom-img"),n=t.find(".custom-img-container"),d=t.find(".custom-img-id");i.on("click",function(e){e.preventDefault(),o||(o=wp.media({title:"Select or Upload Media Of Your Chosen Persuasion",button:{text:"Use this media"},multiple:!0})).on("select",function(){var e=o.state().get("selection").first().toJSON();n.append(''),d.val(e.id)}),o.open()}),a.on("click",function(e){e.preventDefault(),n.html(""),i.removeClass("hidden"),a.addClass("hidden"),d.val("")})}),window.eoxiaJS.wpshop.product={},window.eoxiaJS.wpshop.product.init=function(){window.eoxiaJS.wpshop.product.event()},window.eoxiaJS.wpshop.product.event=function(){jQuery(document).on("wps-change-toggle",".stock-field .toggle",window.eoxiaJS.wpshop.product.displayBlockStock),jQuery(document).on("click",'.wps-list-product .table-header input[type="checkbox"]',window.eoxiaJS.wpshop.product.checkAll),jQuery(document).on("click",".button-apply",window.eoxiaJS.wpshop.product.apply),jQuery(document).ready(window.eoxiaJS.wpshop.product.autoSynchro),jQuery(".similar-product").select2({ajax:{url:scriptParams.url+"/wp-json/wpshop/v2/product/search",data:function(e){return{s:e.term}},processResults:function(e){var o=[];for(var t in e){var i={id:e[t].id,text:e[t].title};o.push(i)}return{results:o}},cache:!0},minimumInputLength:1})},window.eoxiaJS.wpshop.product.displayBlockStock=function(e,o){o?jQuery(".stock-block").fadeIn():jQuery(".stock-block").fadeOut()},window.eoxiaJS.wpshop.product.checkAll=function(){jQuery(this).is(":checked")?jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!0):jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!1)},window.eoxiaJS.wpshop.product.apply=function(){"quick-edit"===jQuery(".select-apply").val()&&jQuery(".wps-list-product .table-row:not(.table-header)").each(function(){jQuery(this).find('input[type="checkbox"]').is(":checked")&&jQuery(this).find('.action-attribute[data-action="change_mode"]').click()})},window.eoxiaJS.wpshop.product.autoSynchro=function(e){jQuery(this).find('.button-synchro[data-entry-id="1"]')},window.eoxiaJS.wpshop.product.changeMode=function(e,o){jQuery(e).closest("div.table-row").replaceWith(o.data.view)},window.eoxiaJS.wpshop.settings={},window.eoxiaJS.wpshop.settings.init=function(){},window.eoxiaJS.wpshop.settings.dismiss=function(e,o){jQuery(".notice-erp").fadeOut()},window.eoxiaJS.wpshop.doliAssociate={},window.eoxiaJS.wpshop.doliAssociate.init=function(){jQuery(document).on("keyup",".synchro-single .filter-entry",window.eoxiaJS.wpshop.doliAssociate.filter),jQuery(document).on("click",".synchro-single li",window.eoxiaJS.wpshop.doliAssociate.clickEntry)},window.eoxiaJS.wpshop.doliAssociate.filter=function(e){var o=jQuery(".synchro-single ul.select li");o.show();for(var t=jQuery(this).val().toLowerCase(),i=0;i
'),d.after('')}),o.open()}),a.on("click",function(e){e.preventDefault(),n.html(""),i.removeClass("hidden"),a.addClass("hidden"),d.val("")})}),window.eoxiaJS.wpshop.product={},window.eoxiaJS.wpshop.product.init=function(){window.eoxiaJS.wpshop.product.event()},window.eoxiaJS.wpshop.product.event=function(){jQuery(document).on("wps-change-toggle",".stock-field .toggle",window.eoxiaJS.wpshop.product.displayBlockStock),jQuery(document).on("click",'.wps-list-product .table-header input[type="checkbox"]',window.eoxiaJS.wpshop.product.checkAll),jQuery(document).on("click",".button-apply",window.eoxiaJS.wpshop.product.apply),jQuery(document).ready(window.eoxiaJS.wpshop.product.autoSynchro),jQuery(".similar-product").select2({ajax:{url:scriptParams.url+"/wp-json/wpshop/v2/product/search",data:function(e){return{s:e.term}},processResults:function(e){var t=[];for(var o in e){var i={id:e[o].id,text:e[o].title};t.push(i)}return{results:t}},cache:!0},minimumInputLength:1})},window.eoxiaJS.wpshop.product.displayBlockStock=function(e,t){t?jQuery(".stock-block").fadeIn():jQuery(".stock-block").fadeOut()},window.eoxiaJS.wpshop.product.checkAll=function(){jQuery(this).is(":checked")?jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!0):jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!1)},window.eoxiaJS.wpshop.product.apply=function(){"quick-edit"===jQuery(".select-apply").val()&&jQuery(".wps-list-product .table-row:not(.table-header)").each(function(){jQuery(this).find('input[type="checkbox"]').is(":checked")&&jQuery(this).find('.action-attribute[data-action="change_mode"]').click()})},window.eoxiaJS.wpshop.product.autoSynchro=function(e){jQuery(this).find('.button-synchro[data-entry-id="1"]')},window.eoxiaJS.wpshop.product.changeMode=function(e,t){jQuery(e).closest("div.table-row").replaceWith(t.data.view)},window.eoxiaJS.wpshop.settings={},window.eoxiaJS.wpshop.settings.init=function(){},window.eoxiaJS.wpshop.settings.dismiss=function(e,t){jQuery(".notice-erp").fadeOut()},window.eoxiaJS.wpshop.doliAssociate={},window.eoxiaJS.wpshop.doliAssociate.init=function(){jQuery(document).on("keyup",".synchro-single .filter-entry",window.eoxiaJS.wpshop.doliAssociate.filter),jQuery(document).on("click",".synchro-single li",window.eoxiaJS.wpshop.doliAssociate.clickEntry)},window.eoxiaJS.wpshop.doliAssociate.filter=function(e){var t=jQuery(".synchro-single ul.select li");t.show();for(var o=jQuery(this).val().toLowerCase(),i=0;i' ); + //imgIdInput.val( attachment.id ); + }); + + var i; + + for (i = 0; i < attachments.length; ++i) { + + //sample function 1: add image preview + imgContainer.append( + '
' + ); + + //sample function 2: add hidden input for each image + imgIdInput.after( + '' + ); + } // Send the attachment URL to our custom image input field. - imgContainer.append( '' ); // Send the attachment id to our hidden input - imgIdInput.val( attachment.id ); // Hide the add image link //addImgLink.addClass( 'hidden' ); diff --git a/modules/dolibarr/doli-documents/class/class-doli-documents.php b/modules/dolibarr/doli-documents/class/class-doli-documents.php index 8f743dc..b876f78 100644 --- a/modules/dolibarr/doli-documents/class/class-doli-documents.php +++ b/modules/dolibarr/doli-documents/class/class-doli-documents.php @@ -11,7 +11,7 @@ namespace wpshop; -use eoxia\Post_Class; +use eoxia\Attachment_Class; use stdClass; defined( 'ABSPATH' ) || exit; @@ -19,7 +19,7 @@ /** * Doli Documents Class. */ -class Doli_Documents extends Post_Class { +class Doli_Documents extends Attachment_Class { /** * Le nom du modèle. @@ -71,66 +71,6 @@ class Doli_Documents extends Post_Class { */ protected $post_type_name = 'documents'; - /** - * Appel la vue "list" du module "doli-order". - * - * @since 2.0.0 - * @version 2.0.0 - */ - public function display() { - $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); - $per_page = get_user_meta( get_current_user_id(), Doli_Order::g()->option_per_page, true ); - - if ( empty( $per_page ) || 1 > $per_page ) { - $per_page = Doli_Order::g()->limit; - } - - $current_page = isset( $_GET['current_page'] ) ? (int) $_GET['current_page'] : 1; - - $s = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; - - $route = 'orders?sortfield=t.rowid&sortorder=DESC&limit=' . $per_page . '&page=' . ( $current_page - 1 ); - - if ( ! empty( $s ) ) { - // La route de dolibarr ne fonctionne pas avec des caractères en base10 - $route .= '&sqlfilters=(t.ref%3Alike%3A\'%25' . $s . '%25\')'; - } - - $doli_orders = Request_Util::get( $route ); - $orders = $this->convert_to_wp_order_format( $doli_orders ); - - if ( ! empty( $orders ) ) { - foreach ( $orders as &$element ) { - $element->data['tier'] = Third_Party::g()->get( array( 'id' => $element->data['parent_id'] ), true ); - $element->data['datec'] = \eoxia\Date_Util::g()->fill_date( $element->data['datec'] ); - } - } - - View_Util::exec( 'wpshop', 'doli-order', 'list', array( - 'orders' => $orders, - 'doli_url' => $dolibarr_option['dolibarr_url'], - ) ); - } - - /** - * Appel la vue "item" d'une commande. - * - * @since 2.0.0 - * @version 2.0.0 - * - * @param Doli_Order $order Les données d'une commande. - * @param string $doli_url L'url de Dolibarr. - */ - public function display_item( $order, $doli_url = '' ) { - if ( empty( $order->data['tier'] ) ) { - $order->data['tier'] = Third_Party::g()->get( array( 'id' => $order->data['parent_id'] ), true ); - } - View_Util::exec( 'wpshop', 'doli-order', 'item', array( - 'order' => $order, - 'doli_url' => $doli_url, - ) ); - } - /** * Convertit un tableau Documents Object provenant de Dolibarr vers un format Documents Object WPshop afin de normisé pour l'affichage. * @@ -200,34 +140,6 @@ public function doli_to_wp( $doli_document, $wp_document, $only_convert = false } return $wp_document; } - - /** - * Fonction de recherche. - * - * @since 2.0.0 - * @version 2.0.0 - * - * @param string $s Le terme de la recherche. - * @param array $default_args Les arguments par défaut. - * @param boolean $count Si true compte le nombre d'élement, sinon renvoies l'ID des éléments trouvés. - * - * @return array|integer Les ID des éléments trouvés ou le nombre d'éléments trouvés. - */ - public function search( $s = '', $default_args = array(), $count = false ) { - $route = 'orders?sortfield=t.rowid&sortorder=DESC'; - - if ( ! empty( $s ) ) { - $route .= '&sqlfilters=(t.ref%3Alike%3A\'%25' . $s . '%25\')'; - } - - $doli_orders = Request_Util::get( $route ); - - if ( $count && ! empty( $doli_orders ) ) { - return count( $doli_orders ); - } else { - return 0; - } - } } Doli_Documents::g(); diff --git a/modules/dolibarr/doli-documents/model/class-doli-documents-model.php b/modules/dolibarr/doli-documents/model/class-doli-documents-model.php index c7e1122..f08cea4 100644 --- a/modules/dolibarr/doli-documents/model/class-doli-documents-model.php +++ b/modules/dolibarr/doli-documents/model/class-doli-documents-model.php @@ -11,14 +11,14 @@ namespace wpshop; -use eoxia\Post_Model; +use eoxia\Attachment_Model; defined( 'ABSPATH' ) || exit; /** * Doli Documents Model Class. */ -class Doli_Documents_Model extends Post_Model { +class Doli_Documents_Model extends Attachment_Model { /** * Le constructeur. @@ -35,8 +35,8 @@ public function __construct( $object, $req_method = null ) { 'type' => 'integer', 'meta_type' => 'single', 'field' => '_external_id', - 'since' => '2.0.0', - 'version' => '2.0.0', + 'since' => '2.1.0', + 'version' => '2.1.0', 'description' => 'L\'ID du customer (dolibarr). Relation avec dolibarr.', ); diff --git a/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php b/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php index 4a98038..7d1c0ee 100644 --- a/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php +++ b/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php @@ -31,6 +31,7 @@ protected function construct() { add_filter( 'doli_build_sha_wps-product', array( $this, 'build_sha_product' ), 10, 2 ); add_filter( 'doli_build_sha_wps-third-party', array( $this, 'build_sha_third_party' ), 10, 2 ); + add_filter( 'doli_build_sha_wps-document', array( $this, 'build_sha_document' ), 10, 2 ); } /** @@ -137,6 +138,33 @@ public function build_sha_third_party( $response, $wp_id ) { return $response; } + + /** + * La construction du SHA256 d'une synchronisation d'un document. + * + * @since 2.01.0 + * @version 2.1.0 + * + * @param Doli_Documents $response Les données d'un document. + * @param integer $wp_id L'id d'un tier WordPress. + * + * @return Doli_Documents Les données d'un document avec le SHA256. + */ + public function build_sha_document( $response, $wp_id ) { + $data_sha = array(); + + $data_sha['doli_id'] = $response->id; + $data_sha['wp_id'] = $wp_id; + $data_sha['path'] = $response->data['path']; + $data_sha['fullpath'] = $response->data['fullpath']; + $data_sha['date'] = $response->data['date']; + $data_sha['size'] = $response->data['size']; + $data_sha['dolibarr_type'] = $response->data['dolibarr_type']; + + $response->sha = hash( 'sha256', implode( ',', $data_sha ) ); + + return $response; + } } Doli_Sync_Filter::g(); diff --git a/modules/products/class/class-product.php b/modules/products/class/class-product.php index 7499720..3f49ee0 100644 --- a/modules/products/class/class-product.php +++ b/modules/products/class/class-product.php @@ -264,12 +264,16 @@ public function callback_add_meta_box_gallery( $post ) { $doli_documents = Request_Util::get( 'documents?modulepart=product&id=' . $product->data['external_id'] ); $wp_documents = Doli_Documents::g()->convert_to_wp_documents_format( $doli_documents ); - if ( ! empty ( $wp_documents ) ) { - $attachments = get_children( array( 'post_parent' => $product->data['external_id'], 'post_type' => 'attachment' ) ); - if ( empty ( $attachments ) ) { + if ( ! empty( $wp_documents ) ) { + $attachments = get_children( + array( + 'post_parent' => $product->data['external_id'], + 'post_type' => 'attachment', + ) + ); + if ( empty( $attachments ) ) { foreach ( $wp_documents as $key => $wp_document ) { - - $uploadfile = $wp_upload_dir['path'] . '/' . $wp_document->data['name']; + $uploadfile = $wp_upload_dir['path'] . '/' . $wp_document->data['name']; $contents = file_get_contents( $wp_document->data['fullpath'] ); $savefile = fopen( $uploadfile, 'w' ); @@ -278,11 +282,11 @@ public function callback_add_meta_box_gallery( $post ) { $filetype = wp_check_filetype( basename( $wp_document->data['fullpath'] ), null ); - $args = array( + $args = array( 'post_name' => $wp_document->data['name'], 'post_mime_type' => $filetype['type'], - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $wp_document->data['fullpath'] ) ), - 'meta_input' => array( + 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $wp_document->data['fullpath'] ) ), + 'meta_input' => array( 'path' => $wp_document->data['path'], 'fullpath' => $wp_document->data['fullpath'], 'date' => $wp_document->data['date'], @@ -291,34 +295,41 @@ public function callback_add_meta_box_gallery( $post ) { ), ); $attachment_id = wp_insert_attachment( $args, $uploadfile, $product->data['external_id'] ); - require_once( ABSPATH . 'wp-admin/includes/image.php' ); - $attached_file = get_post_meta( $attachment_id , '_wp_attached_file', true ); - $attach_data = wp_generate_attachment_metadata( $attachment_id,$wp_upload_dir['baseurl'] . '/' . $attached_file ); + require_once ABSPATH . 'wp-admin/includes/image.php'; + $attached_file = get_post_meta( $attachment_id, '_wp_attached_file', true ); + $attach_data = wp_generate_attachment_metadata( $attachment_id, $wp_upload_dir['baseurl'] . '/' . $attached_file ); wp_update_attachment_metadata( $attachment_id, $attach_data ); } } } $attachment = array(); - foreach ( $attachments as $key => $attachment_object ) { - foreach ( $attachment_object as $key => $attachment_data ) { - $attachment[$key] = $attachment_data; - $attachment['fullpath'] = get_post_meta( $attachment_object->ID , 'fullpath', true ); - $attachment['size'] = get_post_meta( $attachment_object->ID , 'size', true ); - $attachment['attached_file'] = get_post_meta( $attachment_object->ID , '_wp_attached_file', true ); + if ( ! empty( $attachments ) ) { + foreach ( $attachments as $key => $attachment_object ) { + foreach ( $attachment_object as $id => $attachment_data ) { + $attachment[ $id ] = $attachment_data; + $attachment['fullpath'] = get_post_meta( $attachment_object->ID, 'fullpath', true ); + $attachment['size'] = get_post_meta( $attachment_object->ID, 'size', true ); + $attachment['attached_file'] = get_post_meta( $attachment_object->ID, '_wp_attached_file', true ); + } + $attachments[ $attachment_object->ID ] = $attachment; } - $attachments[$attachment_object->ID] = $attachment; } $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); - View_Util::exec( 'wpshop', 'products', 'metabox/gallery', array( - 'id' => ! empty( $product->data['id'] ) ? $product->data['id'] : $post->ID, - 'wp_upload_dir' => $wp_upload_dir, - 'attachments' => $attachments, - 'product' => $product, - 'doli_url' => $dolibarr_option['dolibarr_url'], - 'sync_status' => false, - ) ); + View_Util::exec( + 'wpshop', + 'products', + 'metabox/gallery', + array( + 'id' => ! empty( $product->data['id'] ) ? $product->data['id'] : $post->ID, + 'wp_upload_dir' => $wp_upload_dir, + 'attachments' => ! empty( $attachments ) ? $attachments : '', + 'product' => $product, + 'doli_url' => $dolibarr_option['dolibarr_url'], + 'sync_status' => false, + ) + ); } /** diff --git a/modules/products/view/metabox/gallery.view.php b/modules/products/view/metabox/gallery.view.php index 6181583..864de0e 100644 --- a/modules/products/view/metabox/gallery.view.php +++ b/modules/products/view/metabox/gallery.view.php @@ -64,7 +64,7 @@
-
    --> +
      '; print_r($attachment); echo ''; exit; ?> From 6835561a07156718cd7f7d3356e91ac1e24d4967 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 3 Sep 2020 17:32:43 +0200 Subject: [PATCH 07/13] New : Add link for documents --- modules/settings/class/class-settings.php | 1 + modules/settings/view/erp.view.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/settings/class/class-settings.php b/modules/settings/class/class-settings.php index dc0a6da..a55b980 100644 --- a/modules/settings/class/class-settings.php +++ b/modules/settings/class/class-settings.php @@ -73,6 +73,7 @@ protected function construct() { //-Liens Produits 'dolibarr_create_product' => 'product/card.php?leftmenu=product&action=create&type=0', 'dolibarr_products_lists' => 'product/list.php?leftmenu=product&type=0', + 'dolibarr_product_document' => 'product/document.php?id=', /**-Liens Services //@todo 'dolibarr_create_service' => 'product/card.php?leftmenu=service&action=create&type=1', //@todo 'dolibarr_services_lists' => 'product/list.php?leftmenu=service&type=1', diff --git a/modules/settings/view/erp.view.php b/modules/settings/view/erp.view.php index 7e3a5aa..3d3b49f 100644 --- a/modules/settings/view/erp.view.php +++ b/modules/settings/view/erp.view.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -100,6 +100,15 @@
+
+ + + + +
+ From 4e9458731bbd35cbaba9ad743cd20f2ad615df07 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 3 Sep 2020 17:34:02 +0200 Subject: [PATCH 08/13] Update : Add product gallery and product document --- core/asset/js/backend.min.js | 2 +- core/asset/language/wpshop-fr_FR.mo | Bin 26051 -> 24617 bytes core/asset/language/wpshop-fr_FR.po | 1431 +++++++++-------- .../action/class-doli-documents.action.php | 35 + .../asset/doli-documents.backend.js | 22 +- .../class/class-doli-documents.php | 73 + .../doli-documents/doli-documents.config.json | 1 + .../doli-sync/class/class-doli-sync.php | 4 +- .../filter/class-doli-sync-filter.php | 19 +- modules/products/class/class-product.php | 170 +- .../products/view/metabox/document.view.php | 53 + .../products/view/metabox/gallery.view.php | 96 +- 12 files changed, 1073 insertions(+), 833 deletions(-) create mode 100644 modules/dolibarr/doli-documents/action/class-doli-documents.action.php create mode 100644 modules/products/view/metabox/document.view.php diff --git a/core/asset/js/backend.min.js b/core/asset/js/backend.min.js index 0f13bed..b4bf2d8 100644 --- a/core/asset/js/backend.min.js +++ b/core/asset/js/backend.min.js @@ -1 +1 @@ -window.eoxiaJS.wpshop={},window.eoxiaJS.wpshopFrontend={},window.eoxiaJS.wpshop.init=function(){jQuery(".wps-sync").length&&jQuery(".wps-sync").each(function(){var e={action:"check_sync_status",wp_id:jQuery(this).find(".button-synchro").data("wp-id"),type:jQuery(this).find(".button-synchro").data("type")};window.eoxiaJS.loader.display(jQuery(this));var t=jQuery(this);jQuery.post(ajaxurl,e,function(e){window.eoxiaJS.loader.remove(t),t.replaceWith(e.data.view),e.data.status&&"0x1"==e.data.status.status_code&&jQuery('.table-row[data-id="'+e.data.id+'"] .reference-id li:last').remove()}).fail(function(){window.eoxiaJS.loader.remove(t),t.find(".statut").attr("aria-label","500 (Internal Server Error)"),t.find(".statut").addClass("statut-red")})});var e={action:"check_erp_statut",_wpnonce:scriptParams.check_erp_statut_nonce};jQuery.post(ajaxurl,e,function(e){!e.data.statut&&e.data.view&&jQuery("body").append(e.data.view)})},window.eoxiaJS.wpshop.API={},window.eoxiaJS.wpshop.API.init=function(){},window.eoxiaJS.wpshop.API.generatedAPIKey=function(e,t){e.closest(".wpshop-fields").replaceWith(t.data.view)},window.eoxiaJS.wpshop.thirdParties={},window.eoxiaJS.wpshop.thirdParties.init=function(){window.eoxiaJS.wpshop.thirdParties.event()},window.eoxiaJS.wpshop.thirdParties.event=function(){jQuery(document).on("click","#wps-third-party-contact .add-contact",window.eoxiaJS.wpshop.thirdParties.toggleContactFormNew),jQuery(document).on("click",".wpeo-autocomplete.search-contact .autocomplete-search-list .autocomplete-result",window.eoxiaJS.wpshop.thirdParties.putContactID)},window.eoxiaJS.wpshop.thirdParties.toggleContactFormNew=function(){jQuery("#wps-third-party-contact .row.new").toggle()},window.eoxiaJS.wpshop.thirdParties.putContactID=function(){jQuery(this).closest(".wpeo-autocomplete").find(".button-associate-contact").attr("data-contact-id",jQuery(this).data("id")),jQuery(this).closest(".wpeo-autocomplete").find("input#search-contact").val(jQuery(this).data("result"))},window.eoxiaJS.wpshop.thirdParties.loaddedTitleEdit=function(e,t){e.closest("h2").html(t.data.view)},window.eoxiaJS.wpshop.thirdParties.savedThird=function(e,t){e.closest("h2").html(t.data.view)},window.eoxiaJS.wpshop.thirdParties.loaddedBillingAddressSuccess=function(e,t){e.closest(".inside").html(t.data.view)},window.eoxiaJS.wpshop.thirdParties.savedBillingAddressSuccess=function(e,t){e.closest(".inside").html(t.data.view)},window.eoxiaJS.wpshop.thirdParties.loaddedContactSuccess=function(e,t){e.closest("tr").replaceWith(t.data.view)},window.eoxiaJS.wpshop.thirdParties.savedContact=function(e,t){e.closest(".inside").html(t.data.view)},window.eoxiaJS.wpshop.thirdParties.associatedContactSuccess=function(e,t){e.closest(".inside").html(t.data.view)},window.eoxiaJS.wpshop.tools={},window.eoxiaJS.wpshop.tools.init=function(){jQuery(document).on("click",".import-third-party .wpeo-button.button-primary",window.eoxiaJS.wpshop.tools.importThirdParty),jQuery(document).on("click",".import-product .wpeo-button.button-primary",window.eoxiaJS.wpshop.tools.importProduct)},window.eoxiaJS.wpshop.tools.importThirdParty=function(e){var t=new FormData;e.preventDefault(),t.append("file",jQuery(".import-third-party input[type=file]")[0].files[0]),t.append("action","import_third_party"),t.append("_wpnonce",jQuery(this).closest("form").find('input[name="_wpnonce"]').val()),t.append("index_element",0),window.eoxiaJS.wpshop.tools.requestImportThirdParty(t)},window.eoxiaJS.wpshop.tools.importProduct=function(e){var t=new FormData;e.preventDefault(),t.append("file",jQuery(".import-product input[type=file]")[0].files[0]),t.append("action","import_third_party"),t.append("_wpnonce",jQuery(this).closest("form").find('input[name="_wpnonce"]').val()),t.append("index_element",0),window.eoxiaJS.wpshop.tools.requestImportProduct(t)},window.eoxiaJS.wpshop.tools.requestImportThirdParty=function(e){jQuery.ajax({url:ajaxurl,data:e,processData:!1,contentType:!1,type:"POST",beforeSend:function(){window.eoxiaJS.loader.display(jQuery(".import-third-party .wpeo-button")),jQuery(".import-details").html("In progress")},success:function(e){var t=new FormData;e.success&&(jQuery(".import-third-party progress").attr("max",e.data.count_element),jQuery(".import-third-party progress").val(e.data.index_element/e.data.count_element*e.data.count_element),e.data.end?(jQuery(".import-detail").html("Importation terminé"),window.eoxiaJS.loader.remove(jQuery(".import-third-party .wpeo-button"))):(t.append("action","import_third_party"),t.append("_wpnonce",jQuery(".import-third-party").find('input[name="_wpnonce"]').val()),t.append("path_to_json",e.data.path_to_json),t.append("index_element",e.data.index_element),t.append("count_element",e.data.count_element),jQuery(".import-detail").html("Progress"),window.eoxiaJS.wpshop.tools.requestImport(t)))}})},window.eoxiaJS.wpshop.tools.requestImportProduct=function(e){jQuery.ajax({url:ajaxurl,data:e,processData:!1,contentType:!1,type:"POST",beforeSend:function(){window.eoxiaJS.loader.display(jQuery(".import-product .wpeo-button")),jQuery(".import-details").html("In progress")},success:function(e){var t=new FormData;e.success&&(jQuery(".import-product progress").attr("max",e.data.count_element),jQuery(".import-product progress").val(e.data.index_element/e.data.count_element*e.data.count_element),e.data.end?(jQuery(".import-detail").html("Importation terminé"),window.eoxiaJS.loader.remove(jQuery(".import-product .wpeo-button"))):(t.append("action","import_product"),t.append("_wpnonce",jQuery(".import-product").find('input[name="_wpnonce"]').val()),t.append("path_to_json",e.data.path_to_json),t.append("index_element",e.data.index_element),t.append("count_element",e.data.count_element),jQuery(".import-detail").html("Progress"),window.eoxiaJS.wpshop.tools.requestImportProduct(t)))}})},jQuery(function(e){var o,t=e("#wps_product_gallery.postbox"),i=t.find(".upload-custom-img"),a=t.find(".delete-custom-img"),n=t.find(".custom-img-container"),d=t.find(".custom-img-id");i.on("click",function(e){e.preventDefault(),o||(o=wp.media({title:"Select or Upload Media Of Your Chosen Persuasion",button:{text:"Use this media"},multiple:!0})).on("select",function(){for(var e=o.state().get("selection").map(function(e){return e.toJSON(),e}),t=0;t
'),d.after('')}),o.open()}),a.on("click",function(e){e.preventDefault(),n.html(""),i.removeClass("hidden"),a.addClass("hidden"),d.val("")})}),window.eoxiaJS.wpshop.product={},window.eoxiaJS.wpshop.product.init=function(){window.eoxiaJS.wpshop.product.event()},window.eoxiaJS.wpshop.product.event=function(){jQuery(document).on("wps-change-toggle",".stock-field .toggle",window.eoxiaJS.wpshop.product.displayBlockStock),jQuery(document).on("click",'.wps-list-product .table-header input[type="checkbox"]',window.eoxiaJS.wpshop.product.checkAll),jQuery(document).on("click",".button-apply",window.eoxiaJS.wpshop.product.apply),jQuery(document).ready(window.eoxiaJS.wpshop.product.autoSynchro),jQuery(".similar-product").select2({ajax:{url:scriptParams.url+"/wp-json/wpshop/v2/product/search",data:function(e){return{s:e.term}},processResults:function(e){var t=[];for(var o in e){var i={id:e[o].id,text:e[o].title};t.push(i)}return{results:t}},cache:!0},minimumInputLength:1})},window.eoxiaJS.wpshop.product.displayBlockStock=function(e,t){t?jQuery(".stock-block").fadeIn():jQuery(".stock-block").fadeOut()},window.eoxiaJS.wpshop.product.checkAll=function(){jQuery(this).is(":checked")?jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!0):jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!1)},window.eoxiaJS.wpshop.product.apply=function(){"quick-edit"===jQuery(".select-apply").val()&&jQuery(".wps-list-product .table-row:not(.table-header)").each(function(){jQuery(this).find('input[type="checkbox"]').is(":checked")&&jQuery(this).find('.action-attribute[data-action="change_mode"]').click()})},window.eoxiaJS.wpshop.product.autoSynchro=function(e){jQuery(this).find('.button-synchro[data-entry-id="1"]')},window.eoxiaJS.wpshop.product.changeMode=function(e,t){jQuery(e).closest("div.table-row").replaceWith(t.data.view)},window.eoxiaJS.wpshop.settings={},window.eoxiaJS.wpshop.settings.init=function(){},window.eoxiaJS.wpshop.settings.dismiss=function(e,t){jQuery(".notice-erp").fadeOut()},window.eoxiaJS.wpshop.doliAssociate={},window.eoxiaJS.wpshop.doliAssociate.init=function(){jQuery(document).on("keyup",".synchro-single .filter-entry",window.eoxiaJS.wpshop.doliAssociate.filter),jQuery(document).on("click",".synchro-single li",window.eoxiaJS.wpshop.doliAssociate.clickEntry)},window.eoxiaJS.wpshop.doliAssociate.filter=function(e){var t=jQuery(".synchro-single ul.select li");t.show();for(var o=jQuery(this).val().toLowerCase(),i=0;i
'),d.after('')}),o.open()}),a.on("click",function(e){e.preventDefault(),n.html(""),i.removeClass("hidden"),a.addClass("hidden"),d.val("")})}),window.eoxiaJS.wpshop.doliDocument={},window.eoxiaJS.wpshop.doliDocument.init=function(){},window.eoxiaJS.wpshop.product={},window.eoxiaJS.wpshop.product.init=function(){window.eoxiaJS.wpshop.product.event()},window.eoxiaJS.wpshop.product.event=function(){jQuery(document).on("wps-change-toggle",".stock-field .toggle",window.eoxiaJS.wpshop.product.displayBlockStock),jQuery(document).on("click",'.wps-list-product .table-header input[type="checkbox"]',window.eoxiaJS.wpshop.product.checkAll),jQuery(document).on("click",".button-apply",window.eoxiaJS.wpshop.product.apply),jQuery(document).ready(window.eoxiaJS.wpshop.product.autoSynchro),jQuery(".similar-product").select2({ajax:{url:scriptParams.url+"/wp-json/wpshop/v2/product/search",data:function(e){return{s:e.term}},processResults:function(e){var t=[];for(var o in e){var i={id:e[o].id,text:e[o].title};t.push(i)}return{results:t}},cache:!0},minimumInputLength:1})},window.eoxiaJS.wpshop.product.displayBlockStock=function(e,t){t?jQuery(".stock-block").fadeIn():jQuery(".stock-block").fadeOut()},window.eoxiaJS.wpshop.product.checkAll=function(){jQuery(this).is(":checked")?jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!0):jQuery('.wps-list-product .table-row:not(.table-header) input[type="checkbox"]').attr("checked",!1)},window.eoxiaJS.wpshop.product.apply=function(){"quick-edit"===jQuery(".select-apply").val()&&jQuery(".wps-list-product .table-row:not(.table-header)").each(function(){jQuery(this).find('input[type="checkbox"]').is(":checked")&&jQuery(this).find('.action-attribute[data-action="change_mode"]').click()})},window.eoxiaJS.wpshop.product.autoSynchro=function(e){jQuery(this).find('.button-synchro[data-entry-id="1"]')},window.eoxiaJS.wpshop.product.changeMode=function(e,t){jQuery(e).closest("div.table-row").replaceWith(t.data.view)},window.eoxiaJS.wpshop.settings={},window.eoxiaJS.wpshop.settings.init=function(){},window.eoxiaJS.wpshop.settings.dismiss=function(e,t){jQuery(".notice-erp").fadeOut()},window.eoxiaJS.wpshop.doliAssociate={},window.eoxiaJS.wpshop.doliAssociate.init=function(){jQuery(document).on("keyup",".synchro-single .filter-entry",window.eoxiaJS.wpshop.doliAssociate.filter),jQuery(document).on("click",".synchro-single li",window.eoxiaJS.wpshop.doliAssociate.clickEntry)},window.eoxiaJS.wpshop.doliAssociate.filter=function(e){var t=jQuery(".synchro-single ul.select li");t.show();for(var o=jQuery(this).val().toLowerCase(),i=0;iSliB@(eD)>uk%MMB6XL8OQvg4k1J#GXwSk)&Dd<4)SK)Mz{A)-qJ7 znO2Qz%Pm8-s_6L7n4(ootNgVcl(yPhs>(2*?>$e9ne%%6yr1nn`?<6Sk2tpMceu_q z^<8Q4)Hp1wErvI=tbjU}72QgumNnXGS&cCR-@_dA#qjo)r6!%R0S>^HI1-!TbPU3I zSRa?6Kd!_8T#x-M%Vljg6<=XJD!w-jZle!*pD_DHe^iG-*a$;SJ_a?BWYk16Q4=V@ zHaH(2!Bwbqh9<3HS=?({0ge0>!$u^)WG+# zE;b9dC)66X(r{G&Jy2VphFaJtbcK@0C(#ZUp=S06)QY#FCb9?B(E(HkC(swqqE`L| zYC_+l>TjS1yoZ{2V1(Uo8`RE)VJgN&u>T<>Dk;!Jeuo-x2Wp0UQJ3mN)EQsK=2)kr zUEUJaF3#lBur>L~CO;c>6wjjG--H@(uPOhuBm1wd`<4QA?C50AFc`Ix4p#rd8=n|^ zWg(~z6HyZzgc>jdwUska9V|iZ#9GvVJJ5S%sP>0Y@1HaI%cvdjiM9J_fi86vPeNxu z5VbWEQD4OzY=q0viEB{a1^|2K*Q5$m+%MX<{IMsGq(Vgu}5RPKsmy zbv8v5$a2&QW}`ZAp^jt`s^ev-GhK;+_%dojJ5k^F2d4faYNfYOpJ6~(dxD|ZjeI0( zyh&Zze|3~gfd;NX&1@b9;SyB+YV=+nli!V6@nKZ^S$uI2M%$O&{i(Q99)SS@F$~xf<3Wd)BquBsj zpw~?KKGe>*j*-v`E}&L)4V&N{V zCcFYQv5j`#Wo;*+8SY1&^-0u(K1H3;CDhEXqITe($v5n7pLttUhdogJ3^MtNsEL)J z?#LX}PX89QfX!H6-~V!)kqd+rCM-BKGYM`kmUyRzB*{CyJgqrXwQ@;^AlHZ0} z@yDq5&tNiMM14KskJ@*mCw3v9?jq5WL=}2hX!4tkZ=nYI$oLt?k-vz=7~G3VVhuLK z&rt*4M17uCZ|(tvq82z9wcydHg}BC&&pLf%0+d!81)PH0_qNJLrwfG)D9d#y>}Ef(ewC-i^Odbx-=~Y*hkP7^IbXL=rZ-sqKuLkER(Ai%>b#NUA zq7Q$x!6B$4$wjquq5h$=)YQL(I^+GQ9s9=A`=r^I&}r<8;nYt;y3EB7f}9`N`F=B|_&u`G5{08G@)I?s# zNOZkRLM!+R^@DK@bw*9n?G>~|?MMWMVLIw|mzesws0lxTxU&T(i8};6KR6p18 z0M;93@4yjkslWfvkf^5yr~&SxRvb9o{=rDV`sBx;RxkziIpv_v_6gK`Zq(MkggV=u zsDV#oL;MD{6Sq;{f4vcuGrrZHgw8e=W3dlvi)LU9E=Aq`U8p1a2-Wcqs1E%`+PAy~ zMw9P``f8@3+RsN#Y%MmxKcW5uXBWB}k@(mYe1ZDztx@*Bc!E(g?T6|x3$?XXs0lug z>TnN6;QOeFeT|y1HQHWzThtDAHg-qtc*d!p@76Y7P!TbZbFiZj@M?Z6@mbVhEB!Hwu05Sx%c ziJI{x)BxY3R_b`nt`9~nAQGEmKh(s>p!%JR>ZcgH-~!YS)n=DT>_e^KBu3%|9E^cu z?9VO}$C00l+VW$@Gw7WdYM}2;{$Hqt`Hi)AvN>w!x?o34z~<=6BB3)bMQzCv)Yfk@ z<-0ME{D-K4&ZAa(8MOijvr@hlHpi~0?>`MY<5bi{oO20k;|VV|Vf=Pz$Ix-u{z3?JCqQ-GI7$dr>PnU_6Dod{;0I@1S-dD$Cx|MAUnIjH#x4DC+D-qwd&vQ(uTK z4NztZo-HMzOuJ4n6G81%AJjzqqZar$YP@-< z_RmaU|25<1D3I$+#U|7Xub{SWyK%3nf8TfnHPH`Im+u^E!q-s~xR08!??n4DHp5or zlTp8bnG@OnUL>k0(2K95zR$g=jxVBq^RJuwTc+G+l6|&~QSCxdD~m!+I0ZFuI_kS0 zk3Fy$wa|^IyRq3tVg!ku=tQ5%w&AEPPQx}h19fW`qb|?$rrd)X=qPI7v#14K!Z{c= zh2IQZhkCEYRJ(mNs()8+5{V?TQ9H24_(#;t-$1SK0P0ANp)S)uP-l1^HNlG*ijHY^ zeS36}*OP4H{j(8;8%gO)`jEqx-+D@Asc6% zBZ|#?z41r#ZxQ+|HFP7mW$ZlJICv=Gx5PBM$_M`Ft$j5q1`FwE`F_iLK7>_;C7d5{3oMr8kNr(0bA0uj?A(Z&Ih($yJ@n=HMW}@<; zb}1$uio3lnxQL|N5HrX>j?u(m;7#ZbR+H(NyK+VHc^+l zFv5@Y1RRV0*ok)tnUk)pCXLpz%pY5Dp zRFdzkDsxs9<~#Gsa;sK5C%dA;8evyz zV7u?R4_AA(#%%EOv*+VZ=^o-g*gO7Q&)Dwmd>WLO6jeFPE6Vb!bKRvqXSuKRZ135X zl;Y!V-RFqAb#j&4libC9Gr5C%aNkerKN{1un=`&=uY`C{my~oLwJT?9LjI;|Uwtug(BAMT3_7*L#)K75}q0 z-Zl@$bw1p{Gj+6oy@1+{uXJx8-z>&C_TZM1gIjV7vnvYnvvW%FEw)TEcII`mPcpB% zc4C%0eq69;<@i+JxG@K}lxJ6%>68=|lxkN0Spu2t(n{v)EYB`wM()#-YTVN%cXUL% ikB?~Qd3nkqANO-PSKWtmSGX7F^>Clei+3mFulP5{xi0Sj delta 10300 zcmb8!d3Y36zQ*wi2?2ruLI4Si6j@k92w@3^uj$=y0!!h#QK6ry8;L z#hCinW5OS_joWH*T^nOrU9k89%j(+1vL5TGQp>WtTUHzFjxS*j#^FiSBR^qFY@2FX z7ve>jj6<+BPQe6RfSu97rMM28SytFOPND?`-{L6z*}Y-qr&(5W^5anVrD)Bx&G9s4V)!v~|~VaxiIgep3P4Bk46NtlrC_Ph(KyeGED zL8ykNpq`s=?k~f5^3|vjuR%3UztsceV=~;C zXpV8@lTah*V9HZb&-FF;b8tTSTvP{c!lw8Ds$-9$X5?uMtHA~mn&P)nBm4-v;Sbmq zJM?fnI0!ZJeALoRK~*#h^?ot7Lm#T68&C~y!g!3Jp1T9p?gKqoe~n}p1)6~uQB(aY zj>Wg|B24M&c4#Q7;rXbJdQh9L8nxCpqB`)1DSsaI+*>C94`XaEcS$<;V*d4F76oc( zqPbCmnz|ZPg*Tu&wjDKsC$K5*!FYTDW3d4>^4Cz$zk!;8!zTYZszWDHGno+X?M`7w zV{g<8d8h`)qaK`!YN!A;<%@AHuE5LjRa}7SecVkMM%8mOw!phg`9sLIvi^+CF#JA= zP9%<^8nF7hFEm5tlTf?2BX-bjbAJqKgws$J6`-E;piV`|cr`XBe;ca9_n|s;8mTXA zHOX{eOhG-EiTY3sMve3`)Mim_5LALeaCP$ z?OUfwTtGo(Kexg4sEQ(}k=%g^_!w$!ccV_lbJ!9Op+@wX$)CU!@@G)>cF1xYOhY|C z5cT{>mFxUZHU$N!O<07Q%Js+zw6>y_XfJ9cZ=*)=HL7F3pc-t^-<`QM)cYe*&(B0P zxD2&aA=LA$F{}!1H3j#fM!Xlb1p81G9Y?MG8PpdnIomxQ*_cRv9NIV&)nE|y{AN_c z+fhsV7^=OeQA_klr{ zt#A>lLlvlFzR}#j2b0J@F@X8kd3=ci_3#}Wh##REZkOX$)EU)qAJm%WpgKCz+`j}> z;Ube?j;b$=dVUjXfLoED7wdl10A6W)U>^n1&4gN;&u}oRH=4>JxCE!8Mz+)V0;*&C zQ4PF}n(|N0{jV{Z{8`j74g6HP)*(JWL?SD_kQ zgKF@P*c?sKhC9qW!7SPmxW{O6L;$i|olCZj4^fU0OI zYVDSzHqAGxv9z{BG0?G@$A`fMF#Lkx<1)Pz@e4`EOAp{t+L= zrbFpH?nGwOI)J+0{9@M*s0PxpA7-Owc9F3Z)lL94fRz_B|0)QZ8yis_*o=Dd7UMmr zDSHIfz~iVH+Jo(}0kw38QO|vjdhScS5Ko(Yn>=?NcoMa?FQ7X9rn!FzwU<6ejkwh?_x<)boV*<-p<}cNwV766 zAKZZI`3{VZ(Bu!JJ|HJezGJ@IV74(2`*VLBF2fLV60Hxh5ZlqJz6T-9!0;v#8qp5a z`Q3wR_#pPg6PSe^N4PUF5j8WHqDDL$^}d6ex#g%mRfU>~HP{z7VK(kE_mASwF|7Yr zBs9X~qxeO`Ur|f)^=S8J_IuP?CXI2=cUM#ghoF{h2C4(4H~@oqIX;M5x|p%<{REsv zzCEgg-l(kq3R6&n>hU_0-)xMaJ}h^l8r+5Iz<$)oK0_PZj&sWgqLy+hcE*LM25V4L zzYe?LR&1y9{}c(m@Cv5lyQl`vpw4r<@$TkJLsgWGnvtQX_r{?*I2YBRAGO&wV^iFM zdha&ufZL3_F?#;@n+M)Tz4!s@i+9v`%G_@{!L2Y69quP%H>|;UydAX^+fW1e6Y3LO zZ^{p%miiOSz@H|t{%It-O?20MENVoPFdi3}ya&~xAZqG1U>t5k&BTMKrF#<9fxW2B z*rnUaL9O*3)D#{y_s?Kg@+p&D zb5ZZjLG6_Q>PvV%YM{@eI{X1@X1)lM(1X9CdX_T9oq^uig8VRSisLaBr($!w1U16> zsQ0|6y;6hvL~lYZ!K0`KUq)@d{iyHF5mde5QzY~S`x!OmEvC91YJ*G3_rVg}f?D&R zP!$zUb2nAccqOVM8?YBfPy=`lFTw_FiAOO3zeNTTw$6~y)HI#$?*87W2d3c#I1e@A zVpPKwsHt0rnz>ue{hg?e?m^9jJ;R-`{-`AxX!4h0I{DeyhW4!*5~}z*RK@q8rl=0J z85@iTQ6u`ocoH?DU$7@8T;jf$gQ{mdzKjd7HFmw!U6OvN0gcBbo&OmmG~&gmH7-LP zD?hfu8&MtEhN|c()Ed8xYUoqcO#OtdF#a<4d(a+Lo`s1x46|@DYDQLKxF3nFB=q5^ zN3GR|sEU6AeAjXD+esD?i_`EO9?KXI1(H>k8( z%)h=|(%CFXEXm=)4x-o-Txjo!y~BU@r5Zrfg0hD*an-;ahIecs-t~S9h!*AScGb*8Z`r3 zP)o55HRF$Cw7oEiBnpn8dVCVqz*%gEt>(J-(@-NAjBRl`s^g1M6)!{8Q;mJ_TI_(k zjIW~xa0GkdcQ_Hlo#(m7t_W$^HLZ1P)Cduj(#Z`gXC#Dx?zU}I2>v1irL!TSJLapuh z*dI@$M%t^;?Z5!k^W#wsOf}9l=QOkB)A;bC9YdnKr289>#0H|kUWXqbc^*nzt7ENYEkG5NPpQ+ou} z;~!8BTORkkx5mL_yQ4-t5B2^coQ~ya9?1p!u?(fAINzf;&f=qzWh99gOTxB}{ArhBT zP;LsJAwQh-a(s!<#ka`nYwkx2NMB6iSK>=z6Zxgl8}3O`@_LhBkBd!Od_r_?tc&)e zS1JW5rm)JCX_|Ks+la}8j?_+~J6jn`X^3F8pcRyd!6 z8Zw_@8ICqLz9;V?UM7}MmO~6AE+t=uBe5Hy>vHmK2rc6(;v&-efbp4#UiyDax{kP< z`*XGa`|km=r->Hkp_@pjoAe(@#}c|WxmBc!thW``5d5}SEh+R8U6dyDNzNr6B;7#pwY9DwzXT&hnGQXa&ycmwMDFqc?PUe{qwSO%GoqFH`Ijc4#@qCJtu{VC>!+2p&KbSZvC z{vX7fMB{ZkiILnJYMxX1#iV=SG-b@ynzAn%*S`mu3yH4WJZK(hYMe>Au5m8b9^-TP zBw?F;PvbqdRSwtO?LR>@W(%0`w^Fp+MKW-!5 zAd*b^3#3bkX5?STv4pO*(Ld=7R+#i(@kf&mcj1LNlgY&(`8#l;saUrb5GCZF#j8yD zKS_@ubp3%c{bo$SdMsDrdDjN>P6tdR0^IxBy+6#l(>(Z-v6=^pNxx0>COwTCyNO;URr5&cWf> z3Gc_5gs$o2=ioAQa6B=P&@Ym%u+5E0#N%XAi7e8Ey2JGdQ9ztjhU)_t>uR1EMCkgn z%eg;Kk;*Z-i!j}!!#w{j=?icaF^}|8eMfcuiI_{FL+I*E=&v2RhPmiR*E&R8N96O| z^LPnfe z?-9+2cErs@f9~Cfj}f|laEbnRQb*E>CO^O!XX=_l{#8>pOw;l-nRd9$6pG`-YGMr#&0)F4p5g7y0i}U-Nj6K%x3weq{c3MVG zda<1`C_QL_Yr3}xz$`kVXeRYS^Z;q+ErpH%J z;wO3Sj9_LY*n32?VsDWrq zZxsWNb}>4U3^tg_EEL<`kmg7)EOETPrS|fGpWy|a;=H=pKF`F|o$7mceB}O|1R=?$G7y~W;in=+WiWDz_C3c=KI`^8JNzV(c)`v z>nev#h)s3ua=*V!9j^AU-qas-qNCMp1^s?sR%Fk``}$`D-EC%mfrJ?ySjNx)yh8+nll!wx0n_RAS)56I2S9#q#Se{$^a&WRoJ z1eQ9X;i-j7%00d^&W+z2u**Gmk-wsXrFQ=Rr^jJm71!4;tKVi$PkpUTy3%Kdyquo2 zR=*vY=!pr8Tp#bAn8=BduSfnlYD|*ONpv#@qnp_-uFD?1CT4a~puUzGs{A3=ufk6= zPV`JT|L4hxK3~E7pa1mlj!)fPV_L>^`CkokSd0BWAMXe29vZtlCXzWJq3-(e8)I9J z@%xr(HFc)iOkUJHdZwJpK%{K4Q(PIOcl_b?v2AEKXs@VrI4Bf(s+3*gb$pzy`iCpc zFdFAshbzk->y(!}{ffM{CXpvO8v%Oa*lY%G$fu0dBit6rEdG| zg1AWEg0=DW+lxw_V5GL7SJ*D@Npmb@bjE&bX*r*qp!yy?X>+6V$fop#yd_=_hfuA$ z$8D~Xt*_-ns#SF7o=&SO?rSw@r^+8Zw_}2tbL>!kZFzkyN080s-Ywx9 zTN!XTm@J~#=M8y1(_`4{kb<%R$N diff --git a/core/asset/language/wpshop-fr_FR.po b/core/asset/language/wpshop-fr_FR.po index a1cd094..9770936 100644 --- a/core/asset/language/wpshop-fr_FR.po +++ b/core/asset/language/wpshop-fr_FR.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: wpshop\n" -"POT-Creation-Date: 2020-07-23 17:04+0200\n" -"PO-Revision-Date: 2020-07-23 17:04+0200\n" +"POT-Creation-Date: 2020-09-03 17:12+0200\n" +"PO-Revision-Date: 2020-09-03 17:21+0200\n" "Last-Translator: \n" "Language-Team: Eoxia\n" "Language: fr_FR\n" @@ -18,55 +18,55 @@ msgstr "" "X-Poedit-SearchPath-1: modules\n" "X-Poedit-SearchPathExcluded-0: core/external\n" -#: core/action/class-core-action.php:177 +#: core/action/class-wpshop-action.php:183 msgid "WPshop" msgstr "WPshop" -#: core/action/class-core-action.php:178 +#: core/action/class-wpshop-action.php:184 #: modules/dashboard/view/main.view.php:17 msgid "Dashboard" msgstr "Tableau de bord" #: core/asset/js/blocks/block.js:21 -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:63 -#: modules/order/action/class-order-action.php:39 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:64 #: modules/order/action/class-order-action.php:40 -#: modules/products/action/class-product-action.php:49 +#: modules/order/action/class-order-action.php:41 +#: modules/products/action/class-product-action.php:47 #: modules/products/action/class-product-action.php:116 +#: modules/products/filter/class-product-filter.php:63 #: modules/products/filter/class-product-filter.php:65 -#: modules/products/filter/class-product-filter.php:67 -#: modules/products/view/main.view.php:21 +#: modules/products/view/main.view.php:34 msgid "Products" msgstr "Produits" #: core/asset/js/blocks/block.js:25 -#: modules/products/filter/class-product-filter.php:100 +#: modules/products/filter/class-product-filter.php:98 msgid "product" msgstr "produit" -#: core/filter/class-core-filter.php:126 -#: modules/settings/action/class-settings-action.php:52 -#: modules/settings/view/main.view.php:20 -#: modules/settings/view/payment-method.view.php:24 +#: core/filter/class-wpshop-filter.php:137 +#: modules/settings/action/class-settings-action.php:53 +#: modules/settings/view/main.view.php:26 +#: modules/settings/view/payment-method.view.php:30 msgid "Settings" msgstr "Réglages" -#: core/util/class-countries-util.php:63 -#: modules/checkout/class/class-checkout.php:95 -#: modules/dolibarr/doli-associate/view/compare-wps-third-party.view.php:36 -#: modules/dolibarr/doli-order/view/metabox-order-details.view.php:41 -#: modules/dolibarr/doli-order/view/metabox-order-details.view.php:52 -#: modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php:56 -#: modules/my-account/view/frontend/my-account-details.php:97 -#: modules/third-parties/view/metaboxes/metabox-billing-address.view.php:34 +#: core/util/class-countries-util.php:70 +#: modules/checkout/class/class-checkout.php:97 +#: modules/dolibarr/doli-associate/view/compare-wps-third-party.view.php:40 +#: modules/dolibarr/doli-order/view/metabox-order-details.view.php:47 +#: modules/dolibarr/doli-order/view/metabox-order-details.view.php:58 +#: modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php:57 +#: modules/my-account/view/frontend/my-account-details.php:108 +#: modules/third-parties/view/metaboxes/metabox-billing-address.view.php:39 msgid "Country" msgstr "Pays" -#: core/view/erp-connexion-error.view.php:22 +#: core/view/erp-connexion-error.view.php:19 msgid "Connection failed with your ERP" msgstr "Échec de la connexion avec votre ERP" -#: core/view/erp-connexion-error.view.php:25 +#: core/view/erp-connexion-error.view.php:21 msgid "" "Your ERP is not connected. Maybe your ERP is not connected or your " "configuration is not correct" @@ -74,120 +74,121 @@ msgstr "" "Votre ERP n'est pas connecté. Peut-être que votre ERP n'est pas connecté ou " "que votre configuration n'est pas correcte" -#: core/view/erp-connexion-error.view.php:26 +#: core/view/erp-connexion-error.view.php:22 msgid "Need help ? Follow this guide" msgstr "Besoin d'aide ? Suivez ce guide" -#: modules/api/view/field-api.view.php:20 +#: modules/api/view/field-api.view.php:25 msgid "WPshop API" msgstr "API de WPshop" -#: modules/api/view/field-api.view.php:25 +#: modules/api/view/field-api.view.php:30 msgid "API Key" msgstr "Clé API" -#: modules/cart/class/class-cart.php:177 +#: modules/cart/class/class-cart.php:185 #, php-format msgid "%s is sold out." msgstr "%s n'est plus disponible." -#: modules/cart/shortcode/class-cart-shortcode.php:78 -#: modules/products/view/frontend/wps-product-single.php:38 +#: modules/cart/shortcode/class-cart-shortcode.php:79 +#: modules/products/view/frontend/wps-product-single.php:42 msgid "Add to cart" msgstr "Ajouter au panier" -#: modules/cart/view/frontend/cart-resume.php:51 -#: modules/checkout/view/frontend/review-order.php:71 -#: modules/dolibarr/doli-associate/view/compare-wps-proposal.view.php:34 -#: modules/emails/view/frontend/order-details.php:76 +#: modules/cart/view/frontend/cart-resume.php:47 +#: modules/checkout/view/frontend/review-order.php:75 +#: modules/dolibarr/doli-associate/view/compare-wps-proposal.view.php:38 +#: modules/dolibarr/doli-invoice/view/metabox-invoice-products.view.php:89 +#: modules/emails/view/frontend/order-details.php:73 msgid "Total TTC" msgstr "Total TTC" -#: modules/cart/view/frontend/cart-totals.php:30 +#: modules/cart/view/frontend/cart-totals.php:26 msgid "Cart totals" msgstr "Total du panier" -#: modules/cart/view/frontend/cart-totals.php:39 -#: modules/checkout/view/frontend/valid-checkout.php:35 +#: modules/cart/view/frontend/cart-totals.php:35 +#: modules/checkout/view/frontend/valid-checkout.php:46 msgid "Total" msgstr "Total" -#: modules/cart/view/frontend/cart.php:51 +#: modules/cart/view/frontend/cart.php:46 msgid "Update cart" msgstr "Mettre à jour le panier" -#: modules/cart/view/frontend/empty-cart.php:19 +#: modules/cart/view/frontend/empty-cart.php:16 msgid "Your cart is empty." msgstr "Votre panier est vide." -#: modules/cart/view/frontend/link-cart.php:31 +#: modules/cart/view/frontend/link-cart.php:27 #, php-format msgid "Product \"%1$s\" x%2$d added to the card" msgstr "Produit \"%1$s\" x%2$d ajouté au panier" -#: modules/cart/view/frontend/link-cart.php:34 +#: modules/cart/view/frontend/link-cart.php:30 msgid "View cart" msgstr "Voir le panier" -#: modules/checkout/action/class-checkout-action.php:457 +#: modules/checkout/action/class-checkout-action.php:487 msgid "I accept " msgstr "J'accepte " -#: modules/checkout/action/class-checkout-action.php:461 +#: modules/checkout/action/class-checkout-action.php:491 #, php-format msgid "the %2$s and " msgstr "les %2$s et " -#: modules/checkout/action/class-checkout-action.php:466 +#: modules/checkout/action/class-checkout-action.php:496 #, php-format msgid "the %2$s" msgstr "la %2$s" -#: modules/checkout/class/class-checkout.php:68 +#: modules/checkout/class/class-checkout.php:70 msgid "Terms" msgstr "Termes" -#: modules/checkout/class/class-checkout.php:73 -#: modules/checkout/view/frontend/form-shipping.php:26 +#: modules/checkout/class/class-checkout.php:75 +#: modules/checkout/view/frontend/form-shipping.php:34 msgid "First name" msgstr "Prénom" -#: modules/checkout/class/class-checkout.php:77 +#: modules/checkout/class/class-checkout.php:79 msgid "Last name" msgstr "Nom de famille" -#: modules/checkout/class/class-checkout.php:81 -#: modules/dolibarr/doli-order/view/metabox-order-details.view.php:28 -#: modules/my-account/view/frontend/my-account-details.php:48 -#: modules/third-parties/view/metaboxes/metabox-billing-address-edit.view.php:34 -#: modules/third-parties/view/metaboxes/metabox-billing-address.view.php:35 -#: modules/third-parties/view/metaboxes/metabox-contacts-edit.view.php:23 +#: modules/checkout/class/class-checkout.php:83 +#: modules/dolibarr/doli-order/view/metabox-order-details.view.php:34 +#: modules/my-account/view/frontend/my-account-details.php:59 +#: modules/third-parties/view/metaboxes/metabox-billing-address-edit.view.php:39 +#: modules/third-parties/view/metaboxes/metabox-billing-address.view.php:40 +#: modules/third-parties/view/metaboxes/metabox-contacts-edit.view.php:29 msgid "Phone" msgstr "Numéro de téléphone" -#: modules/checkout/class/class-checkout.php:85 +#: modules/checkout/class/class-checkout.php:87 msgid "Email contact" msgstr "Adresse email" -#: modules/checkout/class/class-checkout.php:89 -#: modules/my-account/view/frontend/form-login.php:56 +#: modules/checkout/class/class-checkout.php:91 +#: modules/my-account/view/frontend/form-login.php:54 msgid "Password" msgstr "Mot de passe" -#: modules/checkout/class/class-checkout.php:99 +#: modules/checkout/class/class-checkout.php:101 msgid "Street Address" msgstr "Adresse" -#: modules/checkout/class/class-checkout.php:103 +#: modules/checkout/class/class-checkout.php:105 msgid "Postcode / Zip" msgstr "Code postal" -#: modules/checkout/class/class-checkout.php:107 -#: modules/checkout/view/frontend/form-shipping.php:79 +#: modules/checkout/class/class-checkout.php:109 +#: modules/checkout/view/frontend/form-shipping.php:83 msgid "Town / City" msgstr "Ville" -#: modules/checkout/class/class-checkout.php:126 +#: modules/checkout/class/class-checkout.php:129 msgid "" "You need to accept the general conditions of sale and " "the privacy policy" @@ -195,197 +196,198 @@ msgstr "" "Veuillez accepter Les conditions générales de vente et " "la Politique confidentialité" -#: modules/checkout/class/class-checkout.php:139 +#: modules/checkout/class/class-checkout.php:142 #, php-format msgid "%s is a required field." msgstr "%s est un champs requis." -#: modules/checkout/class/class-checkout.php:151 +#: modules/checkout/class/class-checkout.php:154 #, php-format msgid "%s is already used." msgstr "%s est déjà utilisé." -#: modules/checkout/filter/class-checkout-filter.php:55 +#: modules/checkout/filter/class-checkout-filter.php:60 msgid "Add to wish list" msgstr "Ajouter à la liste d'envie" -#: modules/checkout/shortcode/class-checkout-shortcode.php:102 -#: modules/checkout/shortcode/class-checkout-shortcode.php:109 +#: modules/checkout/shortcode/class-checkout-shortcode.php:103 +#: modules/checkout/shortcode/class-checkout-shortcode.php:110 msgid "quotation" msgstr "devis" -#: modules/checkout/shortcode/class-checkout-shortcode.php:103 -#: modules/checkout/shortcode/class-checkout-shortcode.php:110 +#: modules/checkout/shortcode/class-checkout-shortcode.php:104 +#: modules/checkout/shortcode/class-checkout-shortcode.php:111 msgid "See my quotations" msgstr "Voir mes devis" -#: modules/checkout/shortcode/class-checkout-shortcode.php:117 +#: modules/checkout/shortcode/class-checkout-shortcode.php:118 msgid "order" msgstr "commande" -#: modules/checkout/shortcode/class-checkout-shortcode.php:118 +#: modules/checkout/shortcode/class-checkout-shortcode.php:119 msgid "See my orders" msgstr "Voir mes commandes" -#: modules/checkout/shortcode/class-checkout-shortcode.php:123 +#: modules/checkout/shortcode/class-checkout-shortcode.php:124 msgid "You can not see this page. Go back to %s with the dolibarr%s avec les données de " "dolibarr" -#: modules/dolibarr/doli-proposals/action/class-doli-proposals-action.php:68 -#: modules/dolibarr/doli-proposals/view/main.view.php:20 +#: modules/dolibarr/doli-proposals/action/class-doli-proposals-action.php:70 +#: modules/dolibarr/doli-proposals/view/main.view.php:34 msgid "Dolibarr Proposals" msgstr "Propositions commerciales" -#: modules/dolibarr/doli-proposals/action/class-doli-proposals-action.php:85 +#: modules/dolibarr/doli-proposals/action/class-doli-proposals-action.php:88 #, fuzzy #| msgid "Proposals" msgid "Proposals Dolibarr" msgstr "Propositions commerciales" -#: modules/dolibarr/doli-proposals/view/list.view.php:21 +#: modules/dolibarr/doli-proposals/view/list.view.php:29 #: modules/proposals/view/list.view.php:21 msgid "Proposal reference" msgstr "Référence du devis" -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:40 -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:66 -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:88 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:44 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:70 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:92 msgid "Draft" msgstr "Brouillon" -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:44 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:48 msgid "Waiting for a signature" msgstr "En attente de la signature" -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:48 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:52 msgid "Signed" msgstr "Signé" -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:52 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:56 msgid "Not signed" msgstr "Non signé" -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:70 -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:92 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:74 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:96 msgid "Not paid" msgstr "Non payée" -#: modules/dolibarr/doli-statut/class/class-doli-statut.php:100 +#: modules/dolibarr/doli-statut/class/class-doli-statut.php:104 msgid "Abandoned" msgstr "Abondonée" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:53 -#: modules/third-parties/action/class-third-party-action.php:155 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:54 +#: modules/third-parties/action/class-third-party-action.php:157 #: modules/third-parties/filter/class-third-party-filter.php:43 #: modules/third-parties/filter/class-third-party-filter.php:45 msgid "Third parties" msgstr "Tiers" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:73 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:74 #: modules/proposals/filter/class-proposals-filter.php:42 #: modules/proposals/filter/class-proposals-filter.php:44 -#: modules/third-parties/view/metaboxes/metabox-dolibarr-proposals.view.php:20 -#: modules/third-parties/view/metaboxes/metabox-proposals.view.php:20 +#: modules/third-parties/view/metaboxes/metabox-dolibarr-proposals.view.php:26 +#: modules/third-parties/view/metaboxes/metabox-proposals.view.php:27 msgid "Proposals" msgstr "Propositions commerciales" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:162 -#: modules/dolibarr/doli-third-parties/class/class-doli-third-parties.php:63 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:168 +#: modules/dolibarr/doli-third-parties/class/class-doli-third-parties.php:64 #, php-format msgid "" "Erase data for the third party %s with the " @@ -1064,32 +1056,36 @@ msgstr "" "Effacer les données pour le tiers %s avec les données de " "dolibarr" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:263 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:278 msgid "WP Object is not equal Dolibarr Object" msgstr "L'objet WordPress n'est pas égal à l'objet Dolibarr" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:270 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:285 msgid "Sync OK" msgstr "Synchronisation OK" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:281 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:308 msgid "Looking for sync status" msgstr "Rechercher un statut de synchronisation" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:292 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:319 msgid "No associated to an ERP Entity" msgstr "Cette entitée n'est pas associé à votre ERP" -#: modules/dolibarr/doli-sync/class/class-doli-sync.php:323 +#: modules/dolibarr/doli-sync/class/class-doli-sync.php:350 msgid "Error not defined" msgstr "Erreur non définie" -#: modules/dolibarr/doli-sync/view/sync-item.view.php:31 +#: modules/dolibarr/doli-sync/view/sync-header.view.php:16 +msgid "Synchro" +msgstr "Synchroniser" + +#: modules/dolibarr/doli-sync/view/sync-item.view.php:36 #, php-format msgid "Associate and synchronize %s" msgstr "Associer et synchroniser %s" -#: modules/dolibarr/doli-third-parties/class/class-doli-third-parties.php:137 +#: modules/dolibarr/doli-third-parties/class/class-doli-third-parties.php:138 #, php-format msgid "" "Erase data for the third party %s with the " @@ -1098,195 +1094,128 @@ msgstr "" "Effacer les données pour le tiers %s avec les données de " "WordPress" -#: modules/dolibarr/doli-user/view/frontend/user-alert.php:25 +#: modules/dolibarr/doli-user/view/frontend/user-alert.php:22 msgid "There is a problem connecting your account to our ERP" msgstr "IL Y A UN PROBLÈME DE CONNEXION DE VOTRE COMPTE À NOTRE ERP" -#: modules/emails/class/class-emails.php:47 -#: modules/pages/class/class-pages.php:103 +#: modules/emails/class/class-emails.php:48 +#: modules/pages/class/class-pages.php:108 msgid "New account" msgstr "Nouveau compte" -#: modules/emails/class/class-emails.php:48 -#: modules/pages/class/class-pages.php:118 +#: modules/emails/class/class-emails.php:49 +#: modules/pages/class/class-pages.php:123 msgid "" "Welcome
This email confirms that your account has been created.
" "Thank you for your trust and see you soon on our shop." msgstr "" -#: modules/emails/class/class-emails.php:52 +#: modules/emails/class/class-emails.php:53 msgid "Pending order" msgstr "Commande en cours" -#: modules/emails/class/class-emails.php:53 -#: modules/pages/class/class-pages.php:119 +#: modules/emails/class/class-emails.php:54 +#: modules/pages/class/class-pages.php:124 msgid "" "Hello
We have just recorded your order, thank you to send us your " "payment.
We thank you for your confidence and see you soon on our shop." msgstr "" -#: modules/emails/class/class-emails.php:57 +#: modules/emails/class/class-emails.php:58 msgid "New order" msgstr "Nouvelle commande payée" -#: modules/emails/class/class-emails.php:58 -#: modules/pages/class/class-pages.php:120 +#: modules/emails/class/class-emails.php:59 +#: modules/pages/class/class-pages.php:125 msgid "" "Hello
This email confirms that your payment for your recent order has " "just been validated.
See you soon on our shop." msgstr "" -#: modules/emails/class/class-emails.php:70 +#: modules/emails/class/class-emails.php:71 msgid "Send invoice" msgstr "Votre facture" -#: modules/emails/class/class-emails.php:71 -#: modules/pages/class/class-pages.php:122 +#: modules/emails/class/class-emails.php:72 +#: modules/pages/class/class-pages.php:127 msgid "Hello
You can access your invoices by logging in to your account." msgstr "" -#: modules/emails/view/admin-new-order.php:30 -#, php-format -msgid "You’ve received the following order from %s:" -msgstr "Vous avez reçu la commande suivante de %s:" - -#: modules/emails/view/admin-new-order.php:33 -#, php-format -msgid "
View order" -msgstr "Voir la commande" - -#: modules/emails/view/customer-delivered-order.php:30 -#: modules/emails/view/customer-invoice.php:30 -#: modules/emails/view/customer-new-account.php:26 -#: modules/emails/view/customer-processing-order.php:26 -#, php-format -msgid "Hi %s," -msgstr "Bonjour %s," - -#: modules/emails/view/customer-delivered-order.php:36 -#, php-format -msgid "Your %s order has beed marked delivered on our side." -msgstr "Votre commande de %s a été marquée comme livrée de notre côté." - -#: modules/emails/view/customer-delivered-order.php:47 -#, php-format -msgid "Your tracking link: %s." -msgstr "Votre lien de suivi : %s." - -#: modules/emails/view/customer-invoice.php:37 -#, php-format -msgid "Your invoice %1$s for your order %2$s" -msgstr "Votre facture #%1$s pour votre commande #%2$s" - -#: modules/emails/view/customer-new-account.php:32 -#, php-format -msgid "" -"Thanks for creating an account on %1$s. Your username is %2$s. You can " -"access your account area to view orders, change your password, and more at: " -"%4$s" -msgstr "" -"Merci d'avoir crée votre compte sur %1$s. Votre identifiant est %2$s. Vous " -"pouvez accéder à votre compte pour voir vos commandes, télécharger vos " -"factures, réinitialiser votre mot de passe et bien d'autre, sur : %4$s" - -#: modules/emails/view/customer-new-account.php:44 -#, php-format -msgid "" -"Click here to create your password: Create my " -"password" -msgstr "" -"Cliquez ici pour créer votre mot de passe: Créer mon " -"mot de passe" - -#: modules/emails/view/customer-new-account.php:48 -msgid "We look forward to seeing you soon." -msgstr "Nous avons hâte de vous revoir bientôt." - -#: modules/emails/view/customer-processing-order.php:32 -#, php-format -msgid "" -"Just to let you know — we've received your order #%s, and it is now being " -"processed:" -msgstr "" -"Nous vous informons que nous avons bien reçu votre commande #%s. Celle-ci " -"est en cours de traitement:" - -#: modules/emails/view/frontend/order-details.php:26 +#: modules/emails/view/frontend/order-details.php:32 #, php-format msgid "Order #%1$s ()" msgstr "Commande #%1$s ()" -#: modules/emails/view/frontend/order-details.php:82 +#: modules/emails/view/frontend/order-details.php:79 msgid "See my orders or my downloadable products" msgstr "Voir mes commandes ou mes produits téléchargeables" -#: modules/my-account/action/class-my-account-action.php:83 +#: modules/my-account/action/class-my-account-action.php:82 msgid "Your username or password is incorrect." msgstr "Votre identifiant ou votre mot de passe est incorrect." -#: modules/my-account/action/class-my-account-action.php:213 +#: modules/my-account/action/class-my-account-action.php:212 msgid "What do you try to do ?" msgstr "Qu'essayez-vous de faire ?" -#: modules/my-account/class/class-my-account.php:110 -#: modules/pages/class/class-pages.php:87 +#: modules/my-account/class/class-my-account.php:127 +#: modules/pages/class/class-pages.php:92 msgid "My account" msgstr "Mon compte" -#: modules/my-account/class/class-my-account.php:115 +#: modules/my-account/class/class-my-account.php:132 #: modules/proposals/action/class-proposals-action.php:61 #: modules/proposals/view/main.view.php:21 msgid "Wish List" msgstr "Liste d'envies" -#: modules/my-account/class/class-my-account.php:120 +#: modules/my-account/class/class-my-account.php:137 msgid "Dolibarr Quotation" msgstr "Proposition" -#: modules/my-account/class/class-my-account.php:135 +#: modules/my-account/class/class-my-account.php:152 msgid "Downloads" msgstr "Téléchargements" -#: modules/my-account/class/class-my-account.php:140 +#: modules/my-account/class/class-my-account.php:157 msgid "Logout" msgstr "Deconnexion" -#: modules/my-account/class/class-my-account.php:153 +#: modules/my-account/class/class-my-account.php:170 msgid "Switch back" msgstr "Retour" -#: modules/my-account/view/frontend/checkout-login.php:21 +#: modules/my-account/view/frontend/checkout-login.php:24 msgid "Returning customer ?" msgstr "Déjà client ? Cliquez ici pour vous connecter ?" -#: modules/my-account/view/frontend/checkout-login.php:21 +#: modules/my-account/view/frontend/checkout-login.php:24 msgid "Click here to login" msgstr "Cliquez ici pour vous connecter" -#: modules/my-account/view/frontend/form-login.php:50 -#: modules/my-account/view/frontend/lost-password.php:33 +#: modules/my-account/view/frontend/form-login.php:48 +#: modules/my-account/view/frontend/lost-password.php:32 msgid "Username or email address" msgstr "Nom d'utilisateur ou adresse électronique" -#: modules/my-account/view/frontend/form-login.php:63 +#: modules/my-account/view/frontend/form-login.php:61 msgid "Log in" msgstr "Connexion" -#: modules/my-account/view/frontend/form-login.php:64 +#: modules/my-account/view/frontend/form-login.php:62 msgid "Lost Password" msgstr "Mot de passe perdu" -#: modules/my-account/view/frontend/login-title.php:21 -#: modules/my-account/view/frontend/my-account-details.php:55 +#: modules/my-account/view/frontend/login-title.php:16 +#: modules/my-account/view/frontend/my-account-details.php:66 msgid "Login" msgstr "Connexion" -#: modules/my-account/view/frontend/lost-password.php:20 +#: modules/my-account/view/frontend/lost-password.php:19 msgid "Lost password ?" msgstr "Mot de passe perdu ?" -#: modules/my-account/view/frontend/lost-password.php:22 +#: modules/my-account/view/frontend/lost-password.php:21 msgid "" "Lost your password? Please enter your username or email address. You will " "receive a link to create a new password via email." @@ -1295,93 +1224,93 @@ msgstr "" "ou votre adresse électronique. Vous recevrez un lien pour créer un nouveau " "mot de passe par courrier électronique." -#: modules/my-account/view/frontend/lost-password.php:40 +#: modules/my-account/view/frontend/lost-password.php:39 msgid "Reset password" msgstr "Réinitialisation du mot de passe" -#: modules/my-account/view/frontend/my-account-details.php:83 +#: modules/my-account/view/frontend/my-account-details.php:94 msgid "Zip" msgstr "Code postal" -#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:24 -#: modules/my-account/view/frontend/my-account-invoices.php:25 -#: modules/my-account/view/frontend/my-account-orders.php:24 +#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:31 +#: modules/my-account/view/frontend/my-account-invoices.php:31 +#: modules/my-account/view/frontend/my-account-orders.php:30 msgid "Please contact commercial" msgstr "Veuillez contacter le service commercial" -#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:44 -#: modules/my-account/view/frontend/my-account-invoices.php:46 -#: modules/my-account/view/frontend/my-account-orders.php:44 -#: modules/my-account/view/frontend/my-account-proposals.php:33 +#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:47 +#: modules/my-account/view/frontend/my-account-invoices.php:47 +#: modules/my-account/view/frontend/my-account-orders.php:46 +#: modules/my-account/view/frontend/my-account-proposals.php:32 msgid "View details" msgstr "Voir les détails" -#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:78 +#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:80 #: modules/my-account/view/frontend/my-account-invoices.php:75 -#: modules/my-account/view/frontend/my-account-orders.php:81 -#: modules/my-account/view/frontend/my-account-proposals.php:67 +#: modules/my-account/view/frontend/my-account-orders.php:82 +#: modules/my-account/view/frontend/my-account-proposals.php:66 msgid "No products to display" msgstr "Aucun produits à afficher" -#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:89 +#: modules/my-account/view/frontend/my-account-dolibarr-proposals.php:88 msgid "No quotations" msgstr "Aucun devis" -#: modules/my-account/view/frontend/my-account-downloads.php:47 +#: modules/my-account/view/frontend/my-account-downloads.php:52 msgid "No downloadable product" msgstr "Aucun produit téléchargeable" -#: modules/my-account/view/frontend/my-account-invoices.php:86 +#: modules/my-account/view/frontend/my-account-invoices.php:83 msgid "No invoice" msgstr "Aucune facture" -#: modules/my-account/view/frontend/my-account-orders.php:92 +#: modules/my-account/view/frontend/my-account-orders.php:90 msgid "No orders" msgstr "Aucune commande" -#: modules/my-account/view/frontend/my-account-proposals.php:78 +#: modules/my-account/view/frontend/my-account-proposals.php:77 msgid "No wishes" msgstr "Aucune envie" -#: modules/pages/class/class-pages.php:84 +#: modules/pages/class/class-pages.php:89 msgid "Shop" msgstr "Boutique" -#: modules/pages/class/class-pages.php:85 +#: modules/pages/class/class-pages.php:90 msgid "Cart" msgstr "Panier" -#: modules/pages/class/class-pages.php:86 +#: modules/pages/class/class-pages.php:91 msgid "Checkout" msgstr "Tunnel de vente" -#: modules/pages/class/class-pages.php:88 +#: modules/pages/class/class-pages.php:93 msgid "General conditions of sale" msgstr "Condition générales de vente" -#: modules/pages/class/class-pages.php:105 +#: modules/pages/class/class-pages.php:110 msgid "Current order" msgstr "Commande en cours" -#: modules/pages/class/class-pages.php:107 +#: modules/pages/class/class-pages.php:112 msgid "Completed order" msgstr "Commande complétée" -#: modules/pages/class/class-pages.php:109 -#: modules/pages/class/class-pages.php:121 +#: modules/pages/class/class-pages.php:114 +#: modules/pages/class/class-pages.php:126 msgid "Paid order" msgstr "Commande payée" -#: modules/pages/class/class-pages.php:113 -#: modules/pages/class/class-pages.php:123 +#: modules/pages/class/class-pages.php:118 +#: modules/pages/class/class-pages.php:128 msgid "Delivered order" msgstr "Commande livrée" -#: modules/payment/class/class-payment.php:52 +#: modules/payment/class/class-payment.php:54 msgid "Cheque" msgstr "Chèque" -#: modules/payment/class/class-payment.php:53 +#: modules/payment/class/class-payment.php:55 msgid "" "Please send a check to Store Name, Store Street, Store Town, Store State / " "County, Store Postcode." @@ -1389,50 +1318,50 @@ msgstr "" "Veuillez envoyer un chèque au Nom de la boutique, adresse, ville, pays, Code " "postal." -#: modules/payment/class/class-payment.php:59 +#: modules/payment/class/class-payment.php:61 msgid "Payment in shop" msgstr "Paiement en boutique" -#: modules/payment/class/class-payment.php:60 +#: modules/payment/class/class-payment.php:62 msgid "Pay and pick up directly your products at the shop." msgstr "Payez et retirer vos produits à la boutique." -#: modules/payment/class/class-payment.php:65 +#: modules/payment/class/class-payment.php:67 msgid "PayPal" msgstr "PayPal" -#: modules/payment/class/class-payment.php:66 +#: modules/payment/class/class-payment.php:68 msgid "Accept payments via PayPal using account balance or credit card." msgstr "" "Paiements par PayPal utilisant le solde du compte ou la carte de crédit " "acceptés." -#: modules/payment/class/class-payment.php:73 +#: modules/payment/class/class-payment.php:75 msgid "Stripe" msgstr "Stripe" -#: modules/payment/class/class-payment.php:74 +#: modules/payment/class/class-payment.php:76 msgid "Use your credit card to place your order" msgstr "Utilisez votre carte de crédit pour passer votre commande" -#: modules/payment/class/class-payment.php:85 +#: modules/payment/class/class-payment.php:87 msgid "Waiting for the check" msgstr "En attente du chèque" -#: modules/payment/class/class-payment.php:86 -#: modules/payment/class/class-payment.php:90 -#: modules/payment/class/class-payment.php:94 -#: modules/payment/class/class-payment.php:98 +#: modules/payment/class/class-payment.php:88 +#: modules/payment/class/class-payment.php:92 +#: modules/payment/class/class-payment.php:96 +#: modules/payment/class/class-payment.php:100 msgid "Paid" msgstr "Payée" -#: modules/payment/class/class-payment.php:89 -#: modules/payment/class/class-payment.php:93 -#: modules/payment/class/class-payment.php:97 +#: modules/payment/class/class-payment.php:91 +#: modules/payment/class/class-payment.php:95 +#: modules/payment/class/class-payment.php:99 msgid "Waiting for the payment" msgstr "En attente du paiement" -#: modules/paypal/filter/class-paypal-filter.php:46 +#: modules/paypal/filter/class-paypal-filter.php:45 msgid "" " SANDBOX ENABLED. You can use sandbox testing accounts only. See the PayPal " @@ -1443,57 +1372,65 @@ msgstr "" "lifecycle/ug_sandbox/\">Guide de test des bacs à sable de PayPal pour " "plus de détails." -#: modules/paypal/view/form-setting.view.php:20 +#: modules/paypal/view/form-setting.view.php:24 msgid "Paypal email" msgstr "Email Paypal" -#: modules/paypal/view/form-setting.view.php:29 +#: modules/paypal/view/form-setting.view.php:33 msgid "PayPal Sandbox" msgstr "Sandbox de PayPal" -#: modules/products/action/class-product-action.php:53 +#: modules/products/action/class-product-action.php:51 msgid "Products Category" msgstr "Catégories de produits" -#: modules/products/action/class-product-action.php:344 +#: modules/products/action/class-product-action.php:350 #, php-format msgid "Search result for \"%s\"" msgstr "Résultats de la recherche pour \"%s\"" -#: modules/products/class/class-product.php:173 +#: modules/products/class/class-product.php:191 msgid "Product configuration" msgstr "Configuration du produit" +#: modules/products/class/class-product.php:198 +msgid "Product Gallery" +msgstr "Galerie d'image du produit" + +#: modules/products/class/class-product.php:206 +msgid "Product Document" +msgstr "Documents du produit" + +#: modules/products/filter/class-product-filter.php:64 #: modules/products/filter/class-product-filter.php:66 -#: modules/products/filter/class-product-filter.php:68 msgid "Product" msgstr "Produit" -#: modules/products/filter/class-product-filter.php:70 +#: modules/products/filter/class-product-filter.php:68 msgid "Add New Product" msgstr "Ajouter nouveau produit" -#: modules/products/filter/class-product-filter.php:71 +#: modules/products/filter/class-product-filter.php:69 msgid "New Product" msgstr "Nouveau produit" -#: modules/products/filter/class-product-filter.php:72 +#: modules/products/filter/class-product-filter.php:70 msgid "Edit Product" msgstr "Editer produit" -#: modules/products/filter/class-product-filter.php:73 +#: modules/products/filter/class-product-filter.php:71 msgid "View Product" msgstr "Voir produit" -#: modules/products/filter/class-product-filter.php:74 +#: modules/products/filter/class-product-filter.php:72 msgid "All Products" msgstr "Tous les produits" -#: modules/products/filter/class-product-filter.php:75 +#: modules/products/filter/class-product-filter.php:73 msgid "Search Products" msgstr "Rechercher Produits" -#: modules/products/filter/class-product-filter.php:76 +#: modules/products/filter/class-product-filter.php:74 msgid "Parent Products:" msgstr "Parent de produits:" @@ -1542,83 +1479,111 @@ msgstr "Nouvelle catégorie de produitNom" msgid "category-product" msgstr "categorie-produit" -#: modules/products/filter/class-product-filter.php:256 +#: modules/products/filter/class-product-filter.php:259 msgid "Sold out" msgstr "Rupture de stock" -#: modules/products/view/frontend/wps-product-list-edit.php:43 -#: modules/products/view/frontend/wps-product-list.php:33 +#: modules/products/view/frontend/wps-product-grid.php:40 +#, fuzzy +#| msgid "Search a product" +msgid "See the product" +msgstr "Rechercher un produit" + +#: modules/products/view/frontend/wps-product-grid.php:50 +#, fuzzy +#| msgid "Add New Product category" +msgid "Add the product to cart" +msgstr "Ajouter une nouvelle catégorie de produits" + +#: modules/products/view/frontend/wps-product-list-edit.php:50 +#: modules/products/view/frontend/wps-product-list.php:37 msgid "Unit price:" msgstr "Prix unitaire:" #: modules/products/view/frontend/wps-product-single.php:48 -#: modules/products/view/metabox/main.view.php:109 +#: modules/products/view/metabox/main.view.php:120 msgid "Similar products" msgstr "Produits similaires" -#: modules/products/view/frontend/wps-product-stock.php:19 +#: modules/products/view/frontend/wps-product-stock.php:26 #, php-format msgid "%s in stock" msgstr "%s en stock" -#: modules/products/view/frontend/wps-product-taxonomy.php:23 +#: modules/products/view/frontend/wps-product-taxonomy.php:30 msgid "Read more" msgstr "Détails" -#: modules/products/view/item-edit.view.php:39 +#: modules/products/view/item-edit.view.php:40 msgid "Save" msgstr "Sauvegarder" -#: modules/products/view/item-edit.view.php:68 +#: modules/products/view/item-edit.view.php:66 msgid "No product parent" msgstr "Pas de produit parent" -#: modules/products/view/item-edit.view.php:74 -#: modules/products/view/metabox/main.view.php:87 +#: modules/products/view/item-edit.view.php:71 +#: modules/products/view/metabox/main.view.php:98 msgid "Manage Stock" msgstr "Gérer le stock" -#: modules/products/view/item-edit.view.php:80 -#: modules/products/view/list.view.php:28 -#: modules/products/view/metabox/main.view.php:93 +#: modules/products/view/item-edit.view.php:77 +#: modules/products/view/list.view.php:37 +#: modules/products/view/metabox/main.view.php:104 msgid "Stock" msgstr "Stock" -#: modules/products/view/item.view.php:27 +#: modules/products/view/item.view.php:33 msgid "Edit" msgstr "Modifier" -#: modules/products/view/item.view.php:29 -#: modules/products/view/metabox/main.view.php:26 -#: modules/third-parties/view/item.view.php:32 +#: modules/products/view/item.view.php:35 +#: modules/products/view/metabox/main.view.php:37 +#: modules/third-parties/view/item.view.php:38 msgid "Edit in Dolibarr" msgstr "Editer sur Dolibarr" -#: modules/products/view/item.view.php:31 +#: modules/products/view/item.view.php:37 msgid "Delete" msgstr "Supprimer" -#: modules/products/view/item.view.php:32 +#: modules/products/view/item.view.php:38 msgid "Preview" msgstr "Afficher" -#: modules/products/view/item.view.php:39 +#: modules/products/view/item.view.php:45 msgid "No handle stock" msgstr "Stock non configuré" -#: modules/products/view/list.view.php:22 +#: modules/products/view/list.view.php:31 msgid "Thumbnail" msgstr "Vignette" -#: modules/products/view/list.view.php:25 +#: modules/products/view/list.view.php:34 msgid "Tax Rate" msgstr "Taux de TVA" -#: modules/products/view/metabox/main.view.php:32 +#: modules/products/view/metabox/document.view.php:43 +msgid "Modify documents on Dolibarr" +msgstr "Modifier les documents sur Dolibarr" + +#: modules/products/view/metabox/document.view.php:47 +msgid "Add a file to the document" +msgstr "Ajouter un fichier au document" + +#: modules/products/view/metabox/gallery.view.php:43 +msgid "Modify the gallery on Dolibarr" +msgstr "Modifier la galerie sur Dolibarr" + +#: modules/products/view/metabox/gallery.view.php:47 +msgid "Add an image to the gallery" +msgstr "Ajouter une image à la galerie" + +#: modules/products/view/metabox/main.view.php:43 msgid "Autres informations du produit" msgstr "" -#: modules/products/view/metabox/main.view.php:100 +#: modules/products/view/metabox/main.view.php:111 msgid "Product Downloadable" msgstr "Produit Téléchargeable" @@ -1629,8 +1594,8 @@ msgstr "Devis" #: modules/proposals/filter/class-proposals-filter.php:43 #: modules/proposals/filter/class-proposals-filter.php:45 #: modules/proposals/view/single.view.php:21 -#: modules/third-parties/view/metaboxes/metabox-dolibarr-proposals.view.php:24 -#: modules/third-parties/view/metaboxes/metabox-proposals.view.php:24 +#: modules/third-parties/view/metaboxes/metabox-dolibarr-proposals.view.php:30 +#: modules/third-parties/view/metaboxes/metabox-proposals.view.php:31 msgid "Proposal" msgstr "Proposition commerciale" @@ -1680,11 +1645,11 @@ msgstr "Résultats de la recherche pour \"%s\"" msgid "Details" msgstr "Détails" -#: modules/search/view/search-field.view.php:20 +#: modules/search/view/search-field.view.php:17 msgid "Search for:" msgstr "Rechercher:" -#: modules/search/view/search-field.view.php:21 +#: modules/search/view/search-field.view.php:18 msgid "Search products…" msgstr "Rechercher un produit…" @@ -1693,231 +1658,239 @@ msgstr "Rechercher un produit…" msgid "Search a product" msgstr "Rechercher un produit" -#: modules/search/widget/class-search-widget.php:61 +#: modules/search/widget/class-search-widget.php:63 msgid "New title" msgstr "Nouveau titre" -#: modules/search/widget/class-search-widget.php:64 +#: modules/search/widget/class-search-widget.php:66 msgid "Title:" msgstr "Titre:" -#: modules/settings/action/class-settings-action.php:146 -#: modules/settings/action/class-settings-action.php:305 +#: modules/settings/action/class-settings-action.php:150 +#: modules/settings/action/class-settings-action.php:313 msgid "WPshop cannot connect to dolibarr. Please check your settings" msgstr "" "WPshop n'est pas connecté à Dolibarr. Veuillez vérifier vos configurations" -#: modules/settings/action/class-settings-action.php:153 -#: modules/settings/action/class-settings-action.php:189 -#: modules/settings/action/class-settings-action.php:221 -#: modules/settings/action/class-settings-action.php:249 -#: modules/settings/action/class-settings-action.php:312 +#: modules/settings/action/class-settings-action.php:157 +#: modules/settings/action/class-settings-action.php:194 +#: modules/settings/action/class-settings-action.php:227 +#: modules/settings/action/class-settings-action.php:256 +#: modules/settings/action/class-settings-action.php:320 msgid "Your settings have been saved." msgstr "Vos réglages ont été enregistrés." -#: modules/settings/class/class-settings.php:134 +#: modules/settings/class/class-settings.php:141 msgid "No page" msgstr "Pas de page" -#: modules/settings/class/class-settings.php:219 +#: modules/settings/class/class-settings.php:229 msgid "No product" msgstr "Aucun produit" -#: modules/settings/view/email-single.view.php:48 -#: modules/settings/view/erp.view.php:181 -#: modules/settings/view/general.view.php:57 -#: modules/settings/view/pages.view.php:56 -#: modules/settings/view/payment-method-single.view.php:53 -#: modules/settings/view/shipping-cost.view.php:54 -msgid "Save Changes" -msgstr "Enregistrer les changements" - -#: modules/settings/view/emails.view.php:22 +#: modules/settings/view/emails.view.php:28 msgid "E-mail" msgstr "Email" -#: modules/settings/view/emails.view.php:38 -#: modules/settings/view/notice-activate-erp.view.php:22 -#: modules/settings/view/payment-method.view.php:37 +#: modules/settings/view/emails.view.php:39 +#: modules/settings/view/notice-activate-erp.view.php:19 +#: modules/settings/view/payment-method.view.php:43 msgid "Configure" msgstr "Configurer" -#: modules/settings/view/erp.view.php:26 +#: modules/settings/view/erp.view.php:29 msgid "Dolibarr URL" msgstr "URL de Dolibarr" -#: modules/settings/view/erp.view.php:34 +#: modules/settings/view/erp.view.php:37 msgid "Dolibarr Secret Key" msgstr "Clé API de Dolibarr" -#: modules/settings/view/erp.view.php:35 +#: modules/settings/view/erp.view.php:38 msgid "Secret key used for sell with Dolibarr" msgstr "Clé API utilisée pour la connexion avec Dolibarr" -#: modules/settings/view/erp.view.php:39 +#: modules/settings/view/erp.view.php:40 msgid "Connected to Dolibarr" msgstr "Connecter à Dolibarr" -#: modules/settings/view/erp.view.php:43 +#: modules/settings/view/erp.view.php:42 msgid "Connection to dolibarr failed" msgstr "La connexion à Dolibarr a échoué" -#: modules/settings/view/erp.view.php:55 +#: modules/settings/view/erp.view.php:52 msgid "Dolibarr Public Key (Optional)" msgstr "Clé publique Dolibarr (facultatif)" -#: modules/settings/view/erp.view.php:56 +#: modules/settings/view/erp.view.php:53 msgid "Public key used for your theme" msgstr "Clé publique utilisée pour votre thème" -#: modules/settings/view/erp.view.php:68 +#: modules/settings/view/erp.view.php:65 msgid "Dolibarr Create Tier" msgstr "Crée un Tier Dolibarr" -#: modules/settings/view/erp.view.php:69 modules/settings/view/erp.view.php:78 -#: modules/settings/view/erp.view.php:89 modules/settings/view/erp.view.php:99 -#: modules/settings/view/erp.view.php:120 -#: modules/settings/view/erp.view.php:130 -#: modules/settings/view/erp.view.php:141 -#: modules/settings/view/erp.view.php:150 -#: modules/settings/view/erp.view.php:163 -#: modules/settings/view/erp.view.php:173 +#: modules/settings/view/erp.view.php:66 modules/settings/view/erp.view.php:75 +#: modules/settings/view/erp.view.php:86 modules/settings/view/erp.view.php:96 +#: modules/settings/view/erp.view.php:105 +#: modules/settings/view/erp.view.php:126 +#: modules/settings/view/erp.view.php:136 +#: modules/settings/view/erp.view.php:147 +#: modules/settings/view/erp.view.php:156 +#: modules/settings/view/erp.view.php:169 +#: modules/settings/view/erp.view.php:179 msgid "Test the link" msgstr "Tester le lien" -#: modules/settings/view/erp.view.php:77 +#: modules/settings/view/erp.view.php:74 msgid "Dolibarr Tiers Lists" msgstr "Listes des Tiers Dolibarr" -#: modules/settings/view/erp.view.php:88 +#: modules/settings/view/erp.view.php:85 msgid "Dolibarr Create Product" msgstr "Créer un Produit Dolibarr" -#: modules/settings/view/erp.view.php:98 +#: modules/settings/view/erp.view.php:95 msgid "Dolibarr Products Lists" msgstr "Listes des Produits Dolibarr" -#: modules/settings/view/erp.view.php:119 +#: modules/settings/view/erp.view.php:104 +msgid "Dolibarr Product Document" +msgstr "Les documents des produits Dolibarr" + +#: modules/settings/view/erp.view.php:125 msgid "Dolibarr Create Proposal" msgstr "Créer une Proposition Commerciale Dolibarr" -#: modules/settings/view/erp.view.php:129 +#: modules/settings/view/erp.view.php:135 msgid "Dolibarr Proposals Lists" msgstr "Listes des Propositions Commerciales Dolibarr" -#: modules/settings/view/erp.view.php:140 +#: modules/settings/view/erp.view.php:146 msgid "Dolibarr Create Order" msgstr "Créer une Commande Dolibarr" -#: modules/settings/view/erp.view.php:149 +#: modules/settings/view/erp.view.php:155 msgid "Dolibarr Orders Lists" msgstr "Listes des Commandes Dolibarr" -#: modules/settings/view/erp.view.php:162 +#: modules/settings/view/erp.view.php:168 msgid "Dolibarr Invoices Lists" msgstr "Listes des Factures Dolibarr" -#: modules/settings/view/erp.view.php:172 +#: modules/settings/view/erp.view.php:178 msgid "Dolibarr Payments Lists" msgstr "Listes des Paiements Dolibarr" -#: modules/settings/view/general.view.php:25 +#: modules/settings/view/erp.view.php:187 +#: modules/settings/view/general.view.php:68 +#: modules/settings/view/pages.view.php:66 +#: modules/settings/view/payment-method-single.view.php:58 +#: modules/settings/view/shipping-cost.view.php:57 +msgid "Save Changes" +msgstr "Enregistrer les changements" + +#: modules/settings/view/general.view.php:29 msgid "Shop Email" msgstr "Email de la boutique WPshop" -#: modules/settings/view/general.view.php:33 +#: modules/settings/view/general.view.php:37 msgid "WPshop width size" msgstr "Largeur de la fenêtre de WPshop" -#: modules/settings/view/general.view.php:42 +#: modules/settings/view/general.view.php:46 msgid "WPshop height size" msgstr "Hauteur de la fenêtre de WPshop" -#: modules/settings/view/general.view.php:52 +#: modules/settings/view/general.view.php:56 msgid "Enable wish list" msgstr "Activer la liste d'envies" -#: modules/settings/view/main.view.php:34 modules/tools/view/main.view.php:24 +#: modules/settings/view/general.view.php:63 +msgid "Split product" +msgstr "Séparer les lignes des produits dans le panier" + +#: modules/settings/view/main.view.php:40 modules/tools/view/main.view.php:29 msgid "General" msgstr "Général" -#: modules/settings/view/main.view.php:35 +#: modules/settings/view/main.view.php:41 msgid "Pages" msgstr "Pages" -#: modules/settings/view/main.view.php:36 +#: modules/settings/view/main.view.php:42 msgid "Emails" msgstr "Emails" -#: modules/settings/view/main.view.php:38 +#: modules/settings/view/main.view.php:44 msgid "ERP" msgstr "ERP" -#: modules/settings/view/notice-activate-erp.view.php:21 +#: modules/settings/view/notice-activate-erp.view.php:18 msgid "WPshop: You have not yet set up your ERP ?" msgstr "WPshop: Avez vous réglé votre ERP ?" -#: modules/settings/view/notice-activate-erp.view.php:23 -#: modules/settings/view/notice-error-erp.view.php:22 +#: modules/settings/view/notice-activate-erp.view.php:20 +#: modules/settings/view/notice-error-erp.view.php:26 msgid "Follow this guide" msgstr "Suivre ce guide" -#: modules/settings/view/notice-activate-erp.view.php:27 +#: modules/settings/view/notice-activate-erp.view.php:24 msgid "Do not show this message again." msgstr "Ne montrez plus ce message." -#: modules/settings/view/notice-error-erp.view.php:27 +#: modules/settings/view/notice-error-erp.view.php:31 msgid "Do not show this message again" msgstr "Ne montrez plus ce message" -#: modules/settings/view/payment-method-single.view.php:39 -#: modules/settings/view/payment-method.view.php:34 +#: modules/settings/view/payment-method-single.view.php:44 +#: modules/settings/view/payment-method.view.php:40 msgid "Activate" msgstr "Activer" -#: modules/settings/view/payment-method.view.php:22 +#: modules/settings/view/payment-method.view.php:28 msgid "Method" msgstr "Méthode" -#: modules/settings/view/payment-method.view.php:23 +#: modules/settings/view/payment-method.view.php:29 msgid "Activated" msgstr "Activé" -#: modules/settings/view/payment-method.view.php:34 +#: modules/settings/view/payment-method.view.php:40 msgid "Deactivate" msgstr "Désactiver" -#: modules/settings/view/shipping-cost.view.php:26 +#: modules/settings/view/shipping-cost.view.php:32 msgid "Select shipping product" msgstr "Sélectionner votre produit \"Frais de livraison\"" -#: modules/settings/view/shipping-cost.view.php:48 +#: modules/settings/view/shipping-cost.view.php:51 msgid "Free delivery starting from (€) HT" msgstr "Livraison gratuite à partir de (€) HT" -#: modules/stripe/filter/class-stripe-filter.php:46 +#: modules/stripe/filter/class-stripe-filter.php:45 msgid " SANDBOX ENABLED" msgstr " BAC À SABLE ACTIVÉ" -#: modules/stripe/view/form-setting.view.php:20 +#: modules/stripe/view/form-setting.view.php:24 msgid "Publish key" msgstr "Clé publique" -#: modules/stripe/view/form-setting.view.php:27 +#: modules/stripe/view/form-setting.view.php:31 msgid "Secret key" msgstr "Clé secrète" -#: modules/stripe/view/form-setting.view.php:36 +#: modules/stripe/view/form-setting.view.php:40 msgid "Stripe Sandbox" msgstr "Bac à sable Stripe" #: modules/third-parties/action/class-third-party-action.php:64 #: modules/third-parties/action/class-third-party-action.php:65 -#: modules/third-parties/view/main.view.php:21 +#: modules/third-parties/view/main.view.php:34 msgid "Third Parties" msgstr "Tiers" -#: modules/third-parties/class/class-third-party.php:284 +#: modules/third-parties/class/class-third-party.php:299 #, php-format msgid "Dissociate contact %1$s from %2$s" msgstr "Dissocier contact %1$s depuis %2$s" @@ -1963,84 +1936,158 @@ msgstr "Aucun tiers trouvé." msgid "No third parties found in Trash." msgstr "Aucun Tier trouvé dans la Corbeille." -#: modules/third-parties/view/list.view.php:22 +#: modules/third-parties/view/list.view.php:29 msgid "Society name" msgstr "Nom de la société" -#: modules/third-parties/view/list.view.php:23 +#: modules/third-parties/view/list.view.php:30 msgid "User" msgstr "Utilisateur" -#: modules/third-parties/view/list.view.php:24 +#: modules/third-parties/view/list.view.php:31 msgid "Commercial" msgstr "Commercial" -#: modules/third-parties/view/list.view.php:25 +#: modules/third-parties/view/list.view.php:32 msgid "Actions" msgstr "Actions" -#: modules/third-parties/view/metaboxes/metabox-activity.view.php:20 -msgid "Activity" -msgstr "Activité" - -#: modules/third-parties/view/metaboxes/metabox-billing-address-edit.view.php:20 +#: modules/third-parties/view/metaboxes/metabox-billing-address-edit.view.php:25 msgid "Billing Address" msgstr "Adresse de facturation" -#: modules/third-parties/view/metaboxes/metabox-contacts.view.php:20 +#: modules/third-parties/view/metaboxes/metabox-contacts.view.php:29 msgid "Users" msgstr "Utilisateurs" -#: modules/third-parties/view/metaboxes/metabox-dolibarr-proposals.view.php:26 -#: modules/third-parties/view/metaboxes/metabox-invoices.view.php:27 -#: modules/third-parties/view/metaboxes/metabox-orders.view.php:26 -#: modules/third-parties/view/metaboxes/metabox-proposals.view.php:26 +#: modules/third-parties/view/metaboxes/metabox-dolibarr-proposals.view.php:32 +#: modules/third-parties/view/metaboxes/metabox-invoices.view.php:34 +#: modules/third-parties/view/metaboxes/metabox-orders.view.php:33 +#: modules/third-parties/view/metaboxes/metabox-proposals.view.php:33 msgid "€ TTC" msgstr "€ TTC" -#: modules/third-parties/view/metaboxes/metabox-indicator.view.php:20 -msgid "Indicator" -msgstr "Indicateur" - -#: modules/third-parties/view/metaboxes/metabox-task.view.php:20 -msgid "Tasks" -msgstr "Tâches" - -#: modules/third-parties/view/single-title-edit.view.php:26 +#: modules/third-parties/view/single-title-edit.view.php:30 msgid "New third party" msgstr "Nouveau tier" -#: modules/third-parties/view/single-title.view.php:20 +#: modules/third-parties/view/single-title.view.php:24 #, fuzzy, php-format #| msgid "Tier name %s" msgid "Tier %s" msgstr "Nom du Tier %s" -#: modules/tools/view/general.view.php:22 +#: modules/tools/view/general.view.php:19 msgid "Import third party CSV" msgstr "Importer des clients depuis un CSV" -#: modules/tools/view/general.view.php:32 -#: modules/tools/view/general.view.php:48 +#: modules/tools/view/general.view.php:29 +#: modules/tools/view/general.view.php:45 msgid "Import" msgstr "Importer" -#: modules/tools/view/general.view.php:38 +#: modules/tools/view/general.view.php:35 msgid "Import Product CSV" msgstr "Importer des produits depuis un CSV" -#: modules/tools/view/main.view.php:20 +#: modules/tools/view/main.view.php:25 msgid "Tools" msgstr "Outils" -#: modules/transfert-data/action/class-transfert-data-action.php:184 -#, php-format -msgid "" -"
  • %1$d Contact #%2$d %4$s is already affected to another " -"third party #%3$d %4$s
  • " +#: modules/wishlist/view/frontend/wishlist-add.view.php:19 +msgid "Choose the list or create another list" msgstr "" -"
  • %1$d Contact #%2$d %4$s est déjà affecté à un tier #" -"%3$d %4$s
  • " + +#: modules/wishlist/view/frontend/wishlist-add.view.php:22 +#, fuzzy +#| msgid "Last name" +msgid "List name" +msgstr "Nom de famille" + +#~ msgid "Click on the image to highlight it" +#~ msgstr "Cliquez sur l'image pour la mettre en avant" + +#, fuzzy +#~| msgid "Latest customers" +#~ msgid "Set custom image" +#~ msgstr "Derniers clients" + +#~ msgid "Data synchronization" +#~ msgstr "Synchronisation des données" + +#~ msgid "All Invoices Sync" +#~ msgstr "Synchronisation des factures" + +#, php-format +#~ msgid "You’ve received the following order from %s:" +#~ msgstr "Vous avez reçu la commande suivante de %s:" + +#, php-format +#~ msgid "View order" +#~ msgstr "Voir la commande" + +#, php-format +#~ msgid "Hi %s," +#~ msgstr "Bonjour %s," + +#, php-format +#~ msgid "Your %s order has beed marked delivered on our side." +#~ msgstr "Votre commande de %s a été marquée comme livrée de notre côté." + +#, php-format +#~ msgid "Your tracking link: %s." +#~ msgstr "Votre lien de suivi : %s." + +#, php-format +#~ msgid "Your invoice %1$s for your order %2$s" +#~ msgstr "Votre facture #%1$s pour votre commande #%2$s" + +#, php-format +#~ msgid "" +#~ "Thanks for creating an account on %1$s. Your username is %2$s. You can " +#~ "access your account area to view orders, change your password, and more " +#~ "at: %4$s" +#~ msgstr "" +#~ "Merci d'avoir crée votre compte sur %1$s. Votre identifiant est %2$s. " +#~ "Vous pouvez accéder à votre compte pour voir vos commandes, télécharger " +#~ "vos factures, réinitialiser votre mot de passe et bien d'autre, sur : %4$s" + +#, php-format +#~ msgid "" +#~ "Click here to create your password: Create my " +#~ "password" +#~ msgstr "" +#~ "Cliquez ici pour créer votre mot de passe: Créer " +#~ "mon mot de passe" + +#~ msgid "We look forward to seeing you soon." +#~ msgstr "Nous avons hâte de vous revoir bientôt." + +#, php-format +#~ msgid "" +#~ "Just to let you know — we've received your order #%s, and it is now being " +#~ "processed:" +#~ msgstr "" +#~ "Nous vous informons que nous avons bien reçu votre commande #%s. Celle-ci " +#~ "est en cours de traitement:" + +#~ msgid "Activity" +#~ msgstr "Activité" + +#~ msgid "Indicator" +#~ msgstr "Indicateur" + +#~ msgid "Tasks" +#~ msgstr "Tâches" + +#, php-format +#~ msgid "" +#~ "
  • %1$d Contact #%2$d %4$s is already affected to " +#~ "another third party #%3$d %4$s
  • " +#~ msgstr "" +#~ "
  • %1$d Contact #%2$d %4$s est déjà affecté à un tier #" +#~ "%3$d %4$s
  • " #~ msgid "Last Quotations" #~ msgstr "Derniers Devis" diff --git a/modules/dolibarr/doli-documents/action/class-doli-documents.action.php b/modules/dolibarr/doli-documents/action/class-doli-documents.action.php new file mode 100644 index 0000000..6478ede --- /dev/null +++ b/modules/dolibarr/doli-documents/action/class-doli-documents.action.php @@ -0,0 +1,35 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +use eoxia\LOG_Util; +use eoxia\View_Util; + +defined( 'ABSPATH' ) || exit; + +/** + * Doli Documents Action Class. + */ +class Doli_Documents_Action { + + /** + * Le constructeur. + * + * @since 2.1.0 + * @version 2.1.0 + */ + public function __construct() { + } +} + +new Doli_Documents_Action(); + diff --git a/modules/dolibarr/doli-documents/asset/doli-documents.backend.js b/modules/dolibarr/doli-documents/asset/doli-documents.backend.js index e9e1576..7bf4ad9 100644 --- a/modules/dolibarr/doli-documents/asset/doli-documents.backend.js +++ b/modules/dolibarr/doli-documents/asset/doli-documents.backend.js @@ -5,8 +5,8 @@ jQuery(function($){ metaBox = $('#wps_product_gallery.postbox'), // Your meta box id here addImgLink = metaBox.find('.upload-custom-img'), delImgLink = metaBox.find( '.delete-custom-img'), - imgContainer = metaBox.find( '.custom-img-container'), - imgIdInput = metaBox.find( '.custom-img-id' ); + imgContainer = metaBox.find( '.wps-product-gallery-container' ), + imgIdInput = metaBox.find( '.wps-product-gallery-attachments-hidden-id' ); // ADD IMAGE LINK addImgLink.on( 'click', function( event ){ @@ -92,3 +92,21 @@ jQuery(function($){ }); }); + +/** + * Gestion JS des assoications Dolibarr. + * + * @since 2.1.0 + * @version 2.1.0 + */ +window.eoxiaJS.wpshop.doliDocument = {}; + +/** + * La méthode "init" est appelé automatiquement par la lib JS de Eo-Framework. + * + * @since 2.1.0 + * @version 2.1.0 + */ +window.eoxiaJS.wpshop.doliDocument.init = function() { + +}; diff --git a/modules/dolibarr/doli-documents/class/class-doli-documents.php b/modules/dolibarr/doli-documents/class/class-doli-documents.php index b876f78..1ee8611 100644 --- a/modules/dolibarr/doli-documents/class/class-doli-documents.php +++ b/modules/dolibarr/doli-documents/class/class-doli-documents.php @@ -140,6 +140,79 @@ public function doli_to_wp( $doli_document, $wp_document, $only_convert = false } return $wp_document; } + + public function get_attachments( $product, $mine_type ) { + global $wpdb; + $mine_type = $mine_type . "%"; + $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE post_parent = %d AND post_mime_type LIKE %s", $product->data['external_id'], $mine_type ) ); + $attachments = json_decode( json_encode( $attachments ), true ); + + return $attachments; + } + + public function create_attachments( $wp_documents, $product , $mine_type ) { + $wp_upload_dir = wp_upload_dir(); + foreach ( $wp_documents as $key => $wp_document ) { + $filetype = wp_check_filetype( basename( $wp_document->data['fullpath'] ), null ); + if ( strstr( $filetype['type'], $mine_type ) ) { + $uploadfile = $wp_upload_dir['path'] . '/' . $wp_document->data['name']; + + $contents = file_get_contents( $wp_document->data['fullpath'] ); + $savefile = fopen( $uploadfile, 'w' ); + fwrite( $savefile, $contents ); + fclose( $savefile ); + + $args = array( + 'post_name' => $wp_document->data['name'], + 'post_mime_type' => $filetype['type'], + 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $wp_document->data['fullpath'] ) ), + 'meta_input' => array( + 'path' => $wp_document->data['path'], + 'fullpath' => $wp_document->data['fullpath'], + 'date' => $wp_document->data['date'], + 'size' => $wp_document->data['size'], + 'dolibarr_type' => $wp_document->data['dolibarr_type'], + ), + ); + $attachment_id = wp_insert_attachment( $args, $uploadfile, $product->data['external_id'] ); + require_once ABSPATH . 'wp-admin/includes/image.php'; + $attached_file = get_post_meta( $attachment_id, '_wp_attached_file', true ); + $attach_data = wp_generate_attachment_metadata( $attachment_id, $wp_upload_dir['baseurl'] . '/' . $attached_file ); + wp_update_attachment_metadata( $attachment_id, $attach_data ); + } + } + } + + public function build_sha_documents( $id, $doli_documents ) { + $doli_documents_array = json_decode( json_encode( $doli_documents ), true ); + $data_sha_array = array(); + if ( ! empty( $doli_documents_array ) ) { + foreach ( $doli_documents_array as $doli_documents_array_single ) { + $data_sha_array[] = implode ( ',', $doli_documents_array_single ); + } + } + $data_sha = hash( 'sha256', implode ( ',', $data_sha_array ) ); + update_post_meta( $id, 'sha256_documents', $data_sha ); + + return $data_sha; + } + + public function add_metadata_attachements( $attachments ) { + $attachment = array(); + if ( ! empty( $attachments ) ) { + foreach ( $attachments as $key => $attachment_object ) { + foreach ( $attachment_object as $id => $attachment_data ) { + $attachment[ $id ] = $attachment_data; + $attachment['fullpath'] = get_post_meta( $attachment_object['ID'], 'fullpath', true ); + $attachment['size'] = get_post_meta( $attachment_object['ID'], 'size', true ); + $attachment['attached_file'] = get_post_meta( $attachment_object['ID'], '_wp_attached_file', true ); + } + $attachments[$key] = $attachment; + } + } + + return $attachments; + } } Doli_Documents::g(); diff --git a/modules/dolibarr/doli-documents/doli-documents.config.json b/modules/dolibarr/doli-documents/doli-documents.config.json index a53cf32..80cc329 100644 --- a/modules/dolibarr/doli-documents/doli-documents.config.json +++ b/modules/dolibarr/doli-documents/doli-documents.config.json @@ -7,6 +7,7 @@ "path": "modules/dolibarr/doli-documents/", "dependencies": { "class": {}, + "action": {}, "model": {} } } diff --git a/modules/dolibarr/doli-sync/class/class-doli-sync.php b/modules/dolibarr/doli-sync/class/class-doli-sync.php index 1d180e5..28451c7 100644 --- a/modules/dolibarr/doli-sync/class/class-doli-sync.php +++ b/modules/dolibarr/doli-sync/class/class-doli-sync.php @@ -226,6 +226,7 @@ public function check_status( $id, $type ) { } else { $external_id = get_post_meta( $id, '_external_id', true ); $sha_256 = get_post_meta( $id, '_sync_sha_256', true ); + $sha_documents = get_post_meta( $id, 'sha256_documents', true ); } $sync_info = $this->sync_infos[ $type ]; @@ -269,9 +270,8 @@ public function check_status( $id, $type ) { } $response = apply_filters( 'doli_build_sha_' . $type, $response, $id ); - // WP Object is not equal Dolibarr Object. - if ($response->sha !== $sha_256) { + if ( $response->sha !== $sha_256 || $response->sha_documents != $sha_documents ) { return array( 'status' => true, 'status_code' => '0x3', diff --git a/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php b/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php index 7d1c0ee..6085ba2 100644 --- a/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php +++ b/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php @@ -104,6 +104,15 @@ public function build_sha_product( $response, $wp_id ) { $data_sha['status'] = 'draft'; } + $doli_documents = Request_Util::get( 'documents?modulepart=product&id=' . $response->id ); + $doli_documents_array = json_decode( json_encode( $doli_documents ), true ); + $data_sha_array = array(); + if ( ! empty( $doli_documents_array ) ) { + foreach ($doli_documents_array as $doli_documents_array_single) { + $data_sha_array[] = implode(',', $doli_documents_array_single); + } + $response->sha_documents = hash('sha256', implode(',', $data_sha_array)); + } $response->sha = hash( 'sha256', implode( ',', $data_sha ) ); return $response; @@ -151,17 +160,7 @@ public function build_sha_third_party( $response, $wp_id ) { * @return Doli_Documents Les données d'un document avec le SHA256. */ public function build_sha_document( $response, $wp_id ) { - $data_sha = array(); - $data_sha['doli_id'] = $response->id; - $data_sha['wp_id'] = $wp_id; - $data_sha['path'] = $response->data['path']; - $data_sha['fullpath'] = $response->data['fullpath']; - $data_sha['date'] = $response->data['date']; - $data_sha['size'] = $response->data['size']; - $data_sha['dolibarr_type'] = $response->data['dolibarr_type']; - - $response->sha = hash( 'sha256', implode( ',', $data_sha ) ); return $response; } diff --git a/modules/products/class/class-product.php b/modules/products/class/class-product.php index 3f49ee0..b6c7f6f 100644 --- a/modules/products/class/class-product.php +++ b/modules/products/class/class-product.php @@ -6,7 +6,7 @@ * @author Eoxia * @copyright (c) 2011-2020 Eoxia . * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ namespace wpshop; @@ -180,10 +180,10 @@ public function display_item( $product, $sync_status, $doli_url = '' ) { } /** - * Ajoute une metabox pour configurer le produit. + * Ajoute des metabox pour configurer le produit. * * @since 2.0.0 - * @version 2.0.0 + * @version 2.1.0 */ public function callback_register_meta_box() { add_meta_box( @@ -200,6 +200,14 @@ public function callback_register_meta_box() { 'wps-product', 'side' ); + + add_meta_box( + 'wps_product_document', + __( 'Product Document', 'wpshop'), + array( $this, 'callback_add_meta_box_document' ), + 'wps-product', + 'side' + ); } /** @@ -240,7 +248,7 @@ public function callback_add_meta_box( $post ) { } /** - * La vue de la metabox pour configurer le produit. + * La vue de la metabox pour configurer la galerie d'image du produit. * * @since 2.1.0 * @version 2.1.0 @@ -260,74 +268,122 @@ public function callback_add_meta_box_gallery( $post ) { $product->data['parent_post'] = $parent_post; } + // Get Dolibarr documents. + $doli_documents = Request_Util::get( 'documents?modulepart=product&id=' . $product->data['external_id'] ); + $wp_documents = Doli_Documents::g()->convert_to_wp_documents_format( $doli_documents ); + + $mine_type = 'image'; $wp_upload_dir = wp_upload_dir(); - $doli_documents = Request_Util::get( 'documents?modulepart=product&id=' . $product->data['external_id'] ); - $wp_documents = Doli_Documents::g()->convert_to_wp_documents_format( $doli_documents ); - if ( ! empty( $wp_documents ) ) { - $attachments = get_children( - array( - 'post_parent' => $product->data['external_id'], - 'post_type' => 'attachment', - ) - ); - if ( empty( $attachments ) ) { - foreach ( $wp_documents as $key => $wp_document ) { - $uploadfile = $wp_upload_dir['path'] . '/' . $wp_document->data['name']; - - $contents = file_get_contents( $wp_document->data['fullpath'] ); - $savefile = fopen( $uploadfile, 'w' ); - fwrite( $savefile, $contents ); - fclose( $savefile ); - - $filetype = wp_check_filetype( basename( $wp_document->data['fullpath'] ), null ); - - $args = array( - 'post_name' => $wp_document->data['name'], - 'post_mime_type' => $filetype['type'], - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $wp_document->data['fullpath'] ) ), - 'meta_input' => array( - 'path' => $wp_document->data['path'], - 'fullpath' => $wp_document->data['fullpath'], - 'date' => $wp_document->data['date'], - 'size' => $wp_document->data['size'], - 'dolibarr_type' => $wp_document->data['dolibarr_type'], - ), - ); - $attachment_id = wp_insert_attachment( $args, $uploadfile, $product->data['external_id'] ); - require_once ABSPATH . 'wp-admin/includes/image.php'; - $attached_file = get_post_meta( $attachment_id, '_wp_attached_file', true ); - $attach_data = wp_generate_attachment_metadata( $attachment_id, $wp_upload_dir['baseurl'] . '/' . $attached_file ); - wp_update_attachment_metadata( $attachment_id, $attach_data ); + // create the sha256 for documents. + $sha256 = get_post_meta( $post->ID, 'sha256_documents', true ); + $data_sha = Doli_Documents::g()->build_sha_documents( $post->ID, $doli_documents ); + + if ( $sha256 != $data_sha ) { + + $attachments = Doli_Documents::g()->get_attachments( $product, $mine_type ); + + if ( ! empty( $attachments ) ) { + foreach ( $attachments as $attachment ) { + wp_delete_attachment( $attachment['ID'] ); } } + + Doli_Documents::g()->create_attachments( $wp_documents, $product , $mine_type ); + } + + $attachments = Doli_Documents::g()->get_attachments( $product, $mine_type ); + $attachments = Doli_Documents::g()->add_metadata_attachements( $attachments ); + + $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); + + $dolibarr_product_document = $dolibarr_option['dolibarr_product_document']; + $dolibarr_url = $dolibarr_option['dolibarr_url']; + + $upload_link = esc_url( get_upload_iframe_src( 'image', $product->data['id'] ) ); + + View_Util::exec( + 'wpshop', + 'products', + 'metabox/gallery', + array( + 'id' => ! empty( $product->data['id'] ) ? $product->data['id'] : $post->ID, + 'wp_upload_dir' => $wp_upload_dir, + 'upload_link' => $upload_link, + 'attachments' => ! empty( $attachments ) ? $attachments : '', + 'product' => $product, + 'dolibarr_url' => $dolibarr_url, + 'dolibarr_product_document' => $dolibarr_product_document, + ) + ); + } + + /** + * La vue de la metabox pour configurer les documents du produit. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param WP_Post $post Le produit. + */ + public function callback_add_meta_box_document( $post ) { + $product = $this->get( array( 'id' => $post->ID ), true ); + + if ( empty( $product ) ) { + $product = $this->get( array( 'schema' => true ), true ); } - $attachment = array(); - if ( ! empty( $attachments ) ) { - foreach ( $attachments as $key => $attachment_object ) { - foreach ( $attachment_object as $id => $attachment_data ) { - $attachment[ $id ] = $attachment_data; - $attachment['fullpath'] = get_post_meta( $attachment_object->ID, 'fullpath', true ); - $attachment['size'] = get_post_meta( $attachment_object->ID, 'size', true ); - $attachment['attached_file'] = get_post_meta( $attachment_object->ID, '_wp_attached_file', true ); + if ( ! empty( $product->data['fk_product_parent'] ) ) { + $parent_post = get_post( Doli_Products::g()->get_wp_id_by_doli_id( $product->data['fk_product_parent'] ) ); + + $product->data['parent_post'] = $parent_post; + } + + // Get Dolibarr documents. + $doli_documents = Request_Util::get( 'documents?modulepart=product&id=' . $product->data['external_id'] ); + $wp_documents = Doli_Documents::g()->convert_to_wp_documents_format( $doli_documents ); + + $mine_type = 'application'; + $wp_upload_dir = wp_upload_dir(); + + // create the sha256 for documents. + $sha256 = get_post_meta( $post->ID, 'sha256_documents', true ); + $data_sha = Doli_Documents::g()->build_sha_documents( $post->ID, $doli_documents ); + + if ( $sha256 == $data_sha ) { + + $attachments = Doli_Documents::g()->get_attachments( $product, $mine_type ); + + if ( ! empty( $attachments ) ) { + foreach ( $attachments as $attachment ) { + wp_delete_attachment( $attachment['ID'] ); } - $attachments[ $attachment_object->ID ] = $attachment; } + + Doli_Documents::g()->create_attachments( $wp_documents, $product , $mine_type ); } + $attachments = Doli_Documents::g()->get_attachments( $product, $mine_type ); + $attachments = Doli_Documents::g()->add_metadata_attachements( $attachments ); + $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); + + $dolibarr_url = $dolibarr_option['dolibarr_url']; + $dolibarr_product_document = $dolibarr_option['dolibarr_product_document']; + $upload_link = esc_url( get_upload_iframe_src( 'image', $product->data['id'] ) ); + View_Util::exec( 'wpshop', 'products', - 'metabox/gallery', + 'metabox/document', array( - 'id' => ! empty( $product->data['id'] ) ? $product->data['id'] : $post->ID, - 'wp_upload_dir' => $wp_upload_dir, - 'attachments' => ! empty( $attachments ) ? $attachments : '', - 'product' => $product, - 'doli_url' => $dolibarr_option['dolibarr_url'], - 'sync_status' => false, + 'id' => ! empty( $product->data['id'] ) ? $product->data['id'] : $post->ID, + 'wp_upload_dir' => $wp_upload_dir, + 'upload_link' => $upload_link, + 'attachments' => ! empty( $attachments ) ? $attachments : '', + 'product' => $product, + 'dolibarr_url' => $dolibarr_url, + 'dolibarr_product_document' => $dolibarr_product_document, ) ); } diff --git a/modules/products/view/metabox/document.view.php b/modules/products/view/metabox/document.view.php new file mode 100644 index 0000000..45dc12b --- /dev/null +++ b/modules/products/view/metabox/document.view.php @@ -0,0 +1,53 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +defined( 'ABSPATH' ) || exit; + +/** + * Documentation des variables utilisées dans la vue. + * + * @var Product $product Les données d'un produit. + * @var array $attachments Le tableau contenant toutes les données des documents. + * @var array $attachment Les données d'un document. + * @var array $wp_upload_dir Le tableau contenant les données du répertoire des médias. + * @var string $dolibarr_url L'url de Dolibarr. + * @var string $dolibarr_product_document L'url des documents de Dolibarr. + * @var string $upload_link Le lien vers l'iframe d'ajout d'un média. + */ +?> + +
    + + +

    + dolibarr_is_active() ) : ?> + + + + + + + + +

    + + +
    diff --git a/modules/products/view/metabox/gallery.view.php b/modules/products/view/metabox/gallery.view.php index 864de0e..08904f4 100644 --- a/modules/products/view/metabox/gallery.view.php +++ b/modules/products/view/metabox/gallery.view.php @@ -1,12 +1,12 @@ * @copyright (c) 2011-2020 Eoxia . - * @since 2.0.0 - * @version 2.0.0 + * @since 2.1.0 + * @version 2.1.0 */ namespace wpshop; @@ -16,80 +16,38 @@ /** * Documentation des variables utilisées dans la vue. * - * @var Product $product Les données d'un produit. - * @var string $sync_status True si on affiche le statut de la synchronisation. - * @var string $doli_url L'url de Dolibarr. - * @var boolean $has_selected True si le produit est selectionné. - * @var array $tva Les types de TVA. - * @var string $selected L'attribut HTML "selected". - * @var array $similar_products Le tableau contenant toutes les données des produits similaires. - * @var Product $similar_product Les données d'un produit similaire. + * @var Product $product Les données d'un produit. + * @var array $attachments Le tableau contenant toutes les données des documents. + * @var array $attachment Les données d'un document. + * @var array $wp_upload_dir Le tableau contenant les données du répertoire des médias. + * @var string $dolibarr_url L'url de Dolibarr. + * @var string $dolibarr_product_document L'url des documents de Dolibarr. + * @var string $upload_link Le lien vers l'iframe d'ajout d'un média. */ ?> - - - - - -'; print_r($attachment); echo ''; exit; ?> - - - - - - - - - - - - -ID ) ); - -// See if there's a media id already saved as post meta -$your_img_id = get_post_meta( $post->ID, '_thumbnail_id', true ); - -// Get the image src -$your_img_src = wp_get_attachment_image_src( $your_img_id, 'full' ); - -// For convenience, see if the array is valid -$you_have_img = is_array( $your_img_src ); -?> - - -
    -
      + - -

      - - - - - - -

      +

      + dolibarr_is_active() ) : ?> + + + + + + + + +

      - - + +
    From e412e5787bcd0accc2d7e724c713a62b41102b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Thu, 3 Sep 2020 16:36:19 +0200 Subject: [PATCH 09/13] Add categories synchronization --- .../action/class-doli-associate-action.php | 39 +-- .../action/class-doli-categories-action.php | 169 ++++++++++++ .../dolibarr/doli-categories/action/index.php | 2 + .../class/class-doli-categories.php | 253 ++++++++++++++++++ .../dolibarr/doli-categories/class/index.php | 2 + .../doli-categories.config.json | 14 + .../filter/class-doli-categories-filter.php | 89 ++++++ .../dolibarr/doli-categories/filter/index.php | 2 + modules/dolibarr/doli-categories/index.php | 2 + .../model/class-doli-categories-model.php | 74 +++++ .../dolibarr/doli-categories/model/index.php | 2 + .../dolibarr/doli-categories/view/index.php | 2 + .../doli-categories/view/item.view.php | 68 +++++ .../doli-categories/view/list.view.php | 45 ++++ .../doli-categories/view/main.view.php | 33 +++ .../action/class-doli-sync-action.php | 22 +- .../doli-sync/asset/js/doli-sync.backend.js | 1 - .../doli-sync/class/class-doli-sync.php | 67 +++-- .../filter/class-doli-sync-filter.php | 25 ++ .../doli-sync/view/sync-item.view.php | 5 +- .../products/action/class-product-action.php | 4 +- .../products/filter/class-product-filter.php | 6 +- wpshop.config.json | 1 + 23 files changed, 867 insertions(+), 60 deletions(-) create mode 100644 modules/dolibarr/doli-categories/action/class-doli-categories-action.php create mode 100644 modules/dolibarr/doli-categories/action/index.php create mode 100644 modules/dolibarr/doli-categories/class/class-doli-categories.php create mode 100644 modules/dolibarr/doli-categories/class/index.php create mode 100644 modules/dolibarr/doli-categories/doli-categories.config.json create mode 100644 modules/dolibarr/doli-categories/filter/class-doli-categories-filter.php create mode 100644 modules/dolibarr/doli-categories/filter/index.php create mode 100644 modules/dolibarr/doli-categories/index.php create mode 100644 modules/dolibarr/doli-categories/model/class-doli-categories-model.php create mode 100644 modules/dolibarr/doli-categories/model/index.php create mode 100644 modules/dolibarr/doli-categories/view/index.php create mode 100644 modules/dolibarr/doli-categories/view/item.view.php create mode 100644 modules/dolibarr/doli-categories/view/list.view.php create mode 100644 modules/dolibarr/doli-categories/view/main.view.php diff --git a/modules/dolibarr/doli-associate/action/class-doli-associate-action.php b/modules/dolibarr/doli-associate/action/class-doli-associate-action.php index a58812a..5b6b182 100644 --- a/modules/dolibarr/doli-associate/action/class-doli-associate-action.php +++ b/modules/dolibarr/doli-associate/action/class-doli-associate-action.php @@ -43,7 +43,7 @@ public function load_associate_modal() { $id = ! empty( $_POST['wp_id'] ) ? (int) $_POST['wp_id'] : 0; $type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : ''; - + $sync_info = Doli_Sync::g()->get_sync_infos( $type ); $entries = Request_Util::get( $sync_info['endpoint'] . '?limit=-1' ); @@ -59,24 +59,25 @@ public function load_associate_modal() { } } } - - ob_start(); - View_Util::exec( 'wpshop', 'doli-associate', 'main', array( - 'entries' => $entries, - 'wp_id' => $id, - 'type' => $type, - 'label' => $sync_info['title'], - ) ); - $view = ob_get_clean(); - - ob_start(); - View_Util::exec( 'wpshop', 'doli-associate', 'single-footer' ); - $buttons_view = ob_get_clean(); - - wp_send_json_success( array( - 'view' => $view, - 'buttons_view' => $buttons_view, - ) ); + if ($type == 'wps-product') { + ob_start(); + View_Util::exec( 'wpshop', 'doli-associate', 'main', array( + 'entries' => $entries, + 'wp_id' => $id, + 'type' => $type, + 'label' => $sync_info['title'], + ) ); + $view = ob_get_clean(); + + ob_start(); + View_Util::exec( 'wpshop', 'doli-associate', 'single-footer' ); + $buttons_view = ob_get_clean(); + + wp_send_json_success( array( + 'view' => $view, + 'buttons_view' => $buttons_view, + ) ); + } } /** diff --git a/modules/dolibarr/doli-categories/action/class-doli-categories-action.php b/modules/dolibarr/doli-categories/action/class-doli-categories-action.php new file mode 100644 index 0000000..f284099 --- /dev/null +++ b/modules/dolibarr/doli-categories/action/class-doli-categories-action.php @@ -0,0 +1,169 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +use eoxia\LOG_Util; +use eoxia\View_Util; +use stdClass; + +defined( 'ABSPATH' ) || exit; + +/** + * Doli Category Action Class. + */ +class Doli_Category_Action { + + /** + * Définition des metaboxes sur la page. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var array + */ + public $metaboxes = null; + + /** + * Le constructeur. + * + * @since 2.1.0 + * @version 2.1.0 + */ + public function __construct() { + + add_action( 'admin_menu', array( $this, 'callback_admin_menu' ), 60 ); + + add_action( 'wps_checkout_create_category', array( $this, 'create_category' ), 10, 1 ); + add_action( 'admin_post_wps_download_category', array( $this, 'download_category' ) ); + + } + + /** + * Initialise la page "Catégories". + * + * @since 2.1.0 + * @version 2.1.0 + */ + public function callback_admin_menu() { + if ( Settings::g()->dolibarr_is_active() ) { + $hook = add_submenu_page( 'wpshop', __( 'Categories', 'wpshop' ), __( 'Categories', 'wpshop' ), 'manage_options', 'wps-product-cat', array( $this, 'callback_add_menu_page' ) ); + + if ( ! isset( $_GET['id'] ) ) { + add_action( 'load-' . $hook, array( $this, 'callback_add_screen_option' ) ); + } + } + } + + /** + * Affichage de la vue du menu. + * + * @since 2.1.0 + * @version 2.1.0 + */ + public function callback_add_menu_page() { + global $wpdb; + if ( isset( $_GET['id'] ) ) { + // Single page. + $id = ! empty( $_GET['id'] ) ? (int) $_GET['id'] : 0; + + $doli_category = Request_Util::get( 'categories/' . $id ); + $wp_category = Doli_Category::g()->get( array( 'schema' => true ), true ); + $wp_category = Doli_Category::g()->doli_to_wp( $doli_category, $wp_category); + + $wp_category->data['datec'] = \eoxia\Date_Util::g()->fill_date( $wp_category->data['datec'] ); + + $third_party = Third_Party::g()->get( array( 'id' => $wp_category->data['parent_id'] ), true ); + + View_Util::exec( 'wpshop', 'doli-categories', 'single', array( + 'third_party' => $third_party, + 'category' => $wp_category, + ) ); + } else { + // Listing page. + // @todo: Doublon avec Class Doli Category display() ? + $per_page = get_user_meta( get_current_user_id(), Doli_Category::g()->option_per_page, true ); + $dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings ); + $dolibarr_url = $dolibarr_option['dolibarr_url']; + + $dolibarr_create_category = 'categories/card.php?action=create&type=product&backtopage=%2Fdolibarr%2Fhtdocs%2Fcategories%2Findex.php%3Ftype%3Dproduct'; + + if ( empty( $per_page ) || 1 > $per_page ) { + $per_page = Doli_Category::g()->limit; + } + + $s = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; + + $count = Doli_Category::g()->search( $s, array(), true ); + $number_page = ceil( $count / $per_page ); + $current_page = isset( $_GET['current_page'] ) ? (int) $_GET['current_page'] : 1; + + $base_url = admin_url( 'admin.php?page=wps-product-cat' ); + + $begin_url = $base_url . '¤t_page=1'; + $end_url = $base_url . '¤t_page=' . $number_page; + + $prev_url = $base_url . '¤t_page=' . ( $current_page - 1 ); + $next_url = $base_url . '¤t_page=' . ( $current_page + 1 ); + + if ( ! empty( $s ) ) { + $begin_url .= '&s=' . $s; + $end_url .= '&s=' . $s; + $prev_url .= '&s=' . $s; + $next_url .= '&s=' . $s; + } + + $wp_categories = Doli_Category::g()->get(); + + if ( ! empty($wp_categories)) { + foreach( $wp_categories as $wp_category) { + if (empty($wp_category->data['external_id'] )) { + wp_delete_term($wp_category->data['id'],'wps-product-cat'); + } + } + } + + View_Util::exec( 'wpshop', 'doli-categories', 'main', array( + 'number_page' => $number_page, + 'current_page' => $current_page, + 'count' => $count, + 'begin_url' => $begin_url, + 'end_url' => $end_url, + 'prev_url' => $prev_url, + 'next_url' => $next_url, + 's' => $s, + 'wp_categories'=> $wp_categories, + + 'dolibarr_create_category' => $dolibarr_create_category, + 'dolibarr_url' => $dolibarr_url, + ) ); + } + } + + /** + * Ajoute le menu "Options de l'écran". + * + * @since 2.1.0 + * @version 2.1.0 + */ + public function callback_add_screen_option() { + add_screen_option( + 'per_page', + array( + 'label' => _x( 'Categories', 'Category per page', 'wpshop' ), + 'default' => Doli_Category::g()->limit, + 'option' => Doli_Category::g()->option_per_page, + ) + ); + } +} + +new Doli_Category_Action(); diff --git a/modules/dolibarr/doli-categories/action/index.php b/modules/dolibarr/doli-categories/action/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/modules/dolibarr/doli-categories/action/index.php @@ -0,0 +1,2 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +use eoxia\Term_Class; +use eoxia\View_Util; +use stdClass; + +defined( 'ABSPATH' ) || exit; + +/** + * Doli Category Class. + */ +class Doli_Category extends Term_Class { + + /** + * Le nom du modèle. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var string + */ + protected $model_name = '\wpshop\Doli_Category_Model'; + + /** + * Le term type. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var string + */ + protected $type = 'wps-product-cat'; + + /** + * La clé principale du modèle. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var string + */ + protected $meta_key = 'doli-categories'; + + /** + * La route pour accéder à l'objet dans la rest API. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var string + */ + protected $base = 'doli-categories'; + + /** + * Le nom du term type. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var string + */ + protected $post_type_name = 'Doli Category'; + + /** + * La limite par page. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var integer + */ + public $limit = 10; + + /** + * Le nom de l'option pour la limite par page. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @var string + */ + public $option_per_page = 'category_doli_per_page'; + + /** + * Appel la vue "list" du module "doli-categories". + * + * @since 2.1.0 + * @version 2.1.0 + */ + 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'] ) : ''; + + $route = 'categories?sortfield=t.rowid&sortorder=DESC&limit=' . $per_page . '&page=' . ( $current_page - 1 ); + + if ( ! empty( $s ) ) { + // 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)) { + foreach( $wp_categories as $wp_category) { + if (empty($wp_category->data['external_id'] )) { + wp_delete_term($wp_category->data['id'],'wps-product-cat'); + } + } + } + + View_Util::exec( 'wpshop', 'doli-categories', 'list', array( + 'categories' => $wp_categories, + 'doli_url' => $dolibarr_option['dolibarr_url'], + ) ); + } + + /** + * Appel la vue "item" d'une catégorie. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param Doli_Category $category Les données d'une catégorie. + * @param string $doli_url L'url de Dolibarr. + */ + public function display_item( $category, $doli_url = '' ) { + View_Util::exec( 'wpshop', 'doli-categories', 'item', array( + 'category' => $category, + ) ); + } + + /** + * Convertit un tableau Category Object provenant de Dolibarr vers un format Category Object WPshop afin de normisé pour l'affichage. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param stdClass $doli_categories Le tableau contenant toutes les données des catégories provenant de Dolibarr. + * + * @return Doli_Category Le tableau contenant toutes les données des catégories convertis depuis le format de Dolibarr. + */ + 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 ); + $wp_categories[] = $this->doli_to_wp( $doli_category, $wp_category); + } + } + + return $wp_categories; + } + + /** + * Synchronise depuis Dolibarr vers WP. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param stdClass $doli_category Les données d'une catégorie Dolibarr. + * @param Doli_Category $wp_category Les données d'une catégorie WordPress. + * @param boolean $save Enregistres les données sinon renvoies l'objet remplit sans l'enregistrer en base de donnée. + * @param array $notices Gestion des erreurs et informations de l'évolution de la méthode. * + * @return Doli_Category Les données d'une catégorie WordPress avec ceux de Dolibarr. + */ + public function doli_to_wp( $doli_category, $wp_category, $save = true, &$notices = array( + 'errors' => array(), + 'messages' => array(), + ) ) { + $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['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é ? + + update_term_meta( $wp_category->data['id'], '_sync_sha_256', $wp_category->data['sync_sha_256'] ); + update_term_meta( $wp_category->data['id'], '_external_id', (int) $doli_category->id ); + $notices['messages'][] = sprintf( __( 'Erase data for the product %s with the dolibarr data', 'wpshop' ), $wp_category->data['name'] ); + } + + return $wp_category; + } + + /** + * Fonction de recherche. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param string $s Le terme de la recherche. + * @param array $default_args Les arguments par défaut. + * @param boolean $count Si true compte le nombre d'élement, sinon renvoies l'ID des éléments trouvés. + * + * @return array|integer Les ID des éléments trouvés ou le nombre d'éléments trouvés. + */ + public function search( $s = '', $default_args = array(), $count = false ) { + $route = 'categories?sortfield=t.rowid&sortorder=DESC'; + + if ( ! empty( $s ) ) { + $route .= '&sqlfilters=(t.ref%3Alike%3A\'%25' . $s . '%25\')'; + } + + $doli_categories = Request_Util::get( $route ); + + if ( $count && ! empty( $doli_categories ) ) { + return count( $doli_categories ); + } else { + return 0; + } + } +} + +Doli_Category::g(); diff --git a/modules/dolibarr/doli-categories/class/index.php b/modules/dolibarr/doli-categories/class/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/modules/dolibarr/doli-categories/class/index.php @@ -0,0 +1,2 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +defined( 'ABSPATH' ) || exit; + +/** + * Dolibarr Category Filter Class. + */ +class Doli_Category_Filter { + + /** + * Le constructeur. + * + * @since 2.1.0 + * @version 2.1.0 + */ + public function __construct() { + if ( Settings::g()->dolibarr_is_active() ) { + //add_filter( 'wps-product-cat_after_get', array( $this, 'auto_sync' ), 10, 2 ); + add_filter( 'wps_category_filter_sync', array( $this, 'category_sync' ), 10, 1 ); + } + } + + /** + * La synchronisation automatique d'une catégorie. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param Doli_Category $object Les données d'une catégorie. + * @param array $args_cb Les arguments supplémentaires. + * + * @return Doli_Category Les données d'une catégorie synchronisé. + */ + public function auto_sync( $object, $args_cb ) { + if ( empty( $object->data['external_id'] ) ) { + return $object; + } + $status = Doli_Sync::g()->check_status( $object->data['id'], $object->data['type'] ); + + if ($status['status_code'] != '0x3') { + return $object; + } + + $doli_category = Request_Util::get( 'categories/' . $object->data['external_id'] ); + $object = Doli_Category::g()->doli_to_wp( $doli_category, $object ); + + return $object; + } + + /** + * La synchronisation manuelle d'unecatégorie. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param Doli_Category $category Les données d'une catégorie. + * + * @return Doli_Category Les données d'une catégorie synchronisé. + */ + public function category_sync( $category ) { + $external_id = get_term_meta( $category->ID, '_external_id', true ); + $status = Doli_Sync::g()->check_status( $category->ID, $category->term_type ); + + if ($status['status_code'] != '0x3') { + return $category; + } + + $doli_category = Request_Util::get( 'categories/' . $external_id ); + $object = Doli_Category::g()->get( array( 'id' => $category->ID ), true ); + $object = Doli_Category::g()->doli_to_wp( $doli_category, $object ); + + $category = get_term( $category->ID ); + + return $category; + } +} + +new Doli_Category_Filter(); diff --git a/modules/dolibarr/doli-categories/filter/index.php b/modules/dolibarr/doli-categories/filter/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/modules/dolibarr/doli-categories/filter/index.php @@ -0,0 +1,2 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +use eoxia\Term_Model; + +defined( 'ABSPATH' ) || exit; + +/** + * Doli Category Model Class. + */ +class Doli_Category_Model extends Term_Model { + + /** + * Le constructeur. + * + * @since 2.1.0 + * @version 2.1.0 + * + * @param Doli_Category $object Les données de l'objet. + * @param string $req_method La méthode de la requête. + */ + public function __construct( $object, $req_method = null ) { + $this->schema['external_id'] = array( + 'type' => 'integer', + 'meta_type' => 'single', + 'field' => '_external_id', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'L\'ID provenant de dolibarr', + ); + + $this->schema['sync_sha_256'] = array( + 'type' => 'string', + 'meta_type' => 'single', + 'field' => '_sync_sha_256', + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'La cohérence de la synchronisation avec un ERP', + ); + + $this->schema['datec'] = array( + 'type' => 'wpeo_date', + 'meta_type' => 'single', + 'field' => 'datec', + 'context' => array( 'GET' ), + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Date de création de la fature. Relation avec dolibarr', + ); + + $this->schema['date_category'] = array( + 'type' => 'wpeo_date', + 'meta_type' => 'single', + 'field' => 'date_category', + 'context' => array( 'GET' ), + 'since' => '2.1.0', + 'version' => '2.1.0', + 'description' => 'Date de la fature. Relation avec dolibarr', + ); + + parent::__construct( $object, $req_method ); + } +} diff --git a/modules/dolibarr/doli-categories/model/index.php b/modules/dolibarr/doli-categories/model/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/modules/dolibarr/doli-categories/model/index.php @@ -0,0 +1,2 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +defined( 'ABSPATH' ) || exit; + +/** + * Documentation des variables utilisées dans la vue. + * + * @var Doli_Category $category Les données d'une facture. + * @var string $doli_url L'url de Dolibarr. + */ + +?> + +
    +
    +
      + data['external_id'] ) ) : ?> +
    • Doli : data['external_id'] ); ?>
    • + +
    • data['datec']['rendered']['date_time'] ); ?>
    • +
    +
      + data['name'] ) ) : ?> + data['name'] ); ?> + - +
    +
      +
    • + data['external_id'] ) ) : ?> +
    • + +
    +
    +
    + data['name'] ) ) : ?> + data['name'] ); ?> + - +
    +
    + data['slug'] ) ) : ?> + data['slug'] ); ?> + - +
    +
    + data['parent_id'] ) ) : ?> + data['parent_id'] ); ?> + - +
    +
    + +
    + +
    diff --git a/modules/dolibarr/doli-categories/view/list.view.php b/modules/dolibarr/doli-categories/view/list.view.php new file mode 100644 index 0000000..5619d2c --- /dev/null +++ b/modules/dolibarr/doli-categories/view/list.view.php @@ -0,0 +1,45 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + + +namespace wpshop; + +use eoxia\View_Util; + +defined( 'ABSPATH' ) || exit; + +/** + * Documentation des variables utilisées dans la vue. + * + * @var array $categories Le tableau contanant toutes les données des factures. + * @var Doli_Category $category Les données d'une catégorie. + * @var string $doli_url L'url de Dolibarr. + */ + +?> + +
    +
    +
    +
    +
    +
    +
    +
    + $category, + 'doli_url' => $doli_url, + ) ); + endforeach; + endif; ?> +
    diff --git a/modules/dolibarr/doli-categories/view/main.view.php b/modules/dolibarr/doli-categories/view/main.view.php new file mode 100644 index 0000000..a5dcc99 --- /dev/null +++ b/modules/dolibarr/doli-categories/view/main.view.php @@ -0,0 +1,33 @@ + + * @copyright (c) 2011-2020 Eoxia . + * @since 2.1.0 + * @version 2.1.0 + */ + +namespace wpshop; + +defined( 'ABSPATH' ) || exit; + +/** + * Documentation des variables utilisées dans la vue. + * @var string $dolibarr_create_category Endpoint de création de catégorie dolibarr. + * @var string $dolibarr_url L'url de fin dolibarr. + */ +?> + +
    +

    + + dolibarr_is_active() ) : ?> + + + + +

    + display(); ?> +
    diff --git a/modules/dolibarr/doli-sync/action/class-doli-sync-action.php b/modules/dolibarr/doli-sync/action/class-doli-sync-action.php index a4da5bc..b31e932 100644 --- a/modules/dolibarr/doli-sync/action/class-doli-sync-action.php +++ b/modules/dolibarr/doli-sync/action/class-doli-sync-action.php @@ -111,7 +111,7 @@ public function sync() { $last = ( ! empty( $_POST['last'] ) && '1' == $_POST['last'] ) ? true : false; $sync_info = Doli_Sync::g()->get_sync_infos( $type ); - + // @todo: Do Array http_build_query. $doli_entries = Request_Util::get( $sync_info['endpoint'] . '?sortfield=t.rowid&sortorder=ASC&limit=' . Doli_Sync::g()->limit_entries_by_request . '&page=' . $done_number / Doli_Sync::g()->limit_entries_by_request ); @@ -177,17 +177,17 @@ public function sync_entry() { $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_status = Doli_Sync::g()->sync( $wp_id, $entry_id, $type ); $sync_info = Doli_Sync::g()->get_sync_infos( $type ); - + ob_start(); // @todo: Add display_item for contact. - if ( $type !== 'wps-user' ) { + if ( $type !== 'wps-user' || $type !== 'wps-product-cat' ) { $sync_info['wp_class']::g()->display_item( $sync_status['wp_object'], true, $dolibarr_option['dolibarr_url'] ); } - + $item_view = ob_get_clean(); - + wp_send_json_success( array( 'id' => $wp_id, 'namespace' => 'wpshop', @@ -224,7 +224,7 @@ public function add_sync_header( $type ) { * @param boolean $sync_status Le statut de la synchronisation. */ public function add_sync_item( $object, $sync_status ) { - if ( Settings::g()->dolibarr_is_active() && in_array( $object->data['type'], array( 'wps-product', 'wps-third-party', 'wps-proposal' ) ) ) { + if ( Settings::g()->dolibarr_is_active() && in_array( $object->data['type'], array( 'wps-product', 'wps-third-party', 'wps-proposal','wps-product-cat' ) ) ) { Doli_Sync::g()->display_sync_status( $object, $object->data['type'], $sync_status ); } } @@ -240,14 +240,14 @@ public function check_sync_status() { $wp_id = ! empty( $_POST['wp_id'] ) ? (int) $_POST['wp_id'] : 0; $type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : ''; - if ( empty( $wp_id ) && ! in_array( $type, array( 'wps-product', 'wps-third-party', 'wps-proposals', 'wps-user' ) ) ) { + if ( empty( $wp_id ) && ! in_array( $type, array( 'wps-product', 'wps-third-party', 'wps-proposals', 'wps-user', 'wps-product-cat' ) ) ) { wp_send_json_error(); } - + $sync_info = Doli_Sync::g()->get_sync_infos( $type ); - + $object = $sync_info['wp_class']::g()->get( array( 'id' => $wp_id ), true ); - + ob_start(); $status = Doli_Sync::g()->display_sync_status( $object, $type ); $view = ob_get_clean(); diff --git a/modules/dolibarr/doli-sync/asset/js/doli-sync.backend.js b/modules/dolibarr/doli-sync/asset/js/doli-sync.backend.js index 6509435..0e31b03 100644 --- a/modules/dolibarr/doli-sync/asset/js/doli-sync.backend.js +++ b/modules/dolibarr/doli-sync/asset/js/doli-sync.backend.js @@ -117,7 +117,6 @@ window.eoxiaJS.wpshop.doliSync.syncEntrySuccess = function( triggeredElement, re var modal = jQuery( '.wpeo-modal.modal-active' ); // If it is associate action. - if ( modal.length > 0 ) { modal.addClass( 'modal-force-display' ); modal.find( '.modal-content' ).html( response.data.modal_view ); diff --git a/modules/dolibarr/doli-sync/class/class-doli-sync.php b/modules/dolibarr/doli-sync/class/class-doli-sync.php index 8ca180a..9b1b5e2 100644 --- a/modules/dolibarr/doli-sync/class/class-doli-sync.php +++ b/modules/dolibarr/doli-sync/class/class-doli-sync.php @@ -80,6 +80,16 @@ protected function construct() { 'doli_class' => '\wpshop\\Doli_Proposals', 'doli_type' => 'propal', ), + 'wps-product-cat' => array( + 'title' => __( 'Categories', 'wpshop' ), + 'action' => 'sync_categories', + 'nonce' => 'sync_categories', + 'endpoint' => 'categories', + 'associate_endpoint' => 'Category', + 'wp_class' => '\wpshop\\Doli_Category', + 'doli_class' => '\wpshop\\Doli_Category', + 'doli_type' => 'category', + ), ); } @@ -173,7 +183,7 @@ public function sync( $wp_id, $entry_id, $type ) { $doli_product = Request_Util::get( 'products/' . $entry_id ); $wp_product = Product::g()->get( array( 'id' => $wp_id ), true ); $wp_product = Doli_Products::g()->doli_to_wp( $doli_product, $wp_product ); - + $messages[] = sprintf( __( 'Erase data for the product %s with the dolibarr data', 'wpshop' ), $wp_product->data['title'] ); $wp_object = $wp_product; @@ -183,13 +193,20 @@ public function sync( $wp_id, $entry_id, $type ) { $wp_proposal = Proposals::g()->get( array( 'id' => $wp_id ), true ); Doli_Proposals::g()->doli_to_wp( $doli_proposal, $wp_proposal ); - + $wp_object = $wp_proposal; break; + case 'wps-product-cat': + $doli_category = Request_Util::get( 'categories/' . $entry_id ); + $wp_category = Doli_Category::g()->get( array( 'id' => $wp_id ), true ); + $wp_category = Doli_Category::g()->doli_to_wp( $doli_category, $wp_category); + + $wp_object = $wp_category; + break; default: break; } - + return array( 'messages' => $messages, 'wp_error' => $wp_error, @@ -211,26 +228,33 @@ public function sync( $wp_id, $entry_id, $type ) { public function check_status( $id, $type ) { $external_id = 0; $sha_256 = 0; + global $wpdb; if ( $type == 'wps-user' ) { $external_id = get_user_meta( $id, '_external_id', true ); $sha_256 = get_user_meta( $id, '_sync_sha_256', true ); + } elseif ( $type == 'wps-product-cat' ) { + $external_id = get_term_meta( $id, '_external_id', true ); + $sha_256 = get_term_meta( $id, '_sync_sha_256', true ); } else { $external_id = get_post_meta( $id, '_external_id', true ); $sha_256 = get_post_meta( $id, '_sync_sha_256', true ); } - + $sync_info = $this->sync_infos[ $type ]; - + $response = Request_Util::get( $sync_info['endpoint'] . '/' . $external_id ); - + // Dolibarr return false when object is not found. if ( ! $response ) { // @todo: Doublon if ( $type == 'wps-user' ) { delete_user_meta( $id, '_external_id' ); delete_user_meta( $id, '_sync_sha_256' ); - } else { + } elseif ( $type == 'wps-product-cat' ) { + delete_term_meta( $id, '_external_id' ); + delete_term_meta( $id, '_sync_sha_256' ); + } else { delete_post_meta( $id, '_external_id' ); delete_post_meta( $id, '_sync_sha_256' ); } @@ -241,13 +265,16 @@ public function check_status( $id, $type ) { 'status_message' => 'Dolibarr Object: #' . $external_id . ' not exist. Automatically delete external_id.', ); } - + // Dolibarr Object is not linked to this WP Object. if ( $response->array_options->options__wps_id != $id ) { // @todo: Doublon if ( $type == 'wps-user' ) { delete_user_meta( $id, '_external_id' ); delete_user_meta( $id, '_sync_sha_256' ); + } elseif ( $type == 'wps-product-cat' ) { + delete_term_meta( $id, '_external_id' ); + delete_term_meta( $id, '_sync_sha_256' ); } else { delete_post_meta( $id, '_external_id' ); delete_post_meta( $id, '_sync_sha_256' ); @@ -259,7 +286,7 @@ public function check_status( $id, $type ) { 'status_message' => 'Dolibarr Object is not linked to this WP Object.', ); } - + $response = apply_filters( 'doli_build_sha_' . $type, $response, $id ); // WP Object is not equal Dolibarr Object. @@ -291,7 +318,7 @@ public function check_status( $id, $type ) { * @return string Le statut de la synchronisation. */ public function display_sync_status( $object, $type, $load_erp_status = true ) - { + { $data_view = array( 'object' => $object, 'type' => $type, @@ -300,24 +327,24 @@ public function display_sync_status( $object, $type, $load_erp_status = true ) 'message_tooltip' => __( 'Looking for sync status', 'wpshop' ), 'can_sync' => false, ); - + if ( ! $load_erp_status ) { View_Util::exec('wpshop', 'doli-sync', 'sync-item', $data_view); return; } if ( empty($object->data['external_id'] ) ) { - $data_view['status_color'] = 'red'; + $data_view['status_color'] = 'none'; $data_view['message_tooltip'] = __('No associated to an ERP Entity', 'wpshop'); View_Util::exec('wpshop', 'doli-sync', 'sync-item', $data_view); return; } - + $response = Doli_Sync::g()->check_status($object->data['id'], $type); - + if ( ! $response || ! $response['status'] ) { - $data_view['status_color'] = 'red'; + $data_view['status_color'] = 'none'; } else { // @todo: Do Const for status_code. switch ($response['status_code']) { @@ -326,22 +353,22 @@ public function display_sync_status( $object, $type, $load_erp_status = true ) $data_view['can_sync'] = true; break; case '0x1': - $data_view['status_color'] = 'red'; + $data_view['status_color'] = 'none'; break; case '0x2': - $data_view['status_color'] = 'red'; + $data_view['status_color'] = 'none'; $object->data['external_id'] = ''; break; case '0x3': - $data_view['status_color'] = 'orange'; + $data_view['status_color'] = 'red'; $data_view['can_sync'] = true; break; } } - + $data_view['message_tooltip'] = isset ( $response['status_message'] ) ? $response['status_message'] : __( 'Error not defined', 'wpshop' ); View_Util::exec( 'wpshop', 'doli-sync', 'sync-item', $data_view ); - + return $response; } } diff --git a/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php b/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php index 4a98038..5fae130 100644 --- a/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php +++ b/modules/dolibarr/doli-sync/filter/class-doli-sync-filter.php @@ -31,6 +31,7 @@ protected function construct() { add_filter( 'doli_build_sha_wps-product', array( $this, 'build_sha_product' ), 10, 2 ); add_filter( 'doli_build_sha_wps-third-party', array( $this, 'build_sha_third_party' ), 10, 2 ); + add_filter( 'doli_build_sha_wps-product-cat', array( $this, 'build_sha_categories' ), 10, 2 ); } /** @@ -137,6 +138,30 @@ public function build_sha_third_party( $response, $wp_id ) { return $response; } + + /** + * La construction du SHA256 d'une synchronisation d'une catégorie. + * + * @since 2.0.0 + * @version 2.0.0 + * + * @param Third_Party $response Les données d'un tier. + * @param integer $wp_id L'id d'un tier WordPress. + * + * @return Third_Party Les données d'un tier avec le SHA256. + */ + public function build_sha_categories( $response, $wp_id ) { + $data_sha = array(); + + $data_sha['doli_id'] = (int) $response->id; + $data_sha['wp_id'] = $wp_id; + $data_sha['name'] = $response->label; + $data_sha['slug'] = $response->array_options->options__wps_slug; + + $response->sha = hash( 'sha256', implode( ',', $data_sha ) ); + + return $response; + } } Doli_Sync_Filter::g(); diff --git a/modules/dolibarr/doli-sync/view/sync-item.view.php b/modules/dolibarr/doli-sync/view/sync-item.view.php index 100717b..2e80258 100644 --- a/modules/dolibarr/doli-sync/view/sync-item.view.php +++ b/modules/dolibarr/doli-sync/view/sync-item.view.php @@ -22,12 +22,11 @@ * @var string $type Le type d'entité. * @var string $status_color La couleur du statut d'une synchronisation. * @var string $message_tooltip Le message de la tooltip. - */ + */ ?> -
      -
    • WP : data['id'] ); ?>
    • +
    • WP : data['id'] ); ?>
    • Doli : data['external_id'] ) ? esc_html( $object->data['external_id'] ) : "N/A"; ?>
    dolibarr_is_active() ) { add_submenu_page( 'wpshop', __( 'Add', 'wpshop' ), __( 'Add', 'wpshop' ), 'manage_options', 'post-new.php?post_type=wps-product' ); } - add_submenu_page( 'wpshop', __( 'Products Category', 'wpshop' ), __( 'Products Category', 'wpshop' ), 'manage_options', 'edit-tags.php?taxonomy=wps-product-cat&post_type=wps-product' ); - add_action( 'load-' . $hook, array( $this, 'callback_add_screen_option' ) ); } /** @@ -89,7 +87,7 @@ public function callback_add_menu_page() { $prev_url .= '&s=' . $s; $next_url .= '&s=' . $s; } - + View_Util::exec( 'wpshop', 'products', 'main', array( 'number_page' => $number_page, 'current_page' => $current_page, diff --git a/modules/products/filter/class-product-filter.php b/modules/products/filter/class-product-filter.php index 7782544..d3eabeb 100644 --- a/modules/products/filter/class-product-filter.php +++ b/modules/products/filter/class-product-filter.php @@ -124,7 +124,7 @@ public function callback_register_post_type_args( $args ) { */ public function callback_taxonomy( $args ) { $labels = array( - 'name' => _x( 'Products category', 'taxonomy general name', 'wpshop' ), + 'name' => _x( 'Product category', 'taxonomy general name', 'wpshop' ), 'singular_name' => _x( 'Product category', 'taxonomy singular name', 'wpshop' ), 'search_items' => __( 'Search Products category', 'wpshop' ), 'all_items' => __( 'All Products category', 'wpshop' ), @@ -132,7 +132,7 @@ public function callback_taxonomy( $args ) { 'parent_item_colon' => __( 'Parent Product: category', 'wpshop' ), 'edit_item' => __( 'Edit Product category', 'wpshop' ), 'update_item' => __( 'Update Product category', 'wpshop' ), - 'add_new_item' => __( 'Add New Product category', 'wpshop' ), + 'add_new_item' => __( 'Add with Dolibarr', 'wpshop' ), 'new_item_name' => __( 'New Product categoryName', 'wpshop' ), 'menu_name' => __( 'Product category', 'wpshop' ), ); @@ -145,7 +145,7 @@ public function callback_taxonomy( $args ) { 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array( - 'slug' => __( 'category-product', 'wpshop' ), + 'slug' => __( 'wps-product-cat', 'wpshop' ), ), ); diff --git a/wpshop.config.json b/wpshop.config.json index 9f1e035..1244ca7 100644 --- a/wpshop.config.json +++ b/wpshop.config.json @@ -39,6 +39,7 @@ "modules/dolibarr/doli-statut/doli-statut.config.json", "modules/dolibarr/doli-proposals/doli-proposals.config.json", "modules/dolibarr/doli-order/doli-order.config.json", + "modules/dolibarr/doli-categories/doli-categories.config.json", "modules/dolibarr/doli-third-parties/doli-third-parties.config.json", "modules/dolibarr/doli-user/doli-user.config.json", "modules/dolibarr/doli-invoice/doli-invoice.config.json", From bda8b8b643d9049780bddd815fa9ee5adc1da725 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 4 Sep 2020 17:56:04 +0200 Subject: [PATCH 10/13] Docs : Changelog 2.1.0 --- readme.txt | 11 +++++++++-- wpshop.config.json | 2 +- wpshop.php | 11 ++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/readme.txt b/readme.txt index 9c635a6..fb4ecb0 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: Eoxia Tags: boutique, catalog, catalogue, commerce, e-commerce, ecommerce, m-commerce, mcommerce, produits, shop, shopping cart, wp shop, wordpress ecommerce, wordpress shop, WPShop, wp-shop, french payment gateway, Donate link: https://www.wpshop.fr/ Requires at least: 4.4 -Tested up to: 5.4.2 +Tested up to: 5.5.1 Requires PHP: 7.0 -Stable tag: 2.0.0 +Stable tag: 2.1.0 License: GPLv3 or later License URI: https://spdx.org/licenses/GPL-3.0-or-later.html @@ -65,6 +65,13 @@ Il n'est pas possible de migrer les données vers la version WPShop 2.X.X. == Changelog == += Version 2.1.0 = + += IMPROVMENT = + +Synchronisation des catégories Dolibarr avec ceux de WordPress. +Synchronisation des médias Dolibarr avec ceux de WordPress. + = Version 2.0.0 = * First Released diff --git a/wpshop.config.json b/wpshop.config.json index 6f31ae4..cb0d80e 100644 --- a/wpshop.config.json +++ b/wpshop.config.json @@ -2,7 +2,7 @@ "name": "WPshop", "slug": "wpshop", "since": "2.0.0", - "version": "2.0.0", + "version": "2.1.0", "description": "L'application WPshop 2", "externals": [], "modules": [ diff --git a/wpshop.php b/wpshop.php index cbf7d3f..4fdc5a0 100644 --- a/wpshop.php +++ b/wpshop.php @@ -3,7 +3,7 @@ * Plugin Name: WPshop 2 * Plugin URI: https://wpshop.fr/ * Description: Simple, fast, efficient it will transform your WordPress into an internet sales site - * Version: 2.0.0 + * Version: 2.1.0 * Author: Eoxia * Author URI: http://www.eoxia.com/ * License: GPLv3 @@ -34,3 +34,12 @@ // Boot your plugin. Init_Util::g()->exec( PLUGIN_WPSHOP_PATH, basename( __FILE__, '.php' ) ); + +add_filter('site_transient_update_plugins', + function ($value) { + if ( $value->checked[plugin_basename(__FILE__)] <= "1.6.4" ) { + unset( $value->response[plugin_basename(__FILE__)] ); + } + return $value; + } +); From 083a189d35044ec2ab517c1969b31455fdc08bc3 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 4 Sep 2020 19:58:05 +0200 Subject: [PATCH 11/13] =?UTF-8?q?ADD=20:=20=E2=82=ACHT=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/products/view/frontend/wps-product-single.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/products/view/frontend/wps-product-single.php b/modules/products/view/frontend/wps-product-single.php index 0bfcad2..4d97f09 100644 --- a/modules/products/view/frontend/wps-product-single.php +++ b/modules/products/view/frontend/wps-product-single.php @@ -22,7 +22,8 @@ ?>
    -
    data['price_ttc'] ) ? esc_html( number_format( $product->data['price_ttc'], 2, ',', '' ) ) . ' €' : ''; ?>
    +
    data['price_ht'] ) ? esc_html( number_format( $product->data['price_ht'], 2, ',', '' ) ) . ' € HT' : ''; ?>
    +
    data['price_ttc'] ) ? esc_html( number_format( $product->data['price_ttc'], 2, ',', '' ) ) . ' € TTC' : ''; ?>
    post_content, $product ); ?>
    From 3e24e78b7fb052f9cf5b5b6d859edd7ef4867737 Mon Sep 17 00:00:00 2001 From: evarisk-theo <68421590+evarisk-theo@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:09:43 +0200 Subject: [PATCH 12/13] Update wpshop.php --- wpshop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpshop.php b/wpshop.php index 4fdc5a0..35c6efb 100644 --- a/wpshop.php +++ b/wpshop.php @@ -30,7 +30,7 @@ } // Include composer component. -require_once 'vendor/autoload.php'; +// require_once 'vendor/autoload.php'; // Boot your plugin. Init_Util::g()->exec( PLUGIN_WPSHOP_PATH, basename( __FILE__, '.php' ) ); From 8c0f9386819876106623c4f0ca7c12d5305d11ae Mon Sep 17 00:00:00 2001 From: evarisk-theo <68421590+evarisk-theo@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:10:33 +0200 Subject: [PATCH 13/13] Update readme.txt --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index fb4ecb0..9eed880 100644 --- a/readme.txt +++ b/readme.txt @@ -67,7 +67,7 @@ Il n'est pas possible de migrer les données vers la version WPShop 2.X.X. = Version 2.1.0 = -= IMPROVMENT = += IMPROVEMENT = Synchronisation des catégories Dolibarr avec ceux de WordPress. Synchronisation des médias Dolibarr avec ceux de WordPress.