diff --git a/.easya_info.json b/.easya_info.json index 6a2581b..c80c9f2 100644 --- a/.easya_info.json +++ b/.easya_info.json @@ -1,4 +1,4 @@ { - "dol_min": 14, - "dol_max": 18 + "dlb_min_version": 14, + "dlb_max_version": 18 } diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..70cee73 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,3 @@ +include: + - project: "opendsi/ci-templates" + file: "/dolibarr/module/main.yml" \ No newline at end of file diff --git a/ChangeLog.md b/ChangeLog.md index 83fe9d1..e06514e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,9 @@ # ChangeLog -## 14.0.1 +## [14.0.2] - 03-06-2024 +- Changement de marque, page support, ajout CI, corrections de coquilles. + +## [14.0.1] - Changement de numérotation ## 4.1.72 @@ -884,3 +887,7 @@ ## 3.9.0.0 - Initial version. + + +[Non Distribué]: https://github.com/OPEN-DSI/ecommerceng_woosync/compare/14.0.2...HEAD +[14.0.2]: https://github.com/OPEN-DSI/ecommerceng_woosync/commits/14.0.2 \ No newline at end of file diff --git a/README.md b/README.md index eac1d43..a062db1 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ ## You have to rename the folder to ecommerceng when you download the zip file or make a git clone. In other case the module will not work -Use it at you onwn risk Open-DSI does not provide support for the use, installation or bug fixing for this software. For this you have to acquire a time from our sales service https://www.easya.solutions/contact. You can also consult our company for any installation, configuration or development services. +Use it at you onwn risk Easya Solution does not provide support for the use, installation or bug fixing for this software. For this you have to acquire a time from our sales service https://www.easya.solutions/contact. You can also consult our company for any installation, configuration or development services. -Before any use, please refer to the documentatio to check the available functionnality +Before any use, please refer to the documentation to check the available functionnality https://link.easya.solutions/woosync_doc -Utilisation à vos risques et périls. Open-DSI ne fournit pas de support à l’utilisation, à l'installation ni de correction de bugs pour ce logiciel. Pour cela vous devrez faire l’acquisition d’un crédit temps auprès de notre service commercial : https://www.easya.solutions/contact. Vous pouvez également nous consulter pour toute prestation d’installation, configuration ou développement. +Utilisation à vos risques et périls. Easya Solutions ne fournit pas de support à l’utilisation, à l'installation ni de correction de bugs pour ce logiciel. Pour cela vous devrez faire l’acquisition d’un crédit temps auprès de notre service commercial : https://www.easya.solutions/contact. Vous pouvez également nous consulter pour toute prestation d’installation, configuration ou développement. Avant toute utilisation, merci de prendre connaissance de la documentation pour vérifier si le module répond en l'état à vos besoins https://link.easya.solutions/woosync_doc diff --git a/VERSION b/VERSION index 63dba86..112969d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -14.0.1 +14.0.2 \ No newline at end of file diff --git a/admin/about.php b/admin/about.php index 234ad36..a0bfc85 100644 --- a/admin/about.php +++ b/admin/about.php @@ -31,7 +31,7 @@ dol_include_once('/ecommerceng/core/modules/modECommerceNg.class.php'); $langs->load("admin"); -$langs->load("ecommerce@ecommerceng"); +$langs->load("ecommerceng@ecommerceng"); $langs->load("opendsi@ecommerceng"); if (!$user->admin && !$user->rights->ecommerceng->site) accessforbidden(); @@ -75,7 +75,8 @@ $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ECommerceSetup"),$linkback,'title_setup'); -include dol_buildpath('/ecommerceng/admin/tpl/selectsite.tpl.php'); +// include dol_buildpath('/ecommerceng/admin/tpl/selectsite.tpl.php'); +print '
'; $head=ecommercengConfigSitePrepareHead($object); diff --git a/admin/changelog.php b/admin/changelog.php new file mode 100755 index 0000000..9bb01fd --- /dev/null +++ b/admin/changelog.php @@ -0,0 +1,103 @@ + + * Copyright (C) 2019 Open-DSI + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/custom/ecommerceng/admin/about.php + * \ingroup ecommerceng + * \brief Page about of ecommerceng module + */ + +// Change this following line to use the correct relative path (../, ../../, etc) +$res=0; +if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory +if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory +if (! $res) die("Include of main fails"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +dol_include_once('/ecommerceng/lib/eCommerce.lib.php'); +dol_include_once('/ecommerceng/lib/opendsi_common.lib.php'); +dol_include_once('/ecommerceng/core/modules/modECommerceNg.class.php'); + +$langs->loadLangs(array("admin", "orders", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng", "opendsi@ecommerceng")); + +if (!$user->admin) accessforbidden(); + + + + + + + + + +$object = new eCommerceSite($db); +if (!($id > 0)) { + $sites = $object->listSites(); + if (!empty($sites)) { + $id = array_values($sites)[0]['id']; + } + $action = ''; +} +if ($id > 0) { + $result = $object->fetch($id); + if ($result < 0) { + accessforbidden($object->errorsToString()); + } elseif ($result == 0) { + $langs->load('errors'); + accessforbidden($langs->trans('ErrorRecordNotFound')); + } +} else { + accessforbidden($langs->trans('ErrorRecordNotFound')); +} + +/*if (empty($conf->facture->enabled) && empty($conf->facture->enabled)) { + accessforbidden($langs->trans('ModuleDisabled')); +} */ + + + + + + +/** + * View + */ + +$wikihelp='EN:ECommerceNg_En|FR:ECommerceNg_Fr|ES:ECommerceNg_Es'; +llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ECommerceSetup"),$linkback,'title_setup'); +print "
\n"; + + +$head=ecommercengConfigSitePrepareHead($object); + +print dol_get_fiche_head($head, 'changelog', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); + +$changelog = opendsi_common_getChangeLog('ecommerceng'); + +print '
'."\n"; +print (!empty($changelog) ? $changelog : $langs->trans("NotAvailable")); +print '
'."\n"; + +print dol_get_fiche_end(); + + +llxFooter(); + +$db->close(); diff --git a/admin/order.php b/admin/order.php index 18a5ed1..d89e09f 100644 --- a/admin/order.php +++ b/admin/order.php @@ -34,7 +34,7 @@ dol_include_once('/ecommerceng/admin/class/data/eCommerceDict.class.php'); dol_include_once('/ecommerceng/class/data/eCommercePaymentGateways.class.php'); -$langs->loadLangs(array("admin", "orders", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng")); +$langs->loadLangs(array("admin", "orders", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng", "opendsi@ecommerceng")); if (!$user->admin && !$user->rights->ecommerceng->site) accessforbidden(); @@ -267,7 +267,7 @@ $form = new Form($db); $formmail = new FormMail($db); -$wikihelp=''; +$wikihelp='EN:ECommerceNg_En|FR:ECommerceNg_Fr|ES:ECommerceNg_Es'; llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp, '', 0, 0, array( '/ecommerceng/js/form.js', )); @@ -297,7 +297,7 @@ $head=ecommercengConfigSitePrepareHead($object); -dol_fiche_head($head, 'order_invoice', $langs->trans("Module107100Name"), 0, 'eCommerce@ecommerceng'); +print dol_get_fiche_head($head, 'order_invoice', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); print '
'; print ''.$langs->trans('ECommerceUpdatePaymentGateways').''; diff --git a/admin/product.php b/admin/product.php index 82bc85c..73cd8f7 100644 --- a/admin/product.php +++ b/admin/product.php @@ -35,7 +35,7 @@ dol_include_once('/ecommerceng/lib/eCommerce.lib.php'); dol_include_once('/ecommerceng/admin/class/data/eCommerceDict.class.php'); -$langs->loadLangs(array("admin", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng")); +$langs->loadLangs(array("admin", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng", "opendsi@ecommerceng")); if (!$user->admin && !$user->rights->ecommerceng->site) accessforbidden(); @@ -265,7 +265,7 @@ $formaccounting = new FormAccounting($db); $v10p = version_compare(DOL_VERSION, "10.0.0") >= 0; -$wikihelp=''; +$wikihelp='EN:ECommerceNg_En|FR:ECommerceNg_Fr|ES:ECommerceNg_Es'; llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp, '', 0, 0, array( '/ecommerceng/js/form.js', )); @@ -299,7 +299,7 @@ $head=ecommercengConfigSitePrepareHead($object); -dol_fiche_head($head, 'product', $langs->trans("Module107100Name"), 0, 'eCommerce@ecommerceng'); +print dol_get_fiche_head($head, 'product', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); print '
'; print ''.$langs->trans('ECommerceWoocommerceUpdateDictAttributes').''; diff --git a/admin/setup.php b/admin/setup.php index 4aece98..d24fc75 100644 --- a/admin/setup.php +++ b/admin/setup.php @@ -33,7 +33,7 @@ use OAuth\Common\Storage\DoliStorage; -$langs->loadLangs(array("admin", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng")); +$langs->loadLangs(array("admin", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerce", "woocommerce@ecommerceng", "opendsi@ecommerceng")); if (!$user->admin && !$user->rights->ecommerceng->site) accessforbidden(); @@ -278,7 +278,7 @@ $form = new Form($db); -$wikihelp=''; +$wikihelp='EN:ECommerceNg_En|FR:ECommerceNg_Fr|ES:ECommerceNg_Es'; llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp); $formconfirm = ''; @@ -306,7 +306,7 @@ $head=ecommercengConfigSitePrepareHead($object); -dol_fiche_head($head, 'settings', $langs->trans("Module107100Name"), 0, 'eCommerce@ecommerceng'); +print dol_get_fiche_head($head, 'settings', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); if ($object->id > 0) { print '
'; diff --git a/admin/stock.php b/admin/stock.php index 45e4c93..8d5ca4f 100644 --- a/admin/stock.php +++ b/admin/stock.php @@ -32,7 +32,7 @@ dol_include_once('/ecommerceng/class/html.formecommerceng.class.php'); dol_include_once('/ecommerceng/class/data/eCommerceRemoteWarehouses.class.php'); -$langs->loadLangs(array("admin", "stocks", "ecommerce@ecommerceng", "woocommerce@ecommerceng")); +$langs->loadLangs(array("admin", "stocks", "ecommerce@ecommerceng", "woocommerce@ecommerceng", "opendsi@ecommerceng")); if (!$user->admin && !$user->rights->ecommerceng->site) accessforbidden(); @@ -135,7 +135,7 @@ $formproduct = new FormProduct($db); $formecommerceng = new FormECommerceNg($db); -$wikihelp=''; +$wikihelp='EN:ECommerceNg_En|FR:ECommerceNg_Fr|ES:ECommerceNg_Es'; llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp); $formconfirm = ''; @@ -163,7 +163,7 @@ $head=ecommercengConfigSitePrepareHead($object); -dol_fiche_head($head, 'stock', $langs->trans("Module107100Name"), 0, 'eCommerce@ecommerceng'); +print dol_get_fiche_head($head, 'stock', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); if (!empty($object->parameters['enable_warehouse_plugin_support'])) { print '
'; diff --git a/admin/thirdparty.php b/admin/thirdparty.php index f031d9c..722149d 100644 --- a/admin/thirdparty.php +++ b/admin/thirdparty.php @@ -34,7 +34,7 @@ dol_include_once('/ecommerceng/lib/eCommerce.lib.php'); dol_include_once('/ecommerceng/admin/class/data/eCommerceDict.class.php'); -$langs->loadLangs(array("admin", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerceng", "woocommerce@ecommerceng")); +$langs->loadLangs(array("admin", "companies", "bills", "accountancy", "banks", "oauth", "ecommerce@ecommerce", "woocommerce@ecommerceng", "opendsi@ecommerceng")); if (!$user->admin && !$user->rights->ecommerceng->site && !empty($conf->societe->enabled)) accessforbidden(); @@ -139,7 +139,7 @@ $form = new Form($db); $category_static = new Categorie($db); -$wikihelp=''; +$wikihelp='EN:ECommerceNg_En|FR:ECommerceNg_Fr|ES:ECommerceNg_Es'; llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp, '', 0, 0, array( '/ecommerceng/js/form.js', )); @@ -151,7 +151,7 @@ $head=ecommercengConfigSitePrepareHead($object); -dol_fiche_head($head, 'thirdparty', $langs->trans("Module107100Name"), 0, 'eCommerce@ecommerceng'); +print dol_get_fiche_head($head, 'thirdparty', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); /** * Settings. diff --git a/core/modules/modECommerceNg.class.php b/core/modules/modECommerceNg.class.php index c2cd66d..3201702 100644 --- a/core/modules/modECommerceNg.class.php +++ b/core/modules/modECommerceNg.class.php @@ -54,18 +54,18 @@ function __construct($db) $this->family = 'easya'; $this->familyinfo = array('easya' => array('position' => '001', 'label' => $langs->trans("easyaFamily"))); // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = 'EcommerceNg'; // Must be same than value used for if $conf->ecommerceng->enabled + $this->name = preg_replace('/^mod/i', '', get_class($this)); // Must be same than value used for if $conf->ecommerceng->enabled // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "Module to synchronise Dolibarr with ECommerce platform (currently ecommerce supported: WooCommerce)"; $this->descriptionlong = "See page https://wiki.dolibarr.org/index.php/Module_Magento_EN for more information"; - $this->editor_name = 'Easya Solutions (Ex Open-Dsi)'; + $this->editor_name = 'Easya Solutions)'; $this->editor_web = 'https://easya.solutions'; $this->editor_url = "https://easya.solutions"; $this->editor_email = 'support@easya.solutions'; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = file_get_contents(__DIR__.'/../../VERSION'); - $this->url_last_version = 'https://git.open-dsi.fr/dolibarr-extension/'.strtolower($this->name).'/-/raw/2022.5.3/VERSION'; + $this->url_last_version = 'https://git.open-dsi.fr/dolibarr-extension/'.strtolower($this->name).'/-/raw/2024/VERSION'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) @@ -114,8 +114,9 @@ function __construct($db) // Dependencies $this->depends = array("modSociete", "modProduct", "modCategorie", "modWebServices"); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5, 3); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module + $easya_info = json_decode(file_get_contents(__DIR__.'/../../.easya_info.json')); + $this->phpmin = explode('.', $easya_info->php_min_version); // Minimum version of PHP required by module + $this->need_dolibarr_version = explode('.', $easya_info->dlb_min_version); // Minimum version of Dolibarr required by module $this->langfiles = array("ecommerce@ecommerceng", "woocommerce@ecommerceng"); // Constants diff --git a/img/object_opendsi copy.png b/img/object_opendsi copy.png new file mode 100644 index 0000000..5733048 Binary files /dev/null and b/img/object_opendsi copy.png differ diff --git a/img/object_opendsi_big.png b/img/object_opendsi_big.png index b129a3a..6ed22cd 100644 Binary files a/img/object_opendsi_big.png and b/img/object_opendsi_big.png differ diff --git a/img/opendsi_dolibarr_preferred_partner.png b/img/opendsi_dolibarr_preferred_partner.png old mode 100755 new mode 100644 index c94f5a0..2b54161 Binary files a/img/opendsi_dolibarr_preferred_partner.png and b/img/opendsi_dolibarr_preferred_partner.png differ diff --git a/langs/fr_FR/ecommerce.lang b/langs/fr_FR/ecommerce.lang index 6144b29..666e416 100644 --- a/langs/fr_FR/ecommerce.lang +++ b/langs/fr_FR/ecommerce.lang @@ -185,7 +185,7 @@ ECommerceConfirmUpdatePriceLevel ThirdPartyForNonLoggedUsers =Tiers générique de recueil des clients sans compte créé SynchUnkownCustomersOnThirdParty =Tiers générique auquel seront rattachées les commandes de clients sans compte ECommerceDontSearchCompanyByNameAndZip =Recherche par nom et code postal -ECommerceDontSearchCompanyByNameAndZipDescription =Ne pas rechercher le tiers Dolibarr graçe au nom et code postal fournit par WooCommerce +ECommerceDontSearchCompanyByNameAndZipDescription =Ne pas rechercher le tiers Dolibarr grâce au nom et code postal fournit par WooCommerce ECommerceDontUpdateDolibarrCompany =Mise à jour du tiers ECommerceDontUpdateDolibarrCompanyDescription =Ne pas mettre à jour le tiers de Dolibarr lorsqu'il existe déja dans dolibarr @@ -193,7 +193,7 @@ ECommerceDontUpdateDolibarrCompanyDescription ECommerceWordpressAuthenticationOptions =Paramètres de connexion à WordPress ECommerceWordpressAuthenticationSetup =(Allez sur cette page , puis configurer la connexion) ECommerceWordpressAuthenticationType =Type d'authentification -ECommerceWordpressAuthenticationTypeDescription =Choissiez entre la connexion interne Wordpress avec un mot de passe d'application situé sur un utilisateur
Ou une authentification JWT grâçe à l'extension "WordPress REST API Authentication" de miniOrange +ECommerceWordpressAuthenticationTypeDescription =Choissiez entre la connexion interne Wordpress avec un mot de passe d'application situé sur un utilisateur
Ou une authentification JWT grâce à l'extension "WordPress REST API Authentication" de miniOrange ECommerceWordpressAuthenticationTypeWordpressApplication =Mot de passe d'application (Wordpress) ECommerceWordpressAuthenticationTypeJWTAuthentication =Authentification JWT ECommerceWordpressAuthenticationLogin =Identifiant @@ -312,21 +312,21 @@ ECommerceUpdateRemoteCompanyLinkWhenMergeCompany ECommerceSynchronizeStockToECommerce =Synchronisation du stock du produit sur le site %s. ECommerceCreateOrder =Créer la commande -ECommerceCreateOrderDescription =Activer la création de la commande a la synchronisation de la commande +ECommerceCreateOrderDescription =Activer la création de la commande à la synchronisation de la commande ECommerceCreateInvoice =Créer la facture -ECommerceCreateInvoiceDescription =Activer la création de la facture a la synchronisation de la commande -ECommerceCreateInvoiceType =Type la facture -ECommerceCreateInvoiceTypeDescription =Type la facture créée a la synchronisation de la commande +ECommerceCreateInvoiceDescription =Activer la création de la facture à la synchronisation de la commande +ECommerceCreateInvoiceType =Type de la facture +ECommerceCreateInvoiceTypeDescription =Type de la facture créée à la synchronisation de la commande ECommerceCreateInvoiceDepositType = ECommerceCreateInvoiceDepositTypeDescription = ECommerceCreateInvoiceDepositValue =Montant ou pourcentage ECommerceCreateInvoiceDepositValueDescription = ECommerceCreateSupplierInvoiceFromFee =Créer la facture fournisseur à partir des frais -ECommerceCreateSupplierInvoiceFromFeeDescription =Créer la facture fournisseur à partir des frais lors de la creation de la facture +ECommerceCreateSupplierInvoiceFromFeeDescription =Créer la facture fournisseur à partir des frais lors de la création de la facture ECommerceFeeLineAsItemLine =Considérer les lignes de frais comme des lignes de services ECommerceFeeLineAsItemLineDescription =Considérer les lignes de frais comme des lignes de services lors de la création de la commande/facture ECommerceSendInvoiceByMail =Envoyer la facture par courriel -ECommerceSendInvoiceByMailDescription =Envoyer la facture par courriel après la création avec succes de la facture +ECommerceSendInvoiceByMailDescription =Envoyer la facture par courriel après la création avec succès de la facture ECommerceCreateOrderDescription =Actions associées lors de la récupération des commandes WooCommerce (renseigner les modes de paiements associés à WooCommerce) ECommerceCreateInvoiceIfAmount0 =Créer la facture même si le montant est nul ECommerceCreateInvoiceIfAmount0Description =Créer la facture même si le montant est nul lors de la synchronisation de la commande @@ -359,6 +359,7 @@ RestrictSyncToCompanyRemoteID RestrictSyncToProductRemoteID =Limiter la synchronisation des produits aux ID distants suivants (product_id, product_id|variation_id, ...) RestrictSyncToOrderRemoteID =Limiter la synchronisation des commandes aux ID distants suivants (order_id, order_id, ...) DontSyncProductWhenSyncOrders =Ne pas synchroniser les produits lors de la synchronisation des commandes +RestrictNbInSync=Limiter le nombre d'enregistrements d'un même objet à synchroniser dans une même requête ECommerceSiteWebHooksSetup =Configuration des Crochets Web (WebHooks) ECommerceSiteWebHooksUrl =URL de livraison @@ -366,7 +367,7 @@ ECommerceSiteWebHooksUrlDescription ECommerceSiteWebHooksSecret =Secret ECommerceSiteWebHooksSecretDescription =La clé secrète est utilisée pour générer un hachage du crochet Web livré et indiqué dans les en-têtes de requête ECommerceSiteWebHooksVolumetryAlert =Alerte volumétrie -ECommerceSiteWebHooksVolumetryAlertDescription =Envoie un email grace a une tache planifié si le nombre de hooks en attente de traitement depasse cette valeur (0 signifie qu'il n'y a pas de verification) +ECommerceSiteWebHooksVolumetryAlertDescription =Envoie un email grâce à une tâche planifiée si le nombre de hooks en attente de traitement dépasse cette valeur (0 signifie qu'il n'y a pas de vérification) ECommerceShippingService =Frais de port ECommerceShippingServiceDescription =Service utilisé pour la gestion des frais de port ECommerceDiscountCodeService =Code promo @@ -403,7 +404,7 @@ ECommerceWoocommerceOrderFirstDateForECommerceToDolibarr ECommerceWoocommerceOrderFirstDateForECommerceToDolibarrDescription =Les commandes dont la date de création est antérieure seront ignorées ECommerceWoocommerceOrderMetaDataInProductLineToDescriptionForECommerceToDolibarr =Méta-données sur ligne de produit -ECommerceWoocommerceOrderMetaDataInProductLineToDescriptionForECommerceToDolibarrDescription =Ajoute les méta-données des lignes de produit de la commandes WooCommerce dans la description des lignes de produit dans la commande Dolibarr
Les méta-données des lignes de produits des commandes WooCommerce doivent posséder les propriétées 'display_key' et 'display_value' pour que cette fonctionnalité fonctionne +ECommerceWoocommerceOrderMetaDataInProductLineToDescriptionForECommerceToDolibarrDescription =Ajoute les méta-données des lignes de produit de la commande WooCommerce dans la description des lignes de produit dans la commande Dolibarr
Les méta-données des lignes de produits des commandes WooCommerce doivent posséder les propriétées 'display_key' et 'display_value' pour que cette fonctionnalité fonctionne ECommerceWoocommerceOrderFilterMetaDataInProductLineToDescriptionForECommerceToDolibarr =Méta-données sur ligne de produit ECommerceWoocommerceOrderFilterMetaDataInProductLineToDescriptionForECommerceToDolibarrDescription =Liste des clés des méta-données à inclure ou non dans la description (séparées par des virgules) ECommerceExclude =Exclure diff --git a/langs/fr_FR/opendsi.lang b/langs/fr_FR/opendsi.lang index b962104..9634872 100755 --- a/langs/fr_FR/opendsi.lang +++ b/langs/fr_FR/opendsi.lang @@ -2,8 +2,7 @@ CHARSET=UTF-8 easyaFamily=Easya Solutions opendsiFamily=Opendsi -OpenDsiAboutDesc=Ce module a été développé par Open-DSI

Pour toute question technique ou retour, contactez-nous sur support@open-dsi.fr

Pour toute question commerciale, contactez-nous sur contact@open-dsi.fr ou au +33 4 82 53 94 76

Retrouvez nos autres modules sur Dolistore OpenDsiChangeLog=Fichier de log OpenDsiAboutDesc1=Ce module a été développé par Easya Solutions

Pour toute question technique ou retour, déposez une demande de support sur OpenDsiAboutDesc2=notre support -OpenDsiAboutDesc3=ou contactez-nous sur support@easya.solutions

Pour toute question commerciale, contactez-nous sur info@easya.solutions ou au +33 4 82 53 94 76

Retrouvez nos autres modules sur Dolistore +OpenDsiAboutDesc3=

Pour toute question commerciale, contactez-nous sur info@easya.solutions ou au +33 4 82 53 94 76

Retrouvez nos autres modules sur Dolistore diff --git a/lib/eCommerce.lib.php b/lib/eCommerce.lib.php index cd384f1..9e5448f 100644 --- a/lib/eCommerce.lib.php +++ b/lib/eCommerce.lib.php @@ -89,6 +89,11 @@ function ecommercengConfigSitePrepareHead($object) $head[$h][2] = 'about'; $h++; + $head[$h][0] = dol_buildpath("/ecommerceng/admin/changelog.php", 1); + $head[$h][1] = $langs->trans("OpenDsiChangeLog"); + $head[$h][2] = 'changelog'; + $h++; + return $head; } diff --git a/lib/opendsi_common.lib.php b/lib/opendsi_common.lib.php new file mode 100755 index 0000000..bada05d --- /dev/null +++ b/lib/opendsi_common.lib.php @@ -0,0 +1,732 @@ + + * Copyright (C) 2017 Open-DSI + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/module/lib/opendsi_common.lib.php + * \ingroup module + * \brief Common functions opendsi for the module + */ + +/** + * Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md + * + * @param string $moduleName Name of module + * + * @return string Content of ChangeLog + */ +function opendsi_common_getChangeLog($moduleName) +{ + global $langs; + $langs->load("admin"); + + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php'; + + $filefound = false; + + $modulePath = dol_buildpath('/'.strtolower($moduleName), 0); + + // Define path to file README.md. + // First check README-la_LA.md then README.md + $pathoffile = $modulePath . '/ChangeLog-' . $langs->defaultlang . '.md'; + if (dol_is_file($pathoffile)) { + $filefound = true; + } + if (!$filefound) { + $pathoffile = $modulePath . '/ChangeLog.md'; + if (dol_is_file($pathoffile)) { + $filefound = true; + } + } + + $content = ''; + + if ($filefound) // Mostly for external modules + { + $moduleUrlPath = dol_buildpath('/'.strtolower($moduleName), 1); + $content = file_get_contents($pathoffile); + + if ((float)DOL_VERSION >= 6.0) { + @include_once DOL_DOCUMENT_ROOT . '/core/lib/parsemd.lib.php'; + $content = dolMd2Html($content, 'parsedown', array('doc/' => $moduleUrlPath . '/doc/')); + } else { + $content = opendsi_common_dolMd2Html('codenaf', $content, 'parsedown', array('doc/' => $moduleUrlPath . '/doc/')); + } + + } + + return $content; +} + +/** + * Function to parse MD content into HTML + * + * @param string $moduleName Name of module + * @param string $content MD content + * @param string $parser 'parsedown' or 'nl2br' + * @param string $replaceimagepath Replace path to image with another path. Exemple: ('doc/'=>'xxx/aaa/') + * + * @return string Parsed content + */ +function opendsi_common_dolMd2Html($moduleName, $content, $parser='parsedown',$replaceimagepath=null) +{ + if (is_array($replaceimagepath)) { + foreach ($replaceimagepath as $key => $val) { + $keytoreplace = '](' . $key; + $valafter = '](' . $val; + $content = preg_replace('/' . preg_quote($keytoreplace, '/') . '/m', $valafter, $content); + } + } + + if ($parser == 'parsedown') { + dol_include_once('/' . strtolower($moduleName) . '/includes/parsedown/Parsedown.php'); + $Parsedown = new Parsedown(); + $content = $Parsedown->text($content); + } else { + $content = nl2br($content); + } + + return $content; +} + +/** + * Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) + * + * @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR). Example: array("p.field1","p.field2") + * @param string[] $nullfields Array of strings, filled with the name of the field in the SQL query we must check if the searched fields is NULL (when mode = 4). Example: array("p.field1"=>"p.field3") + * @param string $value The value to look for. + * If param $mode is 0, can contains several keywords separated with a space or | + * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 + * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2 + * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" + * If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" + * If param $mode is 3, can contains a list of string separated by comma like "a,b,c" + * If param $mode is 4, can contains a datetime or a date and an operator <, > or = of string like "<=YYYY-MM-DD HH:mm:ss" or "<=YYYY-MM-DD HH:mm" or "=YYYY-MM-DD" or ">YYYY" ( support &, | and () ) + * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4') + * @param integer $nofirstand 1=Do not output the first 'AND' + * @return string $res The statement to append to the SQL query + */ +function opendsi_natural_search($fields, $value, $mode=0, $nofirstand=0, $nullfields=array()) +{ + global $db; + if ($mode == 4) { + if (!is_array($fields)) $fields = array($fields); + + $criterias = array(); + if (preg_match_all('/\s*(&|\|)?\s*(\()?\s*([<>=]+)?\s*([0-9]{4})(?:\s*-\s*([0-9]{2}))?(?:\s*-\s*([0-9]{2}))?(?:\s+([0-9]{2})?(?:\s*\:\s*([0-9]{2}))?(?:\s*\:\s*([0-9]{2}))?)?\s*(\))?\s*/', $value, $matches, PREG_SET_ORDER)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; + foreach ($matches as $match) { + $operatorSQL = !empty($match[1]) && $match[1] == '&' ? ' AND ' : ' OR '; + $openingParenthesis = !empty($match[2]) ? $match[2] : ''; + $operator = !empty($match[3]) ? $match[3] : '='; + $end_limit = $operator == '<=' || $operator == '>'; + $date = $match[4]; // Year + $date .= '-' . (!empty($match[5]) ? $match[5] : ($end_limit ? '12' : '00')); // Month + $date .= '-' . (!empty($match[6]) ? $match[6] : ($end_limit ? (!empty($match[5]) ? dol_get_last_day($match[4], $match[5]) : '31') : '00')); // Day + $date .= ' ' . (!empty($match[7]) ? $match[7] : ($end_limit ? '23' : '00')); // Hour + $date .= ':' . (!empty($match[8]) ? $match[8] : ($end_limit ? '59' : '00')); // Minute + $date .= ':' . (!empty($match[9]) ? $match[9] : ($end_limit ? '59' : '00')); // second + $date = "'" . $db->escape($date) . "'"; + $closingParenthesis = !empty($match[10]) ? $match[10] : ''; + + $not_complete = empty($match[9]) || empty($match[8]) || empty($match[7]) || empty($match[6]) || empty($match[5]); + if ($operator == '=' && $not_complete) { + $criterias[] = array($operatorSQL, $openingParenthesis.'(', '>=', $date, $closingParenthesis); + + $end_limit = true; + $date = $match[4]; // Year + $date .= '-' . (!empty($match[5]) ? $match[5] : ($end_limit ? '12' : '00')); // Month + $date .= '-' . (!empty($match[6]) ? $match[6] : ($end_limit ? (!empty($match[5]) ? dol_get_last_day($match[4], $match[5]) : '31') : '00')); // Day + $date .= ' ' . (!empty($match[7]) ? $match[7] : ($end_limit ? '23' : '00')); // Hour + $date .= ':' . (!empty($match[8]) ? $match[8] : ($end_limit ? '59' : '00')); // Minute + $date .= ':' . (!empty($match[9]) ? $match[9] : ($end_limit ? '59' : '00')); // second + $date = "'" . $db->escape($date) . "'"; + $operatorSQL = ' AND '; + $openingParenthesis = ''; + $operator = '<='; + $closingParenthesis .= ')'; + } + + $criterias[] = array($operatorSQL, $openingParenthesis, $operator, $date, $closingParenthesis); + } + } + + $to_print = array(); + foreach ($fields as $field) { + $ifnull = isset($nullfields[$field]) ? $nullfields[$field] : ''; + $statementSQL = ''; + foreach ($criterias as $criteria) { + $statementSQL .= $criteria[0] . $criteria[1] . (!empty($ifnull) ? $db->ifsql($field . ' IS NULL', $ifnull, $field) : $field) . ' ' . $criteria[2] . ' ' . $criteria[3] . $criteria[4]; + } + $statementSQL = preg_replace('/^( (?:AND|OR) )/', '', $statementSQL); + if (!empty($statementSQL)) $to_print[] = $statementSQL; + } + + return (!empty($to_print) ? ($nofirstand ? "" : " AND ") . "((" . implode(') OR (', $to_print) . "))" : ''); + } else { + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + return natural_search($fields, $value, $mode, $nofirstand); + } +} + +/** + * Return the handle of the object of the specified element + * + * @param DoliDB $db Database handler + * @param string $element_type Type of the element + * @param int $element_id Id of the element + * @return object|int <0 if KO otherwise object handler + */ +function opendsi_get_object($db, $element_type, $element_id) +{ + global $conf; + + $element_prop = getElementProperties($element_type); + if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) { + if (dol_include_once('/' . $element_prop['classpath'] . '/' . $element_prop['classfile'] . '.class.php')) { + if (class_exists($element_prop['classname'], false)) { + $objecttmp = new $element_prop['classname']($db); + $ret = $objecttmp->fetch($element_id); + if ($ret >= 0) { + return $objecttmp; + } + } + } + } + + // Parse element/subelement (ex: project_task) + $element = $subelement = $element_type; + if (preg_match('/^([^_]+)_([^_]+)/i', $element_type, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } + + $classpath = $element; + if ($element_type == 'order' || $element_type == 'commande') { + $classpath = $subelement = 'commande'; + } else if ($element_type == 'propal') { + $classpath = 'comm/propal'; + $subelement = 'propal'; + } else if ($element_type == 'facture') { + $classpath = 'compta/facture'; + $subelement = 'facture'; + } else if ($element_type == 'contract') { + $classpath = $subelement = 'contrat'; + } else if ($element_type == 'shipping') { + $classpath = $subelement = 'expedition'; + } else if ($element_type == 'deplacement') { + $classpath = 'compta/deplacement'; + $subelement = 'deplacement'; + } else if ($element_type == 'order_supplier') { + $classpath = 'fourn'; + $subelement = 'fournisseur.commande'; + } else if ($element_type == 'invoice_supplier') { + $classpath = 'fourn'; + $subelement = 'fournisseur.facture'; + } else if ($element_type == 'chargesociales') { + $classpath = 'compta/sociales'; + } else if ($element_type == 'tva') { + $classpath = 'compta/tva'; + } else if ($element_type == 'salary') { + $classpath = 'salaries'; + } else if ($element_type == 'payment_various') { + $classpath = 'compta/bank'; + $subelement = 'paymentvarious'; + } else if ($element_type == 'bank_account') { + $classpath = 'compta/bank'; + } else if ($element_type == 'stock') { + $classpath = 'product/stock'; + $subelement = 'entrepot'; + } + + $result = dol_include_once('/' . $classpath . '/class/' . $subelement . '.class.php'); + if (!$result) { + return -1; + } + + if ($element_type == 'order_supplier') { + $classname = 'CommandeFournisseur'; + } else if ($element_type == 'invoice_supplier') { + $classname = 'FactureFournisseur'; + } else if ($element_type == 'payment_various') { + $classname = 'PaymentVarious'; + } else if ($element_type == 'stock') { + $classname = 'Entrepot'; + } else $classname = ucfirst($subelement); + + if (!class_exists($classname, false)) { + return -1; + } + + $srcobject = new $classname($db); + $result = $srcobject->fetch($element_id); + if ($result < 0) { + return -1; + } + + return $srcobject; +} + +/** + * Return info of the documents path of the element + * + * @param DoliDB $db Database handler + * @param User $user User handler + * @param string $element_type Type of the element + * @param int $element_id Id of the element + * @return array Return info of the documents path of the element array('module_part' => '', 'file_dir' => '') + */ +function opendsi_get_object_documents_path_info($db, User $user, $element_type, $element_id) +{ + global $conf, $hookmanager; + + $module_part = ''; + $module_sub_dir = ''; + $file_dir = ''; + + if (opendsi_check_user_access_to_object($user, $element_type, $element_id)) { + $object = opendsi_get_object($db, $element_type, $element_id); + if (is_object($object) && $object->id > 0) { + // Add custom element by hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + } + $hookmanager2 = clone $hookmanager; // Génère des erreurs de resultat disparaissant si appelé dans une autre hooks donc on copie la hook + $hookmanager2->initHooks(array('opendsidao')); + $parameters = array('module_part' => &$module_part, 'file_dir' => &$file_dir, 'module_sub_dir' => &$module_sub_dir); + $reshook = $hookmanager2->executeHooks('opendsiGetObjectDocumentsPathInfo', $parameters); // Note that $action and $object may have been + if (empty($reshook)) { + $module_part = $element_type; + $module_sub_dir = dol_sanitizeFileName($object->ref); + + if ($element_type == 'order_supplier') { + $module_part = 'commande_fournisseur'; + } elseif ($element_type == 'invoice_supplier') { + $module_part = 'facture_fournisseur'; + $module_sub_dir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier') . $module_sub_dir; + } elseif ($element_type == 'contrat') { + $module_part = 'contract'; + } elseif ($element_type == 'fichinter') { + $module_part = 'ficheinter'; + } elseif ($element_type == 'project_task') { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($db); + $projectstatic->fetch($object->fk_project); + $module_sub_dir = dol_sanitizeFileName($projectstatic->ref) . '/' . $module_sub_dir; + } elseif ($element_type == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { // For backward compatiblity, we scan also old dirs + $module_sub_dir = substr(substr("000" . $object->id, -2), 1, 1) . '/' . substr(substr("000" . $object->id, -2), 0, 1) . '/' . $object->id . "/photos"; + } else { + $module_sub_dir = get_exdir(0, 0, 0, 1, $object, 'product'); + } + } + } elseif ($element_type == 'action') { + // Note: This 'elseif' block had been deleted, and it caused a bug in agenda display. + // It may be linked to DLB version. + // If this bug happens anew, contact kkhelifa or tnegre by open-dsi. + $module_sub_dir = $object->id; + $module_part = 'actions'; + } elseif ($element_type == 'salary') { + $module_part = 'salaries'; + $module_sub_dir = dol_sanitizeFileName($object->id); + } elseif ($element_type == 'payment_various') { + $module_part = 'banque'; + $module_sub_dir = dol_sanitizeFileName($object->id); + } elseif ($element_type == 'bank_account') { + $module_part = 'bank'; + } elseif ($element_type == 'webhost') { + $module_sub_dir = "/webhost/" . dol_sanitizeFileName($object->id); + } elseif ($element_type == 'webhost_webinstance') { + $module_part = 'webhost'; + $module_sub_dir = "/webinstance/" . dol_sanitizeFileName($object->id); + } elseif ($element_type == 'webhost_webmodule') { + $module_part = 'webhost'; + $module_sub_dir = "/webmodule/" . dol_sanitizeFileName($object->id); + } elseif ($element_type == 'usergroup') { + if (DOL_VERSION > 14) { + $module_part = 'user'; + } + } + + + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $check_access = dol_check_secure_access_document($module_part, $module_sub_dir, $conf->entity, $user, $object->ref); + if ($check_access['accessallowed']) { + $file_dir = $check_access['original_file']; + } else { + $module_part = ''; + } + } + } + } + + return array('module_part' => $module_part, 'file_dir' => $file_dir, 'module_sub_dir' => $module_sub_dir); +} + +/** + * Return if the user is authorized to access to the specified element + * + * @param User $user User handler + * @param string $element_type Type of the element + * @param int $element_id Id of the element + * @return bool + */ +function opendsi_check_user_access_to_object(User $user, $element_type, $element_id) +{ + global $db, $hookmanager; + + // Add custom element by hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + } + $hookmanager2 = clone $hookmanager; // Génère des erreurs de resultat disparaissant si appelé dans une autre hooks donc on copie la hook + $hookmanager2->initHooks(array('opendsidao')); + $parameters = array(); + $reshook = $hookmanager2->executeHooks('opendsiCheckUserAccessToObject', $parameters); // Note that $action and $object may have been + if (empty($reshook)) { + $features = $element_type; + $objectid = $element_id; + $tableandshare = ''; + $feature2 = ''; + $dbt_keyfield = 'fk_soc'; + $dbt_select = 'rowid'; + $objcanvas = null; + $v14p = version_compare(DOL_VERSION, '4.0.0', '>='); + + if ($element_type == 'invoice_supplier') { + $features = 'fournisseur'; + $tableandshare = 'facture_fourn'; + $feature2 = 'facture'; + } elseif ($element_type == 'order_supplier') { + $features = 'fournisseur'; + $tableandshare = 'commande_fournisseur'; + $feature2 = 'commande'; + } elseif ($element_type == 'fichinter') { + $features = 'ficheinter'; + $tableandshare = 'fichinter'; + } elseif ($element_type == 'project') { + $features = 'projet'; + $tableandshare = 'projet&project'; + } elseif ($element_type == 'project_task') { + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + $object = new Task($db); + $object->fetch($element_id); + $objectid = $object->fk_project; + $features = 'projet'; + $tableandshare = 'projet&project'; + } elseif ($element_type == 'expensereport') { + $objectid = 0; + $tableandshare = 'expensereport'; + } elseif ($element_type == 'action') { + $features = 'agenda'; + $tableandshare = 'actioncomm&societe'; + $feature2 = 'myactions|allactions'; + $dbt_select = 'id'; + } elseif ($element_type == 'product') { + $features = 'produit|service'; + $tableandshare = 'product&product'; + } elseif ($element_type == 'tva') { + $features = 'tax'; + $tableandshare = 'tva'; + $feature2 = 'charges'; + } elseif ($element_type == 'salary') { + $features = 'salaries'; + $tableandshare = 'salary'; + } elseif ($element_type == 'payment_various') { + $features = 'banque'; + $objectid = ''; + } elseif ($element_type == 'bank_account') { + $features = 'banque'; + $tableandshare = 'bank_account'; + } elseif ($element_type == 'webhost_webinstance') { + return empty($user->rights->webhost->instance->read) ? 0 : 1; + } elseif ($element_type == 'webhost_webmodule') { + return 1; + } + + return opendsi_restrictedArea($user, $features, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select, $objcanvas); + } + + // $reshook: =-1 not authorized, =1 authorized + return $reshook > 0 ? 1 : 0; +} + +/** + * Check permissions of a user to show a page and an object. Check read permission. + * If GETPOST('action','aZ09') defined, we also check write and delete permission. + * + * @param User $user User to check + * @param string $features Features to check (it must be module name. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...) + * @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). + * @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional). + * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'. + * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) + * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) + * @param Canvas $objcanvas Object canvas + * @return int Always 1, die process if not allowed + * @see dol_check_secure_access_document + */ +function opendsi_restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null) +{ + global $db, $conf; + + $v14p = version_compare(DOL_VERSION, '4.0.0', '>='); + + if ($v14p) { + $result = restrictedArea($user, $features, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select, 0, 1); + return $result; + } + + //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename,$feature2,$dbt_socfield,$dbt_select"); + //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; + //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; + //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; + + // If we use canvas, we try to use function that overlod restrictarea if provided with canvas + if (is_object($objcanvas)) + { + if (method_exists($objcanvas->control,'restrictedArea')) return $objcanvas->control->restrictedArea($user,$features,$objectid,$tableandshare,$feature2,$dbt_keyfield,$dbt_select); + } + + if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; + + // Features/modules to check + $featuresarray = array($features); + if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); + elseif (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); + + // More subfeatures to check + if (! empty($feature2)) $feature2 = explode("|", $feature2); + + // More parameters + $params = explode('&', $tableandshare); + $dbtablename=(! empty($params[0]) ? $params[0] : ''); + $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); + + $listofmodules=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); + + // Check read permission from module + $readok=1; $nbko=0; + foreach ($featuresarray as $feature) // first we check nb of test ko + { + $featureforlistofmodule=$feature; + if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product'; + if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users + { + $readok=0; $nbko++; + continue; + } + + if ($feature == 'societe') + { + if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; } + } + elseif ($feature == 'contact') + { + if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; } + } + elseif ($feature == 'produit|service') + { + if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; } + } + elseif ($feature == 'prelevement') + { + if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; } + } + elseif ($feature == 'cheque') + { + if (! $user->rights->banque->cheque) { $readok=0; $nbko++; } + } + elseif ($feature == 'projet') + { + if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; } + } + elseif (! empty($feature2)) // This should be used for future changes + { + $tmpreadok=1; + foreach($feature2 as $subfeature) + { + if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } + elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } + else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok + } + if (! $tmpreadok) // We found a test on feature that is ko + { + $readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). + $nbko++; + } + } + elseif (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions + { + if (empty($user->rights->$feature->lire) + && empty($user->rights->$feature->read) + && empty($user->rights->$feature->run)) { $readok=0; $nbko++; } + } + } + + // If a or and at least one ok + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1; + + if (! $readok) return 0; + //print "Read access is ok"; + + // Check write permission from module + $createok=1; $nbko=0; + if (GETPOST('action','aZ09') == 'create') + { + foreach ($featuresarray as $feature) + { + if ($feature == 'contact') + { + if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; } + } + elseif ($feature == 'produit|service') + { + if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; } + } + elseif ($feature == 'prelevement') + { + if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; } + } + elseif ($feature == 'commande_fournisseur') + { + if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; } + } + elseif ($feature == 'banque') + { + if (! $user->rights->banque->modifier) { $createok=0; $nbko++; } + } + elseif ($feature == 'cheque') + { + if (! $user->rights->banque->cheque) { $createok=0; $nbko++; } + } + elseif (! empty($feature2)) // This should be used + { + foreach($feature2 as $subfeature) + { + if (empty($user->rights->$feature->$subfeature->creer) + && empty($user->rights->$feature->$subfeature->write) + && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } + else { $createok=1; break; } // Break to bypass second test if the first is ok + } + } + elseif (! empty($feature)) // This is for old permissions ('creer' or 'write') + { + //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; + if (empty($user->rights->$feature->creer) + && empty($user->rights->$feature->write) + && empty($user->rights->$feature->create)) { $createok=0; $nbko++; } + } + } + + // If a or and at least one ok + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; + + if (! $createok) return 0; + //print "Write access is ok"; + } + + // Check create user permission + $createuserok=1; + if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm") == 'yes') + { + if (! $user->rights->user->user->creer) $createuserok=0; + + if (! $createuserok) return 0; + //print "Create user access is ok"; + } + + // Check delete permission from module + $deleteok=1; $nbko=0; + if ((GETPOST('action','aZ09') == 'confirm_delete' && GETPOST("confirm") == 'yes') || GETPOST('action','aZ09') == 'delete') + { + foreach ($featuresarray as $feature) + { + if ($feature == 'contact') + { + if (! $user->rights->societe->contact->supprimer) $deleteok=0; + } + elseif ($feature == 'produit|service') + { + if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0; + } + elseif ($feature == 'commande_fournisseur') + { + if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0; + } + elseif ($feature == 'banque') + { + if (! $user->rights->banque->modifier) $deleteok=0; + } + elseif ($feature == 'cheque') + { + if (! $user->rights->banque->cheque) $deleteok=0; + } + elseif ($feature == 'ecm') + { + if (! $user->rights->ecm->upload) $deleteok=0; + } + elseif ($feature == 'ftp') + { + if (! $user->rights->ftp->write) $deleteok=0; + }elseif ($feature == 'salaries') + { + if (! $user->rights->salaries->delete) $deleteok=0; + } + elseif ($feature == 'salaries') + { + if (! $user->rights->salaries->delete) $deleteok=0; + } + elseif (! empty($feature2)) // This should be used for future changes + { + foreach($feature2 as $subfeature) + { + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; + else { $deleteok=1; break; } // For bypass the second test if the first is ok + } + } + elseif (! empty($feature)) // This is for old permissions + { + //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; + if (empty($user->rights->$feature->supprimer) + && empty($user->rights->$feature->delete) + && empty($user->rights->$feature->run)) $deleteok=0; + } + } + + // If a or and at least one ok + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1; + + if (! $deleteok) return 0; + //print "Delete access is ok"; + } + + // If we have a particular object to check permissions on, we check this object + // is linked to a company allowed to $user. + if (! empty($objectid) && $objectid > 0) + { + require_once DOL_DOCUMENT_ROOT . '/core/lib/security.lib.php'; + $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + return $ok ? 1 : 0; + } + + return 1; +} diff --git a/tpl/index.tpl.php b/tpl/index.tpl.php index 91d2fa0..f50ad3e 100644 --- a/tpl/index.tpl.php +++ b/tpl/index.tpl.php @@ -5,7 +5,7 @@ $form = new Form($db); $linkback=''; -print load_fiche_titre($langs->trans("ECommerceDashboard"), $linkback, 'eCommerceTitle@ecommerceng'); +print load_fiche_titre($langs->trans("ECommerceDashboard"), $linkback, 'title_setup'); print '
'; diff --git a/tpl/site.tpl.php b/tpl/site.tpl.php index 4262c5b..95596b9 100644 --- a/tpl/site.tpl.php +++ b/tpl/site.tpl.php @@ -6,7 +6,9 @@ dol_include_once("/ecommerceng/lib/eCommerce.lib.php"); $linkback = '' . $langs->trans("BackToListOfSites") . ''; - print_fiche_titre($langs->trans('ECommerceSiteSynchro') . ' ' . $site->name, $linkback, 'eCommerceTitle@ecommerceng'); + //print_fiche_titre($langs->trans('ECommerceSiteSynchro') . ' ' . $site->name, $linkback, 'eCommerceTitle@ecommerceng'); + + print load_fiche_titre($langs->trans("ECommerceSiteSynchro"), $linkback, 'title_setup'); print '
'; @@ -15,7 +17,9 @@ $head[1][1] = $langs->trans("Direction") . ' : Ecommerce -> Dolibarr'; $head[1][2] = 'ecommerce2dolibarr'; - dol_fiche_head($head, 'ecommerce2dolibarr', ''); + // dol_fiche_head($head, 'ecommerce2dolibarr', ''); + + print dol_get_fiche_head($head, 'ecommerce2dolibarr', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng'); $disabled = $synchRights != true && empty($conf->global->ECOMMERCE_PROCESSING_WEBHOOK_SYNCHRONIZATION);