From c735653180965a040d1356def8722ae0789b3b8d Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 26 Jul 2018 13:49:12 +0200 Subject: [PATCH 001/622] add postgresql to test + add test on installation process --- .travis.yml | 69 +++++++++++++++++++++++++++++++++------- htdocs/install/step1.php | 1 + htdocs/install/step2.php | 9 ++++++ 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10a2b6e8347..a4d6dbc92d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,16 +64,6 @@ matrix: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '5.4' - env: DB=postgresql - - php: '5.5' - env: DB=postgresql - - php: '5.6' - env: DB=postgresql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - php: hhvm env: DB=postgresql - php: nightly @@ -201,7 +191,7 @@ before_script: mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' mysql -e 'FLUSH PRIVILEGES;' - mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql fi if [ "$DB" = 'postgresql' ]; then #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql @@ -298,6 +288,63 @@ script: # TODO: Check CSS (csslint?) +- | + export INSTALL_FORCED_FILE=htdocs/install/install.forced.php + echo "Setting up Dolibarr $INSTALL_FORCED_FILE" + # Ensure we catch errors + set +e + echo ' $INSTALL_FORCED_FILE + echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then + echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE + fi + if [ "$DB" = 'postgresql' ]; then + echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE + fi + echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databaselogin=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databasepass=\'\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE + # TODO: SQLite + #cat $INSTALL_FORCED_FILE + echo "Installation test" + cd htdocs/install + php step1.php $TRAVIS_BUILD_DIR/htdocs > $TRAVIS_BUILD_DIR/install.log + php step2.php set >> $TRAVIS_BUILD_DIR/install.log + if [ "$?" -ne "0" ]; then + echo "SORRY, AN ERROR OCCURED DURING INSTALLATION PROCESS" + exit 1 + fi + cd ../.. + rm $INSTALL_FORCED_FILE + #cat $TRAVIS_BUILD_DIR/install.log + set +e + echo + + - | + echo "Setting up database to test migrations" + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then + echo "MySQL" + mysql -e 'DROP DATABASE IF EXISTS travis;' + mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql -e 'FLUSH PRIVILEGES;' + mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + fi + if [ "$DB" = 'postgresql' ]; then + #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + pgloader mysql://root@127.0.0.1/travis postgresql:///travis + fi + # TODO: SQLite + echo + - | echo "Upgrading Dolibarr" # Ensure we catch errors diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 838ef34afa3..add57f5d853 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -82,6 +82,7 @@ if (@file_exists($forcedfile)) { // If forced install is enabled, let's replace post values. These are empty because form fields are disabled. if ($force_install_noedit) { $main_dir = detect_dolibarr_main_document_root(); + if (!empty($argv[1])) $main_dir = $argv[1]; // override when executing the script in command line if (!empty($force_install_main_data_root)) { $main_data_dir = $force_install_main_data_root; } else { diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 44661c191d7..e0e7d71c25d 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -65,6 +65,8 @@ if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.fo if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; + // test for travis + if (!empty($argv[1]) && $argv[1] == "set") $action = "set"; } dolibarr_install_syslog("--- step2: entering step2.php page"); @@ -620,8 +622,15 @@ else print 'Parameter action=set not defined'; } +$ret=0; +if (! $ok && isset($argv[1])) $ret=1; +dol_syslog("Exit ".$ret); + dolibarr_install_syslog("--- step2: end"); pFooter($ok?0:1,$setuplang); if (isset($db) && is_object($db)) $db->close(); + +// Return code if ran from command line +if ($ret) exit($ret); From 9a080a5d62b34dfef364f4d9cf44c350fca398df Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 26 Jul 2018 13:53:44 +0200 Subject: [PATCH 002/622] add sourceline for fastcgi --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a4d6dbc92d2..99bdd8f083f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ addons: - apache2 # mod_php is not supported by Travis. Add fcgi. We install FPM later on. - libapache2-mod-fastcgi + - sourceline: 'deb http://http.us.debian.org/debian main non-free' # We need pgloader for import mysql database into pgsql - pgloader From c8b035659cb21e2c7dd0f72cca6dd9bae5a7ce67 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 26 Jul 2018 14:04:22 +0200 Subject: [PATCH 003/622] add sourceline for fastcgi on the right place --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 99bdd8f083f..9c7f562de23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,13 +21,13 @@ addons: - postgresql - sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' + - sourceline: 'deb http://http.us.debian.org/debian main non-free' packages: # We need a webserver to test the webservices # Let's install Apache with. - apache2 # mod_php is not supported by Travis. Add fcgi. We install FPM later on. - libapache2-mod-fastcgi - - sourceline: 'deb http://http.us.debian.org/debian main non-free' # We need pgloader for import mysql database into pgsql - pgloader From 3215e066e49b74e71a51ab2f4b1ecd2477396f09 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Mar 2019 10:00:44 +0100 Subject: [PATCH 004/622] copy linked categories when cloning a product --- htdocs/langs/en_US/products.lang | 1 + htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/card.php | 14 ++++++++++++++ htdocs/product/class/product.class.php | 26 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 401ccc5462e..9c96f12c589 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -147,6 +147,7 @@ RowMaterial=Raw Material CloneProduct=Clone product or service ConfirmCloneProduct=Are you sure you want to clone product or service %s? CloneContentProduct=Clone all main information of product/service +CloneCategoriesProduct=Clone tags/categories linked ClonePricesProduct=Clone prices CloneCompositionProduct=Clone virtual product/service CloneCombinationsProduct=Clone product variants diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 77ad53a3eff..2339a0c921f 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -146,6 +146,7 @@ RowMaterial=Matière première CloneProduct=Cloner produit/service ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service %s ? CloneContentProduct=Cloner les informations générales du produit/service +CloneCategoriesProduct=Cloner les catégories associées ClonePricesProduct=Cloner les prix CloneCompositionProduct=Cloner le produits packagés CloneCombinationsProduct=Cloner les variantes diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 18ea87cb03a..e433b9a6558 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -520,6 +520,19 @@ if (empty($reshook)) } } + if (GETPOST('clone_categories')) + { + $result = $object->clone_categories($originalId, $id); + + if ($result < 1) + { + $db->rollback(); + setEventMessage($langs->trans('ErrorProductClone'), null, 'errors'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); + exit; + } + } + // $object->clone_fournisseurs($originalId, $id); $db->commit(); @@ -1982,6 +1995,7 @@ $formquestionclone=array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), ); if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 51a5d7c72d0..3466625dfe5 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3611,6 +3611,32 @@ class Product extends CommonObject return 1; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * copy related categories to another product + * + * @param int $fromId Id produit source + * @param int $toId Id produit cible + * @return int < 0 si erreur, > 0 si ok + */ + function clone_categories($fromId, $toId) + { + $this->db->begin(); + + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'categorie_product (fk_categorie, fk_product)'; + $sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_product"; + $sql.= " WHERE fk_product = '".$fromId."'"; + + if (! $this->db->query($sql)) + { + $this->db->rollback(); + return -1; + } + + $this->db->commit(); + return 1; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre From 08d517c053ebb4f8bd87d6edd3301505ce745c17 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Mar 2019 10:35:27 +0100 Subject: [PATCH 005/622] custom content was deleted --- htdocs/custom/.gitignore | 4 ++++ htdocs/custom/README.md | 22 ++++++++++++++++++++++ htdocs/custom/index.html | 0 3 files changed, 26 insertions(+) create mode 100644 htdocs/custom/.gitignore create mode 100644 htdocs/custom/README.md create mode 100644 htdocs/custom/index.html diff --git a/htdocs/custom/.gitignore b/htdocs/custom/.gitignore new file mode 100644 index 00000000000..9420e8c61eb --- /dev/null +++ b/htdocs/custom/.gitignore @@ -0,0 +1,4 @@ +/* +!.gitignore +!README.md +!index.html diff --git a/htdocs/custom/README.md b/htdocs/custom/README.md new file mode 100644 index 00000000000..3a486e5a4a8 --- /dev/null +++ b/htdocs/custom/README.md @@ -0,0 +1,22 @@ +# DOLIBARR ERP & CRM custom directory for external modules. + +This directory is dedicated to store external modules. +To use it, just copy here the directory of the module into this directory. + +Note: On linux or MAC systems, it is better to unzip/store the external module directory into +a different place than this directory and just adding a symbolic link here to the htdocs directory +of the module. + +For example on Linux OS: Get the module from the command +mkdir ~/git; cd ~/git +git clone https://git.framasoft.org/p/newmodule/newmodule.git +Then create the symbolic link +ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule + +WARNING !!! +Check also that the /custom directory is active by adding into dolibarr conf/conf.php file the following +two lines, so dolibarr will also scan /custom directory to find external external modules: + +$dolibarr_main_url_root_alt='/custom'; +$dolibarr_main_document_root_alt='/path_to_dolibarr/htdocs/custom/'; + diff --git a/htdocs/custom/index.html b/htdocs/custom/index.html new file mode 100644 index 00000000000..e69de29bb2d From 7bc0260661a138193afa4a442a22dfdef51dc029 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 18 Mar 2019 14:15:55 +0100 Subject: [PATCH 006/622] begin factorization of categories cloning --- htdocs/langs/en_US/categories.lang | 1 + htdocs/langs/fr_FR/categories.lang | 1 + htdocs/product/card.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index eb34e302cad..dd446249ebe 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -88,3 +88,4 @@ AddProductServiceIntoCategory=Add the following product/service ShowCategory=Show tag/category ByDefaultInList=By default in list ChooseCategory=Choose category +CloneCategoriesProduct=Clone tags/categories linked diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index b65024a5217..9d58f0ff40d 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -88,3 +88,4 @@ AddProductServiceIntoCategory=Ajouter le produit/service suivant ShowCategory=Afficher tag/catégorie ByDefaultInList=Par défaut dans la liste ChooseCategory=Choisissez une catégorie +CloneCategories=Cloner les catégories associées diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e433b9a6558..9becc71bbb8 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1995,7 +1995,7 @@ $formquestionclone=array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), - array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategories"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), ); if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) From 61f9aac887f9755531884043abe5a11e091e51d3 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 18 Mar 2019 14:16:41 +0100 Subject: [PATCH 007/622] begin factorization of categories cloning --- htdocs/langs/en_US/products.lang | 1 - htdocs/langs/fr_FR/products.lang | 1 - 2 files changed, 2 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 9c96f12c589..401ccc5462e 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -147,7 +147,6 @@ RowMaterial=Raw Material CloneProduct=Clone product or service ConfirmCloneProduct=Are you sure you want to clone product or service %s? CloneContentProduct=Clone all main information of product/service -CloneCategoriesProduct=Clone tags/categories linked ClonePricesProduct=Clone prices CloneCompositionProduct=Clone virtual product/service CloneCombinationsProduct=Clone product variants diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 2339a0c921f..77ad53a3eff 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -146,7 +146,6 @@ RowMaterial=Matière première CloneProduct=Cloner produit/service ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service %s ? CloneContentProduct=Cloner les informations générales du produit/service -CloneCategoriesProduct=Cloner les catégories associées ClonePricesProduct=Cloner les prix CloneCompositionProduct=Cloner le produits packagés CloneCombinationsProduct=Cloner les variantes From f167ad910e280172e2384b771593f999424d02db Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Apr 2019 11:30:51 +0200 Subject: [PATCH 008/622] camelCase and generic cloneCategories function --- htdocs/core/class/commonobject.class.php | 31 ++++++++++++++++++++++++ htdocs/langs/en_US/products.lang | 1 + htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/card.php | 4 +-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e962e59264c..ccf255af4d7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7517,4 +7517,35 @@ abstract class CommonObject } } } + + /** + * copy related categories to another object + * + * @param int $fromId Id object source + * @param int $toId Id object cible + * @param string $type Type of category ('product', ...) + * @return int < 0 si erreur, > 0 si ok + */ + function cloneCategories($fromId, $toId, $type='') + { + $this->db->begin(); + + if (empty($type)) $type = $this->table_element; + + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $categorystatic = new Categorie($this->db); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type] . " (fk_categorie, fk_product)"; + $sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type]; + $sql.= " WHERE fk_product = '".$fromId."'"; + + if (! $this->db->query($sql)) + { + $this->db->rollback();die($sql); + return -1; + } + + $this->db->commit(); + return 1; + } } diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 401ccc5462e..62c22548f36 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -148,6 +148,7 @@ CloneProduct=Clone product or service ConfirmCloneProduct=Are you sure you want to clone product or service %s? CloneContentProduct=Clone all main information of product/service ClonePricesProduct=Clone prices +CloneCategoriesProduct=Clone tags/categories linked CloneCompositionProduct=Clone virtual product/service CloneCombinationsProduct=Clone product variants ProductIsUsed=This product is used diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 77ad53a3eff..be288c604af 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -147,6 +147,7 @@ CloneProduct=Cloner produit/service ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service %s ? CloneContentProduct=Cloner les informations générales du produit/service ClonePricesProduct=Cloner les prix +CloneCategoriesProduct=Cloner les catégories associées CloneCompositionProduct=Cloner le produits packagés CloneCombinationsProduct=Cloner les variantes ProductIsUsed=Ce produit est utilisé diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9becc71bbb8..5354fcde70f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -522,7 +522,7 @@ if (empty($reshook)) if (GETPOST('clone_categories')) { - $result = $object->clone_categories($originalId, $id); + $result = $object->cloneCategories($originalId, $id); if ($result < 1) { @@ -1995,7 +1995,7 @@ $formquestionclone=array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), - array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategories"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), ); if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) From d0fcece6130dcfb99504a5a824c8414879d23055 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Apr 2019 11:34:23 +0200 Subject: [PATCH 009/622] dont make generic translations --- htdocs/langs/en_US/categories.lang | 1 - htdocs/langs/fr_FR/categories.lang | 1 - 2 files changed, 2 deletions(-) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index dd446249ebe..eb34e302cad 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -88,4 +88,3 @@ AddProductServiceIntoCategory=Add the following product/service ShowCategory=Show tag/category ByDefaultInList=By default in list ChooseCategory=Choose category -CloneCategoriesProduct=Clone tags/categories linked diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index 9d58f0ff40d..b65024a5217 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -88,4 +88,3 @@ AddProductServiceIntoCategory=Ajouter le produit/service suivant ShowCategory=Afficher tag/catégorie ByDefaultInList=Par défaut dans la liste ChooseCategory=Choisissez une catégorie -CloneCategories=Cloner les catégories associées From 45b3a0588f6b02b6bffdfcc2cdc5856d243a3281 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Apr 2019 11:40:57 +0200 Subject: [PATCH 010/622] remove old dev --- htdocs/product/class/product.class.php | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3466625dfe5..0087be5eab5 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3612,31 +3612,6 @@ class Product extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * copy related categories to another product - * - * @param int $fromId Id produit source - * @param int $toId Id produit cible - * @return int < 0 si erreur, > 0 si ok - */ - function clone_categories($fromId, $toId) - { - $this->db->begin(); - - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'categorie_product (fk_categorie, fk_product)'; - $sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_product"; - $sql.= " WHERE fk_product = '".$fromId."'"; - - if (! $this->db->query($sql)) - { - $this->db->rollback(); - return -1; - } - - $this->db->commit(); - return 1; - } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre From 8e2ef8e56cf807e56e3ef949142dfd7c95e25af5 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Apr 2019 11:42:12 +0200 Subject: [PATCH 011/622] remove old dev --- htdocs/product/class/product.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0087be5eab5..51a5d7c72d0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3611,7 +3611,6 @@ class Product extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre From 7a651b50719a74bfcd795b8a59efc18933230f15 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 26 Apr 2019 13:53:22 +0200 Subject: [PATCH 012/622] New: Add ref_client field on template invoice --- .../facture/class/facture-rec.class.php | 6 ++++- htdocs/compta/facture/class/facture.class.php | 1 + htdocs/compta/facture/fiche-rec.php | 22 ++++++++++++++++--- .../install/mysql/migration/9.0.0-10.0.0.sql | 1 + .../install/mysql/tables/llx_facture_rec.sql | 1 + 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 89f324d2450..eba6fa42288 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -77,6 +77,7 @@ class FactureRec extends CommonInvoice public $total; public $db_table; public $propalid; + public $ref_client; public $date_last_gen; public $date_when; @@ -166,6 +167,7 @@ class FactureRec extends CommonInvoice $sql.= ", fk_account"; $sql.= ", fk_cond_reglement"; $sql.= ", fk_mode_reglement"; + $sql.= ", ref_client"; $sql.= ", usenewprice"; $sql.= ", frequency"; $sql.= ", unit_frequency"; @@ -194,6 +196,7 @@ class FactureRec extends CommonInvoice $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null"); $sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); $sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); + $sql.= ",'".$this->db->escape($this->ref_client)."'"; $sql.= ", ".$this->usenewprice; $sql.= ", ".$this->frequency; $sql.= ", '".$this->db->escape($this->unit_frequency)."'"; @@ -382,7 +385,7 @@ class FactureRec extends CommonInvoice $sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.modelpdf'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; - $sql.= ', f.fk_account'; + $sql.= ', f.fk_account, f.ref_client'; $sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; $sql.= ', f.generate_pdf'; $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; @@ -1127,6 +1130,7 @@ class FactureRec extends CommonInvoice $facture->brouillon = 1; $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; + $facture->ref_client = $facturerec->ref_client; $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c2dc89c903e..9e9005d471d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -358,6 +358,7 @@ class Facture extends CommonInvoice $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template $this->entity = $_facrec->entity; // Invoice created in same entity than template + $this->ref_client = $_facrec->ref_client; // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fa8af87ac29..25144edbcb3 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -174,6 +174,7 @@ if (empty($reshook)) if (! $error) { $object->titre = GETPOST('titre', 'alpha'); + $object->ref_client = GETPOST('ref_client', 'alpha'); $object->note_private = GETPOST('note_private', 'none'); $object->note_public = GETPOST('note_public', 'none'); $object->modelpdf = GETPOST('modelpdf', 'alpha'); @@ -274,7 +275,7 @@ if (empty($reshook)) { $object->setProject(GETPOST('projectid', 'int')); } - // Set bank account + // Set titre elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; @@ -286,6 +287,15 @@ if (empty($reshook)) } else dol_print_error($db, $object->error, $object->errors); } + elseif ($action == 'setref_client' && $user->rights->facture->creer) + { + $result=$object->setValueFrom('ref_client', GETPOST('ref_client', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); + if ($result > 0) + { + $object->ref_client = GETPOST('ref_client', 'alpha'); + } + else dol_print_error($db, $object->error, $object->errors); + } // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { @@ -997,6 +1007,11 @@ if ($action == 'create') print ''; print ''; + // Ref Client + print ''.$langs->trans("RefCustomer").''; + print ''; + print ''; + // Third party print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1, 'customer').''; print ''; @@ -1229,8 +1244,9 @@ else $morehtmlref.='
'; // Ref customer - //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); - //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); + $morehtmlref.='
'; // Thirdparty $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 9aa395c22d6..49a19de5316 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -297,3 +297,4 @@ ALTER TABLE llx_inventorydet DROP COLUMN pmp; ALTER TABLE llx_inventorydet DROP COLUMN pa; ALTER TABLE llx_inventorydet DROP COLUMN new_pmp; +ALTER TABLE llx_facture_rec ADD COLUMN ref_client varchar(255) after suspended; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index 1add07c6e8c..2c1c2514488 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -29,6 +29,7 @@ create table llx_facture_rec tms timestamp, -- date creation/modification suspended integer DEFAULT 0, -- 1=suspended + ref_client varchar(255), -- reference for customer amount double(24,8) DEFAULT 0 NOT NULL, remise real DEFAULT 0, From face07ece1577311119b2df0bf2243003a62f9ba Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 1 May 2019 15:15:20 +0200 Subject: [PATCH 013/622] new constant PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC --- htdocs/product/class/product.class.php | 87 +++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3796f5b022e..6afd42e3aae 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2410,6 +2410,28 @@ class Product extends CommonObject $this->stats_propale['nb']=$obj->nb; $this->stats_propale['rows']=$obj->nb_rows; $this->stats_propale['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in proposal by extension + if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + $TFather = $this->getFather(); + if (is_array($TFather) && !empty($TFather)) { + foreach($TFather as &$fatherData) { + $pFather = new Product($this->db); + $pFather->id = $fatherData['id']; + $qtyCoef = $fatherData['qty']; + + if ($fatherData['incdec']) { + $pFather->load_stats_propale($socid); + + $this->stats_propale['customers']+=$pFather->stats_propale['customers']; + $this->stats_propale['nb']+=$pFather->stats_propale['nb']; + $this->stats_propale['rows']+=$pFather->stats_propale['rows']; + $this->stats_propale['qty']+=$pFather->stats_propale['qty'] * $qtyCoef; + } + } + } + } + return 1; } else @@ -2512,7 +2534,7 @@ class Product extends CommonObject $this->stats_commande['qty']=$obj->qty?$obj->qty:0; // if it's a virtual product, maybe it is in order by extension - if (! empty($conf->global->ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC)) { + if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { foreach($TFather as &$fatherData) { @@ -2665,6 +2687,27 @@ class Product extends CommonObject $this->stats_expedition['nb']=$obj->nb; $this->stats_expedition['rows']=$obj->nb_rows; $this->stats_expedition['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in sending by extension + if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + $TFather = $this->getFather(); + if (is_array($TFather) && !empty($TFather)) { + foreach($TFather as &$fatherData) { + $pFather = new Product($this->db); + $pFather->id = $fatherData['id']; + $qtyCoef = $fatherData['qty']; + + if ($fatherData['incdec']) { + $pFather->load_stats_sending($socid, $filtrestatut, $forVirtualStock); + + $this->stats_expedition['customers']+=$pFather->stats_expedition['customers']; + $this->stats_expedition['nb']+=$pFather->stats_expedition['nb']; + $this->stats_expedition['rows']+=$pFather->stats_expedition['rows']; + $this->stats_expedition['qty']+=$pFather->stats_expedition['qty'] * $qtyCoef; + } + } + } + } return 1; } else @@ -2762,6 +2805,27 @@ class Product extends CommonObject $this->stats_contrat['nb']=$obj->nb; $this->stats_contrat['rows']=$obj->nb_rows; $this->stats_contrat['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in contract by extension + if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + $TFather = $this->getFather(); + if (is_array($TFather) && !empty($TFather)) { + foreach($TFather as &$fatherData) { + $pFather = new Product($this->db); + $pFather->id = $fatherData['id']; + $qtyCoef = $fatherData['qty']; + + if ($fatherData['incdec']) { + $pFather->load_stats_contrat($socid); + + $this->stats_contrat['customers']+=$pFather->stats_contrat['customers']; + $this->stats_contrat['nb']+=$pFather->stats_contrat['nb']; + $this->stats_contrat['rows']+=$pFather->stats_contrat['rows']; + $this->stats_contrat['qty']+=$pFather->stats_contrat['qty'] * $qtyCoef; + } + } + } + } return 1; } else @@ -2811,6 +2875,27 @@ class Product extends CommonObject $this->stats_facture['nb']=$obj->nb; $this->stats_facture['rows']=$obj->nb_rows; $this->stats_facture['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in invoice by extension + if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + $TFather = $this->getFather(); + if (is_array($TFather) && !empty($TFather)) { + foreach($TFather as &$fatherData) { + $pFather = new Product($this->db); + $pFather->id = $fatherData['id']; + $qtyCoef = $fatherData['qty']; + + if ($fatherData['incdec']) { + $pFather->load_stats_facture($socid); + + $this->stats_facture['customers']+=$pFather->stats_facture['customers']; + $this->stats_facture['nb']+=$pFather->stats_facture['nb']; + $this->stats_facture['rows']+=$pFather->stats_facture['rows']; + $this->stats_facture['qty']+=$pFather->stats_facture['qty'] * $qtyCoef; + } + } + } + } return 1; } else From be17e31be18e8bf2e126262f870b6b724b679a0b Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 2 May 2019 11:04:55 +0200 Subject: [PATCH 014/622] New: Add ref_client field on template invoice --- htdocs/compta/facture/fiche-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 25144edbcb3..fa71bdd7f2e 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1009,7 +1009,7 @@ if ($action == 'create') // Ref Client print ''.$langs->trans("RefCustomer").''; - print ''; + print ''; print ''; // Third party From aef850f6d3c5af5f6b98d5b6a882480eff045891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 19 May 2019 21:12:22 +0200 Subject: [PATCH 015/622] zapier for dolibarr --- dev/examples/zapier/.gitignore | 7 + dev/examples/zapier/.travis.yml | 7 + dev/examples/zapier/action.json | 56 ++ dev/examples/zapier/authentication.js | 76 ++ dev/examples/zapier/creates/thirdparty.js | 83 ++ dev/examples/zapier/index.js | 72 ++ dev/examples/zapier/package-lock.json | 405 +++++++++ dev/examples/zapier/package.json | 24 + dev/examples/zapier/resources/resources.js | 0 dev/examples/zapier/searches/thirdparty.js | 66 ++ dev/examples/zapier/test/index.js | 17 + dev/examples/zapier/triggers/action.js | 156 ++++ dev/examples/zapier/triggers/order.js | 148 ++++ dev/examples/zapier/triggers/thirdparty.js | 175 ++++ htdocs/core/modules/modZapier.class.php | 375 +++++++++ ...face_99_modZapier_ZapierTriggers.class.php | 567 +++++++++++++ htdocs/langs/en_US/zapier.lang | 53 ++ htdocs/langs/fr_FR/zapier.lang | 48 ++ htdocs/zapier/admin/about.php | 76 ++ htdocs/zapier/admin/setup.php | 124 +++ htdocs/zapier/class/api_zapier.class.php | 382 +++++++++ htdocs/zapier/class/hook.class.php | 773 ++++++++++++++++++ htdocs/zapier/hook_agenda.php | 261 ++++++ htdocs/zapier/hook_card.php | 471 +++++++++++ htdocs/zapier/hook_document.php | 166 ++++ htdocs/zapier/hook_list.php | 642 +++++++++++++++ htdocs/zapier/hook_note.php | 164 ++++ htdocs/zapier/img/object_hook.png | Bin 0 -> 360 bytes .../zapier/img/object_zapierfordolibarr.png | Bin 0 -> 360 bytes htdocs/zapier/img/zapier.png | Bin 0 -> 683 bytes htdocs/zapier/lib/zapier.lib.php | 58 ++ htdocs/zapier/lib/zapier_hook.lib.php | 83 ++ htdocs/zapier/sql/llx_zapier_hook.key.sql | 22 + htdocs/zapier/sql/llx_zapier_hook.sql | 29 + .../sql/llx_zapier_hook_extrafields.sql | 23 + htdocs/zapier/zapierindex.php | 238 ++++++ 36 files changed, 5847 insertions(+) create mode 100644 dev/examples/zapier/.gitignore create mode 100644 dev/examples/zapier/.travis.yml create mode 100644 dev/examples/zapier/action.json create mode 100644 dev/examples/zapier/authentication.js create mode 100644 dev/examples/zapier/creates/thirdparty.js create mode 100644 dev/examples/zapier/index.js create mode 100644 dev/examples/zapier/package-lock.json create mode 100644 dev/examples/zapier/package.json create mode 100644 dev/examples/zapier/resources/resources.js create mode 100644 dev/examples/zapier/searches/thirdparty.js create mode 100644 dev/examples/zapier/test/index.js create mode 100644 dev/examples/zapier/triggers/action.js create mode 100644 dev/examples/zapier/triggers/order.js create mode 100644 dev/examples/zapier/triggers/thirdparty.js create mode 100644 htdocs/core/modules/modZapier.class.php create mode 100644 htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php create mode 100644 htdocs/langs/en_US/zapier.lang create mode 100644 htdocs/langs/fr_FR/zapier.lang create mode 100644 htdocs/zapier/admin/about.php create mode 100644 htdocs/zapier/admin/setup.php create mode 100644 htdocs/zapier/class/api_zapier.class.php create mode 100644 htdocs/zapier/class/hook.class.php create mode 100644 htdocs/zapier/hook_agenda.php create mode 100644 htdocs/zapier/hook_card.php create mode 100644 htdocs/zapier/hook_document.php create mode 100644 htdocs/zapier/hook_list.php create mode 100644 htdocs/zapier/hook_note.php create mode 100644 htdocs/zapier/img/object_hook.png create mode 100644 htdocs/zapier/img/object_zapierfordolibarr.png create mode 100644 htdocs/zapier/img/zapier.png create mode 100644 htdocs/zapier/lib/zapier.lib.php create mode 100644 htdocs/zapier/lib/zapier_hook.lib.php create mode 100644 htdocs/zapier/sql/llx_zapier_hook.key.sql create mode 100644 htdocs/zapier/sql/llx_zapier_hook.sql create mode 100644 htdocs/zapier/sql/llx_zapier_hook_extrafields.sql create mode 100644 htdocs/zapier/zapierindex.php diff --git a/dev/examples/zapier/.gitignore b/dev/examples/zapier/.gitignore new file mode 100644 index 00000000000..d81e057e6d3 --- /dev/null +++ b/dev/examples/zapier/.gitignore @@ -0,0 +1,7 @@ +build +docs +node_modules +*.log +.environment +.env +.zapierapprc diff --git a/dev/examples/zapier/.travis.yml b/dev/examples/zapier/.travis.yml new file mode 100644 index 00000000000..5b8db5906a8 --- /dev/null +++ b/dev/examples/zapier/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - 8.10.0 +before_script: 'npm install -g zapier-platform-cli' +script: 'zapier test' +notifications: + email: false diff --git a/dev/examples/zapier/action.json b/dev/examples/zapier/action.json new file mode 100644 index 00000000000..e3aa4e69881 --- /dev/null +++ b/dev/examples/zapier/action.json @@ -0,0 +1,56 @@ +{ + "table_rowid": "id", + "id": 6764, + "ref": null, + "type_id": "5", + "type_code": "AC_RDV", + "type": null, + "type_color": null, + "code": null, + "label": "azerty", + "datec": null, + "datem": null, + "authorid": null, + "usermodid": null, + "datep": 1555365600, + "datef": 1555538399, + "durationp": 172799, + "fulldayevent": 1, + "punctual": 1, + "percentage": "-1", + "location": "", + "transparency": 1, + "priority": 0, + "userassigned": { + "1": { + "id": "1", + "transparency": 1 + } + }, + "userownerid": "1", + "userdoneid": null, + "usertodo": null, + "userdone": null, + "socid": null, + "contactid": null, + "elementtype": "", + "icalname": null, + "icalcolor": null, + "actions": [], + "email_msgid": null, + "email_from": null, + "email_sender": null, + "email_to": null, + "email_tocc": null, + "email_tobcc": null, + "email_subject": null, + "errors_to": null, + "import_key": null, + "linkedObjectsIds": null, + "fk_project": 0, + "modelpdf": null, + "note_public": null, + "note_private": null, + "note": "wxcvbn", + "duree": 0 +} \ No newline at end of file diff --git a/dev/examples/zapier/authentication.js b/dev/examples/zapier/authentication.js new file mode 100644 index 00000000000..8c373d0b78b --- /dev/null +++ b/dev/examples/zapier/authentication.js @@ -0,0 +1,76 @@ +const testAuth = (z , bundle) => { + const url = bundle.authData.url+'/api/index.php/login'; + // Normally you want to make a request to an endpoint that is either specifically designed to test auth, or one that + // every user will have access to, such as an account or profile endpoint like /me. + // In this example, we'll hit httpbin, which validates the Authorization Header against the arguments passed in the URL path + const promise = z.request({ + url: url, + }); + + // This method can return any truthy value to indicate the credentials are valid. + // Raise an error to show + return promise.then((response) => { + if (response.status === 401) { + throw new Error('The Session Key you supplied is invalid'); + } + return response; + }); +}; + +const getSessionKey = (z, bundle) => { + const url = bundle.authData.url + '/api/index.php/login'; + + const promise = z.request({ + method: 'POST', + url: url, + body: { + login: bundle.authData.login, + password: bundle.authData.password, + } + }); + + return promise.then((response) => { + if (response.status === 401) { + throw new Error('The login/password you supplied is invalid'); + } + const json = JSON.parse(response.content); + return { + sessionKey: json.success.token || 'secret' + }; + }); +}; + +module.exports = { + type: 'session', + // Define any auth fields your app requires here. The user will be prompted to enter this info when + // they connect their account. + fields: [ + { + key: 'url', + label: 'Url of service', + required: true, + type: 'string' + }, + { + key: 'login', + label: 'Login', + required: true, + type: 'string' + }, + { + key: 'password', + label: 'Password', + required: true, + type: 'password' + } + ], + // The test method allows Zapier to verify that the credentials a user provides are valid. We'll execute this + // method whenever a user connects their account for the first time. + test: testAuth, + // The method that will exchange the fields provided by the user for session credentials. + sessionConfig: { + perform: getSessionKey + }, + // assuming "login" is a key returned from the test + connectionLabel: '{{login}}' +}; diff --git a/dev/examples/zapier/creates/thirdparty.js b/dev/examples/zapier/creates/thirdparty.js new file mode 100644 index 00000000000..05928c3f15b --- /dev/null +++ b/dev/examples/zapier/creates/thirdparty.js @@ -0,0 +1,83 @@ +// create a particular thirdparty by name +const createThirdparty = async (z, bundle) => { + const apiurl = bundle.authData.url + '/api/index.php/thirdparties'; + + const response = await z.request({ + method: 'POST', + url: apiurl, + body: JSON.stringify({ + name: bundle.inputData.name, + name_alias: bundle.inputData.name_alias, + address: bundle.inputData.address, + zip: bundle.inputData.zip, + town: bundle.inputData.town, + email: bundle.inputData.email, + client: bundle.inputData.client, + fournisseur: bundle.inputData.fournisseur, + code_client: bundle.inputData.code_client, + code_fournisseur: bundle.inputData.code_fournisseur, + sens: 'fromzapier' + }) + }); + const result = z.JSON.parse(response.content); + // api returns an integer when ok, a json when ko + return result.response || {id: response}; +}; + +module.exports = { + key: 'thirdparty', + noun: 'Thirdparty', + + display: { + label: 'Create Thirdparty', + description: 'Creates a thirdparty.' + }, + + operation: { + inputFields: [ + {key: 'name', required: true}, + {key: 'name_alias', required: false}, + {key: 'address', required: false}, + {key: 'zip', required: false}, + {key: 'town', required: false}, + {key: 'email', required: false}, + {key: 'client', type: 'integer', required: false}, + {key: 'fournisseur', type: 'integer', required: false}, + {key: 'code_client', required: false}, + {key: 'code_fournisseur', required: false} + ], + perform: createThirdparty, + + sample: { + id: 1, + name: 'DUPOND', + name_alias: 'DUPOND Ltd', + address: 'Rue des Canaries', + zip: '34090', + town: 'MONTPELLIER', + phone: '0123456789', + fax: '2345678901', + email: 'robot@domain.com', + client: 1, + fournisseur: 0, + code_client: 'CU1903-1234', + code_fournisseur: 'SU1903-2345' + }, + + outputFields: [ + {key: 'id', label: 'ID'}, + {key: 'name', label: 'Name'}, + {key: 'name_alias', label: 'Name alias'}, + {key: 'address', label: 'Address'}, + {key: 'zip', label: 'Zip'}, + {key: 'town', label: 'Town'}, + {key: 'phone', label: 'Phone'}, + {key: 'fax', label: 'Fax'}, + {key: 'email', label: 'Email'}, + {key: 'client', label: 'Customer/Prospect 0/1/2/3'}, + {key: 'fournisseur', label: 'Supplier 0/1'}, + {key: 'code_client', label: 'Customer code'}, + {key: 'code_fournisseur', label: 'Supplier code'} + ] + } +}; \ No newline at end of file diff --git a/dev/examples/zapier/index.js b/dev/examples/zapier/index.js new file mode 100644 index 00000000000..cd62d6cd7ee --- /dev/null +++ b/dev/examples/zapier/index.js @@ -0,0 +1,72 @@ +const triggerThirdparty = require('./triggers/thirdparty'); +const triggerOrder = require('./triggers/order'); +const triggerAction = require('./triggers/action'); + +const searchThirdparty = require('./searches/thirdparty'); + +const createThirdparty = require('./creates/thirdparty'); + +const authentication = require('./authentication'); + +// To include the session key header on all outbound requests, simply define a function here. +// It runs runs before each request is sent out, allowing you to make tweaks to the request in a centralized spot +const includeSessionKeyHeader = (request, z, bundle) => { + if (bundle.authData.sessionKey) { + request.headers = request.headers || {}; + request.headers['DOLAPIKEY'] = bundle.authData.sessionKey; + } + return request; +}; + +// If we get a response and it is a 401, we can raise a special error telling Zapier to retry this after another exchange. +const sessionRefreshIf401 = (response, z, bundle) => { + if (bundle.authData.sessionKey) { + if (response.status === 401) { + throw new z.errors.RefreshAuthError('Session apikey needs refreshing.'); + } + } + return response; +}; + +// We can roll up all our behaviors in an App. +const App = { + // This is just shorthand to reference the installed dependencies you have. Zapier will + // need to know these before we can upload + version: require('./package.json').version, + platformVersion: require('zapier-platform-core').version, + + authentication: authentication, + + // beforeRequest & afterResponse are optional hooks into the provided HTTP client + beforeRequest: [ + includeSessionKeyHeader + ], + + afterResponse: [ + sessionRefreshIf401 + ], + + // If you want to define optional resources to simplify creation of triggers, searches, creates - do that here! + resources: { + }, + + // If you want your trigger to show up, you better include it here! + triggers: { + [triggerThirdparty.key]: triggerThirdparty, + [triggerOrder.key]: triggerOrder, + [triggerAction.key]: triggerAction + }, + + // If you want your searches to show up, you better include it here! + searches: { + [searchThirdparty.key]: searchThirdparty, + }, + + // If you want your creates to show up, you better include it here! + creates: { + [createThirdparty.key]: createThirdparty, + } +}; + +// Finally, export the app. +module.exports = App; diff --git a/dev/examples/zapier/package-lock.json b/dev/examples/zapier/package-lock.json new file mode 100644 index 00000000000..7483948d5b8 --- /dev/null +++ b/dev/examples/zapier/package-lock.json @@ -0,0 +1,405 @@ +{ + "name": "Dolibarr", + "version": "1.0.2", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "8.10.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.20.tgz", + "integrity": "sha512-M7x8+5D1k/CuA6jhiwuSCmE8sbUWJF0wYsjcig9WrXvwUI5ArEoUBdOXpV4JcEMrLp02/QbDjw+kI+vQeKyQgg==", + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bluebird": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", + "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "dotenv": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-5.0.1.tgz", + "integrity": "sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==" + }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "~0.4.13" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "json-tryparse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/json-tryparse/-/json-tryparse-1.0.5.tgz", + "integrity": "sha1-Khy6CLTjEjNo+p+2o01GQwBFeyc=" + }, + "jsonschema": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.1.1.tgz", + "integrity": "sha1-PO3o4+QR03eHLu+8n98mODy8Ptk=" + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "mime-db": { + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", + "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + }, + "mime-types": { + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", + "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "requires": { + "mime-db": "~1.38.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "node-fetch": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz", + "integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ==", + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "should": { + "version": "13.2.3", + "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", + "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", + "dev": true, + "requires": { + "should-equal": "^2.0.0", + "should-format": "^3.0.3", + "should-type": "^1.4.0", + "should-type-adaptors": "^1.0.1", + "should-util": "^1.0.0" + } + }, + "should-equal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", + "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", + "dev": true, + "requires": { + "should-type": "^1.4.0" + } + }, + "should-format": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", + "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-type-adaptors": "^1.0.1" + } + }, + "should-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", + "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", + "dev": true + }, + "should-type-adaptors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", + "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-util": "^1.0.0" + } + }, + "should-util": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", + "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", + "dev": true + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "zapier-platform-core": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/zapier-platform-core/-/zapier-platform-core-8.0.1.tgz", + "integrity": "sha512-vuAe7JkFQ88AeQ//NwwNEh8ZjiZr30GRWtwYo7Wo/nx1cqZwq+CRc9zJU2WRrhJfJOtOOTUF6w+pArBTtMOC5A==", + "requires": { + "@types/node": "8.10.20", + "bluebird": "3.5.0", + "content-disposition": "0.5.2", + "dotenv": "5.0.1", + "form-data": "2.3.2", + "lodash": "4.17.11", + "node-fetch": "1.7.1", + "oauth-sign": "0.9.0", + "semver": "5.6.0", + "zapier-platform-schema": "8.0.1" + } + }, + "zapier-platform-schema": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/zapier-platform-schema/-/zapier-platform-schema-8.0.1.tgz", + "integrity": "sha512-97KJ0xVLtpU4BiXVaMTPQpiA0T6CQIEzWfzAWwJAWbu5336+6DMFUzDWN4bANBeD3CIsRHHPcZkP8n/17U05ag==", + "requires": { + "jsonschema": "1.1.1", + "lodash": "4.17.10" + }, + "dependencies": { + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + } + } + } + } +} diff --git a/dev/examples/zapier/package.json b/dev/examples/zapier/package.json new file mode 100644 index 00000000000..30ea4939915 --- /dev/null +++ b/dev/examples/zapier/package.json @@ -0,0 +1,24 @@ +{ + "name": "Dolibarr", + "version": "1.0.2", + "description": "An app for connecting Dolibarr to the Zapier platform.", + "repository": "frederic34/ZapierForDolibarr", + "homepage": "https://netlogic-dev.fr/", + "author": "Frédéric France ", + "license": "BSD-3-Clause", + "main": "index.js", + "scripts": { + "test": "mocha --recursive" + }, + "engines": { + "node": "8.10.0", + "npm": ">=5.6.0" + }, + "dependencies": { + "zapier-platform-core": "8.0.1" + }, + "devDependencies": { + "mocha": "^5.2.0", + "should": "^13.2.0" + } +} diff --git a/dev/examples/zapier/resources/resources.js b/dev/examples/zapier/resources/resources.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dev/examples/zapier/searches/thirdparty.js b/dev/examples/zapier/searches/thirdparty.js new file mode 100644 index 00000000000..c71c2965789 --- /dev/null +++ b/dev/examples/zapier/searches/thirdparty.js @@ -0,0 +1,66 @@ +module.exports = { + key: 'thirdparty', + + // You'll want to provide some helpful display labels and descriptions + // for users. Zapier will put them into the UX. + noun: 'Thirdparty', + display: { + label: 'Find a Thirdparty', + description: 'Search for thirdparty.' + }, + + // `operation` is where we make the call to your API to do the search + operation: { + // This search only has one search field. Your searches might have just one, or many + // search fields. + inputFields: [ + { + key: 'name', + type: 'string', + label: 'Name', + helpText: 'Name to limit to the search to (i.e. The company or %company%).' + } + ], + + perform: (z, bundle) => { + const url = bundle.authData.url + '/api/index.php/thirdparties/'; + + // Put the search value in a query param. The details of how to build + // a search URL will depend on how your API works. + const options = { + params: { + sqlfilters: "t.nom like \'%"+bundle.inputData.name+"%\'" + } + }; + + return z.request(url, options).then(response => JSON.parse(response.content)); + }, + + // In cases where Zapier needs to show an example record to the user, but we are unable to get a live example + // from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of + // returned records, and have obviously dummy values that we can show to any user. + sample: { + id: 1, + createdAt: 1472069465, + name: 'DOE', + firstname: 'John', + authorId: 1, + directions: '1. Boil Noodles\n2.Serve with sauce', + style: 'italian' + }, + + // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom + // field definitions. The result will be used to augment the sample. + // outputFields: () => { return []; } + // Alternatively, a static field definition should be provided, to specify labels for the fields + outputFields: [ + {key: 'id', label: 'ID'}, + {key: 'createdAt', label: 'Created At'}, + {key: 'name', label: 'Name'}, + {key: 'firstname', label: 'Firstname'}, + {key: 'directions', label: 'Directions'}, + {key: 'authorId', label: 'Author ID'}, + {key: 'style', label: 'Style'} + ] + } +}; diff --git a/dev/examples/zapier/test/index.js b/dev/examples/zapier/test/index.js new file mode 100644 index 00000000000..220e48f540f --- /dev/null +++ b/dev/examples/zapier/test/index.js @@ -0,0 +1,17 @@ +require('should'); + +const zapier = require('zapier-platform-core'); + +// Use this to make test calls into your app: +const App = require('../index'); +const appTester = zapier.createAppTester(App); + +describe('My App', () => { + + it('should test something', (done) => { + const x = 1; + x.should.eql(1); + done(); + }); + +}); diff --git a/dev/examples/zapier/triggers/action.js b/dev/examples/zapier/triggers/action.js new file mode 100644 index 00000000000..d387d88ec1f --- /dev/null +++ b/dev/examples/zapier/triggers/action.js @@ -0,0 +1,156 @@ +const subscribeHook = (z, bundle) => { + // `z.console.log()` is similar to `console.log()`. + z.console.log('suscribing hook!'); + + // bundle.targetUrl has the Hook URL this app should call when an action is created. + const data = { + url: bundle.targetUrl, + event: bundle.event, + module: 'action', + action: bundle.inputData.action + }; + + const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: url, + method: 'POST', + body: JSON.stringify(data) + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const unsubscribeHook = (z, bundle) => { + // bundle.subscribeData contains the parsed response JSON from the subscribe + // request made initially. + z.console.log('unsuscribing hook!'); + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + method: 'DELETE', + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const getAction = (z, bundle) => { + // bundle.cleanedRequest will include the parsed JSON object (if it's not a + // test poll) and also a .querystring property with the URL's query string. + const action = { + id: bundle.cleanedRequest.id, + ref: bundle.cleanedRequest.ref, + ref_client: bundle.cleanedRequest.ref_client, + name: bundle.cleanedRequest.name, + firstname: bundle.cleanedRequest.firstname, + usertodo__name: bundle.cleanedRequest.usertodo__name, + location: bundle.cleanedRequest.location, + label: bundle.cleanedRequest.label, + authorId: bundle.cleanedRequest.authorId, + createdAt: bundle.cleanedRequest.createdAt, + module: bundle.cleanedRequest.module, + datep: bundle.cleanedRequest.datep, + datef: bundle.cleanedRequest.datef, + fulldayevent: bundle.cleanedRequest.fulldayevent, + transparency: bundle.cleanedRequest.transparency, + icalname: bundle.cleanedRequest.icalname, + icalcolor: bundle.cleanedRequest.icalcolor, + note: bundle.cleanedRequest.note, + note_public: bundle.cleanedRequest.note_public, + note_private: bundle.cleanedRequest.note_private, + action: bundle.cleanedRequest.action + }; + + return [action]; +}; + +const getFallbackRealAction = (z, bundle) => { + // For the test poll, you should get some real data, to aid the setup process. + const module = bundle.inputData.module; + const options = { + url: bundle.authData.url + '/api/index.php/agendaevents/0', + }; + + return z.request(options).then((response) => [JSON.parse(response.content)]); +}; + +// const getActionsChoices = (z, bundle) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const module = bundle.inputData.module; +// const options = { +// url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/actions', +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; + +// We recommend writing your actions separate like this and rolling them +// into the App definition at the end. +module.exports = { + key: 'action', + + // You'll want to provide some helpful display labels and descriptions + // for users. Zapier will put them into the UX. + noun: 'Action', + display: { + label: 'New Agenda', + description: 'Trigger when a new agenda with action is done in Dolibarr.' + }, + + // `operation` is where the business logic goes. + operation: { + + // `inputFields` can define the fields a user could provide, + // we'll pass them in as `bundle.inputData` later. + inputFields: [ + { + key: 'action', + type: 'string', + helpText: 'Which action of agenda this should trigger on.', + choices: { + create: "Create", + modify: "Modify", + delete: "Delete", + } + } + ], + + type: 'hook', + + performSubscribe: subscribeHook, + performUnsubscribe: unsubscribeHook, + + perform: getAction, + performList: getFallbackRealAction, + + // In cases where Zapier needs to show an example record to the user, but we are unable to get a live example + // from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of + // returned records, and have obviously dummy values that we can show to any user. + sample: { + id: 1, + createdAt: 1472069465, + name: 'Best Spagetti Ever', + authorId: 1, + action: 'create' + }, + + // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom + // field definitions. The result will be used to augment the sample. + // outputFields: () => { return []; } + // Alternatively, a static field definition should be provided, to specify labels for the fields + outputFields: [ + {key: 'id', label: 'ID'}, + {key: 'createdAt', label: 'Created At'}, + {key: 'name', label: 'Name'}, + {key: 'usertodo__name', label: 'UserToDo Name'}, + {key: 'authorId', label: 'Author ID'}, + {key: 'action', label: 'Action'} + ] + } +}; diff --git a/dev/examples/zapier/triggers/order.js b/dev/examples/zapier/triggers/order.js new file mode 100644 index 00000000000..6262d734edc --- /dev/null +++ b/dev/examples/zapier/triggers/order.js @@ -0,0 +1,148 @@ +const subscribeHook = (z, bundle) => { + // `z.console.log()` is similar to `console.log()`. + z.console.log('suscribing hook!'); + + // bundle.targetUrl has the Hook URL this app should call when an action is created. + const data = { + url: bundle.targetUrl, + event: bundle.event, + module: 'order', + action: bundle.inputData.action + }; + + const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: url, + method: 'POST', + body: JSON.stringify(data) + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const unsubscribeHook = (z, bundle) => { + // bundle.subscribeData contains the parsed response JSON from the subscribe + // request made initially. + z.console.log('unsuscribing hook!'); + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + method: 'DELETE', + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const getOrder = (z, bundle) => { + // bundle.cleanedRequest will include the parsed JSON object (if it's not a + // test poll) and also a .querystring property with the URL's query string. + const order = { + id: bundle.cleanedRequest.id, + ref: bundle.cleanedRequest.ref, + ref_client: bundle.cleanedRequest.ref_client, + name: bundle.cleanedRequest.name, + firstname: bundle.cleanedRequest.firstname, + directions: bundle.cleanedRequest.directions, + authorId: bundle.cleanedRequest.authorId, + createdAt: bundle.cleanedRequest.createdAt, + note_public: bundle.cleanedRequest.note_public, + note_private: bundle.cleanedRequest.note_private, + action: bundle.cleanedRequest.action + }; + + return [order]; +}; + +const getFallbackRealOrder = (z, bundle) => { + // For the test poll, you should get some real data, to aid the setup process. + const module = bundle.inputData.module; + const options = { + url: bundle.authData.url + '/api/index.php/orders/0', + }; + + return z.request(options).then((response) => [JSON.parse(response.content)]); +}; + +// const getActionsChoices = (z, bundle) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const module = bundle.inputData.module; +// const options = { +// url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/orders', +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; + +// We recommend writing your orders separate like this and rolling them +// into the App definition at the end. +module.exports = { + key: 'order', + + // You'll want to provide some helpful display labels and descriptions + // for users. Zapier will put them into the UX. + noun: 'Order', + display: { + label: 'New Order', + description: 'Trigger when a new order with action is done in Dolibarr.' + }, + + // `operation` is where the business logic goes. + operation: { + + // `inputFields` can define the fields a user could provide, + // we'll pass them in as `bundle.inputData` later. + inputFields: [ + { + key: 'action', + type: 'string', + helpText: 'Which action of order this should trigger on.', + choices: { + create: "Create", + modify: "Modify", + validate: "Validate", + } + } + ], + + type: 'hook', + + performSubscribe: subscribeHook, + performUnsubscribe: unsubscribeHook, + + perform: getOrder, + performList: getFallbackRealOrder, + + // In cases where Zapier needs to show an example record to the user, but we are unable to get a live example + // from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of + // returned records, and have obviously dummy values that we can show to any user. + sample: { + id: 1, + createdAt: 1472069465, + name: 'Best Spagetti Ever', + authorId: 1, + directions: '1. Boil Noodles\n2.Serve with sauce', + action: 'create' + }, + + // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom + // field definitions. The result will be used to augment the sample. + // outputFields: () => { return []; } + // Alternatively, a static field definition should be provided, to specify labels for the fields + outputFields: [ + {key: 'id', label: 'ID'}, + {key: 'createdAt', label: 'Created At'}, + {key: 'name', label: 'Name'}, + {key: 'directions', label: 'Directions'}, + {key: 'authorId', label: 'Author ID'}, + {key: 'module', label: 'Module'}, + {key: 'action', label: 'Action'} + ] + } +}; diff --git a/dev/examples/zapier/triggers/thirdparty.js b/dev/examples/zapier/triggers/thirdparty.js new file mode 100644 index 00000000000..4b13e23ff1c --- /dev/null +++ b/dev/examples/zapier/triggers/thirdparty.js @@ -0,0 +1,175 @@ +const subscribeHook = (z, bundle) => { + // `z.console.log()` is similar to `console.log()`. + z.console.log('suscribing hook!'); + + // bundle.targetUrl has the Hook URL this app should call when an action is created. + const data = { + url: bundle.targetUrl, + event: bundle.event, + module: 'company', + action: bundle.inputData.action + }; + + const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: url, + method: 'POST', + body: JSON.stringify(data) + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const unsubscribeHook = (z, bundle) => { + // bundle.subscribeData contains the parsed response JSON from the subscribe + // request made initially. + z.console.log('unsuscribing hook!'); + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + method: 'DELETE', + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const getThirdparty = (z, bundle) => { + // bundle.cleanedRequest will include the parsed JSON object (if it's not a + // test poll) and also a .querystring property with the URL's query string. + const thirdparty = { + id: bundle.cleanedRequest.id, + name: bundle.cleanedRequest.name, + name_alias: bundle.cleanedRequest.name_alias, + firstname: bundle.cleanedRequest.firstname, + address: bundle.cleanedRequest.address, + zip: bundle.cleanedRequest.zip, + town: bundle.cleanedRequest.town, + email: bundle.cleanedRequest.email, + client: bundle.cleanedRequest.client, + fournisseur: bundle.cleanedRequest.fournisseur, + code_client: bundle.cleanedRequest.code_client, + code_fournisseur: bundle.cleanedRequest.code_fournisseur, + authorId: bundle.cleanedRequest.authorId, + createdAt: bundle.cleanedRequest.createdAt, + action: bundle.cleanedRequest.action + }; + + return [thirdparty]; +}; + +const getFallbackRealThirdparty = (z, bundle) => { + // For the test poll, you should get some real data, to aid the setup process. + const module = bundle.inputData.module; + const options = { + url: bundle.authData.url + '/api/index.php/thirdparties/0', + }; + + return z.request(options).then((response) => [JSON.parse(response.content)]); +}; + +// const getModulesChoices = (z/*, bundle*/) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const options = { +// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; +// const getModulesChoices = () => { + +// return { +// orders: "Order", +// invoices: "Invoice", +// thirdparties: "Thirdparty", +// contacts: "Contacts" +// }; +// }; + +// const getActionsChoices = (z, bundle) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const module = bundle.inputData.module; +// const options = { +// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; + +// We recommend writing your triggers separate like this and rolling them +// into the App definition at the end. +module.exports = { + key: 'thirdparty', + + // You'll want to provide some helpful display labels and descriptions + // for users. Zapier will put them into the UX. + noun: 'Thirdparty', + display: { + label: 'New Thirdparty', + description: 'Trigger when a new thirdpaty action is done in Dolibarr.' + }, + + // `operation` is where the business logic goes. + operation: { + + // `inputFields` can define the fields a user could provide, + // we'll pass them in as `bundle.inputData` later. + inputFields: [ + { + key: 'action', + type: 'string', + helpText: 'Which action of thirdparty this should trigger on.', + choices: { + create: "Create", + modify: "Modify", + validate: "Validate", + } + } + ], + + type: 'hook', + + performSubscribe: subscribeHook, + performUnsubscribe: unsubscribeHook, + + perform: getThirdparty, + performList: getFallbackRealThirdparty, + + // In cases where Zapier needs to show an example record to the user, but we are unable to get a live example + // from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of + // returned records, and have obviously dummy values that we can show to any user. + sample: { + id: 1, + createdAt: 1472069465, + name: 'DOE', + name_alias: 'DOE Ltd', + firstname: 'John', + authorId: 1, + action: 'create' + }, + + // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom + // field definitions. The result will be used to augment the sample. + // outputFields: () => { return []; } + // Alternatively, a static field definition should be provided, to specify labels for the fields + outputFields: [ + {key: 'id', label: 'ID'}, + {key: 'createdAt', label: 'Created At'}, + {key: 'name', label: 'Name'}, + {key: 'name_alias', label: 'Name alias'}, + {key: 'firstname', label: 'Firstame'}, + {key: 'authorId', label: 'Author ID'}, + {key: 'action', label: 'Action'}, + {key: 'client', label: 'Customer/Prospect 0/1/2/3'}, + {key: 'fournisseur', label: 'Supplier 0/1'}, + {key: 'code_client', label: 'Customer code'}, + {key: 'code_fournisseur', label: 'Supplier code'} + ] + } +}; diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php new file mode 100644 index 00000000000..7f7ee47ba1e --- /dev/null +++ b/htdocs/core/modules/modZapier.class.php @@ -0,0 +1,375 @@ + + * Copyright (C) 2019 Frédéric France + * + * 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 . + */ +/** + * \defgroup zapier Module Zapier + * \brief Zapier module descriptor. + * + * \file htdocs/zapier/core/modules/modZapier.class.php + * \ingroup zapier + * \brief Description and activation file for module Zapier + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + +/** + * Description and activation class for module Zapier + */ +class modZapier extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs,$conf; + + $this->db = $db; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 792000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'zapier'; + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "interface"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = 100; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleZapierName' not found (Zapier is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleZapierDesc' not found (Zapier is name of module). + $this->description = "ZapierDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Zapier description (Long)"; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'development'; + //Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + // Key used in llx_const table to save module status enabled/disabled (where ZAPIERFORDOLIBARR is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'technic'; + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 1, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/zapier/css/zapier.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/zapier/js/zapier.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if feature of module are opened to external users + 'moduleforexternal' => 0, + ); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/zapier/temp","/zapier/subdir"); + $this->dirs = array("/zapier/temp"); + // Config pages. Put here list of php page, stored into zapier/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@zapier"); + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array(); + // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->requiredby = array(); + // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); + $this->langfiles = array("zapier@zapier"); + // Minimum version of PHP required by module + //$this->phpmin = array(5, 5); + // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(10, 0); + // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation = array(); + // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); + // $this->automatic_activation = array( + // 'FR'=>'ZapierWasAutomaticallyActivatedBecauseOfYourCountryChoice', + // ); + // If true, can't be disabled + // $this->always_enabled = true; + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array( + // 1 => array('ZAPIERFORDOLIBARR_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('ZAPIERFORDOLIBARR_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array( + // 1 => array('ZAPIERFORDOLIBARR_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ + if (! isset($conf->zapier) || ! isset($conf->zapier->enabled)) { + $conf->zapier=new stdClass(); + $conf->zapier->enabled=0; + } + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@zapier:$user->rights->zapier->read:/zapier/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@zapier:$user->rights->othermodule->read:/zapier/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + // Dictionaries + $this->dictionaries=array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'mylangfile@zapier', + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1","Table2","Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label","code,label","code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid","rowid","rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->zapier->enabled,$conf->zapier->enabled,$conf->zapier->enabled) + ); + */ + // Boxes/Widgets + // Add here list of php file(s) stored in zapier/core/boxes that contains class to show a widget. + $this->boxes = array( + // 0 => array( + // 'file' => 'zapierwidget1.php@zapier', + // 'note' => 'Widget provided by Zapier', + // 'enabledbydefaulton' => 'Home', + // ), + //1=>array('file'=>'zapierwidget2.php@zapier','note'=>'Widget provided by Zapier'), + //2=>array('file'=>'zapierwidget3.php@zapier','note'=>'Widget provided by Zapier') + ); + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/zapier/class/myobject.class.php', + // 'objectname' => 'MyObject', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->zapier->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->zapier->enabled', 'priority'=>50) + // ); + // Permissions + // Permission array used by this module + $this->rights = array(); + + $r=0; + // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r; + // Permission label + $this->rights[$r][1] = 'Read myobject of Zapier'; + // Permission by default for new user (0/1) + $this->rights[$r][3] = 1; + // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) + $this->rights[$r][4] = 'read'; + // In php code, permission will be checked by test if ($user->rights->zapier->level1->level2) + $this->rights[$r][5] = ''; + $r++; + $this->rights[$r][0] = $this->numero + $r; + $this->rights[$r][1] = 'Create/Update myobject of Zapier'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'write'; + $this->rights[$r][5] = ''; + $r++; + $this->rights[$r][0] = $this->numero + $r; + $this->rights[$r][1] = 'Delete myobject of Zapier'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'delete'; + $this->rights[$r][5] = ''; + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + // $this->menu[$r++]=array( + // 'fk_menu' => '', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + // 'type' => 'top', // This is a Top menu entry + // 'titre' => 'Zapier', + // 'mainmenu' => 'zapier', + // 'leftmenu' => '', + // 'url' => '/zapier/zapierindex.php', + // 'langs' => 'zapier@zapier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position' => 1000+$r, + // 'enabled' => '$conf->zapier->enabled', // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. + // 'perms' => '1', // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules + // 'target' => '', + // 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both + // ); + + /* + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=zapier', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List MyObject', + 'mainmenu'=>'zapier', + 'leftmenu'=>'zapier_myobject_list', + 'url'=>'/zapier/myobject_list.php', + 'langs'=>'zapier@zapier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->zapier->enabled', // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=zapier,fk_leftmenu=zapier', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New MyObject', + 'mainmenu'=>'zapier', + 'leftmenu'=>'zapier_myobject_new', + 'url'=>'/zapier/myobject_page.php?action=create', + 'langs'=>'zapier@zapier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->zapier->enabled', // Define condition to show or hide menu entry. Use '$conf->zapier->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->zapier->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + */ + // Exports + $r=1; + /* EXPORT */ + /* + $langs->load("zapier@zapier"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='myobject@zapier'; + $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; + $r++; */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result = $this->_load_tables('/zapier/sql/'); + if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') + + // Create extrafields + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'zapier@zapier', '$conf->zapier->enabled'); + $sql = array(); + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php new file mode 100644 index 00000000000..ae08b55d651 --- /dev/null +++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php @@ -0,0 +1,567 @@ + + * + * 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 core/triggers/interface_99_modZapier_ZapierTriggers.class.php + * \ingroup zapier + * \brief Example trigger. + * + * + * \remarks You can create other triggers by copying this one. + * - File name should be either: + * - interface_99_modZapier_MyTrigger.class.php + * - interface_99_all_MyTrigger.class.php + * - The file must stay in core/triggers + * - The class name must be InterfaceMytrigger + * - The constructor method must be named InterfaceMytrigger + * - The name property name must be MyTrigger + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggers for Zapier module + */ +class InterfaceZapierTriggers extends DolibarrTriggers +{ + /** + * @var DoliDB Database handler + */ + protected $db; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "demo"; + $this->description = "Zapier triggers."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + $this->picto = 'zapier@zapier'; + } + + /** + * Trigger name + * + * @return string Name of trigger file + */ + public function getName() + { + return $this->name; + } + + /** + * Trigger description + * + * @return string Description of trigger file + */ + public function getDesc() + { + return $this->description; + } + + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file + * is inside directory core/triggers + * + * @param string $action Event action code + * @param CommonObject $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + global $db; + if (empty($conf->zapier->enabled)) { + // Module not active, we do nothing + return 0; + } + $logtriggeraction = false; + if ($action!='') { + $actions = explode('_', $action); + $sql = 'SELECT rowid, url FROM '.MAIN_DB_PREFIX.'zapier_hook WHERE'; + $sql .= ' module="'.$db->escape(strtolower($actions[0])).'" AND action="'.$db->escape(strtolower($actions[1])).'"'; + //setEventMessages($sql, null); + } + + switch ($action) { + + // Users + //case 'USER_CREATE': + //case 'USER_MODIFY': + //case 'USER_NEW_PASSWORD': + //case 'USER_ENABLEDISABLE': + //case 'USER_DELETE': + //case 'USER_SETINGROUP': + //case 'USER_REMOVEFROMGROUP': + + case 'USER_LOGIN': + //$logtriggeraction = true; + break; + case 'USER_LOGIN_FAILED': + //$logtriggeraction = true; + break; + case 'USER_LOGOUT': + //$logtriggeraction = true; + break; + // Warning: To increase performances, this action is triggered only if constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. + //case 'USER_UPDATE_SESSION': + + case 'DOSSIERISOLATION_CREATE': + //$logtriggeraction = true; + break; + case 'DOSSIERISOLATION_MODIFY': + //$logtriggeraction = true; + break; + case 'DOSSIERISOLATION_DELETE': + //$logtriggeraction = true; + break; + + // Actions + case 'ACTION_MODIFY': + //$logtriggeraction = true; + break; + case 'ACTION_CREATE': + $resql = $db->query($sql); + // TODO voir comment regrouper les webhooks en un post + while ($resql && $obj = $db->fetch_array($resql)) { + $cleaned = cleanObjectDatas(dol_clone($object)); + $cleaned = cleanAgendaEventsDatas($cleaned); + $json = json_encode($cleaned); + // call the zapierPostWebhook() function + zapierPostWebhook($obj['url'], $json); + //setEventMessages($obj['url'], null); + } + $logtriggeraction = true; + break; + case 'ACTION_DELETE': + //$logtriggeraction = true; + break; + + // Groups + //case 'GROUP_CREATE': + //case 'GROUP_MODIFY': + //case 'GROUP_DELETE': + + // Companies + case 'COMPANY_CREATE': + $resql = $db->query($sql); + while ($resql && $obj = $db->fetch_array($resql)) { + $cleaned = cleanObjectDatas(dol_clone($object)); + $json = json_encode($cleaned); + // call the zapierPostWebhook() function + zapierPostWebhook($obj['url'], $json); + } + $logtriggeraction = true; + break; + case 'COMPANY_MODIFY': + $resql = $db->query($sql); + while ($resql && $obj = $db->fetch_array($resql)) { + $cleaned = cleanObjectDatas(dol_clone($object)); + $json = json_encode($cleaned); + // call the zapierPostWebhook() function + zapierPostWebhook($obj['url'], $json); + } + $logtriggeraction = true; + break; + case 'COMPANY_DELETE': + //$logtriggeraction = true; + break; + + // Contacts + case 'CONTACT_CREATE': + case 'CONTACT_MODIFY': + case 'CONTACT_DELETE': + case 'CONTACT_ENABLEDISABLE': + + // Products + case 'PRODUCT_CREATE': + case 'PRODUCT_MODIFY': + case 'PRODUCT_DELETE': + case 'PRODUCT_PRICE_MODIFY': + case 'PRODUCT_SET_MULTILANGS': + case 'PRODUCT_DEL_MULTILANGS': + + //Stock mouvement + case 'STOCK_MOVEMENT': + + //MYECMDIR + case 'MYECMDIR_DELETE': + case 'MYECMDIR_CREATE': + case 'MYECMDIR_MODIFY': + + // Customer orders + case 'ORDER_CREATE': + $resql = $db->query($sql); + while ($resql && $obj = $db->fetch_array($resql)) { + $cleaned = cleanObjectDatas(dol_clone($object)); + $json = json_encode($cleaned); + // call the zapierPostWebhook() function + zapierPostWebhook($obj['url'], $json); + } + $logtriggeraction = true; + break; + case 'ORDER_CLONE': + break; + case 'ORDER_VALIDATE': + break; + case 'ORDER_DELETE': + case 'ORDER_CANCEL': + case 'ORDER_SENTBYMAIL': + case 'ORDER_CLASSIFY_BILLED': + case 'ORDER_SETDRAFT': + case 'LINEORDER_INSERT': + case 'LINEORDER_UPDATE': + case 'LINEORDER_DELETE': + + // Supplier orders + case 'ORDER_SUPPLIER_CREATE': + case 'ORDER_SUPPLIER_CLONE': + case 'ORDER_SUPPLIER_VALIDATE': + case 'ORDER_SUPPLIER_DELETE': + case 'ORDER_SUPPLIER_APPROVE': + case 'ORDER_SUPPLIER_REFUSE': + case 'ORDER_SUPPLIER_CANCEL': + case 'ORDER_SUPPLIER_SENTBYMAIL': + case 'ORDER_SUPPLIER_DISPATCH': + case 'LINEORDER_SUPPLIER_DISPATCH': + case 'LINEORDER_SUPPLIER_CREATE': + case 'LINEORDER_SUPPLIER_UPDATE': + + // Proposals + case 'PROPAL_CREATE': + case 'PROPAL_CLONE': + case 'PROPAL_MODIFY': + case 'PROPAL_VALIDATE': + case 'PROPAL_SENTBYMAIL': + case 'PROPAL_CLOSE_SIGNED': + //$logtriggeraction = true; + break; + case 'PROPAL_CLOSE_REFUSED': + //$logtriggeraction = true; + break; + case 'PROPAL_DELETE': + //$logtriggeraction = true; + break; + case 'LINEPROPAL_INSERT': + case 'LINEPROPAL_UPDATE': + case 'LINEPROPAL_DELETE': + + // SupplierProposal + case 'SUPPLIER_PROPOSAL_CREATE': + case 'SUPPLIER_PROPOSAL_CLONE': + case 'SUPPLIER_PROPOSAL_MODIFY': + case 'SUPPLIER_PROPOSAL_VALIDATE': + case 'SUPPLIER_PROPOSAL_SENTBYMAIL': + case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED': + case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED': + case 'SUPPLIER_PROPOSAL_DELETE': + case 'LINESUPPLIER_PROPOSAL_INSERT': + case 'LINESUPPLIER_PROPOSAL_UPDATE': + case 'LINESUPPLIER_PROPOSAL_DELETE': + + // Contracts + case 'CONTRACT_CREATE': + case 'CONTRACT_ACTIVATE': + case 'CONTRACT_CANCEL': + case 'CONTRACT_CLOSE': + case 'CONTRACT_DELETE': + case 'LINECONTRACT_INSERT': + case 'LINECONTRACT_UPDATE': + case 'LINECONTRACT_DELETE': + + // Bills + case 'BILL_CREATE': + //$logtriggeraction = true; + break; + case 'BILL_CLONE': + case 'BILL_MODIFY': + case 'BILL_VALIDATE': + case 'BILL_UNVALIDATE': + //$logtriggeraction = true; + break; + case 'BILL_SENTBYMAIL': + //$logtriggeraction = true; + break; + case 'BILL_CANCEL': + //$logtriggeraction = true; + break; + case 'BILL_DELETE': + //$logtriggeraction = true; + break; + case 'BILL_PAYED': + case 'LINEBILL_INSERT': + case 'LINEBILL_UPDATE': + case 'LINEBILL_DELETE': + + //Supplier Bill + case 'BILL_SUPPLIER_CREATE': + case 'BILL_SUPPLIER_UPDATE': + case 'BILL_SUPPLIER_DELETE': + case 'BILL_SUPPLIER_PAYED': + case 'BILL_SUPPLIER_UNPAYED': + case 'BILL_SUPPLIER_VALIDATE': + case 'BILL_SUPPLIER_UNVALIDATE': + case 'LINEBILL_SUPPLIER_CREATE': + case 'LINEBILL_SUPPLIER_UPDATE': + case 'LINEBILL_SUPPLIER_DELETE': + + // Payments + case 'PAYMENT_CUSTOMER_CREATE': + case 'PAYMENT_SUPPLIER_CREATE': + case 'PAYMENT_ADD_TO_BANK': + case 'PAYMENT_DELETE': + + // Online + case 'PAYMENT_PAYBOX_OK': + case 'PAYMENT_PAYPAL_OK': + case 'PAYMENT_STRIPE_OK': + + // Donation + case 'DON_CREATE': + case 'DON_UPDATE': + case 'DON_DELETE': + + // Interventions + case 'FICHINTER_CREATE': + case 'FICHINTER_MODIFY': + case 'FICHINTER_VALIDATE': + case 'FICHINTER_DELETE': + case 'LINEFICHINTER_CREATE': + case 'LINEFICHINTER_UPDATE': + case 'LINEFICHINTER_DELETE': + + // Members + case 'MEMBER_CREATE': + case 'MEMBER_VALIDATE': + case 'MEMBER_SUBSCRIPTION': + case 'MEMBER_MODIFY': + case 'MEMBER_NEW_PASSWORD': + case 'MEMBER_RESILIATE': + case 'MEMBER_DELETE': + + // Categories + case 'CATEGORY_CREATE': + case 'CATEGORY_MODIFY': + case 'CATEGORY_DELETE': + case 'CATEGORY_SET_MULTILANGS': + + // Projects + case 'PROJECT_CREATE': + case 'PROJECT_MODIFY': + case 'PROJECT_DELETE': + + // Project tasks + case 'TASK_CREATE': + case 'TASK_MODIFY': + case 'TASK_DELETE': + + // Task time spent + case 'TASK_TIMESPENT_CREATE': + case 'TASK_TIMESPENT_MODIFY': + case 'TASK_TIMESPENT_DELETE': + + // Shipping + case 'SHIPPING_CREATE': + case 'SHIPPING_MODIFY': + case 'SHIPPING_VALIDATE': + case 'SHIPPING_SENTBYMAIL': + case 'SHIPPING_BILLED': + case 'SHIPPING_CLOSED': + case 'SHIPPING_REOPEN': + //$logtriggeraction = true; + break; + case 'SHIPPING_DELETE': + //$logtriggeraction = true; + break; + } + if ($logtriggeraction) { + dol_syslog("Trigger '" . $this->name . "' for action '.$action.' launched by " . __FILE__ . " id=" . $object->id); + } + return 0; + } +} +/** + * Post webhook in zapier with object data + * + * @param string $url url provided by zapier + * @param string $json data to send + * @return void + */ +function zapierPostWebhook($url, $json) +{ + $headers = array('Accept: application/json', 'Content-Type: application/json'); + // TODO supprimer le webhook en cas de mauvaise réponse + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $json); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $output = curl_exec($ch); + curl_close($ch); +} + +/** + * Clean sensible object datas + * + * @param object $toclean Object to clean + * @return array Array of cleaned object properties + */ +function cleanObjectDatas($toclean) +{ + // Remove $db object property for object + unset($toclean->db); + + // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses + unset($toclean->linkedObjects); + + unset($toclean->lines); // should be ->lines + + unset($toclean->fields); + + unset($toclean->oldline); + + unset($toclean->error); + unset($toclean->errors); + + unset($toclean->ref_previous); + unset($toclean->ref_next); + unset($toclean->ref_int); + + unset($toclean->projet); // Should be fk_project + unset($toclean->project); // Should be fk_project + unset($toclean->author); // Should be fk_user_author + unset($toclean->timespent_old_duration); + unset($toclean->timespent_id); + unset($toclean->timespent_duration); + unset($toclean->timespent_date); + unset($toclean->timespent_datehour); + unset($toclean->timespent_withhour); + unset($toclean->timespent_fk_user); + unset($toclean->timespent_note); + + unset($toclean->statuts); + unset($toclean->statuts_short); + unset($toclean->statuts_logo); + unset($toclean->statuts_long); + + unset($toclean->element); + unset($toclean->fk_element); + unset($toclean->table_element); + unset($toclean->table_element_line); + unset($toclean->picto); + + unset($toclean->skip_update_total); + unset($toclean->context); + + // Remove the $oldcopy property because it is not supported by the JSON + // encoder. The following error is generated when trying to serialize + // it: "Error encoding/decoding JSON: Type is not supported" + // Note: Event if this property was correctly handled by the JSON + // encoder, it should be ignored because keeping it would let the API + // have a very strange behavior: calling PUT and then GET on the same + // resource would give different results: + // PUT /objects/{id} -> returns object with oldcopy = previous version of the object + // GET /objects/{id} -> returns object with oldcopy empty + unset($toclean->oldcopy); + + // If object has lines, remove $db property + if (isset($toclean->lines) && count($toclean->lines) > 0) { + $nboflines = count($toclean->lines); + for ($i=0; $i < $nboflines; $i++) { + $this->cleanObjectDatas($toclean->lines[$i]); + } + } + + // If object has linked objects, remove $db property + /* + if(isset($toclean->linkedObjects) && count($toclean->linkedObjects) > 0) { + foreach($toclean->linkedObjects as $type_object => $linked_object) { + foreach($linked_object as $toclean2clean) { + $this->cleanObjectDatas($toclean2clean); + } + } + }*/ + + return $toclean; +} + +/** + * Clean sensible object datas + * + * @param object $toclean Object to clean + * @return array Array of cleaned object properties + */ +function cleanAgendaEventsDatas($toclean) +{ + unset($toclean->usermod); + unset($toclean->libelle); + //unset($toclean->array_options); + unset($toclean->context); + unset($toclean->canvas); + unset($toclean->contact); + unset($toclean->contact_id); + unset($toclean->thirdparty); + unset($toclean->user); + unset($toclean->origin); + unset($toclean->origin_id); + unset($toclean->ref_ext); + unset($toclean->statut); + unset($toclean->country); + unset($toclean->country_id); + unset($toclean->country_code); + unset($toclean->barcode_type); + unset($toclean->barcode_type_code); + unset($toclean->barcode_type_label); + unset($toclean->barcode_type_coder); + unset($toclean->mode_reglement_id); + unset($toclean->cond_reglement_id); + unset($toclean->cond_reglement); + unset($toclean->fk_delivery_address); + unset($toclean->shipping_method_id); + unset($toclean->fk_account); + unset($toclean->total_ht); + unset($toclean->total_tva); + unset($toclean->total_localtax1); + unset($toclean->total_localtax2); + unset($toclean->total_ttc); + unset($toclean->fk_incoterms); + unset($toclean->libelle_incoterms); + unset($toclean->location_incoterms); + unset($toclean->name); + unset($toclean->lastname); + unset($toclean->firstname); + unset($toclean->civility_id); + unset($toclean->contact); + unset($toclean->societe); + + return $toclean; +} diff --git a/htdocs/langs/en_US/zapier.lang b/htdocs/langs/en_US/zapier.lang new file mode 100644 index 00000000000..2699f54b721 --- /dev/null +++ b/htdocs/langs/en_US/zapier.lang @@ -0,0 +1,53 @@ +# Copyright (C) 2019 Frédéric FRANCE +# +# 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 . + +# +# Generic +# + +# Module label 'ModuleZapierForDolibarrName' +ModuleZapierForDolibarrName = ZapierForDolibarr +# Module description 'ModuleZapierForDolibarrDesc' +ModuleZapierForDolibarrDesc = ZapierForDolibarr description + +# +# Admin page +# +ZapierForDolibarrSetup = ZapierForDolibarr setup +Settings = Settings +ZapierForDolibarrSetupPage = ZapierForDolibarr setup page +ZAPIERFORDOLIBARR_MYPARAM1 = My param 1 +ZAPIERFORDOLIBARR_MYPARAM1Tooltip = My param 1 tooltip +ZAPIERFORDOLIBARR_MYPARAM2=My param 2 +ZAPIERFORDOLIBARR_MYPARAM2Tooltip=My param 2 tooltip + + +# +# About page +# +About = About +ZapierForDolibarrAbout = About ZapierForDolibarr +ZapierForDolibarrAboutPage = ZapierForDolibarr about page + +# +# Sample page +# +MyPageName = My page name + +# +# Sample widget +# +MyWidget = My widget +MyWidgetDescription = My widget description diff --git a/htdocs/langs/fr_FR/zapier.lang b/htdocs/langs/fr_FR/zapier.lang new file mode 100644 index 00000000000..78103a55bae --- /dev/null +++ b/htdocs/langs/fr_FR/zapier.lang @@ -0,0 +1,48 @@ +# Copyright (C) 2019 Frédéric FRANCE +# +# 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 . + +# +# Générique +# + +# Module label 'ModuleZapierForDolibarrName' +ModuleZapierForDolibarrName = ZapierForDolibarr +# Module description 'ModuleZapierForDolibarrDesc' +ModuleZapierForDolibarrDesc = Description de ZapierForDolibarr + +# +# Page d'administration +# +ZapierForDolibarrSetup = Configuration du module ZapierForDolibarr +Settings = Réglages +ZapierForDolibarrSetupPage = Page de configuration du module ZapierForDolibarr + +# +# Page À propos +# +About = À propos +ZapierForDolibarrAbout = À propos de ZapierForDolibarr +ZapierForDolibarrAboutPage = Page à propos de ZapierForDolibarr + +# +# Page d'exemple +# +MyPageName = Nom de ma page + +# +# Box d'exemple +# +MyWidget = Mon widget +MyWidgetDescription = Description de mon widget diff --git a/htdocs/zapier/admin/about.php b/htdocs/zapier/admin/about.php new file mode 100644 index 00000000000..d875928ae8f --- /dev/null +++ b/htdocs/zapier/admin/about.php @@ -0,0 +1,76 @@ + + * Copyright (C) 2019 Frédéric FRANCE + * + * 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 zapier/admin/about.php + * \ingroup zapier + * \brief About page of module Zapier. + */ + +// Load Dolibarr environment +require '../../main.inc.php'; + +// Libraries +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once '../lib/zapier.lib.php'; + +// Translations +$langs->loadLangs(array("errors","admin","zapier@zapier")); + +// Access control +if (! $user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + + +/* + * Actions + */ + +// None + + +/* + * View + */ + +$form = new Form($db); + +$page_name = "ZapierAbout"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier@zapier'); + +// Configuration header +$head = zapierAdminPrepareHead(); +dol_fiche_head($head, 'about', '', 0, 'zapier@zapier'); + +dol_include_once('/zapier/core/modules/modZapier.class.php'); +$tmpmodule = new modZapier($db); +print $tmpmodule->getDescLong(); + +// Page end +dol_fiche_end(); +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/admin/setup.php b/htdocs/zapier/admin/setup.php new file mode 100644 index 00000000000..b8b203b8ab1 --- /dev/null +++ b/htdocs/zapier/admin/setup.php @@ -0,0 +1,124 @@ + + * Copyright (C) 2019 Frédéric FRANCE + * + * 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 zapier/admin/setup.php + * \ingroup zapier + * \brief Zapier setup page. + */ + +// Load Dolibarr environment +require '../../main.inc.php'; + +// Libraries +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once '../lib/zapier.lib.php'; + +// Translations +$langs->loadLangs(array("admin", "zapier@zapier")); + +// Access control +if (! $user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +$arrayofparameters=array( + 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), + 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +); + + +/* + * Actions + */ +if ((float) DOL_VERSION >= 6) { + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; +} + + +/* + * View + */ + +$page_name = "ZapierSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier@zapier'); + +// Configuration header +$head = zapierAdminPrepareHead(); +dol_fiche_head($head, 'settings', '', -1, "zapier@zapier"); + +// Setup page goes here +echo $langs->trans("ZapierSetupPage").'

'; + + +if ($action == 'edit') { + print '
'; + print ''; + print ''; + + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) { + print ''; + } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + print '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + print '
'; +} else { + if (! empty($arrayofparameters)) { + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) { + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + print '' . $conf->global->$key . '
'; + + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; + } else + { + print '
'.$langs->trans("NothingToSetup"); + } +} + + +// Page end +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php new file mode 100644 index 00000000000..239ee5227d6 --- /dev/null +++ b/htdocs/zapier/class/api_zapier.class.php @@ -0,0 +1,382 @@ + + * Copyright (C) 2019 Frédéric France + * + * 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 . + */ + +use Luracast\Restler\RestException; + +dol_include_once('/zapier/class/hook.class.php'); + + + +/** + * \file htdocs/modulebuilder/template/class/api_zapier.class.php + * \ingroup zapier + * \brief File for API management of hook. + */ + +/** + * API class for zapier hook + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class ZapierApi extends DolibarrApi +{ + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'url', + ); + + + /** + * @var Hook $hook {@type Hook} + */ + public $hook; + + /** + * Constructor + * + * @url GET / + * + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->hook = new Hook($this->db); + } + + /** + * Get properties of a hook object + * + * Return an array with hook informations + * + * @param int $id ID of hook + * @return array|mixed data without useless information + * + * @url GET /hooks/{id} + * @throws RestException + */ + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } + + $result = $this->hook->fetch($id); + if (! $result ) { + throw new RestException(404, 'Hook not found'); + } + + if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->hook); + } + + + /** + * Get list of possibles choices for module + * + * Return an array with hook informations + * @param integer $id ID + * + * @return array|mixed data + * + * @url GET /getmoduleschoices/ + * @throws RestException + */ + public function getModulesChoices($id) + { + if(! DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } + $arraychoices = array( + 'invoices' => 'Invoices', + 'orders' => 'Orders', + 'thirdparties' => 'Thirparties', + 'contacts' => 'Contacts', + ); + // $result = $this->hook->fetch($id); + // if (! $result ) { + // throw new RestException(404, 'Hook not found'); + // } + + // if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + // throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + // } + + return $arraychoices; + } + + + /** + * List hooks + * + * Get a list of hooks + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /hooks/ + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + + // Set to 1 if there is a field socid in table of object + $restrictonsocid = 0; + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } + + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= ", sc.fk_soc, sc.fk_user"; + } + $sql.= " FROM ".MAIN_DB_PREFIX."hook_mytable as t"; + + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql.= " WHERE 1 = 1"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + $tmpobject = new Hook($db); + if ($tmpobject->ismultientitymanaged) { + $sql.= ' AND t.entity IN ('.getEntity('hook').')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql.= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql.= " AND t.fk_soc = ".$socid; + } + if ($restrictonsocid && $search_sale > 0) { + // Join for the needed table to filter by sale + $sql.= " AND t.rowid = sc.fk_soc"; + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".$search_sale; + } + if ($sqlfilters) { + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + while ($i < $num) { + $obj = $db->fetch_object($result); + $hook_static = new Hook($db); + if ($hook_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($hook_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve hook list'); + } + if (! count($obj_ret)) { + throw new RestException(404, 'No hook found'); + } + return $obj_ret; + } + + /** + * Create hook object + * + * @param array $request_data Request datas + * @return int ID of hook + * + * @url POST /hook/ + */ + public function post($request_data = null) + { + // $debug = '
'.print_r($request_data, true).'
'; + // $debug .= '
'.print_r(DolibarrApiAccess::$user->rights->zapier, true).'
'; + // mail('frederic.france@free.fr', 'test hook', $debug); + if (! DolibarrApiAccess::$user->rights->zapier->write) { + throw new RestException(401); + } + // Check mandatory fields + $fields = array( + 'url', + ); + $result = $this->validate($request_data, $fields); + + foreach($request_data as $field => $value) { + $this->hook->$field = $value; + } + $this->hook->fk_user = DolibarrApiAccess::$user->id; + // on crée le hook dans la base + if( ! $this->hook->create(DolibarrApiAccess::$user)) { + throw new RestException(500, "Error creating Hook", array_merge(array($this->hook->error), $this->hook->errors)); + } + return array( + 'id' => $this->hook->id, + ); + } + + /** + * Update hook + * + * @param int $id Id of hook to update + * @param array $request_data Datas + * @return int + * + * @url PUT /hooks/{id} + */ + /*public function put($id, $request_data = null) + { + if (! DolibarrApiAccess::$user->rights->zapier->write) { + throw new RestException(401); + } + + $result = $this->hook->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Hook not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->hook->$field = $value; + } + + if ($this->hook->update($id, DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->hook->error); + } + }*/ + + /** + * Delete hook + * + * @param int $id Hook ID + * @return array + * + * @url DELETE /hook/{id} + */ + public function delete($id) + { + if (! DolibarrApiAccess::$user->rights->zapier->delete) { + throw new RestException(401); + } + $result = $this->hook->fetch($id); + if (! $result) { + throw new RestException(404, 'Hook not found'); + } + + if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! $this->hook->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting Hook : '.$this->hook->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Hook deleted' + ) + ); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + public function _cleanObjectDatas($object) + { + // phpcs:disable + $object = parent::_cleanObjectDatas($object); + + /*unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder);*/ + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Array of data to validate + * @param array $fields Array of fields needed + * @return array + * + * @throws RestException + */ + private function validate($data, $fields) + { + $hook = array(); + foreach ($fields as $field) { + if (!isset($data[$field])) { + throw new RestException(400, $field." field missing"); + } + $hook[$field] = $data[$field]; + } + return $hook; + } +} diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php new file mode 100644 index 00000000000..4a3e670056e --- /dev/null +++ b/htdocs/zapier/class/hook.class.php @@ -0,0 +1,773 @@ + + * Copyright (C) 2019 Frédéric France + * 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/modulebuilder/template/class/hook.class.php + * \ingroup zapier + * \brief This file is a CRUD class file for Hook (Create/Read/Update/Delete) + */ + +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; + +/** + * Class for Hook + */ +class Hook extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'hook'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'zapier_hook'; + + /** + * @var int Does hook support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does hook support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for hook. Must be the part after the 'object_' into object_hook.png + */ + public $picto = 'hook@zapier'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_DISABLED = -1; + + + /** + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array( + 'rowid' => array( + 'type' => 'integer', + 'label' => 'TechnicalID', + 'enabled' => 1, + 'visible' => -2, + 'noteditable' => 1, + 'notnull' => 1, + 'index' => 1, + 'position' => 1, + 'comment' => 'Id', + ), + 'entity' => array( + 'type' => 'integer', + 'label' => 'Entity', + 'enabled' => 1, + 'visible' => 0, + 'notnull' => 1, + 'default' => 1, + 'index' => 1, + 'position' => 20, + ), + 'fk_user' => array( + 'type' => 'integer', + 'label' => 'UserOwner', + 'enabled' => 1, + 'visible' => -2, + 'notnull' => 1, + 'position' => 510, + 'foreignkey' => MAIN_DB_PREFIX.'user.rowid', + ), + 'url' => array( + 'type' => 'varchar(255)', + 'label' => 'Url', + 'enabled' => 1, + 'visible' => 1, + 'position' => 30, + 'searchall' => 1, + 'css' => 'minwidth200', + 'help' => 'Hook url', + 'showoncombobox' => 1, + ), + 'module' => array( + 'type' => 'varchar(128)', + 'label' => 'Url', + 'enabled' => 1, + 'visible' => 1, + 'position' => 30, + 'searchall' => 1, + 'css' => 'minwidth200', + 'help' => 'Hook module', + 'showoncombobox' => 1, + ), + 'action' => array( + 'type' => 'varchar(128)', + 'label' => 'Url', + 'enabled' => 1, + 'visible' => 1, + 'position' => 30, + 'searchall' => 1, + 'css' => 'minwidth200', + 'help' => 'Hook action trigger', + 'showoncombobox' => 1, + ), + 'event' => array( + 'type' => 'varchar(255)', + 'label' => 'Event', + 'enabled' => 1, + 'visible' => 1, + 'position' => 30, + 'searchall' => 1, + 'css' => 'minwidth200', + 'help' => 'Event', + 'showoncombobox' => 1, + ), + 'date_creation' => array( + 'type' => 'datetime', + 'label' => 'DateCreation', + 'enabled' => 1, + 'visible' => -2, + 'notnull' => 1, + 'position' => 500, + ), + 'import_key' => array( + 'type' => 'varchar(14)', + 'label' => 'ImportId', + 'enabled' => 1, + 'visible' => -2, + 'notnull' => -1, + 'index' => 0, + 'position' => 1000, + ), + 'status' => array( + 'type' => 'integer', + 'label' => 'Status', + 'enabled' => 1, + 'visible' => 1, + 'notnull' => 1, + 'default' => 0, + 'index' => 1, + 'position' => 1000, + 'arrayofkeyval' => array( + 0 => 'Draft', + 1 => 'Active', + -1 => 'Canceled', + ), + ), + ); + + /** + * @var int ID + */ + public $rowid; + + /** + * @var string Ref + */ + public $ref; + + /** + * @var int Entity + */ + public $entity; + + /** + * @var string label + */ + public $label; + + /** + * @var string amount + */ + public $amount; + + /** + * @var int Status + */ + public $status; + + /** + * @var integer|string date_creation + */ + public $date_creation; + + /** + * @var integer tms + */ + public $tms; + + /** + * @var int ID + */ + public $fk_user_creat; + + /** + * @var int ID + */ + public $fk_user_modif; + + /** + * @var string import_key + */ + public $import_key; + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'hookdet'; + + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_hook'; + + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'MyObjectline'; + + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('hookdet'); + + /** + * @var MyObjectLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible']=0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled']=0; + } + + // Unset fields that are disabled + foreach($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) { + if (is_array($this->fields['status']['arrayofkeyval'])) { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { + // var_dump($key); + // var_dump($clonedObj->array_options[$key]); + // exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); + + // Load lines with object MyObjectLine + + return count($this->lines)?1:0; + }*/ + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records=array(); + + $sql = 'SELECT'; + $sql .= ' t.rowid'; + // TODO Get all fields + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' WHERE t.entity = '.$conf->entity; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key=='t.rowid') { + $sqlwhere[] = $key . '='. $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key=='customsql') { + $sqlwhere[] = $value; + } else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $record = new self($this->db); + + $record->id = $obj->rowid; + // TODO Get other fields + + //var_dump($record->id); + $records[$record->id] = $record; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager, $action; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) { + // Force disable tooltips + $notooltip=1; + } + + $result = ''; + + $label = '' . $langs->trans("Hook") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/zapier/hook_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values=1; + } + if ($add_save_lastsearch_values) { + $url.='&save_lastsearch_values=1'; + } + } + + $linkclose=''; + if (empty($notooltip)) { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('hookdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } else { + $linkclose = ($morecss?' class="'.$morecss.'"':''); + } + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) { + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + } + if ($withpicto != 2) { + $result.= $this->ref; + } + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + $hookmanager->initHooks(array('hookdao')); + $parameters = array( + 'id' => $this->id, + 'getnomurl' => $result, + ); + // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return label of the status + * + * @param int $mode 0 = long label + * 1 = short label + * 2 = Picto + short label + * 3 = Picto, 4=Picto + long label + * 5 = Short label + Picto + * 6 = Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0 = long label, + * 1 = short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) { + global $langs; + //$langs->load("zapier@zapier"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } + + if ($mode == 0) { + return $this->labelstatus[$status]; + } elseif ($mode == 1) { + return $this->labelstatus[$status]; + } elseif ($mode == 2) { + if ($status == 1) { + return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } elseif ($status == 0) { + return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + } elseif ($mode == 3) { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } elseif ($mode == 4) { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } elseif ($mode == 5) { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } elseif ($mode == 6) { + if ($status == 1) { + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + } elseif ($status == 0) { + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + } + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + //public function doScheduledJob($param1, $param2, ...) + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + +/** + * Class MyObjectLine. You can also remove this and generate a CRUD class for lines objects. + */ +/* +class MyObjectLine +{ + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; +} +*/ diff --git a/htdocs/zapier/hook_agenda.php b/htdocs/zapier/hook_agenda.php new file mode 100644 index 00000000000..924db3b8632 --- /dev/null +++ b/htdocs/zapier/hook_agenda.php @@ -0,0 +1,261 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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/modulebuilder/template/myobject_agenda.php + * \ingroup mymodule + * \brief Page of MyObject events + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +dol_include_once('/mymodule/class/myobject.class.php'); +dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); + + +// Load translation files required by the page +$langs->loadLangs(array("mymodule@mymodule","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +if (GETPOST('actioncode', 'array')) +{ + $actioncode=GETPOST('actioncode', 'array', 3); + if (! count($actioncode)) $actioncode='0'; +} +else +{ + $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} +$search_agenda_label=GETPOST('search_agenda_label'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mymodule', $id); + +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='a.datep,a.id'; +if (! $sortorder) $sortorder='DESC'; + +// Initialize technical objects +$object=new MyObject($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $actioncode=''; + $search_agenda_label=''; + } +} + + + +/* + * View + */ + +$contactstatic = new Contact($db); + +$form = new Form($db); + +if ($object->id > 0) +{ + $title=$langs->trans("Agenda"); + //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $help_url = ''; + llxHeader('', $title, $help_url); + + if (! empty($conf->notification->enabled)) $langs->load("mails"); + $head = myobjectPrepareHead($object); + + + dol_fiche_head($head, 'agenda', $langs->trans("MyObject"), -1, 'myobject@mymodule'); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mymodule->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + $object->info($object->id); + print dol_print_object_info($object, 1); + + print '
'; + + dol_fiche_end(); + + + + // Actions buttons + + $objthirdparty=$object; + $objcon=new stdClass(); + + $out=''; + $permok=$user->rights->agenda->myactions->create; + if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; + } + + + print '
'; + + if (! empty($conf->agenda->enabled)) + { + if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + { + $param='&socid='.$socid; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + + + print load_fiche_titre($langs->trans("ActionsOnMyObject"), '', ''); + + // List of all actions + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + + // TODO Replace this with same code than into list.php + //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php new file mode 100644 index 00000000000..283e0a29749 --- /dev/null +++ b/htdocs/zapier/hook_card.php @@ -0,0 +1,471 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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/modulebuilder/template/myobject_card.php + * \ingroup mymodule + * \brief Page to create/edit/view myobject + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/mymodule/class/myobject.class.php'); +dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mymodule@mymodule","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new MyObject($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectcard','globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + $permissiontoadd = $user->rights->mymodule->write; + $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); + $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); + if (empty($backtopage)) { + if (empty($id)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='MYOBJECT_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; + $trackid='myobject'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +llxHeader('', 'MyObject', ''); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("MyObject"))); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("MyObject")); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = myobjectPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); + } + + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mymodule->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswithonsecondcolumn'; + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '

'; + + dol_fiche_end(); + + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if ($user->rights->mymodule->write) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if ($user->rights->mymodule->write) + { + print ''; + } + + /* + if ($user->rights->mymodule->write) + { + if ($object->status == 1) + { + print ''.$langs->trans("Disable").''."\n"; + } + else + { + print ''.$langs->trans("Enable").''."\n"; + } + } + */ + + if ($user->rights->mymodule->delete) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->mymodule->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/hook_document.php b/htdocs/zapier/hook_document.php new file mode 100644 index 00000000000..d9542daf64f --- /dev/null +++ b/htdocs/zapier/hook_document.php @@ -0,0 +1,166 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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/modulebuilder/template/myobject_document.php + * \ingroup mymodule + * \brief Tab for documents linked to MyObject + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/mymodule/class/myobject.class.php'); +dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mymodule@mymodule","companies","other","mails")); + + +$action=GETPOST('action', 'aZ09'); +$confirm=GETPOST('confirm'); +$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mymodule', $id); + +// Get parameters +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +//if (! $sortfield) $sortfield="position_name"; + +// Initialize technical objects +$object=new MyObject($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectdocument','globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/myobject/" . dol_sanitizeFileName($object->id); +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/myobject/" . dol_sanitizeFileName($object->ref); + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title=$langs->trans("MyObject").' - '.$langs->trans("Files"); +$help_url=''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) +{ + /* + * Show tabs + */ + $head = myobjectPrepareHead($object); + + dol_fiche_head($head, 'document', $langs->trans("MyObject"), -1, 'myobject@mymodule'); + + + // Build file list + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'mymodule'; + //$permission = $user->rights->mymodule->create; + $permission = 1; + //$permtoedit = $user->rights->mymodule->create; + $permtoedit = 1; + $param = '&id=' . $object->id; + + //$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + accessforbidden('', 0, 0); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php new file mode 100644 index 00000000000..015d1d8b1cd --- /dev/null +++ b/htdocs/zapier/hook_list.php @@ -0,0 +1,642 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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/modulebuilder/template/hook_list.php + * \ingroup mymodule + * \brief List page for hook + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once __DIR__.'/class/hook.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("mymodule@mymodule","other")); + +// The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; +// The bulk action (combo box choice into lists) +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'hooklist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id', 'int'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action + $page = 0; +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + +// Initialize technical objects +$object = new Hook($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +// Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('hooklist')); +// Fetch optionals attributes and labels +// Load $extrafields->attributes['hook'] +$extralabels = $extrafields->fetch_name_optionals_label('hook'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) { + // Set here default search field. By default 1st field in definition. + $sortfield="t.".key($object->fields); +} +if (! $sortorder) { + $sortorder="ASC"; +} + +// Security check +$socid=0; +if ($user->societe_id > 0) { + // Protection if external user + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'mymodule', $id, ''); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) { + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action='list'; + $massaction=''; +} +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction=''; +} + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) { + // All tests are required to be compatible with all browsers + foreach($object->fields as $key => $val) { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Hook'; + $objectlabel='Hook'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_Hook|FR:Module_Hook_FR|ES:Módulo_Hook"; +$help_url=''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Hooks")); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) { + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + } +} +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/', '', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) { + $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql.=" WHERE 1 = 1"; +} +foreach($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + if ($search[$key] != '') { + $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + } +} +if ($search_all) { + $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +} +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +*/ + +$sql.=$db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { + // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { + $num = $nbtotalofrecords; +} else { + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach($search[$key] as $skey) { + $param.='&search_'.$key.'[]='.urlencode($skey); + } + } else { + $param.= '&search_'.$key.'='.urlencode($search[$key]); + } +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton=''; +//if ($user->rights->mymodule->creer) +//{ + $newcardbutton=''.$langs->trans('New').''; + $newcardbutton.= ''; + $newcardbutton.= ''; +//} +//else +//{ +// $newcardbutton=''.$langs->trans('New').'; +// $newcardbutton.= ''; +// $newcardbutton.= ''; +//} + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="SendHookRef"; +$modelmail="hook"; +$objecttmp=new Hook($db); +$trackid='xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) { + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) { + $cssforfield.=($cssforfield?' ':'').'center'; + } + if (in_array($val['type'], array('timestamp'))) { + $cssforfield.=($cssforfield?' ':'').'nowrap'; + } + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { + $cssforfield.=($cssforfield?' ':'').'right'; + } + if ($key == 'status') { + $cssforfield.=($cssforfield?' ':'').'center'; + } + if (! empty($arrayfields['t.'.$key]['checked'])) { + print ''; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) { + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; + if ($key == 'status') { + $cssforfield.=($cssforfield?' ':'').'center'; + } + if (! empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array( + 'arrayfields' => $arrayfields, + 'param' => $param, + 'sortfield' => $sortfield, + 'sortorder' => $sortorder, +); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + // There is at least one compute field that use $object + $needToFetchEachLine++; + } + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) { + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) { + $cssforfield.=($cssforfield?' ':'').'center'; + } elseif ($key == 'status') { + $cssforfield.=($cssforfield?' ':'').'center'; + } + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; + + if (! empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) { + $i++; + if (! empty($totalarray['pos'][$i])) { + print ''; + } else { + if ($i == 1) { + if ($num < $limit) { + print ''; + } else { + print ''; + } + } else { + print ''; + } + } + } + print ''; +} + +// If no record found +if ($num == 0) { + $colspan=1; + foreach($arrayfields as $key => $val) { + if (! empty($val['checked'])) { + $colspan++; + } + } + print ''; +} + + +$db->free($resql); + +$parameters = array( + 'arrayfields' => $arrayfields, + 'sql' => $sql, +); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) { + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty=0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&', '&', $param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/hook_note.php b/htdocs/zapier/hook_note.php new file mode 100644 index 00000000000..0cbf4c40d8b --- /dev/null +++ b/htdocs/zapier/hook_note.php @@ -0,0 +1,164 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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/modulebuilder/template/myobject_note.php + * \ingroup mymodule + * \brief Car with notes on MyObject + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +dol_include_once('/mymodule/class/myobject.class.php'); +dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mymodule@mymodule","companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new MyObject($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mymodule', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; + +$permissionnote=1; +//$permissionnote=$user->rights->mymodule->creer; // Used by the include of actions_setnotes.inc.php + + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url=''; +llxHeader('', $langs->trans('MyObject'), $help_url); + +if ($id > 0 || ! empty($ref)) +{ + $object->fetch_thirdparty(); + + $head = myobjectPrepareHead($object); + + dol_fiche_head($head, 'note', $langs->trans("MyObject"), -1, 'myobject@mymodule'); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mymodule->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass="titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + dol_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/zapier/img/object_hook.png b/htdocs/zapier/img/object_hook.png new file mode 100644 index 0000000000000000000000000000000000000000..5a307bfc62f85df909a3cf024f27ee87d44be275 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt)eIT^vI+ zChono-m4{0gyqBiz=Ju)w^;&N<{#X1a0!1>bC%GsW3bBL=<%|p84;9-@5SwA|2OIEL% zb=QtBT0T9C&(LA{syqXqqW_DHn`b;(x5}@uA-g2{Ncy)Mhpp~Sy0eY()*3IP6|4C4 z(mDEHWvtPCEP7WZe7{4e?P9&>AE%^j|Mz!&9rL?{G_w^d>;^y&GkCiCxvX~}U&Kt)eIT^vI+ zChono-m4{0gyqBiz=Ju)w^;&N<{#X1a0!1>bC%GsW3bBL=<%|p84;9-@5SwA|2OIEL% zb=QtBT0T9C&(LA{syqXqqW_DHn`b;(x5}@uA-g2{Ncy)Mhpp~Sy0eY()*3IP6|4C4 z(mDEHWvtPCEP7WZe7{4e?P9&>AE%^j|Mz!&9rL?{G_w^d>;^y&GkCiCxvX&bpol<(u!rW?;H+EQ%enXNbFO(BxM6em zT6?Xvzwg`ooU^Y){|U(ZFQBI!m!$&}L7j!5{;fYTRT7^Ei2`otSo}~$jn`>$_0GV8{|=a0ceV}S zT##S2)dC>kW)OEac4ad=0PF{D)D5n&1&hE|5*Fn>+!87O7%&6uq>(Lac(63vU3r8dAUkz5(vJ*$kYi!M+3>2Chh&smne_ z0k^l4oC%S=;mTvomp7S=zUfMq-Pa*-4U* z(fYvM9@LwZ^Z;0LC%nYcD^%FWV(tM!t@kx*iR5*SB+L^EYlZ(WSOrixfZrRuvN}?F RO?LnQ002ovPDHLkV1iP-B{u*7 literal 0 HcmV?d00001 diff --git a/htdocs/zapier/lib/zapier.lib.php b/htdocs/zapier/lib/zapier.lib.php new file mode 100644 index 00000000000..8fc4810599d --- /dev/null +++ b/htdocs/zapier/lib/zapier.lib.php @@ -0,0 +1,58 @@ + + * + * 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 zapier/lib/zapier.lib.php + * \ingroup zapier + * \brief Library files with common functions for ZapierForDolibarr + */ + +/** + * Prepare admin pages header + * + * @return array + */ +function zapierAdminPrepareHead() +{ + global $langs, $conf; + + $langs->load("zapier@zapier"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/zapier/admin/setup.php", 1); + $head[$h][1] = $langs->trans("Settings"); + $head[$h][2] = 'settings'; + $h++; + $head[$h][0] = dol_buildpath("/zapier/admin/about.php", 1); + $head[$h][1] = $langs->trans("About"); + $head[$h][2] = 'about'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@zapier:/zapier/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@zapier:/zapier/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'zapier'); + + return $head; +} diff --git a/htdocs/zapier/lib/zapier_hook.lib.php b/htdocs/zapier/lib/zapier_hook.lib.php new file mode 100644 index 00000000000..e1af0259062 --- /dev/null +++ b/htdocs/zapier/lib/zapier_hook.lib.php @@ -0,0 +1,83 @@ +. + */ + +/** + * \file htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php + * \ingroup mymodule + * \brief Library files with common functions for MyObject + */ + +/** + * Prepare array of tabs for MyObject + * + * @param MyObject $object MyObject + * @return array Array of tabs + */ +function myobjectPrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("mymodule@mymodule"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/mymodule/myobject_card.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->mymodule->dir_output . "/myobject/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'myobject@mymodule'); + + return $head; +} diff --git a/htdocs/zapier/sql/llx_zapier_hook.key.sql b/htdocs/zapier/sql/llx_zapier_hook.key.sql new file mode 100644 index 00000000000..d707e6bba1a --- /dev/null +++ b/htdocs/zapier/sql/llx_zapier_hook.key.sql @@ -0,0 +1,22 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + + +--ALTER TABLE llx_zapierfordolibarr_hook ADD INDEX idx_fieldobject (fieldobject); + +--ALTER TABLE llx_zapierfordolibarr_hook ADD UNIQUE INDEX uk_zapierfordolibarr_hook_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_zapierfordolibarr_hook ADD CONSTRAINT llx_zapierfordolibarr_hook_fk_field FOREIGN KEY (fk_field) REFERENCES llx_zapierfordolibarr_myotherobject(rowid); + diff --git a/htdocs/zapier/sql/llx_zapier_hook.sql b/htdocs/zapier/sql/llx_zapier_hook.sql new file mode 100644 index 00000000000..829ec2bfdc4 --- /dev/null +++ b/htdocs/zapier/sql/llx_zapier_hook.sql @@ -0,0 +1,29 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + + +CREATE TABLE llx_zapierfordolibarr_hook( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + url varchar(255), + event varchar(255), + module varchar(128), + action varchar(128), + status integer, + date_creation DATETIME NOT NULL, + fk_user integer NOT NULL, + tms TIMESTAMP NOT NULL, + import_key varchar(14) +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/zapier/sql/llx_zapier_hook_extrafields.sql b/htdocs/zapier/sql/llx_zapier_hook_extrafields.sql new file mode 100644 index 00000000000..c840007412b --- /dev/null +++ b/htdocs/zapier/sql/llx_zapier_hook_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + +create table llx_zapierfordolibarr_hook_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/zapier/zapierindex.php b/htdocs/zapier/zapierindex.php new file mode 100644 index 00000000000..6e9e0491946 --- /dev/null +++ b/htdocs/zapier/zapierindex.php @@ -0,0 +1,238 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Jean-François Ferry + * + * 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/zapierfordolibarr/template/zapierfordolibarrindex.php + * \ingroup zapierfordolibarr + * \brief Home page of zapierfordolibarr top menu + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("zapierfordolibarr@zapierfordolibarr")); + +$action=GETPOST('action', 'alpha'); + + +// Securite acces client +if (! $user->rights->zapierfordolibarr->read) accessforbidden(); +$socid=GETPOST('socid', 'int'); +if (isset($user->societe_id) && $user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +$max=5; +$now=dol_now(); + + +/* + * Actions + */ + +// None + + +/* + * View + */ + +$form = new Form($db); +$formfile = new FormFile($db); + +llxHeader("", $langs->trans("ZapierForDolibarrArea")); + +print load_fiche_titre($langs->trans("ZapierForDolibarrArea"), '', 'zapierfordolibarr.png@zapierfordolibarr'); + +print '
'; + + +/* BEGIN MODULEBUILDER DRAFT MYOBJECT +// Draft MyObject +if (! empty($conf->zapierfordolibarr->enabled) && $user->rights->zapierfordolibarr->read) +{ + $langs->load("orders"); + + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.fk_statut = 0"; + $sql.= " AND c.entity IN (".getEntity('commande').")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + + $resql = $db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + $var = true; + if ($num > 0) + { + $i = 0; + while ($i < $num) + { + + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) + { + + print '"; + } + } + else + { + + print ''; + } + print "
'.$langs->trans("DraftOrders").($num?' '.$num.'':'').'
'; + $orderstatic->id=$obj->rowid; + $orderstatic->ref=$obj->ref; + $orderstatic->ref_client=$obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + print $orderstatic->getNomUrl(1); + print ''; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1,'customer',16); + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoOrder").'

"; + + $db->free($resql); + } + else + { + dol_print_error($db); + } +} +END MODULEBUILDER DRAFT MYOBJECT */ + + +print '
'; + + +$NBMAX=3; +$max=3; + +/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT +// Last modified myobject +if (! empty($conf->zapierfordolibarr->enabled) && $user->rights->zapierfordolibarr->read) +{ + $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; + $sql.= ", s.code_client"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE s.client IN (1, 2, 3)"; + $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = $socid"; + $sql .= " ORDER BY s.tms DESC"; + $sql .= $db->plimit($max, 0); + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $companystatic->id=$objp->rowid; + $companystatic->name=$objp->name; + $companystatic->client=$objp->client; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas=$objp->canvas; + print ''; + print ''; + print '"; + print '"; + print ''; + $i++; + + + } + + $db->free($resql); + } + else + { + print ''; + } + print "
'; + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max); + else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max); + else print $langs->trans("BoxTitleLastModifiedCustomers",$max); + print ''.$langs->trans("DateModificationShort").'
'.$companystatic->getNomUrl(1,'customer',48).''; + print $companystatic->getLibCustProspStatut(); + print "'.dol_print_date($db->jdate($objp->tms),'day')."
'.$langs->trans("None").'

"; + } +} +*/ + +print '
'; + +// End of page +llxFooter(); +$db->close(); From 872800f604225203f018ff89c8cc89a7486ffab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 19 May 2019 21:38:29 +0200 Subject: [PATCH 016/622] zapier for dolibarr --- .tx/config | 6 ++++++ htdocs/zapier/class/hook.class.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.tx/config b/.tx/config index 0044fb91f49..5c52849c29c 100644 --- a/.tx/config +++ b/.tx/config @@ -410,3 +410,9 @@ source_file = htdocs/langs/en_US/workflow.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.zapier] +file_filter = htdocs/langs//zapier.lang +source_file = htdocs/langs/en_US/zapier.lang +source_lang = en_US +type = MOZILLAPROPERTIES + diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index 4a3e670056e..666e3e6df57 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -111,7 +111,7 @@ class Hook extends CommonObject 'visible' => -2, 'notnull' => 1, 'position' => 510, - 'foreignkey' => MAIN_DB_PREFIX.'user.rowid', + 'foreignkey' => (MAIN_DB_PREFIX.'user.rowid'), ), 'url' => array( 'type' => 'varchar(255)', From 08b1f123b0a24a26d7adbf3a212cb1d004378e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 19 May 2019 21:49:34 +0200 Subject: [PATCH 017/622] zapier for dolibarr --- dev/examples/zapier/package.json | 8 ++++---- htdocs/zapier/class/hook.class.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/examples/zapier/package.json b/dev/examples/zapier/package.json index 30ea4939915..8fbd203f962 100644 --- a/dev/examples/zapier/package.json +++ b/dev/examples/zapier/package.json @@ -1,10 +1,10 @@ { "name": "Dolibarr", - "version": "1.0.2", + "version": "1.0.0", "description": "An app for connecting Dolibarr to the Zapier platform.", - "repository": "frederic34/ZapierForDolibarr", - "homepage": "https://netlogic-dev.fr/", - "author": "Frédéric France ", + "repository": "Dolibarr/dolibarr", + "homepage": "https://www.dolibarr.fr/", + "author": "Frédéric France ", "license": "BSD-3-Clause", "main": "index.js", "scripts": { diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index 666e3e6df57..81b76b1c81f 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -111,7 +111,7 @@ class Hook extends CommonObject 'visible' => -2, 'notnull' => 1, 'position' => 510, - 'foreignkey' => (MAIN_DB_PREFIX.'user.rowid'), + 'foreignkey' => 'llx_user.rowid', ), 'url' => array( 'type' => 'varchar(255)', From 695a00f21caf4f797f8fd928cd3cbd7311b08536 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Wed, 19 Jun 2019 14:04:01 +0100 Subject: [PATCH 018/622] New:Show labels of countries in modulebuilder --- htdocs/core/class/ccountry.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index a97d992bf89..d5a929be0dd 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -30,7 +30,7 @@ /** * Class to manage dictionary Countries (used by imports) */ -class Ccountry // extends CommonObject +class Ccountry extends CommonObject { /** * @var DoliDB Database handler. @@ -332,4 +332,19 @@ class Ccountry // extends CommonObject return 1; } } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $langs; + return $langs->trans($this->label); + } } From 7f34a03034e835e2e7344b67cfdc648ca48a4eac Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Thu, 20 Jun 2019 20:55:48 +0100 Subject: [PATCH 019/622] It's just a mistake. In order to declare a getnomUrl method, Ccountry does not need to extend Commonobject --- htdocs/core/class/ccountry.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index d5a929be0dd..71df0784fba 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -30,7 +30,7 @@ /** * Class to manage dictionary Countries (used by imports) */ -class Ccountry extends CommonObject +class Ccountry// extends CommonObject { /** * @var DoliDB Database handler. From d810e11c4ed967fff1533e003d6567504b31ab2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Jun 2019 19:23:32 +0200 Subject: [PATCH 020/622] Update fiche-rec.php --- htdocs/compta/facture/fiche-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fa71bdd7f2e..c9ee6e592ee 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -275,7 +275,7 @@ if (empty($reshook)) { $object->setProject(GETPOST('projectid', 'int')); } - // Set titre + // Set title/label of template invoice elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; From ecc4d4227b106a430f647fcd0b252b61120fc20b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 29 Jun 2019 10:14:46 +0200 Subject: [PATCH 021/622] translations --- .../core/modules/project/doc/pdf_baleine.modules.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index c7005206fcc..b9ecd61c61c 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -139,15 +139,15 @@ class pdf_baleine extends ModelePDFProjects $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_logo = 1; // Display logo FAC_PDF_LOGO + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Display product-service code - // Recupere emmetteur + // Get source company $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define position of columns $this->posxref=$this->marge_gauche+1; $this->posxlabel=$this->marge_gauche+25; $this->posxworkload=$this->marge_gauche+120; @@ -168,7 +168,7 @@ class pdf_baleine extends ModelePDFProjects // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Fonction generant le projet sur le disque + * Function to build pdf project onto disk * * @param Project $object Object project a generer * @param Translate $outputlangs Lang output object From 05e9885ba71e6517bfc3d24f1f10ffbe9c7df839 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 29 Jun 2019 10:18:45 +0200 Subject: [PATCH 022/622] translations --- htdocs/core/modules/project/doc/pdf_beluga.modules.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index dfbe97c3fd5..97414e745eb 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -21,7 +21,7 @@ /** * \file htdocs/core/modules/project/doc/pdf_beluga.modules.php * \ingroup project - * \brief Fichier de la classe permettant de generer les projets au modele beluga + * \brief File of class to generate project document beluga * \author Charlie Benke */ @@ -50,7 +50,7 @@ if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/com /** - * Class to manage generation of project document Baleine + * Class to manage generation of project document beluga */ class pdf_beluga extends ModelePDFProjects @@ -100,9 +100,9 @@ class pdf_beluga extends ModelePDFProjects $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_logo = 1; // Display logo FAC_PDF_LOGO + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Display product-service code // Recupere emmetteur $this->emetteur=$mysoc; From 59424f228ea2a39965198a588de580668df6a157 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 29 Jun 2019 10:21:26 +0200 Subject: [PATCH 023/622] translations --- htdocs/core/modules/project/doc/pdf_beluga.modules.php | 4 ++-- .../core/modules/project/doc/pdf_timespent.modules.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 97414e745eb..30a983f0b2e 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -104,11 +104,11 @@ class pdf_beluga extends ModelePDFProjects $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Display product-service code - // Recupere emmetteur + // Get source company $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define position of columns if ($this->orientation == 'L' || $this->orientation == 'Landscape') { $this->posxref=$this->marge_gauche+1; $this->posxdate=$this->marge_gauche+105; diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 2c69fbd6bab..99c7fe99cd9 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -71,15 +71,15 @@ class pdf_timespent extends ModelePDFProjects $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_logo = 1; // Display logo FAC_PDF_LOGO + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Display product-service code - // Recupere emmetteur + // Get source company $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define position of columns $this->posxref=$this->marge_gauche+1; $this->posxlabel=$this->marge_gauche+25; $this->posxtimespent=$this->marge_gauche+120; From bd43e90c2bcd59b2c6becebdf7e6fa3bf67cad54 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 29 Jun 2019 10:28:29 +0200 Subject: [PATCH 024/622] translations --- .../modules/propale/doc/pdf_azur.modules.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 54fe56421ea..6cef67a3d21 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -27,7 +27,7 @@ /** * \file htdocs/core/modules/propale/doc/pdf_azur.modules.php * \ingroup propale - * \brief Fichier de la classe permettant de generer les propales au modele Azur + * \brief File of Class to generate PDF proposal with Azur template */ require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -148,16 +148,16 @@ class pdf_azur extends ModelePDFPropales $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; //Support add of a watermark on drafts + $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->franchise=!$mysoc->tva_assuj; From bebd219e5a522616b3d30793469ab42948dba95d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 29 Jun 2019 10:30:26 +0200 Subject: [PATCH 025/622] translations --- .../modules/propale/doc/pdf_cyan.modules.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 14a2456157a..8d0c9eea3e6 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -27,7 +27,7 @@ /** * \file htdocs/core/modules/propale/doc/pdf_cyan.modules.php * \ingroup propale - * \brief Fichier de la classe permettant de generer les propales au modele Cyan + * \brief File of Class to generate PDF proposal with Cyan template */ require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -148,16 +148,16 @@ class pdf_cyan extends ModelePDFPropales $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; //Support add of a watermark on drafts + $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->franchise=!$mysoc->tva_assuj; From 3bdbbc714751e5369cece79cba8d1918b31614a2 Mon Sep 17 00:00:00 2001 From: Nicolas ZABOURI Date: Fri, 26 Jul 2019 17:17:59 +0200 Subject: [PATCH 026/622] NEW list of boxes area --- htdocs/core/class/infobox.class.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 1138e3a69ad..c73d32c8301 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 Nicolas ZABOURI * * 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 @@ -34,7 +35,33 @@ class InfoBox */ public static function getListOfPagesForBoxes() { - return array(0=>'Home'); + return array(0 => 'Home', + 1 => 'userhome', + 2 => 'membersindex', + 3 => 'thirdpartiesindex', + 4 => 'productindex', + 5 => 'productindex', + 6 => 'mrpindex', + 7 => 'commercialindex', + 8 => 'projectsindex', + 9 => 'invoiceindex', + 10 => 'hrmindex', + 11 => 'ticketsindex', + 12 => 'stockindex', + 13 => 'sendingindex', + 14 => 'receptionindex', + 15 => 'activityindex', + 16 => 'proposalindex', + 17 => 'ordersindex', + 18 => 'orderssuppliersindex', + 19 => 'contractindex', + 20 => 'interventionindex', + 21 => 'suppliersproposalsindex', + 22 => 'donationindex', + 23 => 'specialexpensesindex', + 24 => 'expensereportindex', + 25 => 'mailingindex', + 26 => 'opensurveyindex'); } /** From 5aa27a126aa8cd795a3c67e7f82c9bb68ff4bffd Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 28 Aug 2019 13:45:02 +0200 Subject: [PATCH 027/622] Fix trigger create on widthdraw is missing --- .../prelevement/class/bonprelevement.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 7a5a190c465..5c2204dc216 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -775,12 +775,13 @@ class BonPrelevement extends CommonObject * @param string $mode real=do action, simu=test only * @param string $format FRST, RCUR or ALL * @param string $executiondate Date to execute the transfer + * @param int $notrigger Disable triggers * @return int <0 if KO, nbre of invoice withdrawed if OK */ - function Create($banque=0, $agence=0, $mode='real', $format='ALL',$executiondate='') + function Create($banque=0, $agence=0, $mode='real', $format='ALL',$executiondate='', $notrigger = 0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs, $user; dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG); @@ -1091,6 +1092,7 @@ class BonPrelevement extends CommonObject } $this->factures = $factures_prev_id; + $this->factures_prev = $factures_prev; // Generation of SEPA file $this->filename $this->generate($format,$executiondate); @@ -1114,6 +1116,14 @@ class BonPrelevement extends CommonObject dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BON_PRELEVEMENT_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } + if (!$error) { $this->db->commit(); From ac7bcbd1b2cd4d24614bd60cb2fdea79adb80cd8 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 29 Aug 2019 10:59:36 +0200 Subject: [PATCH 028/622] Add main feature level --- htdocs/core/class/infobox.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index c73d32c8301..978501bfd1e 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -35,7 +35,13 @@ class InfoBox */ public static function getListOfPagesForBoxes() { - return array(0 => 'Home', + global $conf; + + if($conf->global->MAIN_FEATURES_LEVEL < 2) + return array(0 => 'Home'); + else + { + return array(0 => 'Home', 1 => 'userhome', 2 => 'membersindex', 3 => 'thirdpartiesindex', @@ -62,6 +68,7 @@ class InfoBox 24 => 'expensereportindex', 25 => 'mailingindex', 26 => 'opensurveyindex'); + } } /** From b535bc0cb96c919312d26ed7b203f87f143ad936 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Sep 2019 11:27:04 +0200 Subject: [PATCH 029/622] start dev --- htdocs/core/lib/company.lib.php | 1 + .../install/mysql/migration/10.0.0-11.0.0.sql | 17 +++++++++-- .../mysql/tables/llx_societe_contact.key.sql | 22 ++++++++++++++ .../mysql/tables/llx_societe_contact.sql | 29 +++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_societe_contact.key.sql create mode 100644 htdocs/install/mysql/tables/llx_societe_contact.sql diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2f6c474e632..8d862d3a9af 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -896,6 +896,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), + 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), ); // Extra fields diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 8efe44db103..5bc114c2294 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -89,5 +89,18 @@ ALTER TABLE llx_projet ADD COLUMN usage_organize_event integer DEFAULT 0; UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0; - - \ No newline at end of file +create table llx_societe_contact +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime NULL, -- date de creation de l'enregistrement + statut smallint DEFAULT 5, -- 5 inactif, 4 actif + + element_id int NOT NULL, -- la reference de l'element. + fk_c_type_contact int NOT NULL, -- nature du contact. + fk_socpeople integer NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); + +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.key.sql b/htdocs/install/mysql/tables/llx_societe_contact.key.sql new file mode 100644 index 00000000000..1409e7edc24 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_contact.key.sql @@ -0,0 +1,22 @@ +-- ======================================================================== +-- Copyright (C) 2019 Florian HENRY +-- +-- 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 . +-- +-- ======================================================================== + +ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); + +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.sql b/htdocs/install/mysql/tables/llx_societe_contact.sql new file mode 100644 index 00000000000..040f8ded124 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_contact.sql @@ -0,0 +1,29 @@ +-- ======================================================================== +-- Copyright (C) 2019 Florian HENRY +-- +-- 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 . +-- +-- ======================================================================== + + +create table llx_societe_contact +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime NULL, -- date de creation de l'enregistrement + statut smallint DEFAULT 5, -- 5 inactif, 4 actif + + element_id int NOT NULL, -- la reference de l'element. + fk_c_type_contact int NOT NULL, -- nature du contact. + fk_socpeople integer NOT NULL +)ENGINE=innodb; From 405c92640c077c4fbda99604123f4574681b1816 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Sep 2019 14:47:32 +0200 Subject: [PATCH 030/622] on going --- htdocs/contact/class/contact.class.php | 50 +++++++++++++- htdocs/core/class/commonobject.class.php | 69 +++++++++++++++++++ htdocs/core/lib/company.lib.php | 44 ++++++++++-- .../install/mysql/migration/10.0.0-11.0.0.sql | 23 ++++--- ...t.key.sql => llx_societe_contacts.key.sql} | 8 +-- ...e_contact.sql => llx_societe_contacts.sql} | 17 ++--- htdocs/langs/en_US/main.lang | 14 +++- 7 files changed, 195 insertions(+), 30 deletions(-) rename htdocs/install/mysql/tables/{llx_societe_contact.key.sql => llx_societe_contacts.key.sql} (61%) rename htdocs/install/mysql/tables/{llx_societe_contact.sql => llx_societe_contacts.sql} (69%) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e064b93504d..db6ab29b802 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -82,7 +82,7 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; - public $civility; + public $civility; public $address; public $zip; public $town; @@ -139,6 +139,8 @@ class Contact extends CommonObject public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $roles=array(); + /** * Constructor @@ -1449,4 +1451,50 @@ class Contact extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Fetch Role for a contact + * + * @return float|int + * @throws Exception + */ + public function fetchRole() + { + + global $langs; + $error= 0; + $num=0; + + $sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle"; + $sql.=" FROM ".MAIN_DB_PREFIX."societe_contacts as sc "; + $sql.=" INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql.=" ON tc.rowid = sc.fk_c_type_contact"; + $sql.=" AND sc.fk_socpeople = ". $this->id; + $sql.=" AND tc.source = 'external' AND tc.active=1"; + $sql.=" AND sc.entity IN (".getEntity('societe').')'; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + + $this->roles=array(); + $resql=$this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) { + $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; + $this->roles[$this->id]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle)); + } + } + } else { + $error++; + $this->errors[]=$this->db->lasterror(); + } + + if (empty($error)) { + return $num; + } else { + return $error * -1; + } + } + } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c57148124be..0eea968ecd2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1210,6 +1210,75 @@ abstract class CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array with list of possible values for type of contacts + * + * @param string $source 'internal', 'external' or 'all' + * @param int $option 0=Return array id->label, 1=Return array code->label + * @param int $activeonly 0=all status of contact, 1=only the active + * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') + * @param string $element Filter Element Type + * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) + */ + public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '') + { + // phpcs:enable + global $langs; + + if (empty($order)) $order='position'; + if ($order == 'position') $order.=',code'; + + $tab = array(); + $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; + + $sqlWhere=array(); + if (!empty($element)) + $sqlWhere[]=" tc.element='".$this->db->escape($element)."'"; + + if ($activeonly == 1) + $sqlWhere[]=" tc.active=1"; // only the active types + + if (! empty($source) && $source != 'all') + $sqlWhere[]=" tc.source='".$this->db->escape($source)."'"; + + if (! empty($code)) + $sqlWhere[]=" tc.code='".$this->db->escape($code)."'"; + + if (count($sqlWhere)>0) { + $sql .= " WHERE ". implode(' AND ', $sqlWhere); + } + + $sql.= $this->db->order('tc.element, tc.position', 'ASC'); + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + $libelle_element = $langs->trans('ContactDefault_'.ucfirst($obj->element)); + $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; + $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); + if (empty($option)) $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; + else $tab[$obj->code]=$libelle_element.' - '.$libelle_type; + $i++; + } + return $tab; + } + else + { + $this->error=$this->db->lasterror(); + //dol_print_error($this->db); + return null; + } + } + /** * Return id of contacts for a source and a contact code. * Example: contact client de facturation ('external', 'BILLING') diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8d862d3a9af..cfc1fcfb30f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -869,6 +869,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if ($search_status=='') $search_status=1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_addressphone = GETPOST("search_addressphone", 'alpha'); + $search_role = GETPOST("search_role", 'array'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="t.lastname"; @@ -887,7 +888,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), + 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), ); // Definition of fields for list @@ -896,8 +898,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), + 'sc.role'=>array('label'=>"Role", 'checked'=>1, 'position'=>40), + 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), ); // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) @@ -927,6 +929,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { $search_status = ''; $search_name = ''; + $search_role = ''; $search_addressphone = ''; $search_array_options=array(); @@ -968,6 +971,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $param="socid=".urlencode($object->id); if ($search_status != '') $param.='&search_status='.urlencode($search_status); + if (count($search_role)>0) $param.=implode('&search_role[]=', $search_role); if ($search_name != '') $param.='&search_name='.urlencode($search_name); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -978,9 +982,15 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; + if (count($search_role)>0) { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_contacts as sc on (sc.fk_socpeople = t.rowid)"; + } $sql .= " WHERE t.fk_soc = ".$object->id; if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); + if (count($search_role)>0) { + $sql .= ' AND sc.fk_c_type_contact IN ('.implode(',',$search_role).')'; + } // Add where from extra fields $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -993,6 +1003,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $num = $db->num_rows($result); + // Fields title search // -------------------------------------------------------------------- print ''; @@ -1002,11 +1013,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) { + print ''; if (in_array($key, array('lastname','name'))) print ''; elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); + elseif (in_array($key, array('role'))) { + $contactType=$contactstatic->listeTypeContacts('external', '', 1); + print $form->multiselectarray('search_role', $contactType, $search_role); + } print ''; } } @@ -1035,7 +1051,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + if ($key == 'role') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + } } // Extra fields $extrafieldsobjectkey=$contactstatic->table_element; @@ -1082,6 +1101,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); + $resultRole=$contactstatic->fetchRole(); + if ($resultRole<0) { + setEventMessages(null, $contactstatic->errors,'errors'); + } + if (is_array($contactstatic->array_options)) { foreach($contactstatic->array_options as $key => $val) @@ -1125,6 +1149,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; } + // Role + if (! empty($arrayfields['sc.role']['checked'])) + { + print ''; + foreach($contactstatic->roles as $key=>$val) { + print '
    '.implode(' ', $val['label']).'
'; + } + print ''; + } + // Status if (! empty($arrayfields['t.statut']['checked'])) { diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 5bc114c2294..1b705133a19 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -89,18 +89,19 @@ ALTER TABLE llx_projet ADD COLUMN usage_organize_event integer DEFAULT 0; UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0; -create table llx_societe_contact +create table llx_societe_contacts ( rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime NULL, -- date de creation de l'enregistrement - statut smallint DEFAULT 5, -- 5 inactif, 4 actif - - element_id int NOT NULL, -- la reference de l'element. - fk_c_type_contact int NOT NULL, -- nature du contact. - fk_socpeople integer NOT NULL + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + fk_soc integer NOT NULL, + fk_c_type_contact int NOT NULL, + fk_socpeople integer NOT NULL, + tms TIMESTAMP, + import_key VARCHAR(14) )ENGINE=innodb; -ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); - -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); +ALTER TABLE llx_societe_contacts ADD UNIQUE INDEX idx_societe_contacts_idx1 (entity, fk_soc, fk_c_type_contact, fk_socpeople); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.key.sql b/htdocs/install/mysql/tables/llx_societe_contacts.key.sql similarity index 61% rename from htdocs/install/mysql/tables/llx_societe_contact.key.sql rename to htdocs/install/mysql/tables/llx_societe_contacts.key.sql index 1409e7edc24..2b2eae8b2ca 100644 --- a/htdocs/install/mysql/tables/llx_societe_contact.key.sql +++ b/htdocs/install/mysql/tables/llx_societe_contacts.key.sql @@ -16,7 +16,7 @@ -- -- ======================================================================== -ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); - -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); +ALTER TABLE llx_societe_contacts ADD UNIQUE INDEX idx_societe_contacts_idx1 (entity, fk_soc, fk_c_type_contact, fk_socpeople); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.sql b/htdocs/install/mysql/tables/llx_societe_contacts.sql similarity index 69% rename from htdocs/install/mysql/tables/llx_societe_contact.sql rename to htdocs/install/mysql/tables/llx_societe_contacts.sql index 040f8ded124..31d82f3003d 100644 --- a/htdocs/install/mysql/tables/llx_societe_contact.sql +++ b/htdocs/install/mysql/tables/llx_societe_contacts.sql @@ -17,13 +17,14 @@ -- ======================================================================== -create table llx_societe_contact +create table llx_societe_contacts ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime NULL, -- date de creation de l'enregistrement - statut smallint DEFAULT 5, -- 5 inactif, 4 actif - - element_id int NOT NULL, -- la reference de l'element. - fk_c_type_contact int NOT NULL, -- nature du contact. - fk_socpeople integer NOT NULL + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + fk_soc integer NOT NULL, + fk_c_type_contact int NOT NULL, + fk_socpeople integer NOT NULL, + tms TIMESTAMP, + import_key VARCHAR(14) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 5c3e30967de..2b92ed783fe 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -989,4 +989,16 @@ ToApprove=To approve GlobalOpenedElemView=Global view NoArticlesFoundForTheKeyword=No article found for the keyword '%s' NoArticlesFoundForTheCategory=No article found for the category -ToAcceptRefuse=To accept | refuse \ No newline at end of file +ToAcceptRefuse=To accept | refuse +ContactDefault_agenda=Event +ContactDefault_commande=Order +ContactDefault_contrat=Contract +ContactDefault_facture=Invoice +ContactDefault_fichinter=Intervention +ContactDefault_invoice_supplier=Supplier Invoice +ContactDefault_order_supplier=Supplier Order +ContactDefault_project=Project +ContactDefault_project_task=Task +ContactDefault_propal=Proposal +ContactDefault_supplier_proposal=Supplier Proposal +ContactDefault_ticketsup=Ticket From d811de4da2e7028d4ffd4150532dcd95ffeb5548 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Sep 2019 22:01:48 +0200 Subject: [PATCH 031/622] let only triggers part --- htdocs/contact/card.php | 28 ++++++- htdocs/contact/class/contact.class.php | 93 +++++++++++++++++++++++- htdocs/contact/list.php | 10 +++ htdocs/core/class/commonobject.class.php | 7 +- htdocs/core/class/html.form.class.php | 40 ++++++++++ htdocs/core/lib/company.lib.php | 29 ++++---- 6 files changed, 179 insertions(+), 28 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 76d0e3911b5..20a61ec4e3e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -371,6 +371,7 @@ if (empty($reshook)) $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -474,9 +475,6 @@ else // Si edition contact deja existant $object = new Contact($db); $res=$object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } // Show tabs $head = contact_prepare_head($object); @@ -724,6 +722,15 @@ else print ""; } + //Role + if (!empty($socid)) { + print '' . $langs->trans("Role") . ''; + print ''; + $contactType = $object->listeTypeContacts('external', '', 1); + print $form->multiselectarray('roles', $contactType); + print ''; + } + // Other attributes $parameters=array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1040,6 +1047,14 @@ else print ""; } + //Role + if (!empty($object->socid)) { + print '' . $langs->trans("Role") . ''; + print ''; + print $form->showRoles("roles", $object, 'edit' ,$object->roles); + print ''; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1238,6 +1253,13 @@ else print ''; } + if (!empty($object->socid)) { + print '' . $langs->trans("Roles") . ''; + print ''; + print $form->showRoles("roles", $object, 'view'); + print ''; + } + // Other attributes $cols = 3; $parameters=array('socid'=>$socid); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index db6ab29b802..d718a898f2d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -399,6 +399,14 @@ class Contact extends CommonObject } } + if (! $error) { + $result=$this->updateRoles(); + if ($result < 0) + { + $error++; + } + } + if (! $error && $this->user_id > 0) { $tmpobj = new User($this->db); @@ -861,6 +869,11 @@ class Contact extends CommonObject // fetch optionals attributes and labels $this->fetch_optionals(); + $resultRole=$this->fetchRoles(); + if ($resultRole<0) { + return $resultRole; + } + return 1; } else @@ -995,6 +1008,20 @@ class Contact extends CommonObject } } + if (! $error) + { + // Remove Roles + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error .= $this->db->lasterror(); + $errorflag=-1; + } + } + if (! $error) { // Remove category @@ -1458,14 +1485,13 @@ class Contact extends CommonObject * @return float|int * @throws Exception */ - public function fetchRole() + public function fetchRoles() { - global $langs; $error= 0; $num=0; - $sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle"; + $sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle, sc.rowid as contactroleid"; $sql.=" FROM ".MAIN_DB_PREFIX."societe_contacts as sc "; $sql.=" INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.=" ON tc.rowid = sc.fk_c_type_contact"; @@ -1482,11 +1508,13 @@ class Contact extends CommonObject if ($num > 0) { while ($obj = $this->db->fetch_object($resql)) { $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; - $this->roles[$this->id]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle)); + $libelle_element = $langs->trans('ContactDefault_'.$obj->element); + $this->roles[$obj->contactroleid]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>$libelle_element. ' - '.($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle)); } } } else { $error++; + $this->error=$this->db->lasterror(); $this->errors[]=$this->db->lasterror(); } @@ -1497,4 +1525,61 @@ class Contact extends CommonObject } } + /** + * Updates Roles + * + * @return float|int + * @throws Exception + */ + public function updateRoles() + { + global $conf; + + $error=0; + + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $result = $this->db->query($sql); + if (!$result) { + $this->errors[]=$this->db->lasterror().' sql='.$sql; + $error++; + } else { + if (count($this->roles)>0) { + foreach ($this->roles as $keyRoles => $valRoles) { + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_contacts"; + $sql .= " (entity,"; + $sql .= "date_creation,"; + $sql .= "fk_soc,"; + $sql .= "fk_c_type_contact,"; + $sql .= "fk_socpeople) "; + $sql .= " VALUES (" . $conf->entity . ","; + $sql .= "'" . $this->db->idate(dol_now()) . "',"; + $sql .= $this->socid . ", "; + $sql .= $valRoles . " , " ; + $sql .= $this->id; + $sql .= ")"; + dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + + $result = $this->db->query($sql); + if (!$result) + { + $this->errors[]=$this->db->lasterror().' sql='.$sql; + $error++; + } + } + } + } + if (empty($error)) { + $this->db->commit(); + return 1; + } else { + $this->error=implode(' ', $this->errors); + $this->db->rollback(); + return $error*-1; + } + } + } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b0db8b0affb..585d6db499d 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -84,6 +84,7 @@ $search_zip=GETPOST('search_zip', 'alpha'); $search_town=GETPOST('search_town', 'alpha'); $search_import_key=GETPOST("search_import_key", "alpha"); $search_country=GETPOST("search_country", 'intcomma'); +$search_roles=GETPOST("search_roles", 'array'); if ($search_status=='') $search_status=1; // always display active customer first @@ -242,6 +243,7 @@ if (empty($reshook)) $search_import_key=''; $toselect=''; $search_array_options=array(); + $search_roles=array(); } // Mass actions @@ -334,6 +336,9 @@ if (strlen($search_linkedin)) $sql.= natural_search('p.linkedin', $search_ if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); +if (count($search_roles)>0) { + $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; +} if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email); if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); @@ -438,6 +443,7 @@ if ($search_status != '') $param.='&search_status='.urlencode($search_status if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -510,6 +516,10 @@ if (! empty($conf->categorie->enabled)) $moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); $moreforfilter.='
'; } + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Roles'). ': '; + $moreforfilter.=$form->showRoles("search_roles", $objecttmp, 'edit', $search_roles); + $moreforfilter.='
'; } if ($moreforfilter) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0eea968ecd2..716b615f503 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1226,9 +1226,6 @@ abstract class CommonObject // phpcs:enable global $langs; - if (empty($order)) $order='position'; - if ($order == 'position') $order.=',code'; - $tab = array(); $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1262,11 +1259,11 @@ abstract class CommonObject { $obj = $this->db->fetch_object($resql); - $libelle_element = $langs->trans('ContactDefault_'.ucfirst($obj->element)); + $libelle_element = $langs->trans('ContactDefault_'.$obj->element); $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); if (empty($option)) $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; - else $tab[$obj->code]=$libelle_element.' - '.$libelle_type; + else $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; $i++; } return $tab; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5ee969a73a0..4eca1ef0f85 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6484,6 +6484,46 @@ class Form return 'ErrorBadValueForParameterRenderMode'; // Should not happened } + /** + * showContactRoles on view and edit mode + * + * @param string $htmlname Html component name and id + * @param Contact $contact Contact Obejct + * @param string $rendermode view, edit + * @param array $selected $key=>$val $val is selected Roles for input mode + * @return string String with contacts roles + */ + public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) + { + if ($rendermode === 'view') { + $toprint = array(); + foreach ($contact->roles as $key => $val) { + $toprint[] = '
  • ' . $val['label'] . '
  • '; + } + return '
      ' . implode(' ', $toprint) . '
    '; + } + + if ($rendermode === 'edit') + { + $contactType=$contact->listeTypeContacts('external', '', 1); + + if (count($selected)>0) { + $newselected=array(); + foreach($selected as $key=>$val) { + if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) { + $newselected[]=$val['id']; + } else { + break; + } + } + if (count($newselected)>0) $selected=$newselected; + } + return $this->multiselectarray($htmlname, $contactType, $selected); + } + + return 'ErrorBadValueForParameterRenderMode'; // Should not happened + } + /** * Show linked object block. diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index cfc1fcfb30f..14b20bbe46b 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -869,7 +869,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if ($search_status=='') $search_status=1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_addressphone = GETPOST("search_addressphone", 'alpha'); - $search_role = GETPOST("search_role", 'array'); + $search_roles = GETPOST("search_roles", 'array'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="t.lastname"; @@ -898,7 +898,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 'sc.role'=>array('label'=>"Role", 'checked'=>1, 'position'=>40), + 'sc.role'=>array('label'=>"Roles", 'checked'=>1, 'position'=>40), 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), ); // Extra fields @@ -929,7 +929,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { $search_status = ''; $search_name = ''; - $search_role = ''; + $search_roles = array(); $search_addressphone = ''; $search_array_options=array(); @@ -971,7 +971,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $param="socid=".urlencode($object->id); if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if (count($search_role)>0) $param.=implode('&search_role[]=', $search_role); + if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); if ($search_name != '') $param.='&search_name='.urlencode($search_name); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -982,14 +982,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; - if (count($search_role)>0) { - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_contacts as sc on (sc.fk_socpeople = t.rowid)"; - } $sql .= " WHERE t.fk_soc = ".$object->id; if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); - if (count($search_role)>0) { - $sql .= ' AND sc.fk_c_type_contact IN ('.implode(',',$search_role).')'; + if (count($search_roles)>0) { + $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } // Add where from extra fields $extrafieldsobjectkey=$contactstatic->table_element; @@ -1020,8 +1017,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($key, array('lastname','name'))) print ''; elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); elseif (in_array($key, array('role'))) { - $contactType=$contactstatic->listeTypeContacts('external', '', 1); - print $form->multiselectarray('search_role', $contactType, $search_role); + print $form->showRoles("search_roles", $contactstatic, 'edit', $search_roles); } print ''; } @@ -1052,9 +1048,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; if ($key == 'role') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) { + if (! empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } + if (! empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + } } // Extra fields $extrafieldsobjectkey=$contactstatic->table_element; @@ -1101,7 +1100,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); - $resultRole=$contactstatic->fetchRole(); + $resultRole=$contactstatic->fetchRoles(); if ($resultRole<0) { setEventMessages(null, $contactstatic->errors,'errors'); } @@ -1153,9 +1152,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (! empty($arrayfields['sc.role']['checked'])) { print ''; - foreach($contactstatic->roles as $key=>$val) { - print '
      '.implode(' ', $val['label']).'
    '; - } + print $form->showRoles("roles", $contactstatic, 'view'); print ''; } From 6c20fbafdf0c5811a5802da2c11468b0798a0359 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 3 Sep 2019 17:04:42 +0200 Subject: [PATCH 032/622] add trigger files --- htdocs/contact/card.php | 4 +- htdocs/contact/class/contact.class.php | 43 +++++++ htdocs/contact/list.php | 4 +- htdocs/core/class/commonobject.class.php | 42 +++--- htdocs/core/class/html.form.class.php | 41 ------ htdocs/core/class/html.formcompany.class.php | 64 +++++++--- htdocs/core/lib/company.lib.php | 6 +- ...rface_90_modSociete_ContactRoles.class.php | 120 ++++++++++++++++++ 8 files changed, 241 insertions(+), 83 deletions(-) create mode 100644 htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 20a61ec4e3e..5861cc71d38 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1051,7 +1051,7 @@ else if (!empty($object->socid)) { print '' . $langs->trans("Role") . ''; print ''; - print $form->showRoles("roles", $object, 'edit' ,$object->roles); + print $formcompany->showRoles("roles", $object, 'edit' ,$object->roles); print ''; } @@ -1256,7 +1256,7 @@ else if (!empty($object->socid)) { print '' . $langs->trans("Roles") . ''; print ''; - print $form->showRoles("roles", $object, 'view'); + print $formcompany->showRoles("roles", $object, 'view'); print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d718a898f2d..6b46e32f532 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1525,6 +1525,49 @@ class Contact extends CommonObject } } + /** + * Get Contact roles for a thirdparty + * + * @param string $element element type + * @return array|int + * @throws Exception + */ + public function getContactRoles($element = '') + { + $tab=array(); + + $sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; + $sql.= ", ".MAIN_DB_PREFIX."societe_contacts sc"; + $sql.= " WHERE sc.fk_soc =".$this->socid; + $sql.= " AND sc.fk_c_type_contact=tc.rowid"; + $sql.= " AND tc.element='".$element."'"; + $sql.= " AND tc.active=1"; + + dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $tab[]=array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact); + + $i++; + } + + return $tab; + } + else + { + $this->error=$this->db->error(); + dol_print_error($this->db); + return -1; + } + } + /** * Updates Roles * diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 585d6db499d..6b595a05860 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -36,6 +36,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "suppliers", "categories")); @@ -264,6 +265,7 @@ if ($search_priv < 0) $search_priv=''; $form=new Form($db); $formother=new FormOther($db); +$formcompany=new FormCompany($db); $contactstatic=new Contact($db); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); @@ -518,7 +520,7 @@ if (! empty($conf->categorie->enabled)) } $moreforfilter.='
    '; $moreforfilter.=$langs->trans('Roles'). ': '; - $moreforfilter.=$form->showRoles("search_roles", $objecttmp, 'edit', $search_roles); + $moreforfilter.=$formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles); $moreforfilter.='
    '; } if ($moreforfilter) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 716b615f503..1a1b5c597ce 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1224,9 +1224,10 @@ abstract class CommonObject public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '') { // phpcs:enable - global $langs; + global $langs, $conf; $tab = array(); + $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1251,27 +1252,36 @@ abstract class CommonObject dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - - $libelle_element = $langs->trans('ContactDefault_'.$obj->element); - $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); - if (empty($option)) $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; - else $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; - $i++; + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) { + if (strpos($obj->element, 'project')!==false) { + $element='projet'; + } elseif($obj->element=='contrat') { + $element='contract'; + } elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') { + $element='fournisseur'; + } elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') { + $element='fournisseur'; + } else { + $element=$obj->element; + } + if ($conf->{$element}->enabled) { + $libelle_element = $langs->trans('ContactDefault_' . $obj->element); + $transkey = "TypeContact_" . $this->element . "_" . $source . "_" . $obj->code; + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); + if (empty($option)) + $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; + else $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; + } + } } return $tab; } else { $this->error=$this->db->lasterror(); - //dol_print_error($this->db); return null; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4eca1ef0f85..f351a361d14 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6484,47 +6484,6 @@ class Form return 'ErrorBadValueForParameterRenderMode'; // Should not happened } - /** - * showContactRoles on view and edit mode - * - * @param string $htmlname Html component name and id - * @param Contact $contact Contact Obejct - * @param string $rendermode view, edit - * @param array $selected $key=>$val $val is selected Roles for input mode - * @return string String with contacts roles - */ - public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) - { - if ($rendermode === 'view') { - $toprint = array(); - foreach ($contact->roles as $key => $val) { - $toprint[] = '
  • ' . $val['label'] . '
  • '; - } - return '
      ' . implode(' ', $toprint) . '
    '; - } - - if ($rendermode === 'edit') - { - $contactType=$contact->listeTypeContacts('external', '', 1); - - if (count($selected)>0) { - $newselected=array(); - foreach($selected as $key=>$val) { - if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) { - $newselected[]=$val['id']; - } else { - break; - } - } - if (count($newselected)>0) $selected=$newselected; - } - return $this->multiselectarray($htmlname, $contactType, $selected); - } - - return 'ErrorBadValueForParameterRenderMode'; // Should not happened - } - - /** * Show linked object block. * diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 2207ab8ab2b..81b87b6f340 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -29,28 +29,11 @@ * Class to build HTML component for third parties management * Only common components are here. */ -class FormCompany + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +class FormCompany extends Form { - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -763,6 +746,45 @@ class FormCompany } } + /** + * showContactRoles on view and edit mode + * + * @param string $htmlname Html component name and id + * @param Contact $contact Contact Obejct + * @param string $rendermode view, edit + * @param array $selected $key=>$val $val is selected Roles for input mode + * @return string String with contacts roles + */ + public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) + { + if ($rendermode === 'view') { + $toprint = array(); + foreach ($contact->roles as $key => $val) { + $toprint[] = '
  • ' . $val['label'] . '
  • '; + } + return '
      ' . implode(' ', $toprint) . '
    '; + } + + if ($rendermode === 'edit') + { + $contactType=$contact->listeTypeContacts('external', '', 1); + if (count($selected)>0) { + $newselected=array(); + foreach($selected as $key=>$val) { + if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) { + $newselected[]=$val['id']; + } else { + break; + } + } + if (count($newselected)>0) $selected=$newselected; + } + return $this->multiselectarray($htmlname, $contactType, $selected); + } + + return 'ErrorBadValueForParameterRenderMode'; // Should not happened + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a select list with zip codes and their town diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 14b20bbe46b..331b03bacc4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -859,6 +859,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') global $user,$conf,$extrafields,$hookmanager; global $contextpage; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); $form = new Form($db); $optioncss = GETPOST('optioncss', 'alpha'); @@ -1017,7 +1019,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($key, array('lastname','name'))) print ''; elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); elseif (in_array($key, array('role'))) { - print $form->showRoles("search_roles", $contactstatic, 'edit', $search_roles); + print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); } print ''; } @@ -1152,7 +1154,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (! empty($arrayfields['sc.role']['checked'])) { print ''; - print $form->showRoles("roles", $contactstatic, 'view'); + print $formcompany->showRoles("roles", $contactstatic, 'view'); print ''; } diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php new file mode 100644 index 00000000000..8fba51e7a69 --- /dev/null +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -0,0 +1,120 @@ + + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2013 Cedric GROSS + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Bahfir Abbes + * + * 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/core/triggers/interface_50_modAgenda_ActionsAuto.class.php + * \ingroup agenda + * \brief Trigger file for agenda module + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggered functions for agenda module + */ +class InterfaceContactRoles extends DolibarrTriggers +{ + public $family = 'agenda'; + public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + + /** + * Version of the trigger + * @var string + */ + public $version = self::VERSION_DOLIBARR; + + /** + * @var string Image of the trigger + */ + public $picto = 'action'; + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: + * $object->actiontypecode (translation action code: AC_OTH, ...) + * $object->actionmsg (note, long text) + * $object->actionmsg2 (label, short text) + * $object->sendtoid (id of contact or array of ids) + * $object->socid (id of thirdparty) + * $object->fk_project + * $object->fk_element + * $object->elementtype + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + // Lors de la création d'un document, récupération des contacts et rôle associés à la société et association avec le document + if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' + || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') { + + if(!empty($object->socid) && $object->socid != '-1') { + global $db, $langs; + + $contactdefault = new Contact($this->db); + $contactdefault->socid=$object->socid; + $TContact = $contactdefault->getContactRoles(); + + // Le trigger est appelé avant que le core n'ajoute lui-même des contacts (contact propale, clone), il ne faut pas les associer avant sinon bug + $TContactAlreadyLinked = array(); + if ($object->id > 0) + { + $class = get_class($object); + $cloneFrom = new $class($db); + $r = $cloneFrom->fetch($object->id); + + if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1,'external'), $cloneFrom->liste_contact(-1,'internal')); + } + + foreach($TContact as $i => $infos) { + // Gestion du cas du clone + foreach ($TContactAlreadyLinked as $contactData) { + if($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]); + } + } + + $nb = 0; + foreach($TContact as $infos) { + // Gestion du cas spécifique de la création de propale avec sélection du contact, cela créé un bug si le contact est ajouté par le module contactdefault + $res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']); + if($res > 0) $nb++; + } + + if($nb > 0) { + setEventMessage($langs->trans('ContactAddedAutomatically', $nb)); + } + } + + dol_syslog( + "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id + ); + } + } +} From b70587c150a4a6cfa9a3438cb80736b6a958216a Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 4 Sep 2019 15:14:16 +0200 Subject: [PATCH 033/622] NEW check if a resource is in use in an event --- htdocs/admin/resource.php | 9 ++ htdocs/comm/action/card.php | 58 ++++++++++++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/resource.lang | 3 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/langs/fr_FR/resource.lang | 3 + htdocs/resource/element_resource.php | 132 +++++++++++++++++++++++++-- 7 files changed, 199 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index a5a0b5fbf3f..3dfd8e1e2c2 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -127,6 +127,15 @@ print ''; print ''; print ''; + +print ''; +print ''.$langs->trans('EnableResourceUsedInEventCheck').''; +print ''; +echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK'); +print ''; +print ''; +print ''; + print ''; print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index af54186e255..f7111ccf545 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -512,6 +512,64 @@ if ($action == 'update') $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error++; + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) . "'"; + $sql .= " WHERE ac.id != " . $object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " WHERE er.element_id = " . $object->id; + $sql .= " AND er.element_type = '" . $db->escape($object->element) . "'"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + if (! $error) { $db->begin(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f59f4449b8e..e06eafd81be 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1900,6 +1900,7 @@ ResourceSetup=Configuration of Resource module UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). DisabledResourceLinkUser=Disable feature to link a resource to users DisabledResourceLinkContact=Disable feature to link a resource to contacts +EnableResourceUsedInEventCheck=Enable feature to check if a resource is in use in an event ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both) diff --git a/htdocs/langs/en_US/resource.lang b/htdocs/langs/en_US/resource.lang index 33a5046e006..134cc4c87a3 100644 --- a/htdocs/langs/en_US/resource.lang +++ b/htdocs/langs/en_US/resource.lang @@ -34,3 +34,6 @@ IdResource=Id resource AssetNumber=Serial number ResourceTypeCode=Resource type code ImportDataset_resource_1=Resources + +ErrorResourcesAlreadyInUse=Some resources are in use +ErrorResourceUseInEvent=%s use in %s event \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 7407396835b..be8e67e3359 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1896,6 +1896,7 @@ ResourceSetup=Configuration du module Ressource UseSearchToSelectResource=Utilisez un champ avec auto-complétion pour choisir les ressources (plutôt qu'une liste déroulante). DisabledResourceLinkUser=Désactiver la fonctionnalité pour lier une ressource aux utilisateurs DisabledResourceLinkContact=Désactiver la fonctionnalité pour lier une ressource aux contacts/adresses +EnableResourceUsedInEventCheck=Activer la fonctionnalité de vérification d'une ressource déjà réservée lors d'un évènement ConfirmUnactivation=Confirmer réinitialisation du module OnMobileOnly=Sur petit écran (smartphone) uniquement DisableProspectCustomerType=Désactiver le type de tiers "Prospect + Client" (le tiers doit donc être un client potentiel ou un client, mais ne peut pas être les deux) diff --git a/htdocs/langs/fr_FR/resource.lang b/htdocs/langs/fr_FR/resource.lang index be7547b36da..5db22aedcbd 100644 --- a/htdocs/langs/fr_FR/resource.lang +++ b/htdocs/langs/fr_FR/resource.lang @@ -34,3 +34,6 @@ IdResource=id ressource AssetNumber=Numéro de série ResourceTypeCode=Code de type de ressource ImportDataset_resource_1=Ressources + +ErrorResourcesAlreadyInUse=Des ressources sont déjà occupées +ErrorResourceUseInEvent=%s occupée dans l'événement %s \ No newline at end of file diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 02565a23dd0..e55399f2da4 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -87,6 +87,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + $error = 0; + if ($action == 'add_element_resource' && ! $cancel) { $res = 0; @@ -100,8 +102,68 @@ if (empty($reshook)) { $objstat = fetchObjectByElement($element_id, $element, $element_ref); $objstat->element = $element; // For externals module, we need to keep @xx - $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); + + // TODO : add this check at update_linked_resource and when modifying event start or end date + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='dolresource' && intval($busy)==1) { + $eventDateStart = $objstat->datep; + $eventDateEnd = $objstat->datef; + $isFullDayEvent = intval($objstat->fulldayevent); + if (empty($eventDateEnd)) { + if ($isFullDayEvent) { + $eventDateStartArr = dol_getdate($eventDateStart); + $eventDateStart = dol_mktime(0, 0, 0, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + $eventDateEnd = dol_mktime(23, 59, 59, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + } + } + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) . "'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($objstat->element) . "'"; + $sql .= " WHERE er.resource_id = " . $resource_id; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $objstat->error = $db->lasterror(); + $objstat->errors[] = $objstat->error; + } else { + if ($db->num_rows($resql)>0) { + // already in use + $error++; + $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $objstat->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $objstat->errors[] = $objstat->error; + } + $db->free($resql); + } + } + + if (!$error) { + $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); + } } + if (! $error && $res > 0) { setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); @@ -123,18 +185,72 @@ if (empty($reshook)) $object->busy = $busy; $object->mandatory = $mandatory; - $result = $object->update_element_resource($user); + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='dolresource' && intval($object->busy)==1) { + $eventDateStart = $object->objelement->datep; + $eventDateEnd = $object->objelement->datef; + $isFullDayEvent = intval($objstat->fulldayevent); + if (empty($eventDateEnd)) { + if ($isFullDayEvent) { + $eventDateStartArr = dol_getdate($eventDateStart); + $eventDateStart = dol_mktime(0, 0, 0, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + $eventDateEnd = dol_mktime(23, 59, 59, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + } + } - if ($result >= 0) - { + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($object->resource_type) . "'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element_type) . "'"; + $sql .= " WHERE er.resource_id = " . $object->resource_id; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql)>0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $object->errors[] = $objstat->error; + } + $db->free($resql); + } + } + + if (!$error) { + $result = $object->update_element_resource($user); + if ($result < 0) $error++; + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); exit; } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } } } From f7fe3d2842993a7232f722adeafe301711a207c7 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 4 Sep 2019 16:30:55 +0200 Subject: [PATCH 034/622] Fix set var in context attribute instead of object attribute --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 5c2204dc216..a7a17c3f18a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1092,7 +1092,7 @@ class BonPrelevement extends CommonObject } $this->factures = $factures_prev_id; - $this->factures_prev = $factures_prev; + $this->context['factures_prev'] = $factures_prev; // Generation of SEPA file $this->filename $this->generate($format,$executiondate); From 4ef7e755ad56dc76eb2319f3a87a8fe819f20055 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 5 Sep 2019 09:29:40 +0200 Subject: [PATCH 035/622] FIX only check on busy resources before updating an event --- htdocs/comm/action/card.php | 7 ++++--- htdocs/resource/element_resource.php | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f7111ccf545..ed0ad19b96d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -524,9 +524,10 @@ if ($action == 'update') $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) . "'"; $sql .= " WHERE ac.id != " . $object->id; $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " WHERE er.element_id = " . $object->id; - $sql .= " AND er.element_type = '" . $db->escape($object->element) . "'"; + $sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . "element_resources"; + $sql .= " WHERE element_id = " . $object->id; + $sql .= " AND element_type = '" . $db->escape($object->element) . "'"; + $sql .= " AND busy = 1"; $sql .= ")"; $sql .= " AND er.busy = 1"; $sql .= " AND ("; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index e55399f2da4..07bcdb3fd99 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -202,6 +202,7 @@ if (empty($reshook)) $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($object->resource_type) . "'"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element_type) . "'"; $sql .= " WHERE er.resource_id = " . $object->resource_id; + $sql .= " AND ac.id != " . $object->element_id; $sql .= " AND er.busy = 1"; $sql .= " AND ("; From 9ed09db93cd5f1c263ba4b231fb046c618825fa4 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 5 Sep 2019 09:41:15 +0200 Subject: [PATCH 036/622] FIX replace "
    " by "
    " --- htdocs/comm/action/card.php | 2 +- htdocs/resource/element_resource.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index ed0ad19b96d..44d6b000efe 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -558,7 +558,7 @@ if ($action == 'update') $error++; $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; while ($obj = $db->fetch_object($resql)) { - $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); } $object->errors[] = $object->error; } diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 07bcdb3fd99..bb9a54a9bf0 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -151,7 +151,7 @@ if (empty($reshook)) $error++; $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; while ($obj = $db->fetch_object($resql)) { - $objstat->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $objstat->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); } $objstat->errors[] = $objstat->error; } @@ -232,7 +232,7 @@ if (empty($reshook)) $error++; $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; while ($obj = $db->fetch_object($resql)) { - $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); } $object->errors[] = $objstat->error; } From 815d0bbc20d7b49ed5adfb06b31d8503e604bd48 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 5 Sep 2019 11:57:12 +0200 Subject: [PATCH 037/622] FIX rename "dolresource" into "resource" for compatibility with PR 11822 --- htdocs/comm/action/card.php | 2 +- htdocs/resource/element_resource.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 44d6b000efe..c9a4f782b4d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -520,7 +520,7 @@ if ($action == 'update') $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'resource'"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) . "'"; $sql .= " WHERE ac.id != " . $object->id; $sql .= " AND er.resource_id IN ("; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index bb9a54a9bf0..b842ad6c832 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -105,7 +105,7 @@ if (empty($reshook)) // TODO : add this check at update_linked_resource and when modifying event start or end date // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='dolresource' && intval($busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='resource' && intval($busy)==1) { $eventDateStart = $objstat->datep; $eventDateEnd = $objstat->datef; $isFullDayEvent = intval($objstat->fulldayevent); @@ -185,7 +185,7 @@ if (empty($reshook)) $object->busy = $busy; $object->mandatory = $mandatory; - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='dolresource' && intval($object->busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='resource' && intval($object->busy)==1) { $eventDateStart = $object->objelement->datep; $eventDateEnd = $object->objelement->datef; $isFullDayEvent = intval($objstat->fulldayevent); From 6bb5860f62463dc8fe28c5621cc829529746287a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 5 Sep 2019 14:12:52 +0000 Subject: [PATCH 038/622] Fixing style errors. --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 55fef7d0185..b668ae0465f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7801,7 +7801,7 @@ abstract class CommonObject * @param string $type Type of category ('product', ...) * @return int < 0 si erreur, > 0 si ok */ - function cloneCategories($fromId, $toId, $type='') + function cloneCategories($fromId, $toId, $type = '') { $this->db->begin(); From 6902b2cbf22969c58202404c15521fa3bfa3f916 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 5 Sep 2019 16:14:15 +0200 Subject: [PATCH 039/622] fix function visibility thanks to stckler --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 55fef7d0185..0f8dd4f0c00 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7801,7 +7801,7 @@ abstract class CommonObject * @param string $type Type of category ('product', ...) * @return int < 0 si erreur, > 0 si ok */ - function cloneCategories($fromId, $toId, $type='') + public function cloneCategories($fromId, $toId, $type='') { $this->db->begin(); From cd96238adc0407213ce276e60f6d788933e9f0be Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 5 Sep 2019 14:19:35 +0000 Subject: [PATCH 040/622] Fixing style errors. --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0f8dd4f0c00..e395f3d4455 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7801,7 +7801,7 @@ abstract class CommonObject * @param string $type Type of category ('product', ...) * @return int < 0 si erreur, > 0 si ok */ - public function cloneCategories($fromId, $toId, $type='') + public function cloneCategories($fromId, $toId, $type = '') { $this->db->begin(); From d50114df649a0d7752f4a549e5d541da1dc27eeb Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 6 Sep 2019 09:20:18 +0200 Subject: [PATCH 041/622] mostlyDone --- htdocs/contact/class/contact.class.php | 2 +- ...rface_90_modSociete_ContactRoles.class.php | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 6b46e32f532..fad72d69637 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1544,7 +1544,7 @@ class Contact extends CommonObject $sql.= " AND tc.element='".$element."'"; $sql.= " AND tc.active=1"; - dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 8fba51e7a69..36a8274c602 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -71,16 +71,20 @@ class InterfaceContactRoles extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - // Lors de la création d'un document, récupération des contacts et rôle associés à la société et association avec le document + if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') { - if(!empty($object->socid) && $object->socid != '-1') { - global $db, $langs; + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc); + + if(!empty($socid) && $socid != '-1') { + global $db, $langs; + var_dump($socid); $contactdefault = new Contact($this->db); - $contactdefault->socid=$object->socid; - $TContact = $contactdefault->getContactRoles(); + $contactdefault->socid=$socid; + $TContact = $contactdefault->getContactRoles($object->element); // Le trigger est appelé avant que le core n'ajoute lui-même des contacts (contact propale, clone), il ne faut pas les associer avant sinon bug $TContactAlreadyLinked = array(); @@ -90,7 +94,7 @@ class InterfaceContactRoles extends DolibarrTriggers $cloneFrom = new $class($db); $r = $cloneFrom->fetch($object->id); - if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1,'external'), $cloneFrom->liste_contact(-1,'internal')); + if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal')); } foreach($TContact as $i => $infos) { @@ -111,10 +115,6 @@ class InterfaceContactRoles extends DolibarrTriggers setEventMessage($langs->trans('ContactAddedAutomatically', $nb)); } } - - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); } } } From e55c7bc378295bd6db964434bb6e8b604484f814 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 6 Sep 2019 11:22:22 +0200 Subject: [PATCH 042/622] Update llx_facture.sql --- htdocs/install/mysql/tables/llx_facture.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 742c63d0a6e..3c678699a7e 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -41,6 +41,7 @@ create table llx_facture date_pointoftax date DEFAULT NULL, -- date point of tax (for GB) date_valid date, -- date validation tms timestamp, -- date creation/modification + date_cloture datetime, -- date de cloture paye smallint DEFAULT 0 NOT NULL, amount double(24,8) DEFAULT 0 NOT NULL, remise_percent real DEFAULT 0, -- remise relative @@ -62,7 +63,8 @@ create table llx_facture fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- user validating - + fk_user_cloture integer, -- user closing + module_source varchar(32), -- name of module when invoice generated by a dedicated module (POS, ...) pos_source varchar(32), -- name of POS station when invoice is generated by a POS module fk_fac_rec_source integer, -- facture rec source From ead8d29ed32ecd8cc65ad90254e912a2dc8cf097 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 6 Sep 2019 11:32:46 +0200 Subject: [PATCH 043/622] Update 10.0.0-11.0.0.sql --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 64de0364139..065104164c9 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -47,7 +47,8 @@ ALTER TABLE llx_entrepot_extrafields ADD INDEX idx_entrepot_extrafields (fk_obje ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit; - +ALTER TABLE llx_facture ADD COLUMN date_cloture datetime DEFAULT NULL after date_valid; +ALTER TABLE llx_facture ADD COLUMN fk_user_cloture integer DEFAULT NULL after fk_user_valid; ALTER TABLE llx_c_shipment_mode ADD COLUMN entity integer DEFAULT 1 NOT NULL; @@ -105,4 +106,4 @@ create table llx_c_hrm_public_holiday )ENGINE=innodb; - \ No newline at end of file + From fc75d72290578cb488ba1480b75c1ed51122dbba Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 6 Sep 2019 11:35:52 +0200 Subject: [PATCH 044/622] Update list.php --- htdocs/compta/facture/list.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ad9e2295d6d..54f0fdb6d08 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -180,6 +180,7 @@ $arrayfields=array( 'rtp'=>array('label'=>"Rest", 'checked'=>0), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 'f.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); @@ -381,7 +382,7 @@ $sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_publ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; -$sql.= ' f.datec as date_creation, f.tms as date_update,'; +$sql.= ' f.datec as date_creation, f.tms as date_update, f.date_cloture as date_cloture,'; if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { $sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,'; @@ -495,7 +496,7 @@ if (! $sall) $sql.= ' f.localtax1, f.localtax2,'; $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut,'; - $sql.= ' f.datec, f.tms,'; + $sql.= ' f.datec, f.tms, f.date_cloture,'; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; $sql.= ' typent.code,'; $sql.= ' state.code_departement, state.nom,'; @@ -864,6 +865,12 @@ if ($resql) print ''; print ''; } + if (! empty($arrayfields['f.date_cloture']['checked'])) + { + print ''; + print ''; + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -930,6 +937,7 @@ if ($resql) print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (! empty($arrayfields['f.date_cloture']['checked'])) print_liste_field_titre($arrayfields['f.date_cloture']['label'], $_SERVER["PHP_SELF"], "f.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -1260,6 +1268,14 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } + // Date cloture + if (! empty($arrayfields['f.date_cloture']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Status if (! empty($arrayfields['f.fk_statut']['checked'])) { From 5d81b0271d6a6eedae203ddaaefcf6c598aaa16c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 6 Sep 2019 11:40:26 +0200 Subject: [PATCH 045/622] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 131f0ee90fd..73323235448 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2136,6 +2136,8 @@ class Facture extends CommonInvoice if ($this->paye != 1) { $this->db->begin(); + + $now=dol_now(); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); @@ -2144,6 +2146,8 @@ class Facture extends CommonInvoice if (! $close_code) $sql.= ', paye=1'; if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; + $sql.= ', fk_user_cloture = '.$user->id; + $sql.= ", date_cloture = '".$this->db->idate($now)."'"; $sql.= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); @@ -2196,6 +2200,8 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; + $sql.= ' date_cloture as datecloture,'; + $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture'; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); @@ -3521,7 +3527,8 @@ class Facture extends CommonInvoice public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; - $sql.= ' fk_user_author, fk_user_valid'; + $sql.= ' date_cloture as datecloture,'; + $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; $sql.= ' WHERE c.rowid = '.$id; @@ -3536,7 +3543,7 @@ class Facture extends CommonInvoice { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) { @@ -3544,9 +3551,17 @@ class Facture extends CommonInvoice $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); // Should be in log table + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_cloture = $this->db->jdate($obj->datecloture); } $this->db->free($result); } From 61d432865b6b42707323b10c8192d64770c9c8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 7 Sep 2019 14:33:36 +0200 Subject: [PATCH 046/622] wip --- ...face_99_modZapier_ZapierTriggers.class.php | 309 ++++++++---------- 1 file changed, 136 insertions(+), 173 deletions(-) diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php index ae08b55d651..9d24af321e7 100644 --- a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php +++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php @@ -54,7 +54,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers $this->db = $db; $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = "demo"; + $this->family = "technic"; $this->description = "Zapier triggers."; // 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; @@ -104,8 +104,8 @@ class InterfaceZapierTriggers extends DolibarrTriggers $logtriggeraction = false; if ($action!='') { $actions = explode('_', $action); - $sql = 'SELECT rowid, url FROM '.MAIN_DB_PREFIX.'zapier_hook WHERE'; - $sql .= ' module="'.$db->escape(strtolower($actions[0])).'" AND action="'.$db->escape(strtolower($actions[1])).'"'; + $sql = 'SELECT rowid, url FROM '.MAIN_DB_PREFIX.'zapier_hook'; + $sql .= ' WHERE module="'.$db->escape(strtolower($actions[0])).'" AND action="'.$db->escape(strtolower($actions[1])).'"'; //setEventMessages($sql, null); } @@ -119,28 +119,11 @@ class InterfaceZapierTriggers extends DolibarrTriggers //case 'USER_DELETE': //case 'USER_SETINGROUP': //case 'USER_REMOVEFROMGROUP': - - case 'USER_LOGIN': - //$logtriggeraction = true; - break; - case 'USER_LOGIN_FAILED': - //$logtriggeraction = true; - break; - case 'USER_LOGOUT': - //$logtriggeraction = true; - break; + // case 'USER_LOGIN': + // case 'USER_LOGIN_FAILED': + // case 'USER_LOGOUT': // Warning: To increase performances, this action is triggered only if constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. - //case 'USER_UPDATE_SESSION': - - case 'DOSSIERISOLATION_CREATE': - //$logtriggeraction = true; - break; - case 'DOSSIERISOLATION_MODIFY': - //$logtriggeraction = true; - break; - case 'DOSSIERISOLATION_DELETE': - //$logtriggeraction = true; - break; + // // case 'USER_UPDATE_SESSION': // Actions case 'ACTION_MODIFY': @@ -200,20 +183,20 @@ class InterfaceZapierTriggers extends DolibarrTriggers case 'CONTACT_ENABLEDISABLE': // Products - case 'PRODUCT_CREATE': - case 'PRODUCT_MODIFY': - case 'PRODUCT_DELETE': - case 'PRODUCT_PRICE_MODIFY': - case 'PRODUCT_SET_MULTILANGS': - case 'PRODUCT_DEL_MULTILANGS': + // case 'PRODUCT_CREATE': + // case 'PRODUCT_MODIFY': + // case 'PRODUCT_DELETE': + // case 'PRODUCT_PRICE_MODIFY': + // case 'PRODUCT_SET_MULTILANGS': + // case 'PRODUCT_DEL_MULTILANGS': //Stock mouvement - case 'STOCK_MOVEMENT': + // case 'STOCK_MOVEMENT': //MYECMDIR - case 'MYECMDIR_DELETE': - case 'MYECMDIR_CREATE': - case 'MYECMDIR_MODIFY': + // case 'MYECMDIR_DELETE': + // case 'MYECMDIR_CREATE': + // case 'MYECMDIR_MODIFY': // Customer orders case 'ORDER_CREATE': @@ -240,165 +223,145 @@ class InterfaceZapierTriggers extends DolibarrTriggers case 'LINEORDER_DELETE': // Supplier orders - case 'ORDER_SUPPLIER_CREATE': - case 'ORDER_SUPPLIER_CLONE': - case 'ORDER_SUPPLIER_VALIDATE': - case 'ORDER_SUPPLIER_DELETE': - case 'ORDER_SUPPLIER_APPROVE': - case 'ORDER_SUPPLIER_REFUSE': - case 'ORDER_SUPPLIER_CANCEL': - case 'ORDER_SUPPLIER_SENTBYMAIL': - case 'ORDER_SUPPLIER_DISPATCH': - case 'LINEORDER_SUPPLIER_DISPATCH': - case 'LINEORDER_SUPPLIER_CREATE': - case 'LINEORDER_SUPPLIER_UPDATE': + // case 'ORDER_SUPPLIER_CREATE': + // case 'ORDER_SUPPLIER_CLONE': + // case 'ORDER_SUPPLIER_VALIDATE': + // case 'ORDER_SUPPLIER_DELETE': + // case 'ORDER_SUPPLIER_APPROVE': + // case 'ORDER_SUPPLIER_REFUSE': + // case 'ORDER_SUPPLIER_CANCEL': + // case 'ORDER_SUPPLIER_SENTBYMAIL': + // case 'ORDER_SUPPLIER_DISPATCH': + // case 'LINEORDER_SUPPLIER_DISPATCH': + // case 'LINEORDER_SUPPLIER_CREATE': + // case 'LINEORDER_SUPPLIER_UPDATE': // Proposals - case 'PROPAL_CREATE': - case 'PROPAL_CLONE': - case 'PROPAL_MODIFY': - case 'PROPAL_VALIDATE': - case 'PROPAL_SENTBYMAIL': - case 'PROPAL_CLOSE_SIGNED': - //$logtriggeraction = true; - break; - case 'PROPAL_CLOSE_REFUSED': - //$logtriggeraction = true; - break; - case 'PROPAL_DELETE': - //$logtriggeraction = true; - break; - case 'LINEPROPAL_INSERT': - case 'LINEPROPAL_UPDATE': - case 'LINEPROPAL_DELETE': + // case 'PROPAL_CREATE': + // case 'PROPAL_CLONE': + // case 'PROPAL_MODIFY': + // case 'PROPAL_VALIDATE': + // case 'PROPAL_SENTBYMAIL': + // case 'PROPAL_CLOSE_SIGNED': + // case 'PROPAL_CLOSE_REFUSED': + // case 'PROPAL_DELETE': + // case 'LINEPROPAL_INSERT': + // case 'LINEPROPAL_UPDATE': + // case 'LINEPROPAL_DELETE': // SupplierProposal - case 'SUPPLIER_PROPOSAL_CREATE': - case 'SUPPLIER_PROPOSAL_CLONE': - case 'SUPPLIER_PROPOSAL_MODIFY': - case 'SUPPLIER_PROPOSAL_VALIDATE': - case 'SUPPLIER_PROPOSAL_SENTBYMAIL': - case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED': - case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED': - case 'SUPPLIER_PROPOSAL_DELETE': - case 'LINESUPPLIER_PROPOSAL_INSERT': - case 'LINESUPPLIER_PROPOSAL_UPDATE': - case 'LINESUPPLIER_PROPOSAL_DELETE': + // case 'SUPPLIER_PROPOSAL_CREATE': + // case 'SUPPLIER_PROPOSAL_CLONE': + // case 'SUPPLIER_PROPOSAL_MODIFY': + // case 'SUPPLIER_PROPOSAL_VALIDATE': + // case 'SUPPLIER_PROPOSAL_SENTBYMAIL': + // case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED': + // case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED': + // case 'SUPPLIER_PROPOSAL_DELETE': + // case 'LINESUPPLIER_PROPOSAL_INSERT': + // case 'LINESUPPLIER_PROPOSAL_UPDATE': + // case 'LINESUPPLIER_PROPOSAL_DELETE': // Contracts - case 'CONTRACT_CREATE': - case 'CONTRACT_ACTIVATE': - case 'CONTRACT_CANCEL': - case 'CONTRACT_CLOSE': - case 'CONTRACT_DELETE': - case 'LINECONTRACT_INSERT': - case 'LINECONTRACT_UPDATE': - case 'LINECONTRACT_DELETE': + // case 'CONTRACT_CREATE': + // case 'CONTRACT_ACTIVATE': + // case 'CONTRACT_CANCEL': + // case 'CONTRACT_CLOSE': + // case 'CONTRACT_DELETE': + // case 'LINECONTRACT_INSERT': + // case 'LINECONTRACT_UPDATE': + // case 'LINECONTRACT_DELETE': // Bills - case 'BILL_CREATE': - //$logtriggeraction = true; - break; - case 'BILL_CLONE': - case 'BILL_MODIFY': - case 'BILL_VALIDATE': - case 'BILL_UNVALIDATE': - //$logtriggeraction = true; - break; - case 'BILL_SENTBYMAIL': - //$logtriggeraction = true; - break; - case 'BILL_CANCEL': - //$logtriggeraction = true; - break; - case 'BILL_DELETE': - //$logtriggeraction = true; - break; - case 'BILL_PAYED': - case 'LINEBILL_INSERT': - case 'LINEBILL_UPDATE': - case 'LINEBILL_DELETE': + // case 'BILL_CREATE': + // case 'BILL_CLONE': + // case 'BILL_MODIFY': + // case 'BILL_VALIDATE': + // case 'BILL_UNVALIDATE': + // case 'BILL_SENTBYMAIL': + // case 'BILL_CANCEL': + // case 'BILL_DELETE': + // case 'BILL_PAYED': + // case 'LINEBILL_INSERT': + // case 'LINEBILL_UPDATE': + // case 'LINEBILL_DELETE': //Supplier Bill - case 'BILL_SUPPLIER_CREATE': - case 'BILL_SUPPLIER_UPDATE': - case 'BILL_SUPPLIER_DELETE': - case 'BILL_SUPPLIER_PAYED': - case 'BILL_SUPPLIER_UNPAYED': - case 'BILL_SUPPLIER_VALIDATE': - case 'BILL_SUPPLIER_UNVALIDATE': - case 'LINEBILL_SUPPLIER_CREATE': - case 'LINEBILL_SUPPLIER_UPDATE': - case 'LINEBILL_SUPPLIER_DELETE': + // case 'BILL_SUPPLIER_CREATE': + // case 'BILL_SUPPLIER_UPDATE': + // case 'BILL_SUPPLIER_DELETE': + // case 'BILL_SUPPLIER_PAYED': + // case 'BILL_SUPPLIER_UNPAYED': + // case 'BILL_SUPPLIER_VALIDATE': + // case 'BILL_SUPPLIER_UNVALIDATE': + // case 'LINEBILL_SUPPLIER_CREATE': + // case 'LINEBILL_SUPPLIER_UPDATE': + // case 'LINEBILL_SUPPLIER_DELETE': - // Payments - case 'PAYMENT_CUSTOMER_CREATE': - case 'PAYMENT_SUPPLIER_CREATE': - case 'PAYMENT_ADD_TO_BANK': - case 'PAYMENT_DELETE': + // Payments + // case 'PAYMENT_CUSTOMER_CREATE': + // case 'PAYMENT_SUPPLIER_CREATE': + // case 'PAYMENT_ADD_TO_BANK': + // case 'PAYMENT_DELETE': - // Online - case 'PAYMENT_PAYBOX_OK': - case 'PAYMENT_PAYPAL_OK': - case 'PAYMENT_STRIPE_OK': + // Online + // case 'PAYMENT_PAYBOX_OK': + // case 'PAYMENT_PAYPAL_OK': + // case 'PAYMENT_STRIPE_OK': - // Donation - case 'DON_CREATE': - case 'DON_UPDATE': - case 'DON_DELETE': + // Donation + // case 'DON_CREATE': + // case 'DON_UPDATE': + // case 'DON_DELETE': - // Interventions - case 'FICHINTER_CREATE': - case 'FICHINTER_MODIFY': - case 'FICHINTER_VALIDATE': - case 'FICHINTER_DELETE': - case 'LINEFICHINTER_CREATE': - case 'LINEFICHINTER_UPDATE': - case 'LINEFICHINTER_DELETE': + // Interventions + // case 'FICHINTER_CREATE': + // case 'FICHINTER_MODIFY': + // case 'FICHINTER_VALIDATE': + // case 'FICHINTER_DELETE': + // case 'LINEFICHINTER_CREATE': + // case 'LINEFICHINTER_UPDATE': + // case 'LINEFICHINTER_DELETE': - // Members - case 'MEMBER_CREATE': - case 'MEMBER_VALIDATE': - case 'MEMBER_SUBSCRIPTION': - case 'MEMBER_MODIFY': - case 'MEMBER_NEW_PASSWORD': - case 'MEMBER_RESILIATE': - case 'MEMBER_DELETE': + // Members + // case 'MEMBER_CREATE': + // case 'MEMBER_VALIDATE': + // case 'MEMBER_SUBSCRIPTION': + // case 'MEMBER_MODIFY': + // case 'MEMBER_NEW_PASSWORD': + // case 'MEMBER_RESILIATE': + // case 'MEMBER_DELETE': - // Categories - case 'CATEGORY_CREATE': - case 'CATEGORY_MODIFY': - case 'CATEGORY_DELETE': - case 'CATEGORY_SET_MULTILANGS': + // Categories + // case 'CATEGORY_CREATE': + // case 'CATEGORY_MODIFY': + // case 'CATEGORY_DELETE': + // case 'CATEGORY_SET_MULTILANGS': - // Projects - case 'PROJECT_CREATE': - case 'PROJECT_MODIFY': - case 'PROJECT_DELETE': + // Projects + // case 'PROJECT_CREATE': + // case 'PROJECT_MODIFY': + // case 'PROJECT_DELETE': - // Project tasks - case 'TASK_CREATE': - case 'TASK_MODIFY': - case 'TASK_DELETE': + // Project tasks + // case 'TASK_CREATE': + // case 'TASK_MODIFY': + // case 'TASK_DELETE': - // Task time spent - case 'TASK_TIMESPENT_CREATE': - case 'TASK_TIMESPENT_MODIFY': - case 'TASK_TIMESPENT_DELETE': + // Task time spent + // case 'TASK_TIMESPENT_CREATE': + // case 'TASK_TIMESPENT_MODIFY': + // case 'TASK_TIMESPENT_DELETE': - // Shipping - case 'SHIPPING_CREATE': - case 'SHIPPING_MODIFY': - case 'SHIPPING_VALIDATE': - case 'SHIPPING_SENTBYMAIL': - case 'SHIPPING_BILLED': - case 'SHIPPING_CLOSED': - case 'SHIPPING_REOPEN': - //$logtriggeraction = true; - break; - case 'SHIPPING_DELETE': - //$logtriggeraction = true; - break; + // Shipping + // case 'SHIPPING_CREATE': + // case 'SHIPPING_MODIFY': + // case 'SHIPPING_VALIDATE': + // case 'SHIPPING_SENTBYMAIL': + // case 'SHIPPING_BILLED': + // case 'SHIPPING_CLOSED': + // case 'SHIPPING_REOPEN': + // case 'SHIPPING_DELETE': } if ($logtriggeraction) { dol_syslog("Trigger '" . $this->name . "' for action '.$action.' launched by " . __FILE__ . " id=" . $object->id); From bd4c9a64a868f17b58c37a26a7333377e5a0b601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 7 Sep 2019 14:48:25 +0200 Subject: [PATCH 047/622] wip --- htdocs/comm/action/class/actioncomm.class.php | 3 +- .../action/class/api_agendaevents.class.php | 33 ++++++++++--------- htdocs/contact/class/contact.class.php | 3 +- htdocs/contrat/class/api_contracts.class.php | 2 +- htdocs/societe/class/api_contacts.class.php | 7 ++-- .../societe/class/api_thirdparties.class.php | 7 ++-- htdocs/societe/class/societe.class.php | 3 +- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 12926f9b360..4da7686b0a2 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1637,7 +1637,7 @@ class ActionComm extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int >0 if ok */ public function initAsSpecimen() { @@ -1669,6 +1669,7 @@ class ActionComm extends CommonObject $this->userownerid=$user->id; $this->userassigned[$user->id]=array('id'=>$user->id, 'transparency'=> 1); + return 1; } /** diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 833f97b3b6b..1109112284a 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -64,25 +64,28 @@ class AgendaEvents extends DolibarrApi public function get($id) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { - throw new RestException(401, "Insuffisant rights to read an event"); + throw new RestException(401, "Insufficient rights to read an event"); + } + if ($id == 0) { + $result = $this->actioncomm->initAsSpecimen(); + } else { + $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetchObjectLinked(); + } } - - $result = $this->actioncomm->fetch($id); if ( ! $result ) { throw new RestException(404, 'Agenda Events not found'); } if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { - throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + throw new RestException(401, "Insufficient rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - - $result = $this->actioncomm->fetch_optionals(); - - $this->actioncomm->fetchObjectLinked(); return $this->_cleanObjectDatas($this->actioncomm); } @@ -106,7 +109,7 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { - throw new RestException(401, "Insuffisant rights to read events"); + throw new RestException(401, "Insufficient rights to read events"); } // case of external user @@ -191,10 +194,10 @@ class AgendaEvents extends DolibarrApi public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { - throw new RestException(401, "Insuffisant rights to create your Agenda Event"); + throw new RestException(401, "Insufficient rights to create your Agenda Event"); } if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { - throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } // Check mandatory fields @@ -230,10 +233,10 @@ class AgendaEvents extends DolibarrApi public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { - throw new RestException(401, "Insuffisant rights to create your Agenda Event"); + throw new RestException(401, "Insufficient rights to create your Agenda Event"); } if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { - throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } $result = $this->actioncomm->fetch($id); @@ -266,13 +269,13 @@ class AgendaEvents extends DolibarrApi public function delete($id) { if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { - throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); + throw new RestException(401, "Insufficient rights to delete your Agenda Event"); } $result = $this->actioncomm->fetch($id); if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { - throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } if( ! $result ) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ebfafa698b7..177f2dd2e93 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1288,7 +1288,7 @@ class Contact extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int >0 if ok */ public function initAsSpecimen() { @@ -1325,6 +1325,7 @@ class Contact extends CommonObject $this->socid = $socid; $this->statut=1; + return 1; } /** diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 194e145210f..d49214dfb4d 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -187,7 +187,7 @@ class Contracts extends DolibarrApi public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401, "Insuffisant rights"); + throw new RestException(401, "Insufficient rights"); } // Check mandatory fields $result = $this->_validate($request_data); diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 38dfdf71fd8..b2adc8ce5ff 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -74,8 +74,11 @@ class Contacts extends DolibarrApi { throw new RestException(401, 'No permission to read contacts'); } - - $result = $this->contact->fetch($id); + if ($id ==0) { + $result = $this->contact->intiAsSpecimen(); + } else { + $result = $this->contact->fetch($id); + } if (!$result) { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ddb19c563fe..919961b4f8f 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -76,8 +76,11 @@ class Thirdparties extends DolibarrApi if(! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - - $result = $this->company->fetch($id); + if ($id ==0) { + $result = $this->company->intiAsSpecimen(); + } else { + $result = $this->company->fetch($id); + } if( ! $result ) { throw new RestException(404, 'Thirdparty not found'); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 26ad0c6bed9..86408c482cc 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3539,7 +3539,7 @@ class Societe extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int >0 if ok */ public function initAsSpecimen() { @@ -3586,6 +3586,7 @@ class Societe extends CommonObject $this->idprof4='idprof4'; $this->idprof5='idprof5'; $this->idprof6='idprof6'; + return 1; } /** From 4054ebaf27da13e7d607d232997aba35d8071796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 7 Sep 2019 15:12:07 +0200 Subject: [PATCH 048/622] wip --- htdocs/core/modules/modZapier.class.php | 10 +++++--- .../mysql/tables}/llx_zapier_hook.key.sql | 6 ++--- .../mysql/tables}/llx_zapier_hook.sql | 24 +++++++++--------- .../tables}/llx_zapier_hook_extrafields.sql | 4 +-- .../img/{zapier.png => object_zapier.png} | Bin .../zapier/img/object_zapierfordolibarr.png | Bin 360 -> 0 bytes 6 files changed, 23 insertions(+), 21 deletions(-) rename htdocs/{zapier/sql => install/mysql/tables}/llx_zapier_hook.key.sql (66%) rename htdocs/{zapier/sql => install/mysql/tables}/llx_zapier_hook.sql (68%) rename htdocs/{zapier/sql => install/mysql/tables}/llx_zapier_hook_extrafields.sql (93%) rename htdocs/zapier/img/{zapier.png => object_zapier.png} (100%) delete mode 100644 htdocs/zapier/img/object_zapierfordolibarr.png diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index 7f7ee47ba1e..da6a8aa1547 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -67,7 +67,7 @@ class modZapier extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'technic'; + $this->picto = 'zapier@zapier'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( // Set this to 1 if module has its own trigger directory (core/triggers) @@ -109,7 +109,9 @@ class modZapier extends DolibarrModules // Example: this->dirs = array("/zapier/temp","/zapier/subdir"); $this->dirs = array("/zapier/temp"); // Config pages. Put here list of php page, stored into zapier/admin directory, to use to setup module. - $this->config_page_url = array("setup.php@zapier"); + $this->config_page_url = array( + // "setup.php@zapier" + ); // Dependencies // A condition to hide module $this->hidden = false; @@ -119,7 +121,7 @@ class modZapier extends DolibarrModules $this->requiredby = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->conflictwith = array(); - $this->langfiles = array("zapier@zapier"); + $this->langfiles = array("zapier"); // Minimum version of PHP required by module //$this->phpmin = array(5, 5); // Minimum version of Dolibarr required by module @@ -148,7 +150,7 @@ class modZapier extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ if (! isset($conf->zapier) || ! isset($conf->zapier->enabled)) { - $conf->zapier=new stdClass(); + $conf->zapier = new stdClass(); $conf->zapier->enabled=0; } // Array to add new pages in new tabs diff --git a/htdocs/zapier/sql/llx_zapier_hook.key.sql b/htdocs/install/mysql/tables/llx_zapier_hook.key.sql similarity index 66% rename from htdocs/zapier/sql/llx_zapier_hook.key.sql rename to htdocs/install/mysql/tables/llx_zapier_hook.key.sql index d707e6bba1a..4bce26ae0ea 100644 --- a/htdocs/zapier/sql/llx_zapier_hook.key.sql +++ b/htdocs/install/mysql/tables/llx_zapier_hook.key.sql @@ -14,9 +14,9 @@ -- along with this program. If not, see http://www.gnu.org/licenses/. ---ALTER TABLE llx_zapierfordolibarr_hook ADD INDEX idx_fieldobject (fieldobject); +--ALTER TABLE llx_zapier_hook ADD INDEX idx_fieldobject (fieldobject); ---ALTER TABLE llx_zapierfordolibarr_hook ADD UNIQUE INDEX uk_zapierfordolibarr_hook_fieldxy(fieldx, fieldy); +--ALTER TABLE llx_zapier_hook ADD UNIQUE INDEX uk_zapier_hook_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_zapierfordolibarr_hook ADD CONSTRAINT llx_zapierfordolibarr_hook_fk_field FOREIGN KEY (fk_field) REFERENCES llx_zapierfordolibarr_myotherobject(rowid); +--ALTER TABLE llx_zapier_hook ADD CONSTRAINT llx_zapier_hook_fk_field FOREIGN KEY (fk_field) REFERENCES llx_zapier_myotherobject(rowid); diff --git a/htdocs/zapier/sql/llx_zapier_hook.sql b/htdocs/install/mysql/tables/llx_zapier_hook.sql similarity index 68% rename from htdocs/zapier/sql/llx_zapier_hook.sql rename to htdocs/install/mysql/tables/llx_zapier_hook.sql index 829ec2bfdc4..27d56352bff 100644 --- a/htdocs/zapier/sql/llx_zapier_hook.sql +++ b/htdocs/install/mysql/tables/llx_zapier_hook.sql @@ -14,16 +14,16 @@ -- along with this program. If not, see http://www.gnu.org/licenses/. -CREATE TABLE llx_zapierfordolibarr_hook( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, - url varchar(255), - event varchar(255), - module varchar(128), - action varchar(128), - status integer, - date_creation DATETIME NOT NULL, +CREATE TABLE llx_zapier_hook( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + url varchar(255), + event varchar(255), + module varchar(128), + action varchar(128), + status integer, + date_creation DATETIME NOT NULL, fk_user integer NOT NULL, - tms TIMESTAMP NOT NULL, - import_key varchar(14) -) ENGINE=innodb; \ No newline at end of file + tms TIMESTAMP NOT NULL, + import_key varchar(14) +) ENGINE=innodb; diff --git a/htdocs/zapier/sql/llx_zapier_hook_extrafields.sql b/htdocs/install/mysql/tables/llx_zapier_hook_extrafields.sql similarity index 93% rename from htdocs/zapier/sql/llx_zapier_hook_extrafields.sql rename to htdocs/install/mysql/tables/llx_zapier_hook_extrafields.sql index c840007412b..09fef4cc399 100644 --- a/htdocs/zapier/sql/llx_zapier_hook_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_zapier_hook_extrafields.sql @@ -13,11 +13,11 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see http://www.gnu.org/licenses/. -create table llx_zapierfordolibarr_hook_extrafields +create table llx_zapier_hook_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_object integer NOT NULL, - import_key varchar(14) -- import key + import_key varchar(14) -- import key ) ENGINE=innodb; diff --git a/htdocs/zapier/img/zapier.png b/htdocs/zapier/img/object_zapier.png similarity index 100% rename from htdocs/zapier/img/zapier.png rename to htdocs/zapier/img/object_zapier.png diff --git a/htdocs/zapier/img/object_zapierfordolibarr.png b/htdocs/zapier/img/object_zapierfordolibarr.png deleted file mode 100644 index 5a307bfc62f85df909a3cf024f27ee87d44be275..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt)eIT^vI+ zChono-m4{0gyqBiz=Ju)w^;&N<{#X1a0!1>bC%GsW3bBL=<%|p84;9-@5SwA|2OIEL% zb=QtBT0T9C&(LA{syqXqqW_DHn`b;(x5}@uA-g2{Ncy)Mhpp~Sy0eY()*3IP6|4C4 z(mDEHWvtPCEP7WZe7{4e?P9&>AE%^j|Mz!&9rL?{G_w^d>;^y&GkCiCxvX Date: Sun, 8 Sep 2019 20:05:13 +0200 Subject: [PATCH 049/622] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 1b516e1c94e..28667cb047f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -581,6 +581,7 @@ class Adherent extends CommonObject $sql.= ", fk_adherent_type = ".$this->db->escape($this->typeid); $sql.= ", morphy = '".$this->db->escape($this->morphy)."'"; $sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null"); + if ($this->socid) $sql.= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a thirdpart if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription if ($this->datevalid) $sql.= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest From a83c0670811683075c684ff07d92dbeccb79475e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 8 Sep 2019 20:08:32 +0200 Subject: [PATCH 050/622] Update card.php --- htdocs/adherents/card.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5836bf48332..d443eb6e462 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -866,6 +866,18 @@ else $object->country_code=$tmparray['code']; $object->country=$tmparray['label']; } + + if (!empty($socid)) { +$object = new Societe($db); +if ($socid > 0) $object->fetch($socid); + +if (! ($object->id > 0)) +{ + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; +} + } $adht = new AdherentType($db); @@ -905,6 +917,7 @@ else print '
    '; print ''; print ''; + print ''; if ($backtopage) print ''; dol_fiche_head(''); From 1368236d29c060e59235ef88b9c30f2ff7ac2ae5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 8 Sep 2019 20:15:05 +0200 Subject: [PATCH 051/622] Update card.php --- htdocs/societe/card.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ab224245de8..2d26747df32 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2664,6 +2664,16 @@ else { print ''."\n"; } + + if (! empty($conf->adherent->enabled)) + { + $adh = new Adherent($db); + $result=$adh->fetch('','',$object->id); + if (!$result && $object->client == 1) + { + print ''.$langs->trans("NewMember").''; + } + } if ($user->rights->societe->supprimer) { From e37875f70a597e011514b233d5dcaded2a0851be Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 8 Sep 2019 20:16:05 +0200 Subject: [PATCH 052/622] Update card.php --- htdocs/societe/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2d26747df32..ee6ca0288ef 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -47,7 +47,8 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -$langs->loadLangs(array("companies","commercial","bills","banks","users")); +$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users")); +if (! empty($conf->adherent->enabled)) $langs->load("members"); if (! empty($conf->categorie->enabled)) $langs->load("categories"); if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); if (! empty($conf->notification->enabled)) $langs->load("mails"); From 2e63e7bc27ffcd53e9c3c89764244613451ed019 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 8 Sep 2019 18:17:51 +0000 Subject: [PATCH 053/622] Fixing style errors. --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ee6ca0288ef..8c1db93c53b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2669,11 +2669,11 @@ else if (! empty($conf->adherent->enabled)) { $adh = new Adherent($db); - $result=$adh->fetch('','',$object->id); + $result=$adh->fetch('', '', $object->id); if (!$result && $object->client == 1) { print ''.$langs->trans("NewMember").''; - } + } } if ($user->rights->societe->supprimer) From 66611f40971344a15d0118cd7051a39c3de0e445 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 9 Sep 2019 09:29:43 +0200 Subject: [PATCH 054/622] FIX rename "resource" (reserved) by "dolresource" --- htdocs/comm/action/card.php | 2 +- htdocs/resource/element_resource.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c9a4f782b4d..44d6b000efe 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -520,7 +520,7 @@ if ($action == 'update') $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'resource'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) . "'"; $sql .= " WHERE ac.id != " . $object->id; $sql .= " AND er.resource_id IN ("; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index b842ad6c832..bb9a54a9bf0 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -105,7 +105,7 @@ if (empty($reshook)) // TODO : add this check at update_linked_resource and when modifying event start or end date // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='resource' && intval($busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='dolresource' && intval($busy)==1) { $eventDateStart = $objstat->datep; $eventDateEnd = $objstat->datef; $isFullDayEvent = intval($objstat->fulldayevent); @@ -185,7 +185,7 @@ if (empty($reshook)) $object->busy = $busy; $object->mandatory = $mandatory; - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='resource' && intval($object->busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='dolresource' && intval($object->busy)==1) { $eventDateStart = $object->objelement->datep; $eventDateEnd = $object->objelement->datef; $isFullDayEvent = intval($objstat->fulldayevent); From 617e430998034d71b59b5b864f5a7e0911be9b9a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 12:31:17 +0200 Subject: [PATCH 055/622] fix stravis and sticker --- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 81b87b6f340..c7467922da5 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -755,7 +755,7 @@ class FormCompany extends Form * @param array $selected $key=>$val $val is selected Roles for input mode * @return string String with contacts roles */ - public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) + public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array()) { if ($rendermode === 'view') { $toprint = array(); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index ec124c8a1a1..2caf438b471 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -175,4 +175,5 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-REPUBLICDAY', 0, 117, '', 0, 1, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-GANDI', 0, 117, '', 0, 10, 2, 1); - +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type; +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start; From 42b3640a5a0cdb0ffc463e720c5f6e0a04fe9c15 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 14:12:28 +0200 Subject: [PATCH 056/622] fix travis --- .../triggers/interface_90_modSociete_ContactRoles.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 36a8274c602..8d2418a8a94 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -81,12 +81,11 @@ class InterfaceContactRoles extends DolibarrTriggers if(!empty($socid) && $socid != '-1') { global $db, $langs; - var_dump($socid); + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactdefault = new Contact($this->db); $contactdefault->socid=$socid; $TContact = $contactdefault->getContactRoles($object->element); - // Le trigger est appelé avant que le core n'ajoute lui-même des contacts (contact propale, clone), il ne faut pas les associer avant sinon bug $TContactAlreadyLinked = array(); if ($object->id > 0) { @@ -98,7 +97,6 @@ class InterfaceContactRoles extends DolibarrTriggers } foreach($TContact as $i => $infos) { - // Gestion du cas du clone foreach ($TContactAlreadyLinked as $contactData) { if($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]); } @@ -106,7 +104,6 @@ class InterfaceContactRoles extends DolibarrTriggers $nb = 0; foreach($TContact as $infos) { - // Gestion du cas spécifique de la création de propale avec sélection du contact, cela créé un bug si le contact est ajouté par le module contactdefault $res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']); if($res > 0) $nb++; } From ee931d0f25dfe42fa9138b180815a9beca1f7ceb Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 14:53:23 +0200 Subject: [PATCH 057/622] fix travis --- .../interface_90_modSociete_ContactRoles.class.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 8d2418a8a94..e9bf9d38a50 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -53,14 +53,8 @@ class InterfaceContactRoles extends DolibarrTriggers * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) * * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: - * $object->actiontypecode (translation action code: AC_OTH, ...) - * $object->actionmsg (note, long text) - * $object->actionmsg2 (label, short text) - * $object->sendtoid (id of contact or array of ids) - * $object->socid (id of thirdparty) - * $object->fk_project - * $object->fk_element - * $object->elementtype + * $object->socid or $object->fk_soc(id of thirdparty) + * $object->element (element type of object) * * @param string $action Event action code * @param Object $object Object @@ -113,5 +107,6 @@ class InterfaceContactRoles extends DolibarrTriggers } } } - } + return 0; + } } From ad92efaee14e8ad5e8523fd6064928ad917cee7a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 14:58:29 +0200 Subject: [PATCH 058/622] add trans --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c4611836a51..04f45f8de4b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1004,3 +1004,4 @@ ContactDefault_project_task=Task ContactDefault_propal=Proposal ContactDefault_supplier_proposal=Supplier Proposal ContactDefault_ticketsup=Ticket +ContactAddedAutomatically=Contact added from contact thirdparty roles From 3ea2e0c915db93fca1ca696a4d6c25477d251fa9 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 9 Sep 2019 15:03:20 +0200 Subject: [PATCH 059/622] NEW add parent id or ref column in warehouse import --- htdocs/core/modules/modStock.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index f3864525d8d..93afcdaebd7 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -316,17 +316,21 @@ class modStock extends DolibarrModules $this->import_fields_array[$r]=array('e.ref'=>"LocationSummary*", 'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse", 'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode', - 'e.statut'=>'Status' + 'e.statut'=>'Status', + 'e.fk_parent'=>'ParentWarehouse' ); $this->import_convertvalue_array[$r]=array( - 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry') + 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), + 'e.fk_parent'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'ref') ); $this->import_regex_array[$r]=array('e.statut'=>'^[0|1]'); $this->import_examplevalues_array[$r]=array('e.ref'=>"ALM001", 'e.description'=>"Central Warehouse",'e.lieu'=>"Central", 'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US', - 'e.statut'=>'1'); + 'e.statut'=>'1', + 'e.fk_parent'=>'' + ); // Import stocks $r++; From f4a565544fc7ac106ccacf004c07e70b91c2914f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 9 Sep 2019 16:33:12 +0200 Subject: [PATCH 060/622] Update api_products.class.php --- htdocs/product/class/api_products.class.php | 87 +++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 446b4fa3cfe..428ebe79c4a 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -178,6 +178,93 @@ class Products extends DolibarrApi } return $obj_ret; } + + /** + * List supplier's products + * + * Get a list of supplier's products + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category + * @param int $supplier Use this param to filter list by supplier + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" + * @return array Array of product objects + * + * @url GET supplier + */ + public function getSupplierProducts($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $supplier = 0, $sqlfilters = '') + { + global $db, $conf; + $obj_ret = array(); + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $sql = "SELECT t.rowid, t.ref, t.ref_ext"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; + if ($category > 0) { + $sql.= ", ".MAIN_DB_PREFIX."categorie_product as c"; + } + $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as s"; + + $sql.= ' WHERE t.entity IN ('.getEntity('product').')'; + + if ($supplier > 0) { + $sql.= " AND s.fk_soc = ".$db->escape($supplier); + } + $sql.= " AND s.fk_product = t.rowid "; + // Select products of given category + if ($category > 0) { + $sql.= " AND c.fk_categorie = ".$db->escape($category); + $sql.= " AND c.fk_product = t.rowid "; + } + if ($mode == 1) { + // Show only products + $sql.= " AND t.fk_product_type = 0"; + } elseif ($mode == 2) { + // Show only services + $sql.= " AND t.fk_product_type = 1"; + } + // Add sql filters + if ($sqlfilters) { + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + $sql.= $db->plimit($limit + 1, $offset); + } + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $product_static = new Product($db); + if($product_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($product_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve product list : '.$db->lasterror()); + } + if(! count($obj_ret)) { + throw new RestException(404, 'No product found'); + } + return $obj_ret; + } /** * Create product object From be66e1bd20ea9bc4de608e4f573c209ba77b9db8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 9 Sep 2019 14:36:02 +0000 Subject: [PATCH 061/622] Fixing style errors. --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 428ebe79c4a..89dd7ff823a 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -193,7 +193,7 @@ class Products extends DolibarrApi * @param int $supplier Use this param to filter list by supplier * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects - * + * * @url GET supplier */ public function getSupplierProducts($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $supplier = 0, $sqlfilters = '') From 6a734ea8289bf1f51cfb21e5a84e9344bb4932b7 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 9 Sep 2019 16:58:20 +0200 Subject: [PATCH 062/622] NEW add minimum stock filter in load warehoues for product form --- htdocs/expedition/card.php | 8 +- .../product/class/html.formproduct.class.php | 97 ++++++++++++------- 2 files changed, 68 insertions(+), 37 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index cc05bf686c3..4202607cbd2 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1262,7 +1262,13 @@ if ($action == 'create') if ($line->fk_product > 0) { print ''; - print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1); + + $stockMin = false; + if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) { + $stockMin = 0; + } + print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1, 0, array(), 'minwidth200', '', 1, $stockMin, 'stock DESC, e.ref'); + if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) { //print $stock.' '.$quantityToBeDelivered; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index a0ebda88cd9..e356226dd2f 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -55,21 +55,24 @@ class FormProduct } - /** - * Load in cache array list of warehouses - * If fk_product is not 0, we do not use cache - * - * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. - * @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''. - * @param string $status warehouse status filter, following comma separated filter options can be used - * 'warehouseopen' = select products from open warehouses, - * 'warehouseclosed' = select products from closed warehouses, - * 'warehouseinternal' = select products from warehouses for internal correct/transfer only - * @param boolean $sumStock sum total stock of a warehouse, default true - * @param array $exclude warehouses ids to exclude - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO - */ - public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') + /** + * Load in cache array list of warehouses + * If fk_product is not 0, we do not use cache + * + * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. + * @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''. + * @param string $status warehouse status filter, following comma separated filter options can be used + * 'warehouseopen' = select products from open warehouses, + * 'warehouseclosed' = select products from closed warehouses, + * 'warehouseinternal' = select products from warehouses for internal correct/transfer only + * @param boolean $sumStock sum total stock of a warehouse, default true + * @param string $exclude warehouses ids to exclude + * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param string $orderBy [='e.ref'] Order by + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + * @throws Exception + */ + public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '', $stockMin = false, $orderBy = 'e.ref') { global $conf, $langs; @@ -130,8 +133,26 @@ class FormProduct if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; - if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; - $sql.= " ORDER BY e.ref"; + // minimum stock + if ($stockMin !== false) { + if (!empty($fk_product)) { + if (!empty($batch)) { + $sql .= " AND pb.qty > " . $this->db->escape($stockMin); + } else { + $sql .= " AND ps.reel > " . $this->db->escape($stockMin); + } + } + } + + if ($sumStock && empty($fk_product)) { + $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; + + // minimum stock + if ($stockMin !== false) { + $sql .= " HAVING sum(ps.reel) > " . $this->db->escape($stockMin); + } + } + $sql.= " ORDER BY " . $orderBy; dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG); $resql = $this->db->query($sql); @@ -192,25 +213,29 @@ class FormProduct /** * Return list of warehouses * - * @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value) - * @param string $htmlname Name of html select html - * @param string $filterstatus warehouse status filter, following comma separated filter options can be used - * 'warehouseopen' = select products from open warehouses, - * 'warehouseclosed' = select products from closed warehouses, - * 'warehouseinternal' = select products from warehouses for internal correct/transfer only - * @param int $empty 1=Can be empty, 0 if not - * @param int $disabled 1=Select is disabled - * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. - * @param string $empty_label Empty label if needed (only if $empty=1) - * @param int $showstock 1=Show stock count - * @param int $forcecombo 1=Force combo iso ajax select2 - * @param array $events Events to add to select2 - * @param string $morecss Add more css classes to HTML select - * @param array $exclude Warehouses ids to exclude - * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse - * @return string HTML select + * @param string|int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value) + * @param string $htmlname Name of html select html + * @param string $filterstatus warehouse status filter, following comma separated filter options can be used + * 'warehouseopen' = select products from open warehouses, + * 'warehouseclosed' = select products from closed warehouses, + * 'warehouseinternal' = select products from warehouses for internal correct/transfer only + * @param int $empty 1=Can be empty, 0 if not + * @param int $disabled 1=Select is disabled + * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. + * @param string $empty_label Empty label if needed (only if $empty=1) + * @param int $showstock 1=Show stock count + * @param int $forcecombo 1=Force combo iso ajax select2 + * @param array $events Events to add to select2 + * @param string $morecss Add more css classes to HTML select + * @param string $exclude Warehouses ids to exclude + * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse + * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param string $orderBy [='e.ref'] Order by + * @return string HTML select + * + * @throws Exception */ - public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') { global $conf,$langs,$user; @@ -218,7 +243,7 @@ class FormProduct $out=''; if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; - $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude); + $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); $nbofwarehouses=count($this->cache_warehouses); if ($conf->use_javascript_ajax && ! $forcecombo) From 48419da7698617d50b69ebcdd56510f5850be975 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 10 Sep 2019 14:58:55 +0200 Subject: [PATCH 063/622] FIX new invoice with generic thirdparty in takepos by default, new invoice should always create with default thirdparty and avoid errors : creating new invoice with last customer and forget to change it... --- htdocs/takepos/invoice.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 6ae5429d062..accc4befe82 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -280,8 +280,10 @@ if ($action == "delete") { $resql1 = $db->query($sql); $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture = ".$placeid; $resql2 = $db->query($sql); + $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql3 = $db->query($sql); - if ($resql1 && $resql2) + if ($resql1 && $resql2 && $resql3) { $db->commit(); } From 95417d4c86129b1a55283d097ebece7857b87265 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 10 Sep 2019 16:24:04 +0200 Subject: [PATCH 064/622] allow standalone credit note even if no invoice --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d81467d64e4..3d363b60bb2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3047,7 +3047,7 @@ if ($action == 'create') { print '
    '; $tmp='global->INVOICE_CREDIT_NOTE_STANDALONE) ) $tmp.=' disabled'; $tmp.= '> '; // Show credit note options only if we checked credit note print ''."\n"; - $urllogofull = 'http://home.destailleur.fr:805/dolibarr_dev/htdocs/viewimage.php?modulepart=mycompany&entity=1&file=logos%2Fthumbs%2Ffbm+logo_small.png'; print ''."\n"; // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. From 8e836155338a47e6831760724e9d33141627b8dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Sep 2019 18:52:35 +0200 Subject: [PATCH 114/622] Add method getSetupIntent --- htdocs/stripe/class/stripe.class.php | 148 ++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9defab81a73..9c0bc9ebae3 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -293,7 +293,7 @@ class Stripe extends CommonObject } /** - * Get the Stripe payment intent. Create it with confirm=false + * Get the Stripe payment intent. Create it with confirmnow=false * Warning. If a payment was tried and failed, a payment intent was created. * But if we change something on object to pay (amount or other), reusing same payment intent is not allowed. * Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), @@ -312,7 +312,7 @@ class Stripe extends CommonObject * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt * @param int $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent * @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok) - * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found + * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create */ public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false) { @@ -503,6 +503,149 @@ class Stripe extends CommonObject } } + + /** + * Get the Stripe payment intent. Create it with confirmnow=false + * Warning. If a payment was tried and failed, a payment intent was created. + * But if we change something on object to pay (amount or other), reusing same payment intent is not allowed. + * Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), + * that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) + * Note: This is used when option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on when making a payment from the public/payment/newpayment.php page + * but not when using the STRIPE_USE_NEW_CHECKOUT. + * + * @param string $description Description + * @param Societe $object Object to pay with Stripe + * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int $status Status (0=test, 1=live) + * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt + * @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok) + * @return \Stripe\SetupIntent|null Stripe SetupIntent or null if not found and failed to create + */ + public function getSetupIntent($description, $object, $customer, $key, $status, $usethirdpartyemailforreceiptemail = 0, $confirmnow = false) + { + global $conf; + + dol_syslog("getSetupIntent", LOG_INFO, 1); + + $error = 0; + + if (empty($status)) $service = 'StripeTest'; + else $service = 'StripeLive'; + + $setupintent = null; + + if (empty($setupintent)) + { + $ipaddress=getUserRemoteIP(); + $metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress); + if (is_object($object)) + { + $metadata['dol_type'] = $object->element; + $metadata['dol_id'] = $object->id; + if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; + } + + $dataforintent = array( + "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent + "payment_method_types" => array("card"), + "description" => $description, + "usage" => "off_session", + "metadata" => $metadata + ); + if (! is_null($customer)) $dataforintent["customer"]=$customer; + // payment_method = + // payment_method_types = array('card') + //var_dump($dataforintent); + + if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) + { + $dataforintent["receipt_email"] = $object->thirdparty->email; + } + + try { + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + + // Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent. + if (empty($key)) { // If the Stripe connect account not set, we use common API usage + //$setupintent = \Stripe\SetupIntent::create($dataforintent, array("idempotency_key" => "$description")); + $setupintent = \Stripe\SetupIntent::create($dataforintent, array()); + } else { + //$setupintent = \Stripe\SetupIntent::create($dataforintent, array("idempotency_key" => "$description", "stripe_account" => $key)); + $setupintent = \Stripe\SetupIntent::create($dataforintent, array("stripe_account" => $key)); + } + //var_dump($setupintent->id); + + // Store the setup intent + /*if (is_object($object)) + { + $setupintentalreadyexists = 0; + // Check that payment intent $setupintent->id is not already recorded. + $sql = "SELECT pi.rowid"; + $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; + $sql.= " WHERE pi.entity IN (".getEntity('societe').")"; + $sql.= " AND pi.ext_payment_site = '" . $service . "'"; + $sql.= " AND pi.ext_payment_id = '".$this->db->escape($setupintent->id)."'"; + + dol_syslog(get_class($this) . "::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) + { + $obj = $this->db->fetch_object($resql); + if ($obj) $setupintentalreadyexists++; + } + } + else dol_print_error($this->db); + + // If not, we create it. + if (! $setupintentalreadyexists) + { + $now=dol_now(); + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site)"; + $sql .= " VALUES ('".$this->db->idate($now)."', '0', '".$this->db->escape($setupintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', " . $conf->entity . ", '" . $service . "')"; + $resql = $this->db->query($sql); + if (! $resql) + { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . "::PaymentIntent failed to insert paymentintent with id=".$setupintent->id." into database."); + } + } + } + else + { + $_SESSION["stripe_setup_intent"] = $setupintent; + }*/ + } + catch(Exception $e) + { + /*var_dump($dataforintent); + var_dump($description); + var_dump($key); + var_dump($setupintent); + var_dump($e->getMessage());*/ + $error++; + $this->error = $e->getMessage(); + } + } + + dol_syslog("getSetupIntent return error=".$error, LOG_INFO, -1); + + if (! $error) + { + return $setupintent; + } + else + { + return null; + } + } + + /** * Get the Stripe card of a company payment mode (with option to create it on Stripe if not linked yet) * @@ -609,6 +752,7 @@ class Stripe extends CommonObject /** * Create charge with public/payment/newpayment.php, stripe/card.php, cronjobs or REST API + * This is using old Stripe API charge. * * @param int $amount Amount to pay * @param string $currency EUR, GPB... From aad6b003fb13ff1fd708450276d858b8bccecdff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 00:02:48 +0200 Subject: [PATCH 115/622] Add cache in fetch_optionnals() to avoid duplicate call to fetch_name_optionals_label --- htdocs/core/class/commonobject.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ebfe7f1abee..26102b9b42a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4517,7 +4517,7 @@ abstract class CommonObject $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - + if(empty($reshook)) { dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); @@ -4902,13 +4902,12 @@ abstract class CommonObject if (! is_array($optionsArray)) { // If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. - // TODO Use of existing $extrafield is not yet ready (must mutualize code that use extrafields in form first) - // global $extrafields; - //if (! is_object($extrafields)) - //{ + global $extrafields; + if (! isset($extrafields) || ! is_object($extrafields)) + { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - //} + } // Load array of extrafields for elementype = $this->table_element if (empty($extrafields->attributes[$this->table_element]['loaded'])) From 4420af683d206ae06a1956f4ada932efcbec39e2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 14 Sep 2019 05:44:28 +0200 Subject: [PATCH 116/622] Fix Bank entries - nowrap on amount --- htdocs/compta/bank/bankentries_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 5609bb6b598..0a63e70d992 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1356,7 +1356,7 @@ if ($resql) // Debit if (! empty($arrayfields['b.debit']['checked'])) { - print ''; + print ''; if ($objp->amount < 0) { print price($objp->amount * -1); @@ -1370,7 +1370,7 @@ if ($resql) // Credit if (! empty($arrayfields['b.credit']['checked'])) { - print ''; + print ''; if ($objp->amount > 0) { print price($objp->amount); From 08f056a0f44d3427494a666b193eeabe710a1b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 14 Sep 2019 09:09:41 +0200 Subject: [PATCH 117/622] Delete interface_50_modIFTTT_IFTTT.class.php IFTTT has been removed --- .../interface_50_modIFTTT_IFTTT.class.php | 147 ------------------ 1 file changed, 147 deletions(-) delete mode 100644 htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php diff --git a/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php b/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php deleted file mode 100644 index c7ce8f121fc..00000000000 --- a/htdocs/core/triggers/interface_50_modIFTTT_IFTTT.class.php +++ /dev/null @@ -1,147 +0,0 @@ - - * 2016 Christophe Battarel - * - * 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/core/triggers/interface_50_modIFTTT_IFTTT.class.php - * \ingroup core - * \brief File of trigger for IFTTT module - */ -require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; - - -/** - * Class of triggers for IFTTT module - */ -class InterfaceIFTTT extends DolibarrTriggers -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - - $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = "ifttt"; - $this->description = "Triggers of the module IFTTT"; - $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version - $this->picto = 'ifttt'; - } - - /** - * Return name of trigger file - * - * @return string Name of trigger file - */ - public function getName() - { - return $this->name; - } - - /** - * Return description of trigger file - * - * @return string Description of trigger file - */ - public function getDesc() - { - return $this->description; - } - - /** - * Return version of trigger file - * - * @return string Version of trigger file - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("Development"); - } elseif ($this->version == 'experimental') { - return $langs->trans("Experimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("Unknown"); - } - } - - /** - * Function called when a Dolibarrr business event is done. - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) - { - $ok = 0; - - if (empty($conf->ifttt->enabled)) return 0; // Module not active, we do nothing - - switch ($action) { - case 'THIRDPARTY_CREATED': - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - - // See https://platform.ifttt.com/docs/api_reference#realtime-api - - $arrayofdata=array(); - $arrayofdata['user_id']=$conf->global->IFTTT_USER_ID; - $arrayofdata['trigger_identity']=$conf->global->IFTTT_TRIGGER_IDENTITY; - $arrayofdata['name']='testabcdef'; - $arrayofdata['email']='testemailabcdef'; - - $url = 'https://realtime.ifttt.com/v1/notifications'; - - $addheaders=array( - 'IFTTT-Service-Key'=>'123', - 'Accept'=>'application/json', - 'Accept-Charset'=>'utf-8', - 'Accept-Encoding'=>'gzip, deflate', - 'Content-Type'=>'application/json', - 'X-Request-ID'=>getRandomPassword(true, null) - ); - - $result = getURLContent($url, 'POSTALREADYFORMATED', '', 1, $addheaders); - - $ok = 1; - break; - } - - return $ok; - } -} From 76f478dc4417c4d97e2c9c7b054fcfa494aa413c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 14:25:47 +0200 Subject: [PATCH 118/622] Fix look and feel --- htdocs/societe/paymentmodes.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 3731cfe07fa..90d90b388ac 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -600,7 +600,7 @@ if (empty($reshook)) $db->rollback(); } } - + if ($action == 'setkey_account_supplier') { $error = 0; @@ -819,7 +819,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
    '; print '
    '; - print ''; + print '
    '; if ($object->client) { @@ -872,7 +872,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; } } - + if ($object->fournisseur) { print ''; print ''; print ''; - + if (is_array($balance->available) && count($balance->available)) { foreach ($balance->available as $cpt) @@ -1322,7 +1322,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; } } - + if (is_array($balance->pending) && count($balance->pending)) { foreach ($balance->pending as $cpt) @@ -1598,7 +1598,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Edit BAN if ($socid && $action == 'edit' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1705,7 +1705,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // Edit Card if ($socid && $action == 'editcard' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1753,7 +1753,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) // Create BAN if ($socid && $action == 'create' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1854,7 +1854,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // Create Card if ($socid && $action == 'createcard' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; From 7965804a34edf52bc8673a1b1975e1fc9d794f43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 16:35:00 +0200 Subject: [PATCH 119/622] Update ldap_groups.php --- htdocs/admin/ldap_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 6dcc26a23e0..6412d2f6a59 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -58,7 +58,7 @@ if ($action == 'setvalue' && $user->admin) //if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others $valkey=''; From 9934f73574d32d8b51825a2407c674112f6e13a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 16:36:04 +0200 Subject: [PATCH 120/622] Update ldap_groups.php --- htdocs/admin/ldap_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 6412d2f6a59..8ae918ce180 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -173,7 +173,7 @@ print ''; // Group id print ''; print ''; print ''; From d380ef1812535ea1adc2fdc571bf61a8d1d10e54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 16:37:07 +0200 Subject: [PATCH 121/622] Update usergroup.class.php --- htdocs/user/class/usergroup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 03c514f79f3..a89126b122f 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -980,8 +980,8 @@ class UserGroup extends CommonObject } $info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:''); } - if(!empty($info[$conf->global->LDAP_FIELD_GROUPID])){ - $info[$conf->global->LDAP_FIELD_GROUPID]=$this->id; + if(!empty($info[$conf->global->LDAP_GROUP_FIELD_GROUPID])){ + $info[$conf->global->LDAP_GROUP_FIELD_GROUPID]=$this->id; } return $info; } From c015bbda14b79b0046d3ddeef356c66e4aa70daa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 16:39:08 +0200 Subject: [PATCH 122/622] Update ldap.class.php --- htdocs/core/class/ldap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 266b41867e8..267949e2149 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -609,7 +609,7 @@ class Ldap } if ($result <= 0) { - $this->error = ldap_errno($this->connection)." ".$this->error; + $this->error = ldap_error($this->connection).' (Code '.ldap_errno($this->connection).") ".$this->error; dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); //print_r($info); return -1; From 54f0532073a3f72ef06ea7311a4bbabf4cf4a368 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 16:51:57 +0200 Subject: [PATCH 123/622] Work on #4432 --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 1 + htdocs/install/mysql/tables/llx_extrafields.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index cc375e72714..92dcdce1128 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -43,6 +43,7 @@ create table llx_entrepot_extrafields ALTER TABLE llx_entrepot_extrafields ADD INDEX idx_entrepot_extrafields (fk_object); +ALTER TABLE llx_extrafields ADD COLUMN printable boolean DEFAULT FALSE; ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index e7ec325d428..49480479a79 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -36,6 +36,7 @@ create table llx_extrafields alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status param text, -- extra parameters to define possible values of field list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing + printable boolean DEFAULT FALSE, -- is the extrafield output on documents totalizable boolean DEFAULT FALSE, -- is extrafield totalizable on list langs varchar(64), -- example: fileofmymodule@mymodule help text, -- to store help tooltip From 844f0903da2f769ab240806381649eeac5b595df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 17:34:57 +0200 Subject: [PATCH 124/622] Fix missing fields --- htdocs/fourn/commande/list.php | 4 +++- htdocs/modulebuilder/template/myobject_list.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 18ba697bc20..db427c24c43 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1090,7 +1090,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -1155,6 +1155,8 @@ if ($resql) elseif ($totalarray['totalttcfield'] == $i) print ''; else print ''; } + + print ''; } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 497f46919fd..a2bd9d39fe7 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -514,7 +514,7 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column From 3caa1bd43c88f180c432e8753f5693bde52381d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 18:21:37 +0200 Subject: [PATCH 125/622] FIX Debug feature orderstoinvoice for suppliers --- htdocs/fourn/card.php | 9 +-- htdocs/fourn/commande/card.php | 13 +++- htdocs/fourn/commande/orderstoinvoice.php | 76 +++++++++++++---------- htdocs/langs/en_US/orders.lang | 1 + 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index c65c1fde57f..90240e4cd2b 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -605,8 +605,9 @@ if ($object->id > 0) $sql2.= ' WHERE c.fk_soc = s.rowid'; $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= ' AND s.rowid = '.$object->id; - // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql2.= " AND c.fk_statut IN (5)"; + // Show orders with status validated, shipping started and delivered (even if any order we can bill) + //$sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; + $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; $sql2.= " AND c.billed = 0"; // Find order that are not already invoiced // just need to check received status because we have the billed status now @@ -826,7 +827,7 @@ if ($object->id > 0) { if (! empty($orders2invoice) && $orders2invoice > 0) { - if ($object->status == 1) + if ($object->status == 1) // Company is open { print ''; } @@ -835,7 +836,7 @@ if ($object->id > 0) print ''; } } - else print ''; + else print ''; } // Add action diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 1f6baa158da..829b82a6903 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2494,11 +2494,18 @@ elseif (! empty($object->id)) { print ''.$langs->trans("ClassifyBilled").''; } - elseif (!empty($object->linkedObjectsIds['invoice_supplier'])) + else { - if ($user->rights->fournisseur->facture->creer) + if (!empty($object->linkedObjectsIds['invoice_supplier'])) { - print ''.$langs->trans("ClassifyBilled").''; + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("ClassifyBilled").''; + } + } + else + { + print ''.$langs->trans("ClassifyBilled").''; } } } diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 093e0fd331b..75a78087366 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -73,18 +73,27 @@ $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST[" $extrafields = new ExtraFields($db); + // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('facture_fourn'); if ($action == 'create') { - if (! is_array($selected)) + if (! GETPOST('createbill')) { - $error++; - setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); - } else { - $origin = GETPOST('origin'); - $originid = GETPOST('originid'); + $action = ''; + } + else + { + if (! is_array($selected)) + { + //$error++; + setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); + $action = ''; + } else { + $origin = GETPOST('origin', 'alpha'); + $originid = GETPOST('originid', 'int'); + } } } @@ -286,7 +295,6 @@ if (($action == 'create' || $action == 'add') && ! $error) { $html = new Form($db); $htmlother = new FormOther($db); $formfile = new FormFile($db); -$companystatic = new Societe($db); // Mode creation if ($action == 'create' && !$error) { @@ -324,6 +332,8 @@ if ($action == 'create' && !$error) { print ''; print ''; print ''; + print ''; + print '
    '; @@ -891,12 +891,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); } - + if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { $permissiontowrite = $user->rights->societe->creer; $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) - + // Stripe customer key 'cu_....' stored into llx_societe_account print '
    '; print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); @@ -905,7 +905,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { $connect=''; - + $url='https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; if ($servicestatus) { @@ -1299,7 +1299,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ""; print '
    '; } - + // List of Stripe payment modes if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $object->fournisseur && ! empty($stripesupplieracc)) { @@ -1311,7 +1311,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
    '.$langs->trans('Amount').''.$langs->trans('Currency').'
    '.$langs->trans("Available").''.price($amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
    '.$langs->trans("LDAPFieldGroupid").''; -print ''; +print ''; print ''.$langs->trans("LDAPFieldGroupidExample").' 
    '.price($totalarray['totalttc']).'
    '; // Ref @@ -333,13 +343,6 @@ if ($action == 'create' && !$error) { print ''; print ''; - // Third party - print ''; - print '' . "\n"; - // Date invoice print ''; - print ''; - print ''; + print ''; + // Private note if (empty($user->societe_id)) { print ''; - print ''; - print ''; + print ''; @@ -406,10 +410,10 @@ if ($action == 'create' && !$error) { print '
    ' . $langs->trans('RefSupplier') . '
    ' . $langs->trans('Customer') . ''; - print $soc->getNomUrl(1); - print ''; - print '
    ' . $langs->trans('Date') . ''; print $html->selectDate('', '', '', '', '', "add", 1, 1); @@ -387,18 +390,19 @@ if ($action == 'create' && !$error) { // Public note print '
    ' . $langs->trans('NotePublic') . ''; + print '' . $langs->trans('NotePublic') . ''; print '
    ' . $langs->trans('NotePrivate') . ''; + print '' . $langs->trans('NotePrivate') . ''; print '
    '; - while ( $i < $n ) { + while ($i < $n) { print ''; - $i ++; + $i++; } // Button "Create Draft" @@ -465,10 +469,16 @@ if (($action != 'create' && $action != 'add') && !$error) { } // Date filter - if ($date_start && $date_end) - $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "' AND c.date_commande <= '" . $db->idate($date_end) . "'"; - if ($date_starty && $date_endy) - $sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "' AND c.date_livraison <= '" . $db->idate($date_endy) . "'"; + //$sql.= dolSqlDateFilter("c.date_commande", GETPOST("date_startday", 'int'), GETPOST("date_startmonth", 'int'), GETPOST("date_startyear", 'int')); + //$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); + if ($date_start) + $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "'"; + if ($date_end) + $sql .= " AND c.date_commande <= '" . $db->idate($date_end) . "'"; + if ($date_starty) + $sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "'"; + if ($date_endy) + $sql .= " AND c.date_livraison <= '" . $db->idate($date_endy) . "'"; if (! empty($sref_client)) { $sql .= natural_search('c.ref_supplier', $sref_client); @@ -484,21 +494,21 @@ if (($action != 'create' && $action != 'add') && !$error) { } $title = $langs->trans('ListOfSupplierOrders'); $title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort'); + $title .= ' - ' . $soc->getNomUrl(1, 'supplier'); + $num = $db->num_rows($resql); + print load_fiche_titre($title); + $i = 0; $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); - if (! empty($socid)) { - // Company - $companystatic->id = $socid; - $companystatic->nom = $soc->nom; - print '

    ' . $companystatic->getNomUrl(1, 'customer') . '

    '; - } - print ''; + print ''; print ''; + + print ''; print ''; print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&socid=' . $socid, '', $sortfield, $sortorder); @@ -511,10 +521,12 @@ if (($action != 'create' && $action != 'add') && !$error) { // Lignes des champs de filtre print ''; + print ''; + // print '
    '; // REF print ''; print ''; print ''; print ''; @@ -604,7 +616,7 @@ if (($action != 'create' && $action != 'add') && !$error) { print ''; print '
    '; // print ''.$langs->trans("GoBack").''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index c170e4c1248..66de42094a6 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -156,3 +156,4 @@ OptionToSetOrderBilledNotEnabled=Option from module Workflow, to set order to 'B IfValidateInvoiceIsNoOrderStayUnbilled=If invoice validation is 'No', the order will remain to status 'Unbilled' until the invoice is validated. CloseReceivedSupplierOrdersAutomatically=Close order to status "%s" automatically if all products are received. SetShippingMode=Set shipping mode +WithReceptionFinished=With reception finished \ No newline at end of file From f45abc1b2af6ec4abc8c63b2951bc68a22f58672 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 18:26:38 +0200 Subject: [PATCH 126/622] Removed useless header --- htdocs/accountancy/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 6982475b53a..0bede00d86d 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -51,7 +51,7 @@ $hookmanager->initHooks(array('accountancyindex')); llxHeader('', $langs->trans("AccountancyArea")); print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy'); -dol_fiche_head(); +//dol_fiche_head(); $step = 0; @@ -177,7 +177,7 @@ else { print $langs->trans("Module10Desc")."
    \n"; } -dol_fiche_end(); +//dol_fiche_end(); // End of page llxFooter(); From e0238705cc89222c1ecce9b8319f09c1b21f1f91 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Sat, 14 Sep 2019 19:04:43 +0200 Subject: [PATCH 127/622] Check if childtablesoncascade is not empty --- htdocs/core/class/commonobject.class.php | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d20a8d2785b..f08be052e96 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7536,18 +7536,20 @@ abstract class CommonObject } // Delete cascade first - foreach($this->childtablesoncascade as $table) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->error; - $this->db->rollback(); - return -1; - } - } + if (! empty($this->childtablesoncascade)) { + foreach($this->childtablesoncascade as $table) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->errors[]=$this->error; + $this->db->rollback(); + return -1; + } + } + } if (! $error) { if (! $notrigger) { From bbb62f27c72271f71e7eb89bae2a52101b3ebf4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Sep 2019 19:25:09 +0200 Subject: [PATCH 128/622] Update doc --- htdocs/fourn/card.php | 4 ++-- htdocs/fourn/commande/orderstoinvoice.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 90240e4cd2b..5ebe8ffed56 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -605,9 +605,9 @@ if ($object->id > 0) $sql2.= ' WHERE c.fk_soc = s.rowid'; $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= ' AND s.rowid = '.$object->id; - // Show orders with status validated, shipping started and delivered (even if any order we can bill) + // Show orders with status validated, shipping started and delivered (even if any order we can bill). //$sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; - $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; + $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/orderstoinvoice.php $sql2.= " AND c.billed = 0"; // Find order that are not already invoiced // just need to check received status because we have the billed status now diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 75a78087366..39f33bebb73 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -450,7 +450,7 @@ if (($action != 'create' && $action != 'add') && !$error) { $sql .= ' AND c.fk_soc = s.rowid'; // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql .= " AND c.fk_statut IN (5)"; + $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php $sql .= " AND c.billed = 0"; // Find order that are not already invoiced From 21e27389d411b3fc9ba3556282ca25f095038c9b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 14 Sep 2019 20:58:12 +0200 Subject: [PATCH 129/622] NEW Bank Add an option for colorize background color of debit or credit movement --- htdocs/admin/agenda_extsites.php | 2 +- htdocs/admin/bank.php | 120 +++++++++++++++++++++++- htdocs/compta/bank/bankentries_list.php | 24 ++++- htdocs/langs/en_US/banks.lang | 4 + 4 files changed, 143 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 6979c49aabc..b59c311eb2f 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -44,7 +44,7 @@ $actionsave=GETPOST('save', 'alpha'); if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -// List of aviable colors +// List of available colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 2a0a66fe269..44cdd5e611b 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,5 +1,4 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand @@ -28,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; @@ -38,6 +38,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); +$actionsave=GETPOST('save', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -60,7 +61,7 @@ if ($action == 'setbankorder') { } } -//Auto report last num releve on conciliate +// Auto report last num releve on conciliate if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -82,6 +83,58 @@ elseif ($action == 'unsetreportlastnumreleve') { } } +// Colorize movements +if ($action == 'setbankcolorizemovement') { + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} +elseif ($action == 'unsetbankcolorizemovement') { + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +if ($actionsave) +{ + $db->begin(); + + $i=1; $errorsaved=0; + $error=0; + + // Save colors + while ($i <= 2) + { + $color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); + if ($color=='-1') $color=''; + + $res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (! $res > 0) $error++; + $i++; + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + if ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -157,10 +210,11 @@ elseif ($action == 'setdoc') { /* - * view + * View */ $form = new Form($db); +$formother=new FormOther($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -169,6 +223,10 @@ llxHeader("", $langs->trans("BankSetupModule")); $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup'); +print ''; +print ''; +print ''; + $head = bank_admin_prepare_head(null); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); @@ -372,7 +430,56 @@ foreach ($dirmodels as $reldir) { print '
    '; //} +print '

    '; +print load_fiche_titre($langs->trans("BankColorizeMovement"), '', ''); +print ''; +print "\n"; +print ''; +print ''."\n"; +print "\n"; + +print '"; +// Active +if ($conf->global->BANK_COLORIZE_MOVEMENT) { + print ''; +} +else +{ + print '"; +} + +print "\n"; + +if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) +{ + $i=1; + while ($i <= 2) + { + $key=$i; + $color='BANK_COLORIZE_MOVEMENT_COLOR'.$key; + + print ''; + + // Label + print '"; + // Color + print ''; + print ""; + $i++; + } +} +print '
    ' . $langs->trans("Name") . ''.$langs->trans("Value").'
    '; +print $langs->trans('BankColorizeMovementDesc'); +print "' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print "
    '.$langs->trans("BankColorizeMovementName".$key)."'; + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key)?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key):$conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print '
    '; print '

    '; @@ -384,7 +491,6 @@ print '

    '; //{ print load_fiche_titre($langs->trans("Other"), '', ''); - print "\n"; print "\n"; print ''; @@ -416,6 +522,12 @@ print "\n"; print '
    ' . $langs->trans("Name") . '
    '; dol_fiche_end(); +print '
    '; +print ''; +print '
    '; + +print "\n"; + // End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index a8002c179be..3522d8b6c9d 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Juanjo Menent - * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2017-2019 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Frédéric France * @@ -1110,7 +1110,27 @@ if ($resql) $bankaccount = $cachebankaccount[$objp->bankid]; } - print ''; + if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) { + $backgroundcolor = "class='oddeven'"; + } else { + if ($objp->amount < 0) + { + if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR1)) { + $color = '#fca955'; + } else { + $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; + } + $backgroundcolor = 'style="background-color: ' . $color . ';"'; + } else { + if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) { + $color = '#7fdb86'; + } else { + $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; + } + $backgroundcolor = 'style="background-color: ' . $color . ';"'; + } + } + print ''; // Ref if (! empty($arrayfields['b.rowid']['checked'])) diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 47295ec7e31..44f80c7c3b7 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -169,3 +169,7 @@ FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make d AutoReportLastAccountStatement=Automatically fill the field 'number of bank statement' with last statement number when making reconciliation CashControl=POS cash fence NewCashFence=New cash fence +BankColorizeMovement=Colorize movements +BankColorizeMovementDesc=If this function is enable, you can choose specific background color for debit or credit movements +BankColorizeMovementName1=Background color for debit movement +BankColorizeMovementName2=Background color for credit movement From 84640d0cd5c3da3d655caa7d805e17e65d31e742 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 10:21:38 +0200 Subject: [PATCH 130/622] Update messaging.php --- htdocs/ticket/messaging.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index aac9cdc4e7b..fa029e65582 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -239,7 +239,7 @@ if (!empty($object->id)) // Show link to add a message (if read and not closed) $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; - $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment', $url, 'add-new-ticket-title-button', $btnstatus); + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-comment', $url, 'add-new-ticket-title-button', $btnstatus); From 5ba6a90acc48905c95ed371d915edb025f257573 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 10:49:40 +0200 Subject: [PATCH 131/622] Fix responsive --- htdocs/societe/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 4657a3e3f64..2010edeb217 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -288,7 +288,7 @@ if ($result) print ''; // Name - print ''; + print ''; print $thirdparty_static->getNomUrl(1); print "\n"; // Type From 6c078bdcb07112798a1620e4b1437cb6751df459 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 10:53:41 +0200 Subject: [PATCH 132/622] Fix translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3eb9f24112d..9202e31308b 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1059,7 +1059,7 @@ BackgroundImageLogin=Background image PermanentLeftSearchForm=Permanent search form on left menu DefaultLanguage=Default language EnableMultilangInterface=Enable multilanguage support -EnableShowLogo=Show logo on left menu +EnableShowLogo=Show the company logo in the menu CompanyInfo=Company/Organization CompanyIds=Company/Organization identities CompanyName=Name From 7019e69ee2d5825da1174220041b6ca596770ef7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:09:36 +0200 Subject: [PATCH 133/622] FIX regression with option to hide picto on top menu --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/theme/eldy/global.inc.php | 51 ++++++++++++++++++++++++++----- htdocs/theme/md/style.css.php | 46 +++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 12b5f63d7e1..86d02bcf22c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7265,7 +7265,7 @@ function printCommonFooter($zone = 'private') { print "\n"; print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; - print 'jQuery(".menuhider").click(function(event) {'; + print 'jQuery("li.menuhider").click(function(event) {'; print ' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'."\n"; print ' console.log("We click on .menuhider");'."\n"; print ' $("body").toggleClass("sidebar-collapse")'."\n"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index cbb69df74f9..5a12e50eaef 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1058,6 +1058,41 @@ div.blockvmenulogo { border-bottom: 0 !important; } +.backgroundforcompanylogo { + margin: px; + margin-left: 6px; + margin-right: 8px; + background-color: rgba(255,255,255,0.7); + padding: 0; + border-radius: 5px; + height: px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; +} +.backgroundforcompanylogo img.mycompany { + object-fit: contain; + width: inherit; + height: inherit; +} +#mainmenutd_companylogo::after, #mainmenutd_menu::after { + content: unset !important; +} +li#mainmenutd_companylogo .tmenucenter { + width: unset; +} +li#mainmenutd_companylogo { + min-width: unset !important; +} + + li#mainmenutd_home { + min-width: unset !important; + } + li#mainmenutd_home .tmenucenter { + width: unset; + } + + div.blockvmenupair, div.blockvmenuimpair { border-top: none !important; border-left: none !important; @@ -1504,9 +1539,6 @@ li.tmenu, li.tmenusel { li.menuhider:hover { background-image: none !important; } -li.tmenusel, li.tmenu:hover { - /* background: rgba(0, 0, 0, 0.1); */ -} li.tmenusel::after, li.tmenu:hover::after{ content: ""; @@ -1559,7 +1591,7 @@ div.tmenucenter padding-top: 2px; height: px; - width: 100%; + /* width: 100%; */ } #menu_titre_logo { padding-top: 0; @@ -1965,8 +1997,8 @@ div.login_block_other { padding-top: 0; text-align: right; margin-right: 8px; } float: right; vertical-align: top; padding: 0px 3px 0px 4px !important; - line-height: 50px; - height: 50px; + line-height: px; + height: px; } .atoplogin, .atoplogin:hover { color: # !important; @@ -2003,8 +2035,8 @@ img.login, img.printer, img.entity { font-weight: bold; } .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ - width: 32px; - height: 32px; + width: px; + height: px; border-radius: 50%; background-size: contain; background-size: contain; @@ -5676,6 +5708,9 @@ div.tabsElem a.tab { /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ @media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 40 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */ { + li.tmenucompanylogo { + display: none; + } div.mainmenu { height: 23px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ebf6b1df23d..8c78e8be88b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1948,6 +1948,11 @@ foreach($mainmenuusedarray as $val) display: none; } +.topmenuimage { + + display: none; + +} a.tmenuimage { display: block; } @@ -2232,6 +2237,41 @@ div.blockvmenulogo { border-bottom: 0 !important; } +.backgroundforcompanylogo { + margin: px; + margin-left: 12px; + margin-right: 6px; + background-color: rgba(255,255,255,0.7); + padding: 0; + border-radius: 5px; + height: px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; +} +.backgroundforcompanylogo img.mycompany { + object-fit: contain; + width: inherit; + height: inherit; +} +#mainmenutd_companylogo::after { + content: unset; +} +li#mainmenutd_companylogo .tmenucenter { + width: unset; +} +li#mainmenutd_companylogo { + min-width: unset !important; +} + + li#mainmenutd_home { + min-width: unset !important; + } + li#mainmenutd_home .tmenucenter { + width: unset; + } + + div.blockvmenupair, div.blockvmenuimpair { font-family: ; @@ -5624,7 +5664,7 @@ border-top-right-radius: 6px; } .menuhider { - width: 40px; + width: px; } /* nboftopmenuentries = , fontsize= */ @@ -5659,6 +5699,10 @@ border-top-right-radius: 6px; /* rule to reduce top menu - 2nd reduction */ @media only screen and (max-width: px) { + li.tmenucompanylogo { + display: none; + } + div.tmenucenter { max-width: px; /* size of viewport */ text-overflow: clip; From 544a1237bc0cc0d65cf3150d536e8f23a0d9cced Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:09:36 +0200 Subject: [PATCH 134/622] FIX regression with option to hide picto on top menu --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/theme/eldy/global.inc.php | 51 ++++++++++++++++++++++++++----- htdocs/theme/md/style.css.php | 46 +++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3d7c9ad0ae2..b6b691117a5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7226,7 +7226,7 @@ function printCommonFooter($zone = 'private') { print "\n"; print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; - print 'jQuery(".menuhider").click(function(event) {'; + print 'jQuery("li.menuhider").click(function(event) {'; print ' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'."\n"; print ' console.log("We click on .menuhider");'."\n"; print ' $("body").toggleClass("sidebar-collapse")'."\n"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 82001a31a41..c3ddd4ff7e2 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1026,6 +1026,41 @@ div.blockvmenulogo { border-bottom: 0 !important; } +.backgroundforcompanylogo { + margin: px; + margin-left: 6px; + margin-right: 8px; + background-color: rgba(255,255,255,0.7); + padding: 0; + border-radius: 5px; + height: px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; +} +.backgroundforcompanylogo img.mycompany { + object-fit: contain; + width: inherit; + height: inherit; +} +#mainmenutd_companylogo::after, #mainmenutd_menu::after { + content: unset !important; +} +li#mainmenutd_companylogo .tmenucenter { + width: unset; +} +li#mainmenutd_companylogo { + min-width: unset !important; +} + + li#mainmenutd_home { + min-width: unset !important; + } + li#mainmenutd_home .tmenucenter { + width: unset; + } + + div.blockvmenupair, div.blockvmenuimpair { border-top: none !important; border-left: none !important; @@ -1469,9 +1504,6 @@ li.tmenu, li.tmenusel { li.menuhider:hover { background-image: none !important; } -li.tmenusel, li.tmenu:hover { - /* background: rgba(0, 0, 0, 0.1); */ -} li.tmenusel::after, li.tmenu:hover::after{ content: ""; @@ -1524,7 +1556,7 @@ div.tmenucenter padding-top: 2px; height: px; - width: 100%; + /* width: 100%; */ } #menu_titre_logo { padding-top: 0; @@ -1930,8 +1962,8 @@ div.login_block_other { padding-top: 0; text-align: right; margin-right: 8px; } float: right; vertical-align: top; padding: 0px 3px 0px 4px !important; - line-height: 50px; - height: 50px; + line-height: px; + height: px; } .atoplogin, .atoplogin:hover { color: # !important; @@ -1968,8 +2000,8 @@ img.login, img.printer, img.entity { font-weight: bold; } .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ - width: 32px; - height: 32px; + width: px; + height: px; border-radius: 50%; background-size: contain; background-size: contain; @@ -5621,6 +5653,9 @@ div.tabsElem a.tab { /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ @media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 40 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */ { + li.tmenucompanylogo { + display: none; + } div.mainmenu { height: 23px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 3b9064e51a1..ee0515da6fe 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1938,6 +1938,11 @@ foreach($mainmenuusedarray as $val) display: none; } +.topmenuimage { + + display: none; + +} a.tmenuimage { display: block; } @@ -2222,6 +2227,41 @@ div.blockvmenulogo { border-bottom: 0 !important; } +.backgroundforcompanylogo { + margin: px; + margin-left: 12px; + margin-right: 6px; + background-color: rgba(255,255,255,0.7); + padding: 0; + border-radius: 5px; + height: px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; +} +.backgroundforcompanylogo img.mycompany { + object-fit: contain; + width: inherit; + height: inherit; +} +#mainmenutd_companylogo::after { + content: unset; +} +li#mainmenutd_companylogo .tmenucenter { + width: unset; +} +li#mainmenutd_companylogo { + min-width: unset !important; +} + + li#mainmenutd_home { + min-width: unset !important; + } + li#mainmenutd_home .tmenucenter { + width: unset; + } + + div.blockvmenupair, div.blockvmenuimpair { font-family: ; @@ -5743,7 +5783,7 @@ border-top-right-radius: 6px; } .menuhider { - width: 40px; + width: px; } /* nboftopmenuentries = , fontsize= */ @@ -5778,6 +5818,10 @@ border-top-right-radius: 6px; /* rule to reduce top menu - 2nd reduction */ @media only screen and (max-width: px) { + li.tmenucompanylogo { + display: none; + } + div.tmenucenter { max-width: px; /* size of viewport */ text-overflow: clip; From 755057c99f6110ee30a622cb488f55ab8e956c07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:15:46 +0200 Subject: [PATCH 135/622] FIX regression with option to hide picto on top menu --- htdocs/core/menus/standard/eldy.lib.php | 55 ++++++++++++------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a4eb2d57053..ba4fd896cd6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -55,22 +55,23 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $usemenuhider = 1; - // Show/Hide vertical menu + // Show/Hide vertical menu. The hamburger icon for .menuhider action. if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode=1; $classname = 'class="tmenu menuhider"'; $idsel='menu'; - $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $menu_arr = array(); + // Home $menu_arr[] = array( 'name' => 'Home', 'link' => '/index.php?mainmenu=home&leftmenu=home', - 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)? '   ' : "Home") , + 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : "Home") , 'level' => 0, 'enabled' => $showmode = 1, 'target' => $atarget, @@ -473,8 +474,30 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->liste = dol_sort_array($menu->liste, 'position'); // Output menu entries + // Show logo company + if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; + if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); + } + else + { + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; + } + $title=$langs->trans("GoIntoSetupToChangeLogo"); + + print "\n".''."\n"; + print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo"', 1); + + print ''."\n"; + + print_end_menu_entry(4); + } + if (empty($noout)) { - foreach($menu->liste as $menkey => $menuval) { + foreach($menu->liste as $menuval) { print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url']!='#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); print_end_menu_entry($menuval['enabled']); @@ -615,30 +638,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $usemenuhider = 0; - // Show logo company - if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; - if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); - } - else - { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; - } - $title=$langs->trans("GoIntoSetupToChangeLogo"); - print "\n".''."\n"; - print ''."\n"; - } - if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page { print "\n"; From 76b366836877de877796f9bf99cac21488c241ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:15:59 +0200 Subject: [PATCH 136/622] FIX regression with option to hide picto on top menu --- htdocs/core/menus/standard/eldy.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b1c3111034f..dbf3ede88f9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -55,14 +55,14 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $usemenuhider = 1; - // Show/Hide vertical menu - if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + // Show/Hide vertical menu. The hamburger icon for .menuhider action. + if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode=1; $classname = 'class="tmenu menuhider"'; $idsel='menu'; - $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $menu_arr = array(); @@ -70,7 +70,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'Home', 'link' => '/index.php?mainmenu=home&leftmenu=home', - 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)? '   ' : "Home") , + 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : "Home") , 'level' => 0, 'enabled' => $showmode = 1, 'target' => $atarget, From f5771e49d8c45ae98e821277dd96abb187ed7e42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:21:52 +0200 Subject: [PATCH 137/622] css --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5a12e50eaef..5beebb89a36 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1060,7 +1060,7 @@ div.blockvmenulogo } .backgroundforcompanylogo { margin: px; - margin-left: 6px; + margin-left: 8px; margin-right: 8px; background-color: rgba(255,255,255,0.7); padding: 0; From 27e3a2cb1d4db962246298b2a6940b71ce43e103 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:32:43 +0200 Subject: [PATCH 138/622] Update perms.php --- htdocs/user/perms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 209e68048c7..137ac659fd7 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -59,7 +59,7 @@ $socid=0; if (isset($user->societe_id) && $user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); // A user can always read its own card if not advanced perms enabled, or if he has advanced perms, except for admin -if ($user->id == $id && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms)) && empty($user->admin)) +if ($user->id == $id && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) { accessforbidden(); } From 4d0ef334713b80f7010d86770be2933d6d252f13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:43:03 +0200 Subject: [PATCH 139/622] FIX #11857 --- htdocs/comm/action/index.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 48165361d7c..d42b1b7d134 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -607,9 +607,7 @@ if ($resql) $event->fk_element=$obj->fk_element; $event->elementtype=$obj->elementtype; - $event->societe->id=$obj->fk_soc; $event->thirdparty_id=$obj->fk_soc; - $event->contact->id=$obj->fk_contact; $event->contact_id=$obj->fk_contact; // Defined date_start_in_calendar and date_end_in_calendar property @@ -1569,28 +1567,31 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type_code == 'ICALEVENT') print '
    ('.dol_trunc($event->icalname, $maxnbofchar).')'; + $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); + $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->cotact->id > 0) ? $event->contact->id : 0)); + // If action related to company / contact $linerelatedto=''; - if (! empty($event->societe->id) && $event->societe->id > 0) + if ($thirdparty_id > 0) { - if (! isset($cachethirdparties[$event->societe->id]) || ! is_object($cachethirdparties[$event->societe->id])) + if (! isset($cachethirdparties[$thirdparty_id]) || ! is_object($cachethirdparties[$thirdparty_id])) { $thirdparty=new Societe($db); - $thirdparty->fetch($event->societe->id); - $cachethirdparties[$event->societe->id]=$thirdparty; + $thirdparty->fetch($thirdparty_id); + $cachethirdparties[$thirdparty_id]=$thirdparty; } - else $thirdparty=$cachethirdparties[$event->societe->id]; + else $thirdparty=$cachethirdparties[$thirdparty_id]; if (! empty($thirdparty->id)) $linerelatedto.=$thirdparty->getNomUrl(1, '', 0); } - if (! empty($event->contact->id) && $event->contact->id > 0) + if (! empty($contact_id) && $contact_id > 0) { - if (! is_object($cachecontacts[$event->contact->id])) + if (! is_object($cachecontacts[$contact_id])) { $contact=new Contact($db); - $contact->fetch($event->contact->id); - $cachecontacts[$event->contact->id]=$contact; + $contact->fetch($contact_id); + $cachecontacts[$contact_id]=$contact; } - else $contact=$cachecontacts[$event->contact->id]; + else $contact=$cachecontacts[$contact_id]; if ($linerelatedto) $linerelatedto.=' '; if (! empty($contact->id)) $linerelatedto.=$contact->getNomUrl(1, '', 0); } From ab07da02c4cabdfecb9220d36bac3304ed6270c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 15:53:04 +0200 Subject: [PATCH 140/622] Fix scrutinizer --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 02039f3edc2..c3c008a5874 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -221,7 +221,7 @@ if (empty($conf->stripeconnect->enabled)) $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID); $endpoint->enabled_events = $stripearrayofwebhookevents; if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) { - if (empty(GETPOST('status', 'alpha'))) { + if (! GETPOST('status', 'alpha')) { $endpoint->disabled = true; } else { $endpoint->disabled = false; From 23860b15ee9b09ee146696eec9d235c875a5097a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 16:00:01 +0200 Subject: [PATCH 141/622] Try a fix for #11852 --- htdocs/societe/class/societe.class.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 26ad0c6bed9..0172d67e5c7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3914,17 +3914,17 @@ class Societe extends CommonObject while($obj=$this->db->fetch_object($resql)) { $tmpobject->id=$obj->rowid; - if ($obj->fk_statut != Facture::STATUS_DRAFT // Not a draft - && ! ($obj->fk_statut == Facture::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice + if ($obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft + && ! ($obj->fk_statut == $tmpobject::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice ) { $outstandingTotal+= $obj->total_ht; $outstandingTotalIncTax+= $obj->total_ttc; } if ($obj->paye == 0 - && $obj->fk_statut != Facture::STATUS_DRAFT // Not a draft - && $obj->fk_statut != Facture::STATUS_ABANDONED // Not abandonned - && $obj->fk_statut != Facture::STATUS_CLOSED) // Not classified as paid + && $obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft + && $obj->fk_statut != $tmpobject::STATUS_ABANDONED // Not abandonned + && $obj->fk_statut != $tmpobject::STATUS_CLOSED) // Not classified as paid //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason { $paiement = $tmpobject->getSommePaiement(); @@ -3935,7 +3935,11 @@ class Societe extends CommonObject } //if credit note is converted but not used - if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed())$outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + // TODO Do this also for customer ? + if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) + { + $outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + } } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } From 5d4f7029209ab1d2daf0c49b417d3f34014b3956 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 15 Sep 2019 16:38:03 +0200 Subject: [PATCH 142/622] Remove bas copy / paste --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 4a34a2b360f..922fea064ec 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -481,7 +481,7 @@ if (empty($reshook)) $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha'); $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); } - https://dashboard.stripe.com/search?query=risk_level%3Ahighest&account=acct_1CVGWQLYhjvFj9Sz + $id = $socid; $upload_dir = $conf->societe->multidir_output[$object->entity]; $permissioncreate=$user->rights->societe->creer; From 5d0ba10f34a24d2f288b6150ad4c4d49402a0d79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 17:04:08 +0200 Subject: [PATCH 143/622] Update api_products.class.php --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 89dd7ff823a..524e36fda6e 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -194,7 +194,7 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects * - * @url GET supplier + * @url GET supplier_prices */ public function getSupplierProducts($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $supplier = 0, $sqlfilters = '') { From 48cbcdc7571922af74a829c11e5253b24a28e567 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 15 Sep 2019 17:08:21 +0200 Subject: [PATCH 144/622] Fix #11876 --- htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql index 70750494a10..737fe66f9da 100644 --- a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql +++ b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql @@ -70,7 +70,7 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-KONEGIE', 0, 41, '', 0, 6, 1, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-26OKT', 0, 41, '', 0, 10, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-TOUSSAINT', 0, 41, '', 0, 11, 1, 1); -INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-IMMACULE', 0, 41, '', 0, 12 8, 1); +INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-IMMACULE', 0, 41, '', 0, 12, 8, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-24DEC', 0, 41, '', 0, 12, 24, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-SAINTSTEFAN', 0, 41, '', 0, 12, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-Silvester', 0, 41, '', 0, 12, 31, 1); From 12d67c5f855de196a56823d2c844ec3c589ad5d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2019 17:18:10 +0200 Subject: [PATCH 145/622] Rename api to get all purchase prices --- htdocs/product/class/api_products.class.php | 177 ++++++++++---------- 1 file changed, 89 insertions(+), 88 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 524e36fda6e..812c2df7459 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -178,93 +178,6 @@ class Products extends DolibarrApi } return $obj_ret; } - - /** - * List supplier's products - * - * Get a list of supplier's products - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param int $category Use this param to filter list by category - * @param int $supplier Use this param to filter list by supplier - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" - * @return array Array of product objects - * - * @url GET supplier_prices - */ - public function getSupplierProducts($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $supplier = 0, $sqlfilters = '') - { - global $db, $conf; - $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; - $sql = "SELECT t.rowid, t.ref, t.ref_ext"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; - if ($category > 0) { - $sql.= ", ".MAIN_DB_PREFIX."categorie_product as c"; - } - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as s"; - - $sql.= ' WHERE t.entity IN ('.getEntity('product').')'; - - if ($supplier > 0) { - $sql.= " AND s.fk_soc = ".$db->escape($supplier); - } - $sql.= " AND s.fk_product = t.rowid "; - // Select products of given category - if ($category > 0) { - $sql.= " AND c.fk_categorie = ".$db->escape($category); - $sql.= " AND c.fk_product = t.rowid "; - } - if ($mode == 1) { - // Show only products - $sql.= " AND t.fk_product_type = 0"; - } elseif ($mode == 2) { - // Show only services - $sql.= " AND t.fk_product_type = 1"; - } - // Add sql filters - if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); - } - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - $i = 0; - while ($i < $min) - { - $obj = $db->fetch_object($result); - $product_static = new Product($db); - if($product_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($product_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieve product list : '.$db->lasterror()); - } - if(! count($obj_ret)) { - throw new RestException(404, 'No product found'); - } - return $obj_ret; - } /** * Create product object @@ -554,6 +467,94 @@ class Products extends DolibarrApi ); } + + /** + * List purchase prices + * + * Get a list of all purchase prices of products + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category of product + * @param int $supplier Use this param to filter list by supplier + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" + * @return array Array of product objects + * + * @url GET purchase_prices + */ + public function getSupplierProducts($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $supplier = 0, $sqlfilters = '') + { + global $db, $conf; + $obj_ret = array(); + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $sql = "SELECT t.rowid, t.ref, t.ref_ext"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; + if ($category > 0) { + $sql.= ", ".MAIN_DB_PREFIX."categorie_product as c"; + } + $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as s"; + + $sql.= ' WHERE t.entity IN ('.getEntity('product').')'; + + if ($supplier > 0) { + $sql.= " AND s.fk_soc = ".$db->escape($supplier); + } + $sql.= " AND s.fk_product = t.rowid "; + // Select products of given category + if ($category > 0) { + $sql.= " AND c.fk_categorie = ".$db->escape($category); + $sql.= " AND c.fk_product = t.rowid "; + } + if ($mode == 1) { + // Show only products + $sql.= " AND t.fk_product_type = 0"; + } elseif ($mode == 2) { + // Show only services + $sql.= " AND t.fk_product_type = 1"; + } + // Add sql filters + if ($sqlfilters) { + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + $sql.= $db->plimit($limit + 1, $offset); + } + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $product_static = new Product($db); + if($product_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($product_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve product list : '.$db->lasterror()); + } + if(! count($obj_ret)) { + throw new RestException(404, 'No product found'); + } + return $obj_ret; + } + /** * Get purchase prices for a product * @@ -602,7 +603,7 @@ class Products extends DolibarrApi if($result) { $this->product = new ProductFournisseur($this->db); $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, $sortfield, $sortorder, 0, 0); + $this->product->list_product_fournisseur_price($id, '', '', 0, 0); } return $this->_cleanObjectDatas($this->product); From ea1baefe9a5edab606f20588169943860c954e95 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 15 Sep 2019 20:50:18 +0200 Subject: [PATCH 146/622] NEW: delete purchase price API --- htdocs/product/class/api_products.class.php | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 756bbde5b29..ad8170921ae 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -467,6 +467,41 @@ class Products extends DolibarrApi ); } + /** + * Delete purchase price for a product + * + * @param int $id Product ID + * @param int $priceid purchase price ID + * + * @url DELETE {id}/purchase_prices/{priceid} + * + * @return array + * + * @throws 401 + * @throws 404 + * + */ + public function deletePurchasePrice($id, $priceid) + { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { + throw new RestException(401); + } + $result = $this->product->fetch($id); + if(! $result ) { + throw new RestException(404, 'Product not found'); + } + + if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if($result) { + $this->product = new ProductFournisseur($this->db); + $this->product->fetch($id); + } + + return $this->product->remove_product_fournisseur_price($priceid); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** From 4db6badfc2bd954ff11a918601d6fb4ce41a650f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 10:24:41 +0200 Subject: [PATCH 147/622] Fix link when no title in search of website content --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5d4c259bf9c..6394428bd42 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3308,7 +3308,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''.$langs->trans("Container").''; print ''; - print ''.$answerrecord->title.''; + print ''.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).''; print ''; print ''.$answerrecord->description; print ''; From 6e806a5aed63476c464c5e58c0aad80388c44e59 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 16 Sep 2019 10:37:55 +0200 Subject: [PATCH 148/622] FIX empty cache when we want to load specific warehouses in select --- htdocs/product/class/html.formproduct.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index e356226dd2f..56d5b4bea74 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -243,6 +243,7 @@ class FormProduct $out=''; if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; + if (!empty($fk_product)) $this->cache_warehouses = array(); $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); $nbofwarehouses=count($this->cache_warehouses); From eb70411ae0d7fd2faeccad56a50d5ab3d303d597 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 11:01:09 +0200 Subject: [PATCH 149/622] Css demo --- htdocs/public/demo/demo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index d137b7be456..e84b67f4b7d 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -99,7 +99,7 @@ img.demothumb { width: 110px; } .demobackground { - background-image: url('dolibarr_demo_ban.jpg'); + background-image: linear-gradient(to bottom, rgba(200,200,255,0.8), rgba(210,220,255,0.5)), url('dolibarr_demo_ban.jpg'); background-size: cover; object-fit: contain; height: 140px; From f5dd4f4f9e9252d22de40542df2370ddea47f6ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 11:08:34 +0200 Subject: [PATCH 150/622] css --- htdocs/public/demo/demo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index e84b67f4b7d..99cda615b48 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -99,7 +99,7 @@ img.demothumb { width: 110px; } .demobackground { - background-image: linear-gradient(to bottom, rgba(200,200,255,0.8), rgba(210,220,255,0.5)), url('dolibarr_demo_ban.jpg'); + background-image: linear-gradient(to bottom, rgba(250,250,255,0.7), rgba(250,250,255,0.4)), url('dolibarr_demo_ban.jpg'); background-size: cover; object-fit: contain; height: 140px; From abee6dceaa872333fc50b4afdb73a68da2c53fb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 11:16:58 +0200 Subject: [PATCH 151/622] Fix css demo --- htdocs/public/demo/demo.css | 5 +++-- htdocs/public/demo/index.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index 99cda615b48..f84aa4ab14c 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -28,8 +28,9 @@ a:hover { /*border: 1px solid #bbb; border-radius: 8px; -moz-border-radius: 8px;*/ - background: -webkit-linear-gradient(bottom, rgb(255,255,255) 85%, rgb(255,255,255) 100%); + + max-width: 346px; } .csscolumns { margin-top: 6px; @@ -99,7 +100,7 @@ img.demothumb { width: 110px; } .demobackground { - background-image: linear-gradient(to bottom, rgba(250,250,255,0.7), rgba(250,250,255,0.4)), url('dolibarr_demo_ban.jpg'); + background-image: linear-gradient(to bottom, rgba(250,250,255,0.5), rgba(250,250,255,0.4)), url('dolibarr_demo_ban.jpg'); background-size: cover; object-fit: contain; height: 140px; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 62de885eac6..d2633d9c708 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -336,7 +336,7 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
    '."\n"; + print '
    '."\n"; print '
    '; From 23777fd5ff4ca3ed7748f49dea6461555f2ee463 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 11:19:02 +0200 Subject: [PATCH 152/622] Fix css --- htdocs/public/demo/demo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index f84aa4ab14c..7f482367eba 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -23,7 +23,7 @@ a:hover { font-weight: normal; color: #444444 !important; - margin: 8px 0px 8px 2px; + margin: 8px 2px 8px 2px; /*border: 1px solid #bbb; border-radius: 8px; From 1c5a5eb5938aef26e2143a40b119d0fe99e8b140 Mon Sep 17 00:00:00 2001 From: Daniel Seichter Date: Mon, 16 Sep 2019 13:24:21 +0200 Subject: [PATCH 153/622] Added hint for setting up database (issue #11815) --- build/docker/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/docker/README.md b/build/docker/README.md index 5a0997cf121..616cbd8fa78 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -23,3 +23,6 @@ The URL to go to the Dolibarr is : The URL to go to PhpMyAdmin is (login/password is root/root) : http://0.0.0.0:8080 + +Setup the database connection during the installation process, please use mariad +b (name of the database container) as database host. From 010e58d9570b6dd115b1bd82453ed1f8a0797bc0 Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 16 Sep 2019 13:56:07 +0200 Subject: [PATCH 154/622] Add switch view behavior --- htdocs/core/lib/ticket.lib.php | 21 ++++++++++++------ htdocs/langs/en_US/ticket.lang | 2 ++ htdocs/ticket/agenda.php | 24 ++++++++++++++++++++- htdocs/ticket/messaging.php | 39 ++++++++++++++++++++++------------ 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 86f02d0ebd5..fb274d06c20 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -108,7 +108,21 @@ function ticket_prepare_head($object) // History - $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; + $ticketViewType = "messaging"; + if(empty($_SESSION['ticket-view-type'])){ + $_SESSION['ticket-view-type'] = $ticketViewType; + } + else{ + $ticketViewType = $_SESSION['ticket-view-type']; + } + + if($ticketViewType == "messaging"){ + $head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id; + } + else{ + // $ticketViewType == "list" + $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; + } $head[$h][1] = $langs->trans('Events'); if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { @@ -118,11 +132,6 @@ function ticket_prepare_head($object) $head[$h][2] = 'tabTicketLogs'; $h++; - // History - $head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id; - $head[$h][1] = $langs->trans('Messaging'); - $head[$h][2] = 'tabTicketMessaging'; - $h++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove'); diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index bc2632a4254..6dbc13ec306 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -139,6 +139,8 @@ TicketViewNonClosedOnly=View only open tickets TicketStatByStatus=Tickets by status OrderByDateAsc=Sort by ascending date OrderByDateDesc=Sort by descending date +MessagingViewType=Show as messaging list +MessageListViewType=Show as table list # # Ticket card diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index ed689b4e966..3d1c41b711c 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -103,6 +103,12 @@ $parameters=array('id'=>$socid); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if(empty($reshook)) +{ + // Set view style + $_SESSION['ticket-view-type'] = "list"; +} + // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { @@ -225,7 +231,23 @@ if (!empty($object->id)) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); + $morehtmlright = ''; + + $messagingUrl = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id; + $morehtmlright .= dolGetButtonTitle($langs->trans('MessagingViewType'), '', 'fa fa-comments', $messagingUrl, $id = '', $status = 1); + + // Show link to add a message (if read and not closed) + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; + $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-title-button', $btnstatus); + + // Show link to add event (if read and not closed) + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"]); + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-calendar-plus', $url, 'add-new-ticket-even-button', $btnstatus); + + + print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); // List of all actions $filters=array(); diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index fa029e65582..5966973d4ca 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -103,6 +103,12 @@ $parameters=array('id'=>$socid); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if(empty($reshook)) +{ + // Set view style + $_SESSION['ticket-view-type'] = "messaging"; +} + // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { @@ -143,7 +149,7 @@ if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { } $head = ticket_prepare_head($object); -dol_fiche_head($head, 'tabTicketMessaging', $langs->trans("Ticket"), 0, 'ticket'); +dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); $morehtmlref ='
    '; $morehtmlref.= $object->subject; @@ -227,20 +233,27 @@ if (!empty($object->id)) $morehtmlright = ''; - if($sortorder === 'desc') { - $sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=asc' . $param; - $morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateAsc'), 'fa fa-sort-numeric-down', $sortUrl, $id = '', $status = 1); - } - else{ - $sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=desc' . $param; - $morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateDesc'), 'fa fa-sort-numeric-down-alt', $sortUrl, $id = '', $status = 1); - } + if($sortorder === 'desc') { + $sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=asc' . $param; + $morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateAsc'), 'fa fa-sort-numeric-down', $sortUrl, $id = '', $status = 1); + } + else{ + $sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=desc' . $param; + $morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateDesc'), 'fa fa-sort-numeric-down-alt', $sortUrl, $id = '', $status = 1); + } - // Show link to add a message (if read and not closed) - $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; - $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; - $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-comment', $url, 'add-new-ticket-title-button', $btnstatus); + $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; + $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-tasks', $messagingUrl, $id = '', $status = 1); + // Show link to add a message (if read and not closed) + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; + $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-title-button', $btnstatus); + + // Show link to add event (if read and not closed) + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"]); + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-calendar-plus', $url, 'add-new-ticket-even-button', $btnstatus); print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); From 36326fa5c04e498a0b0b73c3df4e38908bfd7553 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 15:18:35 +0200 Subject: [PATCH 155/622] Add squarre logo --- htdocs/theme/dolibarr_512x512.png | Bin 0 -> 9520 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/theme/dolibarr_512x512.png diff --git a/htdocs/theme/dolibarr_512x512.png b/htdocs/theme/dolibarr_512x512.png new file mode 100644 index 0000000000000000000000000000000000000000..bd8d7ac3bfd32616c1231e0fc626ae9d5a7d5cae GIT binary patch literal 9520 zcma)i2|Sfu*Y|adWvE1vOm`(Rm3hjLArvwbnWK>Tn5RP-O1P1dp+qRNP%@qjDKcd$ z!imHo6pnfL)}{M-zx#cj`~BX}?}zK`v#zz*UVE+o8uq@eqpe0y!%Bl72)%~7iXMWH z!6O;6hYJ2J`Sz~EKMGGJ4TC-K6S(JU6nx(6rheHILCy}KzZi$4Drp!zf>kxa>bu%w zeXKp~5FZ~OAqN*HPg`p@J0Vw(YpHW*SrLQ_(NH;O;F~r(?1vq;OKGc?{MG6 zp+}Hdr$0zWS*632Z$hc6^Y#b}^;>5hcOBg(h6fCky41ZGU4uWBF4LA%R-N;yDkhHn zS+12>{(0rwh-?UxO!-r1m&7lVE7hGFULEsp1ygHjBOBj>7q*5+7k!KB0xVPz1kY#D zgFz6*A8Xv`+CIJQoK!%NOL4doC$xd{y>%SKRnv-C?beJ69rJvmL56- zbT*(bT(}f1IwB1G@k&haD4_E1k3T5(09`VC_tykA{8szQw=^tETZpyHc%9t%)a(6{I1Iq7)?CFaef8k!Ga zrxikeKAsS#=PP#6;r+0mhHGS1iyAo~`-Y-EY;SP3*F}TTf?n?}*M|70*8HOeMux>N z^8AyGdY>2MS+u}_o^I~AA&Kw#GyRz(iF=Wb^BBZU+agX)uF6M0Zf;m?L10IlmrYkg zwJ`S4v%YRd@!YL4f=PCYsgiIz9bpr+Ci7vE^vu<0IzT`CN6&V(j#TE@f@!UpUN*TJ zKbCMke3?^l;On?Jji(dlOavK{adEANV`53&P&>}RTwZ3f_pxNfE$oy@_A=-5uF$c> zW~=$H9(4tKn)Xm4IELGp$LE(iKSpg|&fQvr*$0E4X$IWUzCQFsZ&vn7@boEaBs~%= zNOz<@$*ukA6%9Re+cNLEfGgEBu}+iKc7xs}1|%)P2z|0SH4H+y{{9Vx){zlo{fL#M z6XA^vv$A?c^a0To)~=;5IRp$Z@>_~fWU2xopGC1+v zAK8QcB`U72{JkIBDeqxSIysIbYwNydSeRC*MYiQ>sgYMPfkTfZ#vkm}5V+AsLbP$BVCeo9DT`Ul;a`=9|@Qd!V+y`^Lv0)-T zrMP`r@TTl)4Tlz|q)tx@eebezw!g=(eT5^2CnVT!nV~MK;_!oDQML0jADdCBbm{c) z6G=%9J>Cy16a*m@UGaqrFGR7O?Z%FC`-=v=jPL3w;jhUY>~aB2oXYr7z!bDm_F(tB zwC9cA78kM(b+j1akuDAYY@Qj}$EkU#_ILYji=F!y3Mm8Ckl5x22qq(ueyY!0;k8%9 zKDNRx#$wmL7lM>I$1$7@ml32(bz$9pisw~F*W21=|J4c7U_j*;>HUguJeyOl8P2+NtXJQqV&zqgRmkLL1mpL&C3LxI^mbYM@E8hGR56d6t9 zyToEk`7%>}AEuO8is&;C0UBR?Ou+6qmn|ilUE?b>%OpybP{8i7jpgmVx%6%LasMG( zs^nNQTG$x;xfdU+h|D_@7kxsuJ-DgKbH=%1L0G)?Sq|dh#YkfD=vMi8`fnN-EIkVE zk*yt?-ShLwg`=IL8P^`ni?CC>M*tE^nc(MpB#Y`*6n0+a-y4i+q3rep5Fn7DJIXk^ zcJF+d-vOE1l9`E@9(qczkRck=i4QZ?=8_99X|vmJP9A))arz|CAH&pN8m%UJ1g+#e zU+`OFh^1}O#vueHSm~7@5xu2Gp8L;VKKYDgt2{trK(0(D#BVLNxCSeIet0S;3m=Y7 zY4iH?k@ZFM#~*Li$itW&I_5E)$VeJ0HqZL39|0?8egZbfwr4e{YVx~7)kM~~mRjgV z&<2;b@7a&D0~Q6YLCbo6XLEY+L^M{7eW33-e~LRf_Gw193WSZ4Xvn5m+-8|a6te^Dv2a#C0xv4bOLY2`?ItWhNzxB$zkfM$e zL3f8QF>A>u#{){KF;EPPuE!yc1q#5kX#6?6n0+8Yipr9!%i*?h>x`S z)p88`w9(NMA2`U+*u3LcZJJo3MXHQmSt-`9uf*|+it{ciELPgMqdACr!ur*msnFsp zSyo}ASf(ZfY|gFq9Y$`c@w7JcCF-{d3gq?(p4!~2+X~P#ZM)7lmB>4_8|66{CZrR^ z{wR(kvP_|=3_fzT#$woKMl(B?LQCx&x?#v*FTdPnh4o3|4Q94nP%N&j>V`o`(68g; znk|aVR{U0y1aUH}u6j#Z4O!aOa_dgr9^J0npZ2^v#Ec}5ll+$~cSMwlr*4bvEdH5a zCgcJlcjT+BxU6rt_W%bT&=WFfH&_{(A}&0DrNbTs56l>ztNP_(_w?k$*ida$)#YaX z7j%3^+#Z6U6dyjL0j7*mEKzgy0iA9U>xWi(G0 zeUN0Q)EyIm*&+kII+z4MV|Dtxv~sezXg)Y22z$c)v}Ymda@|-umD?b}R7qz$OCh}6 zBYc1oT|;A_MRA>1qrtyE>uVnAzNCMCNtB&@7R?y3DMLl+S7pcsci$Ep_XrTBblZ!* zsXyGogg>--gB-YO+Ij{!wZ3C3Y*V-)L(>t8CWz^C%a^Vcc&(}C*b>;#ly3?PR5JroUlj99~WhcKAUv(Du z-JbUE(RHJuLAtadA&TWgx@lHxFI>`)xx7a&Q9J48BjWq%)TF#01qP(q_?)}7(Goq~+IMtjB{eo|e+GhFe*hu3@bl%T;LaN`X2+?nI{18b@6r9q0mdhz%FEV&f2*b3Zbx|Q>x7S3 ziBFZi)`y-x=1E8OdV!u_1cbBxsuU&uoD|)jD6*OCEt(5_q}7HP|G=;3K@nX%LhL!x z`f9w#x!+^OSQfh9D=(!^4)8L4Z^LQhjqr+MCa0Odb#>FoZ8pfr$%Nd@xy16cvy(Nq z^kzV6Y&c7srq;)MU$@HbnIkErF|QD$Nz>Cw-PJ`ZLsF8h>(iH!^@alXDo2|lh?m6c zQSqN2&}Ac15W#Q^L;LSf&E0f$bbCxUEV6Md=*EJMUoBIpucWO~Q5AQQPLO^yk+**w zJmoyQjL{R$ExYIPJ3W5>0cN2@sVN(c+re5#72aX#z)|sk?Bfs|cokBwZW%OnXjayv z0n3Jc0`Vaw7KK=;59@MjOU;kvibv1BGL303%o)$1y&}S=cI5e4dK*>{X8cxzwOoa7 zs!PrMk;2iSCU{-s@j(7Ad^Y-zBzB6sOK*gUCI@qV@?n>=C@kLcuH#5~m2&gy*oXII zR@-v+i_K7)WT_tesBr&A--F<_usf}Jnl0yeUf;lmP;LfNJZu`3M~vT{7U)sf*^~z3 zxGqB@bI#+;x$(spS}i505Kg@kVl%060$rAtqu`Y?ZzgQ1Qev&di^*M--O}g7Jd=Y@ zyPaaYGxe3ZfBMZe<5LamZWa7*_la!>zgQbP!^K5Yz&z>e|6andPhwi_)rWhXZD)F7 zs7M;d+QoBxd=u5|CrccW%Kk8~08*pEXD!oKj%`Nz`pR?>$8hz-SZj6~ z1XsBf`Cx!(CA^X}Y{T{nV*}Y2mrzA{1Znh=;I$Cs0l_Nc)8b;bJu^YvW1j`B@#mUX zCdCCE18Hq)DY0RTEGdc2>vx196B;CLiHZ?~>Vtw~?9J11zgdM5d8HzsY`rkC6n-lR z34Y;=m%5kgUiV??($vm7CWz=KYPOWnP{LvY7TN{*iX9-xP6~_hv|%aoePcM)KlF9b zc37bhEIk?bPMDqY+Eijvt4uTlz*51|zBqCjz4^OL%VbduATod9 zkRckC2rGVlqH>?Hbo{7vr*?)#ppZ%d)+Nk}H+F}Z_Br`jLqxu=yz(uBxW@?0t)#yw zOs|Kbi;CtqO*9!n)8YN?oZ}_{@px0}=r%1i#iPkc6O|c;yxXd_Daj|!kndpp*|T2X zc^%%L>o=u?Y|N@KBIhua#W0)bQ&CLRUIlU5D5@Fm5vKb_c|P`ch%BqP#8He@p_e$i z0`G#Fw^)j_(0QaO;&CixIp+-b_B}URygR`DWhY@gxO?9P{%O$E5r}GF!jMr|RWSCE za*h+|LUEl~irpm^=G46hHgD#~vrZjeHKVc;r@<{!@FK!*Mn#Z(T_lZ%uu>|mPlv9( zu^3 zvs$aiI8(^)P74B=Dr+KX@8&1RpXdLQq{BOYJyUNd6W`g^qHjFz%7W|j{r=^lsp;#T z(LUcvasVCt!%FcU((ll~y}ind#P%MfDI2L`nGZyaXjlD4zT8emuyU}0`4GR8V{xJ? z$Ml?{<`JwoI+m@2u<%j{vAgvvDHD;}N696DTJ?F1+oNe2 z8btwANrJNcedru}f7?RaBq`4_POL}REg}W%W0xe~vQz9OnKu`>)f;O?MJAKezw8tN zp%}U%Qr1uY%Nm|Y%V~ny`hjY}FIOE7X;E$D14 zJ1u}QI4=mf0;eqzx2LufOgNKWm%JOjfV$|t1xkD}I&i@z%<@4DhZVrd*t=hjV2xkn zewJ`|X)}~sd~sdB_2$9_x@15LDTBZ;ufxYtF((rB)nK7zd(@8c2|O2LZ)8OUc&9m& z^BfI3p=G@C7KLxW8v$&;`JD$8NnD#&UklnC88@J8;WM!nZn}V2Q5Fwm9W7>cg_*zV zxW5L6MdfMeW8QCA|7cjN1uxCSWSksph2j=};I9<$TEbZxC`)Z1LFJm$Vi(mJkGu*< zwn#Xvcms^6skYd{=OKVt+_<3^Uw(lodm|r6=I%VW`iAvEi|dZ|t3{pL0A#-wKTsZ^ z?~hKU*pv_2$Z>!G!Typ{;P4FpOW3t2vz?{x+pKBn4l-1OU@SjS*4Y+EPE`eUK;e{; z?tMrHv1#wbH?R4|q}?27kejQWaO9?Dgz7<-?Nt75>xQM@`Zrn{uYOo6O_7j?Qlh*k zR++m%kQ_2(uA(K#J$E)YA^05#H~+FD83t=|IYG6#P8v{ne(%Kj9hVn=qYQt=H_5u4 z=6o@KH&>K;{q13A1>X+ebw#`MqfG0n8n8POpFtkNY9I9@NxP%@I` zWD&@EdnFxwte+EE`WI56N6l>W4R7K9qgwJ=fJYaW=}HD^O_e5cZFZCiwrJp?)LFIt zA&Wg1X78gJ3L$;-7)%KTB!Q1JT|`r%KIr8^^37F`>ZGCl4hL z?uezfkIFtDx(Pot(IW4@^PsCt7zx~i?frPXysT|nUBDt8$6~Z-_MwVF_o&$rEod{j zrKMR6lX`~ab2J(~VM=C`Du?=GcXwiJf9KOhOg}fU;|0H}#zl?u%>Eo*AMZ<`-)J%w ziGvP@TBYOIfniekk?B$XVUXqtz(V0@`{E8-7FzYL{t-kf>@(jYA z(z{73VapNc>@JS>=64h;^_N%hvR%d%SP3 zGV)iwJ^&Z?b@{i9?^lE`NQPWJwz4X?ywI8+xG{PT)>)+j4VPZwn@jK8)ExSol|gh( zwXk#XQA@3P={dFpawxtaQca`<$`_xc@9h3@QElpYV&wAx8a2|`Q^AecXFp9KLt90l z(>{3WnEcLA!hN>hL*rBq-&K{d&6VdaT>P%g$+`ToHNAi{^6Oy)_w4Bj?x`_`Epa=Q z5G{_+mdB}<6FS?7fl}4r@wIg>P`XQz%VNlMOPy-Lz3AJCPfA~ZW=$PXv-K!T8j_6O zAE+|X*H>+zKYATJ9}R|j2?u-YjjO1ZI&>`R1?b-sp8&u@IT8Uv6MfxY=Z<_r697=~ zn8}$p#dGh^d0o=bgKWy*?&-5@>l?-|)|b`wcSeYEw*+x-(ggI|>@NF_fF~&|-#=bRnUNo9f%j+P4+Idu*CITy6_D6_W7>BQJ-91Z4q; z&<4vO!U@TQ0eaDv)L2Z@hp#XAYHKHOus&LsISf+OlvwO)zBvZ{>A)9CMAznY8ugw2{!NAVOL!T z)k0vs-okgiULWy2xQwY2<*RtedJ+(GVv`6ZZ4fd!+8gTH+(1|^g#`Wl59@P z^ayup@6MSFFju66GBtq%gYBk&efl(BT-PYMV-7ubWa`g^JEmJ}6+Qr1_rQp7`~0RJ zzUuAjwUMF9L^}ajO3W#_{k{5xU@4eg3p$EHa@XeT1$C1dcdpz<19TUHTM;y^Haoh) z1Pi2Xf@D{*7dqifgf9~SlH@4gXIq_~{9aEBTA_`CT*Dx`R<+2-xdy#0=WeS0n{DXY z%guP1`sLz;44in;!Ub)eTz|!LxM-k5xdp`IfgBDQoKU}<#NlV11kIKc=qjtfY^)yh z-i$sDAMk$dW-kr%Uois!YNNuZ>04`r&xLpZYE4~*!=!REIBMB5R36b#H50!E=O@tT zO23O@%g?p_ZJYjc9?nCSkWE)1P=g}QrnR+-A?76`ATpYL5|mr>XGpaQHF<8gx(#bG zfkd0}wz|UVC?!M~adt{`RAj04ti^%rYu~qE<P{H~*7Z=|b3dPOaDo;7jRw-`W zxd44HI#g3_auOjihl|=J|LV#`3l5cEs!w0JPh>fRgN$!^j2CHoI7@xUYjWPgh_@-V z=R5>!yiz##q4kB+j}4X4qWBDIsrOG67Y#Vq`x^1&%|OfZ9B8pb-Bv%kZUOJjlp3}IM+qlIbAH%RqZ@L7@oW&Z5O<-2@xcoZB$qx84FR{C ztH;l#Qk0vi_0#gxpHw;aF(|~(e8<-_i^%K70@?9_++z&H+>oG~`$NjnMw9#Wo7Zhi z-)4?#w&0W@pmFWnf-OPUN@Q_613k)2$RXS+)m8in#O(E+%?jwJe%;K0R+NkyFI#sU zr{&XY_isqBQwo7PaZ+7h4t_L``!H}UmZT~R?C=xQM^i~8>c<0lvysq9jRri$H}gTc zxUtoFeP%lg*zNX)_0-~wiT#h|3d3ynEuUN33>5!NkB0Xagg`g6%-LtmnVkEg)wD;K zpogl}?r_ojf#HxqReCK!V9~s}sZCbSS-;cx6eRtTB<}x{n0@DGgc3Enb)4s@NH&@*BwO;xShIe*`}kr59(bXn1J0;zYh)imht>p7^#5P73KVPoBp^V?D4 z-eeS+4cf?5U^7o1sdltJQ(RW+19d4B)d-zwrG({*{CY~>G%IW$stYT{%XWoxK{rD0 z-}vMtLn8p?B#y;wm+YmYVFf*`*9KTe#Y37^wNgrHS`!>c%MpA|tA(5>$Rkx<5yRo@zs94>t4n&ZOa!qsN&;2Q`HnYxkXZwx%lVda6$Ynk zYh$tkzN*8rGZ@2_tmQ~=&&!GVymmaAqS=D!xC3fSzxr#v7FF(G$Z92#7w@-Q)68KA zjS{oc1=QQ6Dl?0;T56cV7zox^GHO+`{a0TfGOe_KK;%{IM8V^i&bu;FSBjyo+ zIJ`d(SZ&Ip_*`&7n|PCQ7hvhRio{;sD!>SJ-HaK&PYivyG+zW-8$fI5YNB`5(tf0ZR>LW)+K8r9>&5JLs*cFkyjJ&@{C; z+{xQv{E-sJS8{nAq?ScB0R>muBxeUQz19YkE#GMe;V*+LRGNYh-LH+Tz>ZrK4tndz zvdojuLiixav}hYRHTRR7);ZK0xyWWzMcDVmBLh#sqG~b|Xq-VA^lRaRmAUF0cUm>o z$gadeJ*{i1Y(2}**SEf@RM>gCH)2z1w}_!^f}RUv3tt{$dfXLzvw6@x!vxIUY4VAU zxL8GUEL9WKi8!HwF9-F`{n~qojo%lrFq}kSsWxn|dPt z8_ECPprG&c=!Vs0-$o@xO4Jb#DBg^(qx23rv!KXU+%qFE24B}K=;>bf6H2k`=4*9{D-XQ>B&FH>JBI4 z|GG`{o9jQzisl!8-LYx Date: Mon, 16 Sep 2019 15:26:13 +0200 Subject: [PATCH 156/622] Introduce a logo squarred into setup (MAIN_INFO_SOCIETE_LOGO_SQUARRED, MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI, ...) --- htdocs/core/menus/standard/eldy.lib.php | 9 +++++++-- ...ibarr_512x512.png => dolibarr_logo_squarred.png} | Bin 2 files changed, 7 insertions(+), 2 deletions(-) rename htdocs/theme/{dolibarr_512x512.png => dolibarr_logo_squarred.png} (100%) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index ba4fd896cd6..2eead6da81d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -478,13 +478,18 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; - if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + $mysoc->logo_squarred_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; + if (! empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); + } + elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); } else { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; } $title=$langs->trans("GoIntoSetupToChangeLogo"); diff --git a/htdocs/theme/dolibarr_512x512.png b/htdocs/theme/dolibarr_logo_squarred.png similarity index 100% rename from htdocs/theme/dolibarr_512x512.png rename to htdocs/theme/dolibarr_logo_squarred.png From 555ea977c9e3a5758b94dcaa9088acd186264808 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 16 Sep 2019 15:32:31 +0200 Subject: [PATCH 157/622] NEW Add units in select products lines --- htdocs/core/class/html.form.class.php | 132 +++++++++++++++++++++----- 1 file changed, 106 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c470231e5de..52be1cec2b0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2064,6 +2064,11 @@ class Form $out=''; $outarray=array(); + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $langs->load('other'); + } + $warehouseStatusArray = array(); if (! empty($warehouseStatus)) { @@ -2114,7 +2119,7 @@ class Form } // Units if (! empty($conf->global->PRODUCT_USE_UNITS)) { - $sql .= ', u.label as unit_long, u.short_label as unit_short'; + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; $selectFields .= ', unit_long, unit_short'; } @@ -2408,6 +2413,42 @@ class Form $outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration, 0, dol_strlen($objp->duration)-1):''; $outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration, -1):''; + // Units + $outvalUnits = ''; + if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($objp->unit_short)) { + $outvalUnits .= ' - ' . $objp->unit_short; + } + if (!empty($objp->weight)) { + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); + $outvalUnits .= ' - ' . $unitToShow; + } + if (!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) { + $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); + $outvalUnits .= ' - ' . $unitToShow; + } + if (!empty($objp->surface)) { + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); + $outvalUnits .= ' - ' . $unitToShow; + } + if (!empty($objp->volume)) { + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); + $outvalUnits .= ' - ' . $unitToShow; + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + } + } + } + $opt = '\n"; $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); } @@ -2679,16 +2708,28 @@ class Form $outarray=array(); $langs->load('stocks'); + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $langs->load('other'); + } $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, p.fk_product_type,"; $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; $sql.= " pfp.supplier_reputation"; + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; + } if (! empty($conf->barcode->enabled)) $sql.= " ,pfp.barcode"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_units u ON u.rowid = p.fk_unit"; + } $sql.= " WHERE p.entity IN (".getEntity('product').")"; $sql.= " AND p.tobuy = 1"; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$this->db->escape($filtertype); @@ -2749,6 +2790,42 @@ class Form $outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration, 0, dol_strlen($objp->duration)-1):''; $outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration, -1):''; + // Units + $outvalUnits = ''; + if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($objp->unit_short)) { + $outvalUnits .= ' - ' . $objp->unit_short; + } + if (!empty($objp->weight)) { + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); + $outvalUnits .= ' - ' . $unitToShow; + } + if (!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) { + $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); + $outvalUnits .= ' - ' . $unitToShow; + } + if (!empty($objp->surface)) { + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); + $outvalUnits .= ' - ' . $unitToShow; + } + if (!empty($objp->volume)) { + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); + $outvalUnits .= ' - ' . $unitToShow; + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + } + } + } + $opt = '\n"; From 8d7d14c7305c74df7708c842d659e923614ff523 Mon Sep 17 00:00:00 2001 From: madx666 Date: Mon, 16 Sep 2019 15:39:58 +0200 Subject: [PATCH 158/622] Fix return to list on page 1 When are on page 1 on any list and we go on an object, when return to the list, we are back on page 0 --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 014ca843236..1c0b86dff88 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -748,7 +748,7 @@ if (! defined('NOLOGIN')) $_SESSION['lastsearch_contextpage_'.$relativepathstring]=$_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]; unset($_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]); } - if (! empty($_SESSION['lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION['lastsearch_page_tmp_'.$relativepathstring] > 1) + if (! empty($_SESSION['lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION['lastsearch_page_tmp_'.$relativepathstring] > 0) { $_SESSION['lastsearch_page_'.$relativepathstring]=$_SESSION['lastsearch_page_tmp_'.$relativepathstring]; unset($_SESSION['lastsearch_page_tmp_'.$relativepathstring]); @@ -2271,7 +2271,7 @@ if (! function_exists("llxFooter")) unset($_SESSION['lastsearch_limit_tmp_'.$relativepathstring]); if (! empty($contextpage)) $_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]=$contextpage; - if (! empty($page) && $page > 1) $_SESSION['lastsearch_page_tmp_'.$relativepathstring]=$page; + if (! empty($page) && $page > 0) $_SESSION['lastsearch_page_tmp_'.$relativepathstring]=$page; if (! empty($limit) && $limit != $conf->limit) $_SESSION['lastsearch_limit_tmp_'.$relativepathstring]=$limit; unset($_SESSION['lastsearch_contextpage_'.$relativepathstring]); From 872f5ed85f8f0a298faaa49d33f856914c65de14 Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 16 Sep 2019 16:49:08 +0200 Subject: [PATCH 159/622] fix_missing_expedition_table_line_tag --- htdocs/expedition/card.php | 53 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4202607cbd2..cab0ec3a189 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2036,27 +2036,28 @@ elseif ($id || $ref) print '
    '; print '
    '; - print ''; + print '
    '; + print ''; print ''; // Adds a line numbering column if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + print ''; } // Product/Service - print ''; + print ''; // Qty - print ''; + print ''; if ($origin && $origin_id > 0) { - print ''; + print ''; } if ($action == 'editline') { $editColspan = 3; if (empty($conf->stock->enabled)) $editColspan--; if (empty($conf->productbatch->enabled)) $editColspan--; - print ''; + print ''; } else { - print ''; + print ''; } if (! empty($conf->stock->enabled)) { - print ''; + print ''; } if (! empty($conf->productbatch->enabled)) { - print ''; + print ''; } } - print ''; - print ''; + print ''; + print ''; //print ''; if ($object->statut == 0) { @@ -2104,7 +2105,7 @@ elseif ($id || $ref) print ''; } print "\n"; - + print ''; $var=false; if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) @@ -2164,6 +2165,7 @@ elseif ($id || $ref) //var_dump($alreadysent); } + print ''; // Loop on each product to send/sent for ($i = 0 ; $i < $num_prod ; $i++) { @@ -2174,12 +2176,12 @@ elseif ($id || $ref) if(empty($reshook)) { print ''; // id of order line - print ''; + print ''; // # if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + print ''; } // Predefined product or service @@ -2195,7 +2197,7 @@ elseif ($id || $ref) else $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); - print ''; + print ''; // Qty in other shipments (with shipment and warehouse used) if ($origin && $origin_id > 0) { - print ''; + print ''; // Warehouse source if (! empty($conf->stock->enabled)) { - print ''; } else { - print ''; + print ''; } } } // Weight - print ''; // Volume - print ''; @@ -2473,6 +2475,7 @@ elseif ($id || $ref) // TODO Show also lines ordered but not delivered print "
      '.$langs->trans("Products").''.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''.$langs->trans("QtyInOtherShipments").''; + print ''; if ($object->statut <= 1) { print $langs->trans("QtyToShip").' - '; @@ -2079,24 +2080,24 @@ elseif ($id || $ref) { if ($object->statut <= 1) { - print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
    '.($i+1).''.($i+1).''; + print ''; // Show product and description $product_static->type=$lines[$i]->fk_product_type; @@ -2215,7 +2217,7 @@ elseif ($id || $ref) } else { - print ""; + print ''; if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); @@ -2231,12 +2233,12 @@ elseif ($id || $ref) } // Qty ordered - print ''.$lines[$i]->qty_asked.''.$lines[$i]->qty_asked.''; + print ''; foreach ($alreadysent as $key => $val) { if ($lines[$i]->fk_origin_line == $key) @@ -2350,12 +2352,12 @@ elseif ($id || $ref) else { // Qty to ship or shipped - print ''.$lines[$i]->qty_shipped.''.$lines[$i]->qty_shipped.''; + print ''; if ($lines[$i]->entrepot_id > 0) { $entrepot = new Entrepot($db); @@ -2385,7 +2387,7 @@ elseif ($id || $ref) if (isset($lines[$i]->detail_batch)) { print ''; - print ''; + print ''; if ($lines[$i]->product_tobatch) { $detail = ''; @@ -2405,19 +2407,19 @@ elseif ($id || $ref) } print ''; + print ''; if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units, "weight"); else print ' '; print ''; + print ''; if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units, "volume"); else print ' '; print '
    \n"; + print ''; print '
    '; } From 5c00712c0a142d1a472c469845c872f67e1f1663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 16 Sep 2019 17:57:40 +0200 Subject: [PATCH 160/622] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 86d02bcf22c..f018bdefe53 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3015,7 +3015,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'note', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', + 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', '1leftarrow', '1rightarrow',, '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'jabber','skype','twitter','facebook','linkedin', 'chevron-left','chevron-right','chevron-down','chevron-top' ) From e43f3a0f58d03864e3fd4dd47c1d9a4b4b77f7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 16 Sep 2019 18:07:06 +0200 Subject: [PATCH 161/622] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f018bdefe53..ad72b8cf22e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3015,7 +3015,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'note', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', '1leftarrow', '1rightarrow',, '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', + 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'jabber','skype','twitter','facebook','linkedin', 'chevron-left','chevron-right','chevron-down','chevron-top' ) From 5233e7d8adcff6e95f5886a828a731050c9d63ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 18:29:04 +0200 Subject: [PATCH 162/622] FIX do not output return code on screen after a select of bank account --- htdocs/cashdesk/index.php | 6 +++--- htdocs/compta/bank/ligne.php | 2 +- htdocs/paybox/admin/paybox.php | 2 +- htdocs/paypal/admin/paypal.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 8bd64c76e2b..9efe1b8ed7f 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -157,7 +157,7 @@ print ''.$langs->trans("CashDeskBankAccountForSell").''; print ''; $defaultknown=0; if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) $defaultknown=1; // If a particular stock is defined, we disable choice -print $form->select_comptes(((GETPOST('bankid_cash') > 0)?GETPOST('bankid_cash'):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown?0:2)); +$form->select_comptes(((GETPOST('bankid_cash') > 0)?GETPOST('bankid_cash'):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown?0:2)); print ''; print "\n"; @@ -166,7 +166,7 @@ print ''.$langs->trans("CashDeskBankAccountForCheque").' print ''; $defaultknown=0; if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) $defaultknown=1; // If a particular stock is defined, we disable choice -print $form->select_comptes(((GETPOST('bankid_cheque') > 0)?GETPOST('bankid_cheque'):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown?0:2)); +$form->select_comptes(((GETPOST('bankid_cheque') > 0)?GETPOST('bankid_cheque'):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown?0:2)); print ''; print "\n"; @@ -175,7 +175,7 @@ print ''.$langs->trans("CashDeskBankAccountForCB").''; print ''; $defaultknown=0; if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) $defaultknown=1; // If a particular stock is defined, we disable choice -print $form->select_comptes(((GETPOST('bankid_cb') > 0)?GETPOST('bankid_cb'):$conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown?0:2)); +$form->select_comptes(((GETPOST('bankid_cb') > 0)?GETPOST('bankid_cb'):$conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown?0:2)); print ''; print "\n"; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 40906bfd455..7581b0c4985 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -323,7 +323,7 @@ if ($result) print ''; if (! $objp->rappro && ! $bankline->getVentilExportCompta()) { - print $form->select_comptes($acct->id, 'accountid', 0, '', 0); + $form->select_comptes($acct->id, 'accountid', 0, '', 0); } else { diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index abad76ce228..8f946a30001 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -197,7 +197,7 @@ if (! empty($conf->banque->enabled)) { print ''; print $langs->trans("BankAccount").''; - print $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); print ''; } diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index aefcb50369a..545fe9c368c 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -214,7 +214,7 @@ if (! empty($conf->banque->enabled)) { print ''; print $langs->trans("BankAccount").''; - print $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); print ''; } From e3480780cfd6a89bd06142ccc7d10e48aeea83da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 18:31:40 +0200 Subject: [PATCH 163/622] Fix label on "Connect" button on Simple POS module --- htdocs/cashdesk/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 9efe1b8ed7f..94b3e4445f7 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -191,7 +191,7 @@ print "\n";
    -
    +
    From 8d794049148f49af4d9531922606752ee6a38288 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2019 18:40:58 +0200 Subject: [PATCH 164/622] Fix css for responsive --- htdocs/cashdesk/index.php | 4 ++-- htdocs/theme/eldy/global.inc.php | 1 + htdocs/theme/md/style.css.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 94b3e4445f7..57dc1cbb394 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -96,11 +96,11 @@ else trans("Login"); ?> - + trans("Password"); ?> - + Date: Mon, 16 Sep 2019 19:08:45 +0200 Subject: [PATCH 165/622] Fix css for company logo in top menu --- htdocs/theme/eldy/global.inc.php | 6 +++--- htdocs/theme/md/style.css.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5beebb89a36..2ee73a7889b 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5673,7 +5673,7 @@ div.tabsElem a.tab { /* nboftopmenuentries = , fontsize= */ /* rule to reduce top menu - 1st reduction: Reduce width of top menu icons */ -@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1) ? round($nbtopmenuentries * 90, 0) + 240 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1; ?>px) /* reduction 1 */ +@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1) ? round($nbtopmenuentries * 90, 0) + 340 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1; ?>px) /* reduction 1 */ { div.tmenucenter { width: px; /* size of viewport */ @@ -5706,7 +5706,7 @@ div.tabsElem a.tab { } } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ -@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 40 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */ +@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 140 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */ { li.tmenucompanylogo { display: none; @@ -5733,7 +5733,7 @@ div.tabsElem a.tab { } } /* rule to reduce top menu - 3rd reduction: The menu for user is on left */ -@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 40 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ +@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 140 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ { .side-nav { z-index: 200; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8c78e8be88b..ab965b1d3d3 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -5670,7 +5670,7 @@ border-top-right-radius: 6px; /* nboftopmenuentries = , fontsize= */ /* disableimages = */ /* rule to reduce top menu - 1st reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { div.tmenucenter { max-width: px; /* size of viewport */ @@ -5697,7 +5697,7 @@ border-top-right-radius: 6px; } } /* rule to reduce top menu - 2nd reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { li.tmenucompanylogo { display: none; From 67b73cf0e6a6f731f340c0c5141615b966019028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 16 Sep 2019 20:57:20 +0200 Subject: [PATCH 166/622] Update actioncomm.class.php --- htdocs/comm/action/class/actioncomm.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 12926f9b360..7e8bd88e5bc 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -772,6 +772,7 @@ class ActionComm extends CommonObject $error=0; $this->db->begin(); + $this->oldcopy = clone $this; $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; $sql.= " WHERE id=".$this->id; From f369c1a80a41dfa032dd875add059edd7a87dcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 16 Sep 2019 20:59:13 +0200 Subject: [PATCH 167/622] Update card.php --- htdocs/comm/action/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 173770d725c..b2438175123 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -608,6 +608,7 @@ if ($action == 'update') if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); + $object->fetch_optionals(); if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) From fb7ef3cefc6ca9765e0e4db5f8058ea390d6c63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 16 Sep 2019 23:12:11 +0200 Subject: [PATCH 168/622] Update card.php --- htdocs/comm/action/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b2438175123..1df5c06f51f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -421,6 +421,7 @@ if ($action == 'update') if ($p2min == -1) $p2min='0'; $object->fetch($id); + $object->fetch_optionals(); $object->fetch_userassigned(); $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); From 78386871f37daa2fab0c5da8acaff4e70777710f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 03:33:58 +0200 Subject: [PATCH 169/622] css --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 2ee73a7889b..533608aa132 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2650,7 +2650,7 @@ table.liste th, table.noborder th, table.noborder tr.liste_titre td, table.nobor } table.liste td, table.noborder td, div.noborder form div, table.tableforservicepart1 td, table.tableforservicepart2 td { padding: 7px 8px 7px 8px; /* t r b l */ - line-height: 22px; + /* line-height: 22px; This create trouble on cell login on list of last events of a contract*/ height: 22px; } div.liste_titre_bydiv .divsearchfield { From a2d3cde2915aee620e791a5472420e3a0c75cd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 07:59:46 +0200 Subject: [PATCH 170/622] some update after night --- htdocs/comm/action/card.php | 6 +++++- htdocs/comm/action/class/actioncomm.class.php | 1 - htdocs/comm/action/class/api_agendaevents.class.php | 12 +++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 1df5c06f51f..4eeb87a5b61 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -422,7 +422,9 @@ if ($action == 'update') $object->fetch($id); $object->fetch_optionals(); - $object->fetch_userassigned(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; + $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -610,6 +612,8 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); $object->fetch_optionals(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7e8bd88e5bc..12926f9b360 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -772,7 +772,6 @@ class ActionComm extends CommonObject $error=0; $this->db->begin(); - $this->oldcopy = clone $this; $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; $sql.= " WHERE id=".$this->id; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 833f97b3b6b..53d0ad61b90 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -237,6 +237,11 @@ class AgendaEvents extends DolibarrApi } $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetch_userassigned(); + $this->actioncomm->oldcopy = clone $this->actioncomm; + } if ( ! $result ) { throw new RestException(404, 'actioncomm not found'); } @@ -269,7 +274,12 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); } - $result = $this->actioncomm->fetch($id); + $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetch_userassigned(); + $this->actioncomm->oldcopy = clone $this->actioncomm; + } if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); From ecac1f9f404f5640ab502ff2fe43050c84d928e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 08:02:55 +0200 Subject: [PATCH 171/622] wip --- htdocs/comm/action/class/api_agendaevents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 53d0ad61b90..3f21e94f53d 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -274,7 +274,7 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); } - $result = $this->actioncomm->fetch($id); + $result = $this->actioncomm->fetch($id); if ($result) { $this->actioncomm->fetch_optionals(); $this->actioncomm->fetch_userassigned(); From 0d63c43ccd239b116b9c0283ddd79ec29f911570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 08:15:01 +0200 Subject: [PATCH 172/622] add doaction to actioncommcard --- htdocs/comm/action/card.php | 49 +++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 003203940a8..31b2f22a194 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -86,6 +86,18 @@ $form = new Form($db); $formfile = new FormFile($db); $formactions = new FormActions($db); +// Load object +if ($id > 0 && $action!='add') { + $ret = $object->fetch($id); + if ($ret > 0) { + $ret = $object->fetch_optionals(); + $ret1 = $object->fetch_userassigned(); + } + if ($ret < 0 || $ret1 < 0) { + dol_print_error('', $object->error); + } +} + // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); @@ -94,6 +106,9 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('actioncard','globalcard')); +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); /* * Actions @@ -101,7 +116,7 @@ $hookmanager->initHooks(array('actioncard','globalcard')); $listUserAssignedUpdated = false; // Remove user to assigned list -if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') +if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) { $idtoremove=GETPOST('removedassigned'); @@ -122,7 +137,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') } // Add user to assigned list -if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) +if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) { // Add a new user if (GETPOST('assignedtouser') > 0) @@ -143,15 +158,15 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) } // Link to a project -if ($action == 'classin' && ($user->rights->agenda->allactions->create || +if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { - $object->fetch($id); + //$object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') +if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { @@ -160,7 +175,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') else { if ($id > 0) { - $object->fetch($id); + //$object->fetch($id); if (!empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned); @@ -178,7 +193,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Add event -if ($action == 'add') +if (empty($reshook) && $action == 'add') { $error=0; @@ -403,7 +418,7 @@ if ($action == 'add') /* * Action update event */ -if ($action == 'update') +if (empty($reshook) && $action == 'update') { if (empty($cancel)) { @@ -420,8 +435,8 @@ if ($action == 'update') if ($p2hour == -1) $p2hour='0'; if ($p2min == -1) $p2min='0'; - $object->fetch($id); - $object->fetch_userassigned(); + //$object->fetch($id); + //$object->fetch_userassigned(); $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -546,9 +561,9 @@ if ($action == 'update') /* * delete event */ -if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') +if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { - $object->fetch($id); + //$object->fetch($id); if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) @@ -571,10 +586,10 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') * Action move update, used when user move an event in calendar by drag'n drop * TODO Move this into page comm/action/index that trigger this call by the drag and drop of event. */ -if (GETPOST('actionmove', 'alpha') == 'mupdate') +if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { - $object->fetch($id); - $object->fetch_userassigned(); + //$object->fetch($id); + //$object->fetch_userassigned(); $shour = dol_print_date($object->datep, "%H"); $smin = dol_print_date($object->datep, "%M"); @@ -614,7 +629,9 @@ if (GETPOST('actionmove', 'alpha') == 'mupdate') // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissioncreate = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); -include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; +if (empty($reshook) { + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; +} /* From 155e8fb50083934adca79862db73d0de76d137b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 08:18:01 +0200 Subject: [PATCH 173/622] fix syntax --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 31b2f22a194..6418869bf1d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -629,7 +629,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissioncreate = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); -if (empty($reshook) { +if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } From e4984492b3173a053362da42bd11f59b7d511ed4 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 17 Sep 2019 09:32:43 +0200 Subject: [PATCH 174/622] Dejarlo igual que develop --- htdocs/compta/facture/class/facture-rec.class.php | 6 +----- htdocs/compta/facture/class/facture.class.php | 1 - htdocs/install/mysql/tables/llx_facture_rec.sql | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 57ecc836acf..37a031198bc 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -77,7 +77,6 @@ class FactureRec extends CommonInvoice public $total; public $db_table; public $propalid; - public $ref_client; public $date_last_gen; public $date_when; @@ -168,7 +167,6 @@ class FactureRec extends CommonInvoice $sql.= ", fk_account"; $sql.= ", fk_cond_reglement"; $sql.= ", fk_mode_reglement"; - $sql.= ", ref_client"; $sql.= ", usenewprice"; $sql.= ", frequency"; $sql.= ", unit_frequency"; @@ -197,7 +195,6 @@ class FactureRec extends CommonInvoice $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null"); $sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); $sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); - $sql.= ",'".$this->db->escape($this->ref_client)."'"; $sql.= ", ".$this->usenewprice; $sql.= ", ".$this->frequency; $sql.= ", '".$this->db->escape($this->unit_frequency)."'"; @@ -386,7 +383,7 @@ class FactureRec extends CommonInvoice $sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.modelpdf'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; - $sql.= ', f.fk_account, f.ref_client'; + $sql.= ', f.fk_account'; $sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; $sql.= ', f.generate_pdf'; $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; @@ -1147,7 +1144,6 @@ class FactureRec extends CommonInvoice $facture->brouillon = 1; $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - $facture->ref_client = $facturerec->ref_client; $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 70ecf6500f5..131f0ee90fd 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -372,7 +372,6 @@ class Facture extends CommonInvoice $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template $this->entity = $_facrec->entity; // Invoice created in same entity than template - $this->ref_client = $_facrec->ref_client; // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index 2c1c2514488..1add07c6e8c 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -29,7 +29,6 @@ create table llx_facture_rec tms timestamp, -- date creation/modification suspended integer DEFAULT 0, -- 1=suspended - ref_client varchar(255), -- reference for customer amount double(24,8) DEFAULT 0 NOT NULL, remise real DEFAULT 0, From 3f25a8d8d57d38792f46ac736dd6ce75630075da Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 17 Sep 2019 09:38:08 +0200 Subject: [PATCH 175/622] New: Load invoices only if showed --- htdocs/compta/facture/card.php | 88 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ff5a280a118..6d0bf2f56bc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -12,7 +12,7 @@ * Copyright (C) 2013 Jean-Francois FERRY * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2014-2018 Ferran Marcet + * Copyright (C) 2014-2019 Ferran Marcet * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2018 Frédéric France * @@ -2862,49 +2862,6 @@ if ($action == 'create') } } - // Type de facture - $facids = $facturestatic->list_replacable_invoices($soc->id); - if ($facids < 0) { - dol_print_error($db, $facturestatic); - exit(); - } - $options = ""; - foreach ($facids as $facparam) - { - $options .= ''; - } - - // Show link for credit note - $facids=$facturestatic->list_qualified_avoir_invoices($soc->id); - if ($facids < 0) - { - dol_print_error($db, $facturestatic); - exit; - } - $optionsav = ""; - $newinvoice_static = new Facture($db); - foreach ($facids as $key => $valarray) - { - $newinvoice_static->id = $key; - $newinvoice_static->ref = $valarray ['ref']; - $newinvoice_static->statut = $valarray ['status']; - $newinvoice_static->type = $valarray ['type']; - $newinvoice_static->paye = $valarray ['paye']; - - $optionsav .= ''; - } - print '' . $langs->trans('Type') . ''; print '
    ' . "\n"; @@ -2981,6 +2938,23 @@ if ($action == 'create') // Replacement if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) { + // Type de facture + $facids = $facturestatic->list_replacable_invoices($soc->id); + if ($facids < 0) { + dol_print_error($db, $facturestatic); + exit(); + } + $options = ""; + foreach ($facids as $facparam) + { + $options .= ''; + } + print ''; print '
    '; $tmp='global->INVOICE_DISABLE_CREDIT_NOTE)) { + // Show link for credit note + $facids=$facturestatic->list_qualified_avoir_invoices($soc->id); + if ($facids < 0) + { + dol_print_error($db, $facturestatic); + exit; + } + $optionsav = ""; + $newinvoice_static = new Facture($db); + foreach ($facids as $key => $valarray) + { + $newinvoice_static->id = $key; + $newinvoice_static->ref = $valarray ['ref']; + $newinvoice_static->statut = $valarray ['status']; + $newinvoice_static->type = $valarray ['type']; + $newinvoice_static->paye = $valarray ['paye']; + + $optionsav .= ''; + } + print '
    '; $tmp=' Date: Tue, 17 Sep 2019 09:43:15 +0200 Subject: [PATCH 176/622] New: Load invoices only if showed --- htdocs/fourn/facture/card.php | 87 ++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ae042b4c4b8..db5b87e590f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -10,6 +10,7 @@ * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2016-2017 Alexandre Spangaro * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Ferran Marcet * * 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 @@ -1765,49 +1766,6 @@ if ($action == 'create') print ''.$langs->trans('RefSupplier').''; print ''; - // Type invoice - $facids = $facturestatic->list_replacable_supplier_invoices($societe->id); - if ($facids < 0) { - dol_print_error($db, $facturestatic); - exit(); - } - $options = ""; - foreach ($facids as $facparam) - { - $options .= ''; - } - - // Show link for credit note - $facids=$facturestatic->list_qualified_avoir_supplier_invoices($societe->id); - if ($facids < 0) - { - dol_print_error($db, $facturestatic); - exit; - } - $optionsav = ""; - $newinvoice_static = new FactureFournisseur($db); - foreach ($facids as $key => $valarray) - { - $newinvoice_static->id = $key; - $newinvoice_static->ref = $valarray ['ref']; - $newinvoice_static->statut = $valarray ['status']; - $newinvoice_static->type = $valarray ['type']; - $newinvoice_static->paye = $valarray ['paye']; - - $optionsav .= ''; - } - print ''.$langs->trans('Type').''; print '
    ' . "\n"; @@ -1860,6 +1818,23 @@ if ($action == 'create') // Replacement if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) { + // Type invoice + $facids = $facturestatic->list_replacable_supplier_invoices($societe->id); + if ($facids < 0) { + dol_print_error($db, $facturestatic); + exit(); + } + $options = ""; + foreach ($facids as $facparam) + { + $options .= ''; + } + print ''; print '
    '; $tmp='global->INVOICE_DISABLE_CREDIT_NOTE)) { + // Show link for credit note + $facids=$facturestatic->list_qualified_avoir_supplier_invoices($societe->id); + if ($facids < 0) + { + dol_print_error($db, $facturestatic); + exit; + } + $optionsav = ""; + $newinvoice_static = new FactureFournisseur($db); + foreach ($facids as $key => $valarray) + { + $newinvoice_static->id = $key; + $newinvoice_static->ref = $valarray ['ref']; + $newinvoice_static->statut = $valarray ['status']; + $newinvoice_static->type = $valarray ['type']; + $newinvoice_static->paye = $valarray ['paye']; + + $optionsav .= ''; + } + print '
    '; $tmp=' Date: Tue, 17 Sep 2019 10:05:35 +0200 Subject: [PATCH 177/622] FIX selectFields for GROUP BY and show only if units defined --- htdocs/core/class/html.form.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 52be1cec2b0..5c2d89cdf60 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2120,7 +2120,7 @@ class Form // Units if (! empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; - $selectFields .= ', unit_long, unit_short'; + $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; } // Multilang : we add translation @@ -2419,19 +2419,19 @@ class Form if (!empty($objp->unit_short)) { $outvalUnits .= ' - ' . $objp->unit_short; } - if (!empty($objp->weight)) { + if (!empty($objp->weight) && $objp->weight_units!==null) { $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); $outvalUnits .= ' - ' . $unitToShow; } - if (!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) { + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units!==null) { $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); $outvalUnits .= ' - ' . $unitToShow; } - if (!empty($objp->surface)) { + if (!empty($objp->surface) && $objp->surface_units!==null) { $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); $outvalUnits .= ' - ' . $unitToShow; } - if (!empty($objp->volume)) { + if (!empty($objp->volume) && $objp->volume_units!==null) { $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); $outvalUnits .= ' - ' . $unitToShow; } @@ -2796,19 +2796,19 @@ class Form if (!empty($objp->unit_short)) { $outvalUnits .= ' - ' . $objp->unit_short; } - if (!empty($objp->weight)) { + if (!empty($objp->weight) && $objp->weight_units!==null) { $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); $outvalUnits .= ' - ' . $unitToShow; } - if (!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) { + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units!==null) { $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); $outvalUnits .= ' - ' . $unitToShow; } - if (!empty($objp->surface)) { + if (!empty($objp->surface) && $objp->surface_units!==null) { $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); $outvalUnits .= ' - ' . $unitToShow; } - if (!empty($objp->volume)) { + if (!empty($objp->volume) && $objp->volume_units!==null) { $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); $outvalUnits .= ' - ' . $unitToShow; } From a44836ae406ac4feaf7fbdcf9e8b562d003e0574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 10:15:55 +0200 Subject: [PATCH 178/622] Update CMailFile.class.php --- htdocs/core/class/CMailFile.class.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 43ad52b5f47..864f2869b82 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -80,6 +80,18 @@ class CMailFile public $headers; public $message; + /** + * @var array fullfilenames list + */ + public $filename_list = array(); + /** + * @var array mimetypes of files list + */ + public $mimetype_list = array(); + /** + * @var array filenames list + */ + public $mimefilename_list = array(); // Image public $html; @@ -125,6 +137,9 @@ class CMailFile global $conf, $dolibarr_main_data_root; $this->sendcontext = $sendcontext; + $this->filename_list = $filename_list; + $this->mimetype_list = $mimetype_list; + $this->mimefilename_list = $mimefilename_list; if (empty($replyto)) $replyto=$from; From 2ac8bd4e1629f27e5f5c745ade6db6f0b3933fd3 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 17 Sep 2019 11:59:58 +0200 Subject: [PATCH 179/622] FIX : If we share invoice, we need to see discount created from a deposit on each entity --- htdocs/core/class/discount.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 2e99a83ec42..d464e986c32 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -91,7 +91,7 @@ class DiscountAbsolute $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; - $sql.= " WHERE sr.entity = " . $conf->entity; + $sql.= " WHERE sr.entity IN (".getEntity('invoice').")"; if ($rowid) $sql.= " AND sr.rowid=".$rowid; if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source; if ($fk_invoice_supplier_source) $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; From d3b17f4f2d4df244f0023fa3b683a122f1fb32d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 12:08:33 +0200 Subject: [PATCH 180/622] FIX form not closed. --- htdocs/projet/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index c025fe91ab5..e1938fa05be 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -48,7 +48,6 @@ $sortorder = GETPOST("sortorder", 'alpha'); $max=3; - /* * View */ @@ -76,12 +75,14 @@ else $titleall=$langs->trans("AllAllowedProjects").'

    '; $morehtml=''; -$morehtml.='
    '; +$morehtml.=''; +$morehtml.=''; $morehtml.=''; $morehtml.=''; +$morehtml.='
    '; print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'title_project.png', 0, $morehtml); From a91f39ea3e99501512dc5fb6a52dc67d4610f615 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 12:08:33 +0200 Subject: [PATCH 181/622] FIX selection of project i am contact of. --- htdocs/projet/index.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index c025fe91ab5..22be3ab35db 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -48,19 +48,17 @@ $sortorder = GETPOST("sortorder", 'alpha'); $max=3; - /* * View */ $companystatic=new Societe($db); $projectstatic=new Project($db); -$userstatic=new User($db); $form=new Form($db); $formfile=new FormFile($db); $projectset = ($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projetset, 1); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projectset, 1); //var_dump($projectsListId); llxHeader("", $langs->trans("Projects"), "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); @@ -74,14 +72,15 @@ $titleall=$langs->trans("AllAllowedProjects"); if (! empty($user->rights->projet->all->lire) && ! $socid) $titleall=$langs->trans("AllProjects"); else $titleall=$langs->trans("AllAllowedProjects").'

    '; - $morehtml=''; -$morehtml.='
    '; +$morehtml.=''; +$morehtml.=''; $morehtml.=''; $morehtml.=''; +$morehtml.='
    '; print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'title_project.png', 0, $morehtml); @@ -164,7 +163,6 @@ print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppst print '
    '; - // Last modified projects $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.tms as datem,"; $sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas"; From 64c53e2e8556c0e2f28b645c223fb70c5235fc3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 12:19:33 +0200 Subject: [PATCH 182/622] Fix "project i am contact for" filter --- htdocs/projet/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 4c4ae4c71cf..3ca6296f81d 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -57,7 +57,7 @@ $form=new Form($db); $formfile=new FormFile($db); $projectset = ($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projetset, 1); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projectset, 1); //var_dump($projectsListId); From 24cb1390e4e4327b84dcc5e58e42b153b72aa0cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 13:17:25 +0200 Subject: [PATCH 183/622] FIX Update of leave request when CSRF with token is on FIX Export of leave request show the number of open days --- htdocs/core/modules/modHoliday.class.php | 5 +++-- htdocs/exports/class/export.class.php | 9 ++++++++- htdocs/holiday/card.php | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index ba792ad28ad..61217d91686 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -202,13 +202,13 @@ class modHoliday extends DolibarrModules $this->export_permission[$r]=array(array("holiday","read_all")); $this->export_fields_array[$r]=array( 'd.rowid'=>"LeaveId",'d.fk_type'=>'TypeOfLeaveId','t.code'=>'TypeOfLeaveCode','t.label'=>'TypeOfLeaveLabel','d.fk_user'=>'UserID', - 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay', + 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay','none.num_open_days'=>'NbUseDaysCP', 'd.date_valid'=>'DateApprove','d.fk_validator'=>"UserForApprovalID",'ua.lastname'=>"UserForApprovalLastname",'ua.firstname'=>"UserForApprovalFirstname", 'ua.login'=>"UserForApprovalLogin",'d.description'=>'Description','d.statut'=>'Status' ); $this->export_TypeFields_array[$r]=array( 'd.rowid'=>"Numeric",'t.code'=>'Text', 't.label'=>'Text','d.fk_user'=>'Numeric', - 'u.lastname'=>'Text','u.firstname'=>'Text','u.login'=>"Text",'d.date_debut'=>'Date','d.date_fin'=>'Date', + 'u.lastname'=>'Text','u.firstname'=>'Text','u.login'=>"Text",'d.date_debut'=>'Date','d.date_fin'=>'Date','none.num_open_days'=>'NumericCompute', 'd.date_valid'=>'Date','d.fk_validator'=>"Numeric",'ua.lastname'=>"Text",'ua.firstname'=>"Text", 'ua.login'=>"Text",'d.description'=>'Text','d.statut'=>'Numeric' ); @@ -216,6 +216,7 @@ class modHoliday extends DolibarrModules 'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ua.lastname'=>'user','ua.firstname'=>'user','ua.login'=>'user' ); $this->export_alias_array[$r]=array('d.rowid'=>"idholiday"); + $this->export_special_array[$r] = array('none.num_open_days'=>'getNumOpenDays'); $this->export_dependencies_array[$r]=array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_sql_start[$r]='SELECT DISTINCT '; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 51a16f717b2..f6ef6a27e2b 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -540,7 +540,7 @@ class Export public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') { // phpcs:enable - global $conf,$langs; + global $conf,$langs,$mysoc; $indice=0; asort($array_selected); @@ -634,6 +634,13 @@ class Export $alias=str_replace(array('.', '-','(',')'), '_', $key); if ($obj->$alias < 0) $obj->$alias='0'; } + // Operation GETNUMOPENDAYS (for Holiday module) + elseif ($this->array_export_special[$indice][$key]=='getNumOpenDays') + { + //$alias=$this->array_export_alias[$indice][$key]; + $alias=str_replace(array('.', '-','(',')'), '_', $key); + $obj->$alias=num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code); + } // Operation INVOICEREMAINTOPAY elseif ($this->array_export_special[$indice][$key]=='getRemainToPay') { diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 204d832a94c..1f597f2ddc2 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1134,6 +1134,7 @@ else if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) $edit = true; print '
    '."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; } From 214bf4375eb9cfafa32723131e597ff01643e0ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 13:28:36 +0200 Subject: [PATCH 184/622] Fix missing include --- htdocs/exports/class/export.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index f6ef6a27e2b..da184f27574 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -637,6 +637,7 @@ class Export // Operation GETNUMOPENDAYS (for Holiday module) elseif ($this->array_export_special[$indice][$key]=='getNumOpenDays') { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; //$alias=$this->array_export_alias[$indice][$key]; $alias=str_replace(array('.', '-','(',')'), '_', $key); $obj->$alias=num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code); From 5e7b7bbc33c846f36768bb3dc8688d4b76879945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 13:31:45 +0200 Subject: [PATCH 185/622] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2eead6da81d..e7764be3ceb 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; */ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '') { - global $user,$conf,$langs,$dolibarr_main_db_name; + global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc; $mainmenu=(empty($_SESSION["mainmenu"])?'':$_SESSION["mainmenu"]); $leftmenu=(empty($_SESSION["leftmenu"])?'':$_SESSION["leftmenu"]); From c8bfd2c7c25ed51ce2bc7894c9b62c9d13531df5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 13:37:34 +0200 Subject: [PATCH 186/622] NEW translation for member type usefull for sync with API and multilanguage front end or application --- htdocs/core/lib/member.lib.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 27df67aedac..3628c9cdc51 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -127,6 +127,15 @@ function member_type_prepare_head(AdherentType $object) $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $head[$h][0] = DOL_URL_ROOT."/adherents/traduction.php?rowid=".$object->id; + $head[$h][1] = $langs->trans("Translation"); + $head[$h][2] = 'translation'; + $h++; + } if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) From cff6da34df676f08e99d9fa0f750ec0a7411c80d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 13:53:06 +0200 Subject: [PATCH 187/622] Create traduction.php --- htdocs/adherents/traduction.php | 323 ++++++++++++++++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 htdocs/adherents/traduction.php diff --git a/htdocs/adherents/traduction.php b/htdocs/adherents/traduction.php new file mode 100644 index 00000000000..23ed3775735 --- /dev/null +++ b/htdocs/adherents/traduction.php @@ -0,0 +1,323 @@ + + * Copyright (C) 2007 Rodolphe Quiedeville + * Copyright (C) 2010-2012 Destailleur Laurent + * Copyright (C) 2014 Henry Florian + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/product/traduction.php + * \ingroup product + * \brief Page de traduction des produits + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('members', 'languages')); + +$id = GETPOST('rowid', 'int'); +$action=GETPOST('action', 'alpha'); +$cancel=GETPOST('cancel', 'alpha'); + +// Security check +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); +$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +if ($user->societe_id) $socid=$user->societe_id; +// Security check +$result=restrictedArea($user, 'adherent', $id, 'adherent_type'); + + +/* + * Actions + */ + +// retour a l'affichage des traduction si annulation +if ($cancel == $langs->trans("Cancel")) +{ + $action = ''; +} + +if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) +{ + $object = new AdherentType($db); + $object->fetch($id); + $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user); +} + +// Add translation +if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ + $object = new AdherentType($db); + $object->fetch($id); + $current_lang = $langs->getDefaultLang(); + + // update de l'objet + if ( $_POST["forcelangprod"] == $current_lang ) + { + $object->label = $_POST["libelle"]; + $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->other = dol_htmlcleanlastbr($_POST["other"]); + } + else + { + $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); + } + + // sauvegarde en base + if ( $object->setMultiLangs($user) > 0 ) + { + $action = ''; + } + else + { + $action = 'add'; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Edit translation +if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ + $object = new AdherentType($db); + $object->fetch($id); + $current_lang = $langs->getDefaultLang(); + + foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet + { + if ( $key == $current_lang ) + { + $object->label = $_POST["libelle-".$key]; + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); + } + else + { + $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); + } + } + + if ( $object->setMultiLangs($user) > 0 ) + { + $action = ''; + } + else + { + $action = 'edit'; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Delete translation +if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ + $object = new AdherentType($db); + $object->fetch($id); + $langtodelete=GETPOST('langdel', 'alpha'); + + + if ( $object->delMultiLangs($langtodelete, $user) > 0 ) + { + $action = ''; + } + else + { + $action = 'edit'; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +$object = new AdherentType($db); +$result = $object->fetch($id); + + +/* + * View + */ + +$title = $langs->trans('MemberTypeCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label, 16); + +$title = $langs->trans('MemberType')." ". $shortlabel ." - ".$langs->trans('Translation'); +$helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + +llxHeader('', $title, $helpurl); + +$form = new Form($db); +$formadmin=new FormAdmin($db); + +$head = member_type_prepare_head($object); +$titre=$langs->trans("MemberType".$object->type); + +// Calculate $cnt_trans +$cnt_trans = 0; +if (! empty($object->multilangs)) +{ + foreach ($object->multilangs as $key => $value) + { + $cnt_trans++; + } +} + + +dol_fiche_head($head, 'translation', $titre, 0, 'group'); + +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'rowid', $linkback); + +dol_fiche_end(); + + + +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ + +print "\n
    \n"; + +if ($action == '') +{ + if ($user->rights->produit->creer || $user->rights->service->creer) + { + print ''.$langs->trans("Add").''; + if ($cnt_trans > 0) print ''.$langs->trans("Update").''; + } +} + +print "\n
    \n"; + + + +if ($action == 'edit') +{ + //WYSIWYG Editor + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + + print ''; + print ''; + print ''; + print ''; + + if (! empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { + $s=picto_from_langcode($key); + print "
    ".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
    "; + + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '.$langs->trans('Label').'
    '.$langs->trans('Description').''; + $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); + $doleditor->Create(); + print '
    '; + } + } + + print '
    '; + + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; + + print ''; +} +elseif ($action != 'add') +{ + if (! empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { + $s=picto_from_langcode($key); + print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; + + print '
    '; + print '
    '; + print ''; + print ''; + print ''; + print '
    '.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
    '.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
    '; + print '
    '; + } + } + if (! $cnt_trans && $action != 'add') print '
    '. $langs->trans('NoTranslation').'
    '; +} + + + +/* + * Form to add a new translation + */ + +if ($action == 'add' && $user->rights->adherent->configurer) +{ + //WYSIWYG Editor + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + + print '
    '; + print '
    '; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''; + print ''; + print ''; + print ''; + + print '
    '.$langs->trans('Language').''; + print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + print '
    '.$langs->trans('Label').'
    '.$langs->trans('Description').''; + $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); + $doleditor->Create(); + print '
    '; + + dol_fiche_end(); + + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; + + print '
    '; + + print '
    '; +} + +// End of page +llxFooter(); +$db->close(); From c01ab4ab53cbfd81284aced4aae976f27f36e82f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 13:53:34 +0200 Subject: [PATCH 188/622] Update adherent_type.class.php --- .../adherents/class/adherent_type.class.php | 206 +++++++++++++++++- 1 file changed, 203 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9591a24fa78..1ed576a362d 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -88,6 +88,8 @@ class AdherentType extends CommonObject /** @var array Array of members */ public $members=array(); + + public $multilangs=array(); /** @@ -101,6 +103,185 @@ class AdherentType extends CommonObject $this->statut = 1; } + /** + * Load array this->multilangs + * + * @return int <0 if KO, >0 if OK + */ + public function getMultiLangs() + { + global $langs; + + $current_lang = $langs->getDefaultLang(); + + $sql = "SELECT lang, label, description, email"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql.= " WHERE fk_type=".$this->id; + + $result = $this->db->query($sql); + if ($result) { + while ($obj = $this->db->fetch_object($result)) + { + //print 'lang='.$obj->lang.' current='.$current_lang.'
    '; + if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. + { + $this->label = $obj->label; + $this->description = $obj->description; + $this->email = $obj->email; + } + $this->multilangs["$obj->lang"]["label"] = $obj->label; + $this->multilangs["$obj->lang"]["description"] = $obj->description; + $this->multilangs["$obj->lang"]["email"] = $obj->email; + } + return 1; + } + else + { + $this->error="Error: ".$this->db->lasterror()." - ".$sql; + return -1; + } + } + + /** + * Update or add a translation for a product + * + * @param User $user Object user making update + * @return int <0 if KO, >0 if OK + */ + public function setMultiLangs($user) + { + global $conf, $langs; + + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); + $current_lang = $langs->getDefaultLang(); + + foreach ($langs_available as $key => $value) + { + if ($key == $current_lang) { + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql.= " WHERE fk_type=".$this->id; + $sql.= " AND lang='".$key."'"; + + $result = $this->db->query($sql); + + if ($this->db->num_rows($result)) // if there is already a description line for this language + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql2.= " SET "; + $sql2.= " label='".$this->db->escape($this->label)."',"; + $sql2.= " description='".$this->db->escape($this->description)."'"; + if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'"; + } + $sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + } + else + { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; + if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email"; + } + $sql2.= ")"; + $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',"; + $sql2.= " '".$this->db->escape($this->description)."'"; + if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'"; + } + $sql2.= ")"; + } + dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); + if (! $this->db->query($sql2)) { + $this->error=$this->db->lasterror(); + return -1; + } + } + elseif (isset($this->multilangs[$key])) { + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql.= " WHERE fk_type=".$this->id; + $sql.= " AND lang='".$key."'"; + + $result = $this->db->query($sql); + + if ($this->db->num_rows($result)) // if there is already a description line for this language + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql2.= " SET "; + $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'"; + } + $sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + } + else + { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; + if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email"; + } + $sql2.= ")"; + $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; + } + $sql2.= ")"; + } + + // We do not save if main fields are empty + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { + if (! $this->db->query($sql2)) { + $this->error=$this->db->lasterror(); + return -1; + } + } + } + else + { + // language is not current language and we didn't provide a multilang description for this language + } + } + + // Call trigger + $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user); + if ($result < 0) { + $this->error = $this->db->lasterror(); + return -1; + } + // End call triggers + + return 1; + } + + /** + * Delete a language for this product + * + * @param string $langtodelete Language code to delete + * @param User $user Object user making delete + * + * @return int <0 if KO, >0 if OK + */ + public function delMultiLangs($langtodelete, $user) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; + + dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + // Call trigger + $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user); + if ($result < 0) { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); + return -1; + } + // End call triggers + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); + return -1; + } + } /** * Fonction qui permet de creer le status de l'adherent @@ -111,7 +292,7 @@ class AdherentType extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf; + global $langs, $conf; $error=0; @@ -180,7 +361,7 @@ class AdherentType extends CommonObject */ public function update($user, $notrigger = 0) { - global $conf, $hookmanager; + global $langs, $conf, $hookmanager; $error=0; @@ -202,6 +383,17 @@ class AdherentType extends CommonObject $result = $this->db->query($sql); if ($result) { + + $this->description = $this->db->escape($this->note); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) { + if ($this->setMultiLangs($user) < 0) { + $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; + return -2; + } + } + $action='update'; // Actions on extra fields @@ -283,6 +475,8 @@ class AdherentType extends CommonObject */ public function fetch($rowid) { + global $langs, $conf; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -299,12 +493,18 @@ class AdherentType extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->label = $obj->label; - $this->morphy = $obj->morphy; + $this->morphy = $obj->morphy; $this->statut = $obj->statut; $this->subscription = $obj->subscription; $this->mail_valid = $obj->mail_valid; $this->note = $obj->note; $this->vote = $obj->vote; + + // multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) { + $this->getMultiLangs(); + } + } return 1; From a295d57e0c79cd40523fb8d565590352065e43c6 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 13:54:17 +0200 Subject: [PATCH 189/622] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 1ed576a362d..4e90390c223 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -493,7 +493,7 @@ class AdherentType extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->label = $obj->label; - $this->morphy = $obj->morphy; + $this->morphy = $obj->morphy; $this->statut = $obj->statut; $this->subscription = $obj->subscription; $this->mail_valid = $obj->mail_valid; From 8d8ded324d2b0eb5fade1cb5360c5d40d9593f00 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 17 Sep 2019 11:56:16 +0000 Subject: [PATCH 190/622] Fixing style errors. --- htdocs/adherents/class/adherent_type.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 4e90390c223..cd8a69e0f7d 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -504,7 +504,6 @@ class AdherentType extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) { $this->getMultiLangs(); } - } return 1; From 50be1a634c9eed41e92be80e803fbe3db1f0254a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 14:02:19 +0200 Subject: [PATCH 191/622] Create llx_adherent_type_lang.php --- .../mysql/tables/llx_adherent_type_lang.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_adherent_type_lang.php diff --git a/htdocs/install/mysql/tables/llx_adherent_type_lang.php b/htdocs/install/mysql/tables/llx_adherent_type_lang.php new file mode 100644 index 00000000000..5f1ceee1f49 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_adherent_type_lang.php @@ -0,0 +1,30 @@ +-- ============================================================================ +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2005-2010 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- 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 . +-- +-- ============================================================================ + +create table llx_adherent_type_lang +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_type integer DEFAULT 0 NOT NULL, + lang varchar(5) DEFAULT 0 NOT NULL, + label varchar(255) NOT NULL, + description text, + email text, + import_key varchar(14) DEFAULT NULL +)ENGINE=innodb; From afb055c8a668882d7ae8e73925d677f3a89a9766 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 14:03:09 +0200 Subject: [PATCH 192/622] Create llx_adherent_type_lang.sql --- .../mysql/tables/llx_adherent_type_lang.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_adherent_type_lang.sql diff --git a/htdocs/install/mysql/tables/llx_adherent_type_lang.sql b/htdocs/install/mysql/tables/llx_adherent_type_lang.sql new file mode 100644 index 00000000000..cbccac26020 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_adherent_type_lang.sql @@ -0,0 +1,30 @@ +-- ============================================================================ +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2005-2010 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- 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 . +-- +-- ============================================================================ + +create table llx_product_lang +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_product integer DEFAULT 0 NOT NULL, + lang varchar(5) DEFAULT 0 NOT NULL, + label varchar(255) NOT NULL, + description text, + note text, + import_key varchar(14) DEFAULT NULL +)ENGINE=innodb; From 430ffae8adc0d0ed870f2a72dfccef9572276619 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 14:03:22 +0200 Subject: [PATCH 193/622] Delete llx_adherent_type_lang.php --- .../mysql/tables/llx_adherent_type_lang.php | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_adherent_type_lang.php diff --git a/htdocs/install/mysql/tables/llx_adherent_type_lang.php b/htdocs/install/mysql/tables/llx_adherent_type_lang.php deleted file mode 100644 index 5f1ceee1f49..00000000000 --- a/htdocs/install/mysql/tables/llx_adherent_type_lang.php +++ /dev/null @@ -1,30 +0,0 @@ --- ============================================================================ --- Copyright (C) 2002-2003 Rodolphe Quiedeville --- Copyright (C) 2005-2010 Regis Houssin --- Copyright (C) 2009 Laurent Destailleur --- --- 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 . --- --- ============================================================================ - -create table llx_adherent_type_lang -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_type integer DEFAULT 0 NOT NULL, - lang varchar(5) DEFAULT 0 NOT NULL, - label varchar(255) NOT NULL, - description text, - email text, - import_key varchar(14) DEFAULT NULL -)ENGINE=innodb; From 4c59f6bffaad3f6c79a94430e8308f628a8092cf Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 14:03:55 +0200 Subject: [PATCH 194/622] Update llx_adherent_type_lang.sql --- htdocs/install/mysql/tables/llx_adherent_type_lang.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_adherent_type_lang.sql b/htdocs/install/mysql/tables/llx_adherent_type_lang.sql index cbccac26020..179a9418790 100644 --- a/htdocs/install/mysql/tables/llx_adherent_type_lang.sql +++ b/htdocs/install/mysql/tables/llx_adherent_type_lang.sql @@ -18,13 +18,13 @@ -- -- ============================================================================ -create table llx_product_lang +create table llx_adherent_type_lang ( rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_product integer DEFAULT 0 NOT NULL, + fk_type integer DEFAULT 0 NOT NULL, lang varchar(5) DEFAULT 0 NOT NULL, label varchar(255) NOT NULL, description text, - note text, + email text, import_key varchar(14) DEFAULT NULL )ENGINE=innodb; From b969de46bc0934029f0050309e69c963e605a602 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 17 Sep 2019 14:05:39 +0200 Subject: [PATCH 195/622] Update 10.0.0-11.0.0.sql --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 92dcdce1128..4ad51248700 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -164,4 +164,13 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-REPUBLICDAY', 0, 117, '', 0, 1, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-GANDI', 0, 117, '', 0, 10, 2, 1); - +create table llx_adherent_type_lang +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_type integer DEFAULT 0 NOT NULL, + lang varchar(5) DEFAULT 0 NOT NULL, + label varchar(255) NOT NULL, + description text, + email text, + import_key varchar(14) DEFAULT NULL +)ENGINE=innodb; From ea5ff59076935967ae95b80057c16d9523a420b0 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 17 Sep 2019 16:43:36 +0200 Subject: [PATCH 196/622] FIX check if a resource is in use after a drag and drop from events --- htdocs/comm/action/card.php | 76 +++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 173770d725c..3ef20a71a9c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -632,6 +632,8 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') */ if (GETPOST('actionmove', 'alpha') == 'mupdate') { + $error = 0; + $object->fetch($id); $object->fetch_userassigned(); @@ -653,10 +655,76 @@ if (GETPOST('actionmove', 'alpha') == 'mupdate') $object->datef+=$datep-$object->datep; } $object->datep=$datep; - $result=$object->update($user); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); + + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) . "'"; + $sql .= " WHERE ac.id != " . $object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . "element_resources"; + $sql .= " WHERE element_id = " . $object->id; + $sql .= " AND element_type = '" . $db->escape($object->element) . "'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
    - ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if (!$error) { + $db->begin(); + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } else { + $db->commit(); + } } } if (! empty($backtopage)) From 49b75e3f52d0c7393d3b4f3e257a0048f1ab56c9 Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Tue, 17 Sep 2019 17:40:42 +0200 Subject: [PATCH 197/622] support referent in the beluga export. The beluga export of a project, now supports additional referents, coming from the hooks. When the element is present in the view of all elements of the project, the beluga export will also export this element. [see: X] --- .../project/doc/pdf_beluga.modules.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 32a2d10f72d..f7314476023 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -361,6 +361,11 @@ class pdf_beluga extends ModelePDFProjects 'lang'=>'agenda') ); + $hookmanager->initHooks(array('completeListOfReferent')); + $hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action); + if(!empty($hookmanager->resArray)) { + $listofreferent = array_merge($listofreferent, $hookmanager->resArray); + } foreach ($listofreferent as $key => $value) { @@ -370,17 +375,13 @@ class pdf_beluga extends ModelePDFProjects $datefieldname=$value['datefieldname']; $qualified=$value['test']; $langstoload=$value['lang']; + $projectField=isset($value['project_field']) ? $value['project_field'] : 'fk_projet'; $langs->load($langstoload); if (! $qualified) continue; //var_dump("$key, $tablename, $datefieldname, $dates, $datee"); - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); - - if ($key == 'agenda') - { -// var_dump($elementarray); - } + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField); $num = count($elementarray); if ($num >= 0) @@ -394,7 +395,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetXY($this->posxref, $curY); $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); - $selectList = $formproject->select_element($tablename, $project->thirdparty->id); + $selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField); $nexY = $pdf->GetY() + 1; $curY = $nexY; $pdf->SetXY($this->posxref, $curY); @@ -569,9 +570,9 @@ class pdf_beluga extends ModelePDFProjects // Amount without tax if (empty($value['disableamount'])) { $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ' '), 1, 'R'); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R'); $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ' '), 1, 'R'); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R'); } else { $pdf->SetXY($this->posxamountht, $curY); if ($key == 'agenda') @@ -608,9 +609,9 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetXY($this->posxref, $curY); $pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L'); $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ' '), 1, 'R'); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R'); $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ' '), 1, 'R'); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R'); $pdf->SetXY($this->posxstatut, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb") . " " . $num, 1, 'L'); } From 3f6afa810c7b7dc2cede1cb867dc9e47637fa315 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 17:55:30 +0200 Subject: [PATCH 198/622] Code comment --- htdocs/core/lib/date.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 6ed17305096..ea5027de1ee 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -323,6 +323,7 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date) * 0 =Input date is local date using PHP server timezone * @return int Date as a timestamp * 19700101020000 -> 7200 with gm=1 + * 19700101000000 -> 0 with gm=1 * * @see dol_print_date(), dol_mktime(), dol_getdate() */ From a43253eab844c8caecc148c23b4dd5025e5ee1a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2019 18:49:56 +0200 Subject: [PATCH 199/622] Fix for deposit not correctly closed --- htdocs/compta/facture/card.php | 2 +- htdocs/install/mysql/migration/repair.sql | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ff5a280a118..6b24807c007 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4982,7 +4982,7 @@ elseif ($id > 0 || ! empty($ref)) } // Classify paid - if ($object->statut == 1 && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) + if (($object->statut == 1 && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) ) { diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 51fe48dcda2..4d87203b068 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -468,6 +468,12 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS -- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL; +-- Note to make all deposit as payed when there is already a discount generated from it. +--drop table tmp_invoice_deposit_mark_as_available; +--create table tmp_invoice_deposit_mark_as_available as select * from llx_facture as f where f.type = 3 and f.paye = 0 and f.rowid in (select fk_facture_source from llx_societe_remise_except); +--update llx_facture set paye = 1 where rowid in (select rowid from tmp_invoice_deposit_mark_as_available); + + -- Note to migrate from old counter aquarium to new one -- drop table tmp; From 87d41256d456a3c68b6822458ce15bf1ee17e905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 22:59:23 +0200 Subject: [PATCH 200/622] Update box_contacts.php --- htdocs/core/boxes/box_contacts.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 667f892bc0a..fb5cf2db7fb 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -83,8 +83,8 @@ class box_contacts extends ModeleBoxes if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; - $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile"; - $sql.= ", s.nom as socname, s.name_alias"; + $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; + $sql.= ", s.nom as socname, s.name_alias, s.email as semail"; $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; @@ -117,12 +117,14 @@ class box_contacts extends ModeleBoxes $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; + $contactstatic->email = $objp->spemail; $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; $societestatic->id = $objp->fk_soc; $societestatic->name = $objp->socname; + $societestatic->email = $objp->semail; $societestatic->name_alias = $objp->name_alias; $societestatic->code_client = $objp->code_client; $societestatic->code_fournisseur = $objp->code_fournisseur; From c38c0bec1c0932b976d060084371301e4c5d6851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 23:03:37 +0200 Subject: [PATCH 201/622] Update box_fournisseurs.php --- htdocs/core/boxes/box_fournisseurs.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 8d231cc472b..b80f9c27975 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015 Frederic France + * Copyright (C) 2015-2019 Frederic France * * 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 @@ -85,7 +85,7 @@ class box_fournisseurs extends ModeleBoxes if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; - $sql.= " s.code_fournisseur,"; + $sql.= " s.code_fournisseur, s.email as semail,"; $sql.= " s.logo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -109,6 +109,7 @@ class box_fournisseurs extends ModeleBoxes $datem=$db->jdate($objp->tms); $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; $thirdpartytmp->code_client = $objp->code_client; $thirdpartytmp->logo = $objp->logo; From c01ab451cc21c4c90c4bfdc8579dbedc973fb307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 17 Sep 2019 23:04:43 +0200 Subject: [PATCH 202/622] Update box_fournisseurs.php --- htdocs/core/boxes/box_fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index b80f9c27975..a90336753da 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -109,7 +109,7 @@ class box_fournisseurs extends ModeleBoxes $datem=$db->jdate($objp->tms); $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->email; + $thirdpartytmp->email = $objp->semail; $thirdpartytmp->code_client = $objp->code_client; $thirdpartytmp->logo = $objp->logo; From ca18448b48f6a041ed13762ac56233a095c5c6c7 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 18 Sep 2019 10:36:13 +0200 Subject: [PATCH 203/622] NEW add units fields in buying price tab of product card --- htdocs/product/fournisseurs.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index cb56ff63cfc..d8cfcae0bb7 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -491,6 +491,13 @@ if ($id > 0 || $ref) { print ''; } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $unit = $object->getLabelOfUnit(); + if ($unit !== '') { + print '  ' . $langs->trans($unit); + } + } print ''; // Vat rate @@ -778,11 +785,11 @@ SCRIPT; $num = count($product_fourn_list); if (($num + ($offset * $limit)) < $nbtotalofrecords) $num++; - print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER ['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); + print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); // Suppliers list title print '
    '; - print ''; + print '
    '; $param="&id=".$object->id; @@ -851,6 +858,13 @@ SCRIPT; // Quantity print ''; // VAT rate From 7455d772a2cda7032e0201be030b96f4382f2d25 Mon Sep 17 00:00:00 2001 From: com4WEB <42214196+com4WEB@users.noreply.github.com> Date: Wed, 18 Sep 2019 10:50:07 +0200 Subject: [PATCH 204/622] Update README.md --- README.md | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8100cabddbe..0ae6d1b9de5 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ If you don't have time to install it yourself, you can try some commercial 'read ## UPGRADING +- At first make a backup of your Dolibarr files & than see https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. - At first next access, Dolibarr will redirect your to the "install/" page to follow the upgrade process.  If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file into the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*"). @@ -90,18 +91,19 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Main application/modules (all optional) -- Customers, Prospects and/or Suppliers directory +- Customers, Prospects (Leads) and/or Suppliers directory - Products and/or Services catalog - Commercial proposals management - Customer and Supplier Orders management - Invoices and payment management - Standing orders management (European SEPA) - Bank accounts management +- Accounting management - Shared calendar/agenda (with ical and vcal export for third party tools integration) - Opportunities and/or project management - Projects management - Contracts management -- Stock management +- Warehouse/Stock management - Shipping management - Interventions management - Employee's leave requests management @@ -111,7 +113,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Foundations members management - Mass emailing - Surveys -- Point of Sale +- Point of Sale (POS) - … ### Other application/modules @@ -131,15 +133,15 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other general features -- Localization in most major languages. -- Multi-Users and groups with finely grained rights. -- Multi-currency. -- Multi-company by adding of an external module. -- Very user friendly and easy to use. +- Localization in most major languages +- Multi-Users and groups with finely grained rights +- Multi-currency +- Multi-company by adding of an external module +- Very user friendly and easy to use +- customizable Dashboard - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- Works with PHP 5.5+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) -- Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. -- APIs. + +- APIs - An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) - Support a lot of country specific features: - Spanish Tax RE and ISPF @@ -153,6 +155,12 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - PDF or ODT generation for invoice, proposals, orders... - … +### System Environment / Requirements + +- Works with PHP 5.5+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) +- Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. + + ### Extending Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). From cf7193691f4d853ca45b4d95efe1b1f157a8a0ee Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 18 Sep 2019 11:22:32 +0200 Subject: [PATCH 205/622] FIX dol_print_date format in buying price tooltip --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6847af5edf1..e18e02d4930 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -998,7 +998,7 @@ class ProductFournisseur extends Product //$out .= ''; $out .= ''; foreach ($productFournLogList as $productFournLog) { - $out.= ''; + $out.= ''; $out.= ''; //$out.= ''; $out.= ''; From 2da50716421b46fdeaa9a9b300d7754ab05a59bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Sep 2019 13:12:22 +0200 Subject: [PATCH 206/622] Fix VAT in New caledonia is now called TGC --- htdocs/langs/fr_NC/admin.lang | 6 ++--- htdocs/langs/fr_NC/companies.lang | 4 ++-- htdocs/langs/fr_NC/compta.lang | 40 +++++++++++++++---------------- htdocs/langs/fr_NC/main.lang | 8 +++---- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/htdocs/langs/fr_NC/admin.lang b/htdocs/langs/fr_NC/admin.lang index d86b324fdc5..f7c25610e3f 100644 --- a/htdocs/langs/fr_NC/admin.lang +++ b/htdocs/langs/fr_NC/admin.lang @@ -1,4 +1,4 @@ # Dolibarr language file - Source file is en_US - admin -VATManagement=Gestion TSS -VATIsUsedDesc=Le taux de TSS proposé par défaut lors de la création de proposition commerciale, facture, commande, etc... répond à la règle standard suivante :
    Si vendeur non assujetti à TSS, TSS par défaut=0. Fin de règle.
    Si le (pays vendeur= pays acheteur) alors TSS par défaut=TSS du produit vendu. Fin de règle.
    Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TSS par défaut=0 (La TSS doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.
    Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TSS par défaut=TSS du produit vendu. Fin de règle.
    Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TSS par défaut=0. Fin de règle.
    Sinon TSS proposée par défaut=0. Fin de règle.
    -VATIsNotUsedDesc=Le taux de TSS proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés. +VATManagement=Gestion TGC +VATIsUsedDesc=Le taux de TGC proposé par défaut lors de la création de proposition commerciale, facture, commande, etc... répond à la règle standard suivante :
    Si vendeur non assujetti à TGC, TGC par défaut=0. Fin de règle.
    Si le (pays vendeur= pays acheteur) alors TGC par défaut=TGC du produit vendu. Fin de règle.
    Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TGC par défaut=0 (La TGC doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.
    Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TGC par défaut=TGC du produit vendu. Fin de règle.
    Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TGC par défaut=0. Fin de règle.
    Sinon TGC proposée par défaut=0. Fin de règle.
    +VATIsNotUsedDesc=Le taux de TGC proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés. diff --git a/htdocs/langs/fr_NC/companies.lang b/htdocs/langs/fr_NC/companies.lang index 9853f7e7e21..c3520226e42 100644 --- a/htdocs/langs/fr_NC/companies.lang +++ b/htdocs/langs/fr_NC/companies.lang @@ -1,3 +1,3 @@ # Dolibarr language file - Source file is en_US - companies -VATIsUsed=Assujetti à la TSS -VATIsNotUsed=Non assujetti à la TSS +VATIsUsed=Assujetti à la TGC +VATIsNotUsed=Non assujetti à la TGC diff --git a/htdocs/langs/fr_NC/compta.lang b/htdocs/langs/fr_NC/compta.lang index f22e834c4a5..2d7a5468f84 100644 --- a/htdocs/langs/fr_NC/compta.lang +++ b/htdocs/langs/fr_NC/compta.lang @@ -1,21 +1,21 @@ # Dolibarr language file - Source file is en_US - compta -VATToPay=TSS ventes -VATReceived=TSS collectée -VATToCollect=TSS achats -VATSummary=Balance de TSS -VATPaid=TSS payée -VATCollected=TSS récupérée -PaymentVat=Règlement TSS -VATPayment=Règlement TSS -VATPayments=Règlements TSS -ShowVatPayment=Affiche paiement TSS -RulesResultInOut=- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TSS.
    - Il se base sur la date de règlement de ces factures, charges et TSS. -VATReportByCustomersInInputOutputMode=Rapport par client des TSS collectées et payées (TSS sur encaissement) -VATReportByQuartersInInputOutputMode=Rapport par taux des TSS collectées et payées (TSS sur encaissement) -SeeVATReportInInputOutputMode=Voir le rapport %sTSS encaissement%s pour mode de calcul standard -SeeVATReportInDueDebtMode=Voir le rapport %sTSS sur débit%s pour mode de calcul avec option sur les débits -RulesVATInServices=- Pour les services, le rapport inclut les TSS des règlements effectivement reçus ou émis en se basant sur la date du règlement. -RulesVATInProducts=- Pour les biens matériels, il inclut les TSS des factures en se basant sur la date de facture. -RulesVATDueServices=- Pour les services, le rapport inclut les TSS des factures dues, payées ou non en se basant sur la date de facture. -RulesVATDueProducts=- Pour les biens matériels, il inclut les TSS des factures en se basant sur la date de facture. -CalculationRuleDesc=Pour calculer le total de TSS, il existe 2 modes:
    Le mode 1 consiste à arrondir la TSS de chaque ligne et à sommer cet arrondi.
    Le mode 2 consiste à sommer la tva de chaque ligne puis à l'arrondir.
    Les résultats peuvent différer de quelques centimes. Le mode par défaut est le mode %s. +VATToPay=TGC ventes +VATReceived=TGC collectée +VATToCollect=TGC achats +VATSummary=Balance de TGC +VATPaid=TGC payée +VATCollected=TGC récupérée +PaymentVat=Règlement TGC +VATPayment=Règlement TGC +VATPayments=Règlements TGC +ShowVatPayment=Affiche paiement TGC +RulesResultInOut=- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TGC.
    - Il se base sur la date de règlement de ces factures, charges et TGC. +VATReportByCustomersInInputOutputMode=Rapport par client des TGC collectées et payées (TGC sur encaissement) +VATReportByQuartersInInputOutputMode=Rapport par taux des TGC collectées et payées (TGC sur encaissement) +SeeVATReportInInputOutputMode=Voir le rapport %sTGC encaissement%s pour mode de calcul standard +SeeVATReportInDueDebtMode=Voir le rapport %sTGC sur débit%s pour mode de calcul avec option sur les débits +RulesVATInServices=- Pour les services, le rapport inclut les TGC des règlements effectivement reçus ou émis en se basant sur la date du règlement. +RulesVATInProducts=- Pour les biens matériels, il inclut les TGC des factures en se basant sur la date de facture. +RulesVATDueServices=- Pour les services, le rapport inclut les TGC des factures dues, payées ou non en se basant sur la date de facture. +RulesVATDueProducts=- Pour les biens matériels, il inclut les TGC des factures en se basant sur la date de facture. +CalculationRuleDesc=Pour calculer le total de TGC, il existe 2 modes:
    Le mode 1 consiste à arrondir la TGC de chaque ligne et à sommer cet arrondi.
    Le mode 2 consiste à sommer la tva de chaque ligne puis à l'arrondir.
    Les résultats peuvent différer de quelques centimes. Le mode par défaut est le mode %s. diff --git a/htdocs/langs/fr_NC/main.lang b/htdocs/langs/fr_NC/main.lang index 82c7a4ee746..23b739d83e5 100644 --- a/htdocs/langs/fr_NC/main.lang +++ b/htdocs/langs/fr_NC/main.lang @@ -20,7 +20,7 @@ FormatDateHourSecShort=%d/%m/%Y %H:%M:%S FormatDateHourTextShort=%d %b %Y %H:%M FormatDateHourText=%d %B %Y %H:%M ErrorNoVATRateDefinedForSellerCountry=Erreur, aucun taux de taxe défini pour le pays '%s'. -AmountVAT=Montant TSS -TotalVAT=Total TSS -VAT=TSS -VATRate=Taux TSS +AmountVAT=Montant TGC +TotalVAT=Total TGC +VAT=TGC +VATRate=Taux TGC From d72548bd76173b2ad8a0c0d2e980bfff97f83563 Mon Sep 17 00:00:00 2001 From: John Botella Date: Wed, 18 Sep 2019 13:43:34 +0200 Subject: [PATCH 207/622] add filters --- htdocs/core/lib/ticket.lib.php | 87 ++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index fb274d06c20..21761286131 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -485,27 +485,50 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $userstatic=new User($db); $contactstatic = new Contact($db); $userGetNomUrlCache = array(); -// $out.='
    '; -// if ($objcon && get_class($objcon) == 'Contact' && -// (is_null($filterobj) || get_class($filterobj) == 'Societe')) -// { -// $out.=''; -// } -// else -// { -// $out.=''; -// } -// if ($filterobj && get_class($filterobj) == 'Societe') $out.=''; -// -// -// $out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1); -// -// $out.=''; -// -// $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); -// $out.=$searchpicto; -// -// $out.=''; + + $out.='
    '; + $out.='
    '; + if ($objcon && get_class($objcon) == 'Contact' && + (is_null($filterobj) || get_class($filterobj) == 'Societe')) + { + $out.=''; + } + else + { + $out.=''; + } + if ($filterobj && get_class($filterobj) == 'Societe') $out.=''; + + $out.="\n"; + + $out.='
    '; + $out.='
    '; print $productfourn->fourn_qty; + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $unit = $object->getLabelOfUnit(); + if ($unit !== '') { + print '  ' . $langs->trans($unit); + } + } print ''.$langs->trans("QtyMin").''.$langs->trans("User").'
    '.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').'
    '.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''.price($productFournLog['price']).''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
    '; + + $out.=''; + $out.=''; + if ($donetodo) + { + $out.=''; + } + $out.=''; + $out.=''; + + $out.=''; + $out.=''; + + + $out.='
    '.$langs->trans("Search").' : '.$langs->trans("Type").' '; + $out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1); + $out.=''; + $out.=$langs->trans("Label").' '; + $out.=''; + $out.=''; + $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $out.=$searchpicto; + $out.='
    '; + + $out.=''; + $out.='
    '; $out.="\n"; @@ -614,7 +637,19 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out.=''; - //$out.=''.$langs->trans('Show').''; + if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { + $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; + $out.=$histo[$key]['id']; + $out.=' '; + } else { + $out.=$actionstatic->getNomUrl(1, -1).' '; + } + +// if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id) +// { +// $out.=''.$langs->trans('Show').''; +// } + if ($user->rights->agenda->allactions->create || (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create)) @@ -645,13 +680,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no // Ref $out.='

    '; -// if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { -// $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; -// $out.=$histo[$key]['id']; -// $out.=''; -// } else { -// $out.=$actionstatic->getNomUrl(1, -1); -// } + // Author of event $out.=''; From 7b512587aadc3eca9e3565eed17f46c36498c643 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Sep 2019 14:15:20 +0200 Subject: [PATCH 208/622] FIX XSS --- htdocs/admin/mails_templates.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index e0dfcd75277..573d4c5fbaa 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -50,7 +50,7 @@ $confirm = GETPOST('confirm','alpha'); // Result of a confirmation $id = GETPOST('id','int'); $rowid = GETPOST('rowid','alpha'); -$search_label=GETPOST('search_label','alpha'); +$search_label=GETPOST('search_label', 'alphanohtml'); // Must allow value like 'Abc Def' or '(MyTemplateName)' $search_type_template=GETPOST('search_type_template','alpha'); $search_lang=GETPOST('search_lang','alpha'); $search_fk_user=GETPOST('search_fk_user','intcomma'); @@ -262,6 +262,7 @@ if (empty($reshook)) { //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); $keycode=$listfieldvalue[$i]; + if ($value == 'label') $_POST[$keycode] = dol_escape_htmltag($_POST[$keycode]); if ($value == 'lang') $keycode='langcode'; if ($value == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; @@ -666,8 +667,6 @@ if ($resql) print ''; foreach ($fieldlist as $field => $value) { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees $showfield=1; // By defaut $align="left"; $sortable=1; @@ -694,7 +693,7 @@ if ($resql) if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;} if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; } - // Affiche nom du champ + // Show fields if ($showfield) { if (! empty($tabhelp[$id][$value])) @@ -812,6 +811,10 @@ if ($resql) $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; + if ($value == 'label' || $value == 'topic') + { + $valuetoshow = dol_escape_htmltag($valuetoshow); + } if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; From 345ac28c8999d53ed541fb14cd08f4692e21aec6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Aug 2019 16:22:24 +0200 Subject: [PATCH 209/622] Fix js injection Conflicts: htdocs/core/lib/functions.lib.php htdocs/user/group/card.php --- htdocs/core/lib/functions.lib.php | 8 ++++++-- htdocs/main.inc.php | 16 +++++++++------- htdocs/user/group/card.php | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 20930ca52c4..bf79b2070d5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -966,11 +966,15 @@ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) * @param string $stringtoescape String to escape * @param int $keepb 1=Preserve b tags (otherwise, remove them) * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a '."\n"; - print ''; + print ''; print ''."\n"; - print ''; + print ''; print ''."\n"; // Country - print ''; + print ''; //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization print $form->select_country($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''."\n"; - print ''; + print ''; $formcompany->select_departement($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'state_id'); print ''."\n"; - print ''; + print ''; print ''; print ''."\n"; - print ''; + print ''; print ''; print ''."\n"; - print ''; + print ''; print ''; print ''."\n"; // Web - print ''; + print ''; print ''; print ''."\n"; // Code - print ''; + print ''; print ''."\n"; // Note - print ''; + print ''; print ''; print ''; @@ -189,24 +189,24 @@ else print '
    '; print ''; - print ''; + print ''; - print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; print '
    '.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
    '.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
    '.$langs->trans("CompanyName").''; + print '
    '.$langs->trans("CompanyName").''; print $conf->global->MAIN_INFO_ACCOUNTANT_NAME; print '
    '.$langs->trans("CompanyAddress").'' . nl2br(empty($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS) . '
    '.$langs->trans("CompanyAddress").'' . nl2br(empty($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS) . '
    '.$langs->trans("CompanyZip").'' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_ZIP)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ZIP) . '
    '.$langs->trans("CompanyZip").'' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_ZIP)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ZIP) . '
    '.$langs->trans("CompanyTown").'' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_TOWN)?'':$conf->global->MAIN_INFO_ACCOUNTANT_TOWN) . '
    '.$langs->trans("CompanyTown").'' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_TOWN)?'':$conf->global->MAIN_INFO_ACCOUNTANT_TOWN) . '
    '.$langs->trans("CompanyCountry").''; + print '
    '.$langs->trans("CompanyCountry").''; if (! empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY)) { $code = getCountry($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 2); @@ -217,23 +217,23 @@ else print '
    '.$langs->trans("Region-State").''; - else print '
    '.$langs->trans("State").''; + if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print '
    '.$langs->trans("Region-State").''; + else print '
    '.$langs->trans("State").''; if (! empty($conf->global->MAIN_INFO_ACCOUNTANT_STATE)) print getState($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $conf->global->MAIN_SHOW_STATE_CODE, 0, $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); else print ' '; print '
    '.$langs->trans("Phone").'' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_PHONE, $mysoc->country_code) . '
    '.$langs->trans("Phone").'' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_PHONE, $mysoc->country_code) . '
    '.$langs->trans("Fax").'' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_FAX, $mysoc->country_code) . '
    '.$langs->trans("Fax").'' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_FAX, $mysoc->country_code) . '
    '.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_ACCOUNTANT_MAIL, 0, 0, 0, 80) . '
    '.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_ACCOUNTANT_MAIL, 0, 0, 0, 80) . '
    '.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_ACCOUNTANT_WEB, '_blank', 80) . '
    '.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_ACCOUNTANT_WEB, '_blank', 80) . '
    '.$langs->trans("AccountantFileNumber").'' . $conf->global->MAIN_INFO_ACCOUNTANT_CODE . '
    '.$langs->trans("AccountantFileNumber").'' . $conf->global->MAIN_INFO_ACCOUNTANT_CODE . '
    '.$langs->trans("Note").'' . (! empty($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) ? nl2br($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) : '') . '
    '.$langs->trans("Note").'' . (! empty($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) ? nl2br($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) : '') . '
    '; print "
    "; From b30c55a2ee610bbe0176000b49ce9d10a06e6d1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Sep 2019 23:40:38 +0200 Subject: [PATCH 224/622] CSS --- htdocs/theme/eldy/global.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 17532380337..334fbe00ba1 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -655,6 +655,14 @@ select.flat.selectlimit { max-width: 0; overflow: auto; } +.divintdwithtwolinesmax { + width: 75px; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; +} + .tablelistofcalendars { margin-top: 25px !important; } From 278312f38f3bbdb528e6741efb946dd0e0678643 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 20 Sep 2019 07:02:14 +0200 Subject: [PATCH 225/622] Translate --- htdocs/adherents/card.php | 8 ++++---- htdocs/adherents/subscription.php | 4 ++-- htdocs/admin/bank.php | 2 +- htdocs/admin/chequereceipts.php | 3 +-- htdocs/admin/delais.php | 2 +- htdocs/admin/dict.php | 14 ++++++------- htdocs/admin/emailcollector_card.php | 2 +- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/expensereport.php | 2 +- htdocs/core/modules/action/rapport.pdf.php | 2 +- .../core/modules/bank/doc/pdf_ban.modules.php | 2 +- .../bank/doc/pdf_sepamandate.modules.php | 2 +- .../modules/cheque/doc/pdf_blochet.class.php | 6 +++--- .../commande/doc/pdf_einstein.modules.php | 2 +- .../doc/doc_generic_contract_odt.modules.php | 2 +- .../contract/doc/pdf_strato.modules.php | 4 ++-- .../modules/dons/html_cerfafr.modules.php | 2 +- .../doc/doc_generic_shipment_odt.modules.php | 2 +- .../expedition/doc/pdf_espadon.modules.php | 2 +- .../expedition/doc/pdf_merou.modules.php | 2 +- .../expedition/doc/pdf_rouget.modules.php | 2 +- .../doc/pdf_standard.modules.php | 4 ++-- .../modules/facture/doc/pdf_crabe.modules.php | 20 +++++++++---------- .../fichinter/doc/pdf_soleil.modules.php | 4 ++-- .../modules/member/doc/pdf_standard.class.php | 2 +- .../doc/pdf_standardlabel.class.php | 2 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 2 +- .../product/doc/pdf_standard.modules.php | 6 +++--- .../doc/doc_generic_project_odt.modules.php | 2 +- .../project/doc/pdf_baleine.modules.php | 2 +- .../project/doc/pdf_beluga.modules.php | 2 +- .../project/doc/pdf_timespent.modules.php | 2 +- .../modules/propale/doc/pdf_azur.modules.php | 4 ++-- .../societe/doc/doc_generic_odt.modules.php | 2 +- .../stock/doc/pdf_standard.modules.php | 6 +++--- .../stock/doc/pdf_stdmovement.modules.php | 6 +++--- .../doc/pdf_aurore.modules.php | 4 ++-- htdocs/core/tpl/card_presend.tpl.php | 2 +- htdocs/public/members/new.php | 2 +- htdocs/public/payment/paymentok.php | 2 +- 40 files changed, 72 insertions(+), 73 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5836bf48332..badf93b4e80 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -638,7 +638,7 @@ if (empty($reshook)) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; @@ -719,7 +719,7 @@ if (empty($reshook)) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; @@ -1483,7 +1483,7 @@ else // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; @@ -1544,7 +1544,7 @@ else // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 0922ca4f572..49e1cbbc553 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -360,7 +360,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template @@ -1093,7 +1093,7 @@ if ($rowid > 0) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 44cdd5e611b..a40448acdc8 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -49,7 +49,7 @@ $type = 'bankaccount'; * Actions */ -//Order display of bank account +// Order display of bank account if ($action == 'setbankorder') { if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index efc192e6de1..7e136bf6978 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -91,7 +91,7 @@ if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') } /* - * view + * View */ $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -233,7 +233,6 @@ print '
    '; /* * Other options - * */ print load_fiche_titre($langs->trans("OtherOptions"), '', ''); diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 1fe8b2285c3..6d6ebe13333 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -222,7 +222,7 @@ if ($action == 'edit') else { /* - * Affichage des parametres + * Show parameters */ print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ff4c3cc6a6b..28dd36b5442 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -251,7 +251,7 @@ $tabsqlsort[35]="c.label ASC"; $tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; $tabsqlsort[37]="r.unit_type ASC, r.scale ASC, r.code ASC"; -// Nom des champs en resultat de select pour affichage du dictionnaire +// Field names in select result for dictionary display $tabfield=array(); $tabfield[1] = "code,libelle,country"; $tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country" @@ -291,7 +291,7 @@ $tabfield[35]= "label"; $tabfield[36]= "range_ik,fk_c_exp_tax_cat"; $tabfield[37]= "code,label,short_label,unit_type,scale"; -// Nom des champs d'edition pour modification d'un enregistrement +// Edit field names for editing a record $tabfieldvalue=array(); $tabfieldvalue[1] = "code,libelle,country"; $tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region" @@ -331,7 +331,7 @@ $tabfieldvalue[35]= "label"; $tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat"; $tabfieldvalue[37]= "code,label,short_label,unit_type,scale"; -// Nom des champs dans la table pour insertion d'un enregistrement +// Field names in the table for inserting a record $tabfieldinsert=array(); $tabfieldinsert[1] = "code,libelle,fk_pays"; $tabfieldinsert[2] = "code_departement,nom,fk_region"; @@ -1283,8 +1283,8 @@ if ($id) { if ($fieldlist[$field] == 'entity') continue; - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees + // Determines the name of the field in relation to the possible names + // in data dictionaries $showfield=1; // By defaut $align="left"; $cssprefix=''; @@ -1850,14 +1850,14 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang'); print ''; } - // Le type de l'element (pour les type de contact) + // The type of the element (for contact types) elseif ($fieldlist[$field] == 'element') { print ''; } - // La source de l'element (pour les type de contact) + // The source of the element (for contact types) elseif ($fieldlist[$field] == 'source') { print ''."\n"; -//Use draft Watermark +// Use draft Watermark print ''."\n"; print ''."\n"; - // Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position + // For each possible position, an activation link is displayed if the box is not already active for that position print '
    '; print $form->selectarray('element', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 6d1b640f45b..011f04b0882 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -36,7 +36,7 @@ include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; if (!$user->admin) accessforbidden(); if (empty($conf->emailcollector->enabled)) accessforbidden(); -// Load traductions files requiredby by page +// Load traductions files required by page $langs->loadLangs(array("admin", "mails", "other")); // Get parameters diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 14cb63cd923..a55f6ee962e 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -34,7 +34,7 @@ dol_include_once('/emailcollector/class/emailcollector.class.php'); if (!$user->admin) accessforbidden(); if (empty($conf->emailcollector->enabled)) accessforbidden(); -// Load traductions files requiredby by page +// Load traductions files required by page $langs->loadLangs(array("admin", "other")); $action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index da77c0e78d3..d0ba9c63a3c 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -496,7 +496,7 @@ else } print '
    '; print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
    '; diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 52b70caf47f..b63b2785e44 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -117,7 +117,7 @@ class CommActionRapport // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); $dir = $conf->agenda->dir_temp."/"; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 23fef1ef2c5..eeee238ac80 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -106,7 +106,7 @@ class pdf_ban extends ModeleBankAccountDoc // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->bank->dir_output) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index e3990bc8ccc..e94af011b1e 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -109,7 +109,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); if (! empty($conf->bank->dir_output)) diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 71866464084..09148746fe9 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -49,7 +49,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts { global $conf,$langs,$mysoc; - // Load traductions files requiredby by page + // Load traductions files required by page $langs->loadLangs(array("main", "bills")); $this->db = $db; @@ -98,7 +98,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $sav_charset_output=$outputlangs->charset_output; if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta")); $dir = $_dir . "/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number; @@ -225,7 +225,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts global $langs; $default_font_size = pdf_getPDFFontSize($outputlangs); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("compta", "banks")); $title = $outputlangs->transnoentities("CheckReceipt"); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index f74291ecac9..4a81f94ed29 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1236,7 +1236,7 @@ class pdf_einstein extends ModelePDFCommandes // phpcs:enable global $conf,$langs,$hookmanager; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 124d51a33ad..7cff0c19e6b 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -217,7 +217,7 @@ class doc_generic_contract_odt extends ModelePDFContract $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='UTF-8'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->contrat->dir_output) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index b04ce5890ab..f7ae9834a65 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -181,7 +181,7 @@ class pdf_strato extends ModelePDFContract // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "contracts")); if ($conf->contrat->dir_output) @@ -602,7 +602,7 @@ class pdf_strato extends ModelePDFContract $default_font_size = pdf_getPDFFontSize($outputlangs); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "contract", "companies")); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 6ef76d21b78..f871cd3e2b0 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -83,7 +83,7 @@ class html_cerfafr extends ModeleDon if (! is_object($outputlangs)) $outputlangs=$langs; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); $currency = !empty($currency) ? $currency : $conf->currency; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 9f94dd86867..52c810fd965 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -227,7 +227,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='UTF-8'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->expedition->dir_output."/sending") diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 996e8035316..8f3441c332c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -165,7 +165,7 @@ class pdf_espadon extends ModelePdfExpedition // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); $nblines = count($object->lines); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 4293f29ed6d..dbdfd722168 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -165,7 +165,7 @@ class pdf_merou extends ModelePdfExpedition // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); if ($conf->expedition->dir_output) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 18ba0ef9d44..d3e254c6132 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -195,7 +195,7 @@ class pdf_rouget extends ModelePdfExpedition // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); $nblines = count($object->lines); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index fb977c19b63..5cfc6c3287e 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -217,7 +217,7 @@ class pdf_standard extends ModeleExpenseReport // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); $nblines = count($object->lines); @@ -635,7 +635,7 @@ class pdf_standard extends ModeleExpenseReport // global $conf, $langs, $hookmanager; global $user, $langs, $conf, $mysoc, $db, $hookmanager; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "trips", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8876137f877..7ec496d385b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -243,7 +243,7 @@ class pdf_crabe extends ModelePDFFactures // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); $nblines = count($object->lines); @@ -1351,7 +1351,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); - + // Retained warranty if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) ) { @@ -1367,29 +1367,29 @@ class pdf_crabe extends ModelePDFFactures } } } - + if($displayWarranty){ $pdf->SetTextColor(40, 40, 40); $pdf->SetFillColor(255, 255, 255); - + $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ; - + // Billed - retained warranty $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); - + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1); - + // retained warranty $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - + $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty") . ' ('.$object->retained_warranty.'%)'; $retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):''; - + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1); @@ -1591,7 +1591,7 @@ class pdf_crabe extends ModelePDFFactures { global $conf, $langs; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "propal", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 847f1de7087..9d39eb5e858 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -173,7 +173,7 @@ class pdf_soleil extends ModelePDFFicheinter // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "interventions", "dict", "companies")); if ($conf->ficheinter->dir_output) @@ -562,7 +562,7 @@ class pdf_soleil extends ModelePDFFicheinter global $conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "interventions")); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index f3a105f99f1..13c28514211 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -329,7 +329,7 @@ class pdf_standard extends CommonStickerGenerator // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); if (empty($mode) || $mode == 'member') diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index e178d16d5bc..f72ca14cc25 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -260,7 +260,7 @@ class pdf_standardlabel extends CommonStickerGenerator // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); $title=$outputlangs->transnoentities('Labels'); diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index f6bb3bc46a7..a2705adcb7d 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -301,7 +301,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "admin")); $title=$outputlangs->transnoentities('Labels'); diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 019d67518a4..88ec5204845 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -119,7 +119,7 @@ class pdf_standard extends ModelePDFProduct { global $conf,$langs,$mysoc; - // Load traductions files requiredby by page + // Load traductions files required by page $langs->loadLangs(array("main", "companies")); $this->db = $db; @@ -169,7 +169,7 @@ class pdf_standard extends ModelePDFProduct // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); $nblines = count($object->lines); @@ -709,7 +709,7 @@ class pdf_standard extends ModelePDFProduct { global $conf,$langs,$hookmanager; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index e682cfd9507..6d67a36c010 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -82,7 +82,7 @@ class doc_generic_project_odt extends ModelePDFProjects { global $conf, $langs, $mysoc; - // Load traductions files requiredby by page + // Load traductions files required by page $langs->loadLangs(array("companies", "main")); $this->db = $db; diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 154c8e067b0..bc2019bfce8 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -183,7 +183,7 @@ class pdf_baleine extends ModelePDFProjects // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 05100fbe8eb..ba815810f28 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -155,7 +155,7 @@ class pdf_beluga extends ModelePDFProjects // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 061ae7a0b58..7685c07b480 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -115,7 +115,7 @@ class pdf_timespent extends ModelePDFProjects // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 77c41d01927..59267e25272 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -224,7 +224,7 @@ class pdf_azur extends ModelePDFPropales // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products")); $nblines = count($object->lines); @@ -1438,7 +1438,7 @@ class pdf_azur extends ModelePDFPropales { global $conf,$langs; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index a6738ddcc90..f8bbf568d86 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -94,7 +94,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc { global $conf,$langs; - // Load traductions files requiredby by page + // Load traductions files required by page $langs->loadLangs(array("companies", "errors")); $form = new Form($this->db); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index e0c831732ba..61bfa916fe2 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -119,7 +119,7 @@ class pdf_standard extends ModelePDFStock { global $conf,$langs,$mysoc; - // Load traductions files requiredby by page + // Load traductions files required by page $langs->loadLangs(array("main", "companies")); $this->db = $db; @@ -198,7 +198,7 @@ class pdf_standard extends ModelePDFStock // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); $nblines = count($object->lines); @@ -875,7 +875,7 @@ class pdf_standard extends ModelePDFStock { global $conf,$langs,$db,$hookmanager; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 380b9ceffa5..6a607de6d37 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -119,7 +119,7 @@ class pdf_stdmovement extends ModelePDFMovement { global $conf,$langs,$mysoc; - // Load traductions files requiredby by page + // Load traductions files required by page $langs->loadLangs(array("main", "companies")); $this->db = $db; @@ -200,7 +200,7 @@ class pdf_stdmovement extends ModelePDFMovement // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); /** @@ -954,7 +954,7 @@ class pdf_stdmovement extends ModelePDFMovement { global $conf,$langs,$db,$hookmanager; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index d243c209848..44fe533f0eb 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -215,7 +215,7 @@ class pdf_aurore extends ModelePDFSupplierProposal // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal")); $nblines = count($object->lines); @@ -1278,7 +1278,7 @@ class pdf_aurore extends ModelePDFSupplierProposal { global $conf, $langs; - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index a8594ec1b62..06b2a8414c0 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -76,7 +76,7 @@ if ($action == 'presend') { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array('commercial','bills','orders','contracts','members','propal','products','supplier_proposal','interventions')); } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 873a6858a1a..81f46897cc6 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -281,7 +281,7 @@ if ($action == 'add') // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 52413921f90..6c9711e4055 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -516,7 +516,7 @@ if ($ispaymentok) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files requiredby by page + // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; From bf6fd2a5e2f904aaade31cb6293885835ce0885c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 20 Sep 2019 09:25:46 +0200 Subject: [PATCH 226/622] Translate & style --- htdocs/admin/agenda_reminder.php | 4 ++-- htdocs/admin/boxes.php | 14 ++++++++------ htdocs/admin/dict.php | 4 ++-- htdocs/admin/ihm.php | 6 ++++-- htdocs/admin/limits.php | 20 +++++++++++--------- htdocs/admin/payment.php | 10 ++++++---- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 3af179ba2e7..43e031a8ce9 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -148,8 +148,8 @@ elseif ($action == 'setdoc') { if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent + // The constant that has been read in front of the new set + // is therefore passed through a variable to have a coherent display $conf->global->ACTION_EVENT_ADDON_PDF = $value; } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 2e81a2c6dad..796d9c7a42b 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -63,7 +63,7 @@ if ($action == 'add') { { $pos = $boxid['pos']; - // Initialize distinct fkuser with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") + // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") $distinctfkuser=array(); if (! $error) { @@ -225,8 +225,8 @@ print load_fiche_titre($langs->trans("Boxes"), '', 'title_setup'); print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."
    \n"; /* - * Recherche des boites actives par defaut pour chaque position possible - * On stocke les boites actives par defaut dans $boxes[position][id_boite]=1 + * Search for the default active boxes for each possible position + * We store the active boxes by default in $boxes[position][id_boite]=1 */ $actives = array(); @@ -257,7 +257,7 @@ if ($resql) array_push($actives, $obj->box_id); if ($obj->box_order == '' || $obj->box_order == '0' || $decalage) $decalage++; - // On renumerote l'ordre des boites si l'une d'elle est a '' + // We renumber the order of the boxes if one of them is in '' // This occurs just after an insert. if ($decalage) { @@ -268,7 +268,7 @@ if ($resql) if ($decalage) { - // Si on a renumerote, on corrige champ box_order + // If we have renumbered, we correct the field box_order // This occurs just after an insert. $sql = "SELECT box_order"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes"; @@ -366,7 +366,7 @@ foreach($boxtoadd as $box) print '
    ' . $box->sourcefile . ''; print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, 0, 1, 0, 0, '', 1)."\n"; print ''."\n"; @@ -483,7 +483,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIV print '
    '; +print '
    '; print '
    '; +print '
    '; print ''; print "\n".''."\n"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 28dd36b5442..9033819b540 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -979,7 +979,7 @@ if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); if (GETPOST('from')) $paramwithsearch.= '&from='.urlencode(GETPOST('from', 'alpha')); -// Confirmation de la suppression de la ligne +// Confirmation of the deletion of the line if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); @@ -991,7 +991,7 @@ if ($action == 'delete') */ if ($id) { - // Complete requete recherche valeurs avec critere de tri + // Complete search values request with sort criteria $sql=$tabsql[$id]; if (! preg_match('/ WHERE /', $sql)) $sql.= " WHERE 1 = 1"; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 37c997ee306..7b0a7983b5a 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -432,11 +432,13 @@ if ($action == 'edit') // Edit print ''."\n"; - print '
    '; + print '
    '; + print '
    '; print ''; - print '   '; + print '   '; print ''; print '
    '; + print '
    '; print ''; } diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index a43f86d0e28..5eb3532e47d 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -102,7 +102,7 @@ if ($action == 'edit') clearstatcache(); print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; - print ''; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("Parameters").''.$langs->trans("Value").'
    '; @@ -110,23 +110,25 @@ if ($action == 'edit') print '
    '; + print '
    '; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); print '
    '.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'
    '.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'
    '; + print '
    '; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); print '
    '; - print '
    '; + print '
    '; + print '
    '; print ''; print '
    '; + print '
    '; print ''; print '
    '; @@ -142,21 +144,21 @@ else print ''.$conf->global->MAIN_MAX_DECIMALS_UNIT.''; - print ''; + print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); print ''.$conf->global->MAIN_MAX_DECIMALS_TOT.''; - print ''.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''.$conf->global->MAIN_MAX_DECIMALS_SHOWN.''; + print ''.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''.$conf->global->MAIN_MAX_DECIMALS_SHOWN.''; - print ''; + print ''; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); print ''.$conf->global->MAIN_ROUNDING_RULE_TOT.''; print ''; - print '
    '; + print '
    '; print ''.$langs->trans("Modify").''; print '
    '; } diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 4e80fe55e25..eb3261f46c6 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -252,14 +252,16 @@ print "\n"; print ''; -print '
    '; +dol_fiche_end(); + +print '
    '; +print '
    '; print ''; -print '
    '; +print '
    '; +print '
    '; print ''; -dol_fiche_end(); - // End of page llxFooter(); $db->close(); From e32772fdc52befab1a903989e6a7fc9089bc7754 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 20 Sep 2019 09:44:49 +0200 Subject: [PATCH 227/622] Translate --- htdocs/adherents/htpasswd.php | 3 +-- .../facture/class/paymentterm.class.php | 1 - .../compta/localtax/class/localtax.class.php | 1 - htdocs/compta/tva/class/tva.class.php | 1 - htdocs/core/class/antivir.class.php | 1 - htdocs/core/modules/action/rapport.pdf.php | 2 +- .../core/modules/bank/doc/pdf_ban.modules.php | 6 +++--- .../bank/doc/pdf_sepamandate.modules.php | 6 +++--- .../modules/cheque/doc/pdf_blochet.class.php | 6 +++--- .../doc/doc_generic_order_odt.modules.php | 2 +- .../doc/doc_generic_contract_odt.modules.php | 2 +- .../contract/doc/pdf_strato.modules.php | 2 +- .../doc/doc_generic_shipment_odt.modules.php | 2 +- .../doc/pdf_standard.modules.php | 2 +- .../modules/export/export_csv.modules.php | 1 - .../modules/export/export_excel.modules.php | 1 - .../export/export_excel2007.modules.php | 1 - .../export/export_excel2007new.modules.php | 1 - .../modules/export/export_tsv.modules.php | 1 - .../doc/doc_generic_invoice_odt.modules.php | 2 +- .../fichinter/doc/pdf_soleil.modules.php | 2 +- .../livraison/doc/pdf_typhon.modules.php | 3 +-- .../doc/doc_generic_product_odt.modules.php | 2 +- .../product/doc/pdf_standard.modules.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 2 +- .../project/doc/pdf_baleine.modules.php | 21 +++++++++---------- .../project/doc/pdf_beluga.modules.php | 11 +++++----- .../project/doc/pdf_timespent.modules.php | 11 +++++----- .../task/doc/doc_generic_task_odt.modules.php | 2 +- .../doc/doc_generic_proposal_odt.modules.php | 2 +- .../modules/rapport/pdf_paiement.class.php | 2 +- .../doc/doc_generic_reception_odt.modules.php | 2 +- .../societe/doc/doc_generic_odt.modules.php | 4 ++-- .../doc/doc_generic_stock_odt.modules.php | 2 +- .../stock/doc/pdf_standard.modules.php | 2 +- .../stock/doc/pdf_stdmovement.modules.php | 2 +- .../pdf/pdf_canelle.modules.php | 4 ++-- ...doc_generic_supplier_order_odt.modules.php | 4 ++-- .../supplier_order/pdf/pdf_cornas.modules.php | 2 +- .../pdf/pdf_muscadet.modules.php | 2 +- .../doc/pdf_standard.modules.php | 4 ++-- ..._generic_supplier_proposal_odt.modules.php | 2 +- .../doc/pdf_aurore.modules.php | 2 +- .../user/doc/doc_generic_user_odt.modules.php | 2 +- .../doc/doc_generic_usergroup_odt.modules.php | 2 +- htdocs/ecm/dir_card.php | 1 - htdocs/public/agenda/index.php | 1 - htdocs/public/donations/index.php | 1 - htdocs/public/index.php | 1 - htdocs/public/members/index.php | 1 - htdocs/public/paybox/index.php | 1 - htdocs/public/paybox/newpayment.php | 1 - htdocs/public/payment/index.php | 1 - htdocs/public/paypal/index.php | 1 - htdocs/public/stripe/index.php | 1 - htdocs/public/theme/common/index.php | 1 - htdocs/public/theme/index.php | 1 - 57 files changed, 63 insertions(+), 89 deletions(-) diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index 885e453c6f1..79de1971dbc 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -20,8 +20,7 @@ /** * \file htdocs/adherents/htpasswd.php * \ingroup member - * \brief Page d'export htpasswd du fichier des adherents - * \author Rodolphe Quiedeville + * \brief Export page htpasswd of the membership file */ require '../main.inc.php'; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index d3b4bd83743..f37c7046633 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -19,7 +19,6 @@ * \file compta/facture/class/paymentterm.class.php * \ingroup facture * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) - * \author Put author name here */ diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 247db26715a..1a8606054e6 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -18,7 +18,6 @@ /** * \file htdocs/compta/localtax/class/localtax.class.php * \ingroup tax - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 55a94d685cc..29194d21ec6 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -22,7 +22,6 @@ /** * \file htdocs/compta/tva/class/tva.class.php * \ingroup tax - * \author Laurent Destailleur */ // Put here all includes required by your class file diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index 4be4d175b47..df2dcd1f94a 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -22,7 +22,6 @@ /** * \file htdocs/core/class/antivir.class.php * \brief File of class to scan viruses - * \author Laurent Destailleur. */ /** diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index b63b2785e44..2fcf6ef7c4f 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -84,7 +84,7 @@ class CommActionRapport $this->month = $month; $this->year = $year; - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index eeee238ac80..91fe828963c 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -61,7 +61,7 @@ class pdf_ban extends ModeleBankAccountDoc $this->name = "ban"; $this->description = $langs->trans("DocumentModelBan").' (Volunteer wanted to finish)'; - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -76,11 +76,11 @@ class pdf_ban extends ModeleBankAccountDoc $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Affiche code produit-service - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define column position $this->posxref=$this->marge_gauche+1; $this->posxlabel=$this->marge_gauche+25; $this->posxworkload=$this->marge_gauche+100; diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index e94af011b1e..f66d005e6c3 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -63,7 +63,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->name = "sepamandate"; $this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -78,11 +78,11 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Affiche code produit-service - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define column position $this->posxref=$this->marge_gauche; } diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 09148746fe9..eaf4047e107 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -57,7 +57,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->tab_top = 60; - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -68,11 +68,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define column position $this->line_height = 5; $this->line_per_page = 40; $this->tab_height = 200; //$this->line_height * $this->line_per_page; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index eced22d03d8..8f1b0f3a3c8 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -75,7 +75,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 7cff0c19e6b..aaec1127963 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_contract_odt extends ModelePDFContract $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index f7ae9834a65..d73ddd4297b 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -132,7 +132,7 @@ class pdf_strato extends ModelePDFContract $this->name = 'strato'; $this->description = $langs->trans("StandardContractsTemplate"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 52c810fd965..e27eb9b7bf0 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -76,7 +76,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 5cfc6c3287e..2c24c4338c5 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -133,7 +133,7 @@ class pdf_standard extends ModeleExpenseReport $this->name = ""; $this->description = $langs->trans('PDFStandardExpenseReports'); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 9d606aadc33..9dfe8efe28c 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -19,7 +19,6 @@ * \file htdocs/core/modules/export/export_csv.modules.php * \ingroup export * \brief File of class to build exports with CSV format - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php'; diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 0e7fd0f1169..2651762998d 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -20,7 +20,6 @@ * \file htdocs/core/modules/export/export_excel.modules.php * \ingroup export * \brief File of class to generate export file with Excel format - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 7460d71ff13..982b42b3ec5 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -20,7 +20,6 @@ * \file htdocs/core/modules/export/export_excel2007.modules.php * \ingroup export * \brief File of class to generate export file with Excel format - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; diff --git a/htdocs/core/modules/export/export_excel2007new.modules.php b/htdocs/core/modules/export/export_excel2007new.modules.php index 038446643a2..42ffd3b5fba 100644 --- a/htdocs/core/modules/export/export_excel2007new.modules.php +++ b/htdocs/core/modules/export/export_excel2007new.modules.php @@ -20,7 +20,6 @@ * \file htdocs/core/modules/export/export_excelnew.modules.php * \ingroup export * \brief File of class to generate export file with Excel format - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index b40da3cd539..f87bcf4fbdb 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -20,7 +20,6 @@ * \file htdocs/core/modules/export/export_csv.modules.php * \ingroup export * \brief File of class to build export files with format TSV - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php'; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 642140e0ce8..8463f1449ed 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -75,7 +75,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'FACTURE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 9d39eb5e858..2b5158e6f48 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -125,7 +125,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->name = 'soleil'; $this->description = $langs->trans("DocumentModelStandardPDF"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 963de1494a7..4c10b7c7864 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -25,7 +25,6 @@ * \file htdocs/core/modules/livraison/doc/pdf_typhon.modules.php * \ingroup livraison * \brief File of class to manage receving receipts with template Typhon - * \author Laurent Destailleur */ require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; @@ -128,7 +127,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->name = "typhon"; $this->description = $langs->trans("DocumentModelTyphon"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index f8861380b2f..9a3381319a7 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -73,7 +73,7 @@ class doc_generic_product_odt extends ModelePDFProduct $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 88ec5204845..119ce6ad632 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -126,7 +126,7 @@ class pdf_standard extends ModelePDFProduct $this->name = "standard"; $this->description = $langs->trans("DocumentModelStandardPDF"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 6d67a36c010..6c1aa5b418b 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -90,7 +90,7 @@ class doc_generic_project_odt extends ModelePDFProjects $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index bc2019bfce8..67b530ef96c 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -20,8 +20,7 @@ /** * \file htdocs/core/modules/project/doc/pdf_baleine.modules.php * \ingroup project - * \brief File of class to generate project document Baleine - * \author Regis Houssin + * \brief File of the class allowing to generate projects with the baleine model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; @@ -128,7 +127,7 @@ class pdf_baleine extends ModelePDFProjects $this->name = "baleine"; $this->description = $langs->trans("DocumentModelBaleine"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -143,11 +142,11 @@ class pdf_baleine extends ModelePDFProjects $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Affiche code produit-service - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define column position $this->posxref=$this->marge_gauche+1; $this->posxlabel=$this->marge_gauche+25; $this->posxworkload=$this->marge_gauche+120; @@ -295,7 +294,7 @@ class pdf_baleine extends ModelePDFProjects $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2); @@ -410,7 +409,7 @@ class pdf_baleine extends ModelePDFProjects $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // Ref of task $pdf->SetXY($this->posxref, $curY); @@ -483,7 +482,7 @@ class pdf_baleine extends ModelePDFProjects $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - // Pied de page + // Footer of the page $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -507,7 +506,7 @@ class pdf_baleine extends ModelePDFProjects $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -545,10 +544,10 @@ class pdf_baleine extends ModelePDFProjects $pdf->SetDrawColor(128, 128, 128); - // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param + // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); - // line prend une position y en 3eme param + // line takes a position y in 3rd parameter $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline); $pdf->SetTextColor(0, 0, 0); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index ba815810f28..7721b29a1bf 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -21,8 +21,7 @@ /** * \file htdocs/core/modules/project/doc/pdf_beluga.modules.php * \ingroup project - * \brief Fichier de la classe permettant de generer les projets au modele beluga - * \author Charlie Benke + * \brief File of the class allowing to generate projects with the beluga model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; @@ -50,7 +49,7 @@ if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/com /** - * Class to manage generation of project document Baleine + * Class to manage generation of project document Beluga */ class pdf_beluga extends ModelePDFProjects @@ -83,7 +82,7 @@ class pdf_beluga extends ModelePDFProjects $this->name = "beluga"; $this->description = $langs->trans("DocumentModelBeluga"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->orientation = 'L'; @@ -104,11 +103,11 @@ class pdf_beluga extends ModelePDFProjects $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Affiche code produit-service - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define column position if ($this->orientation == 'L' || $this->orientation == 'Landscape') { $this->posxref=$this->marge_gauche+1; $this->posxdate=$this->marge_gauche+105; diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 7685c07b480..e4a32541aa9 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -17,10 +17,9 @@ */ /** - * \file htdocs/core/modules/project/doc/pdf_baleine.modules.php + * \file htdocs/core/modules/project/doc/pdf_timespent.modules.php * \ingroup project * \brief File of class to generate project document Baleine - * \author Regis Houssin */ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; @@ -33,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; /** - * Class to manage generation of project document Baleine + * Class to manage generation of project document Timespent */ class pdf_timespent extends ModelePDFProjects @@ -60,7 +59,7 @@ class pdf_timespent extends ModelePDFProjects $this->name = "timespent"; $this->description = $langs->trans("DocumentModelTimeSpent"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -75,11 +74,11 @@ class pdf_timespent extends ModelePDFProjects $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_codeproduitservice = 1; // Affiche code produit-service - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes + // Define column position $this->posxref=$this->marge_gauche+1; $this->posxlabel=$this->marge_gauche+25; $this->posxtimespent=$this->marge_gauche+120; diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index f6da1061c89..a12b1079caf 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -91,7 +91,7 @@ class doc_generic_task_odt extends ModelePDFTask $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 7b274ac0c9a..8c8b566259a 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -72,7 +72,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 127c7a92352..0fb5c1412b2 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -47,7 +47,7 @@ class pdf_paiement $this->db = $db; $this->description = $langs->transnoentities("ListOfCustomerPayments"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 588b848f3d3..fd3a93c130f 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -70,7 +70,7 @@ class doc_generic_reception_odt extends ModelePdfReception $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index f8bbf568d86..cba1a3d894e 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -66,7 +66,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; @@ -78,7 +78,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $this->option_logo = 1; // Affiche logo - // Recupere emmetteur + // Retrieves transmitter $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index ac9c0423694..55a6caea5a2 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -73,7 +73,7 @@ class doc_generic_stock_odt extends ModelePDFStock $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'STOCK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 61bfa916fe2..08e0894bd04 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -126,7 +126,7 @@ class pdf_standard extends ModelePDFStock $this->name = "standard"; $this->description = $langs->trans("DocumentModelStandardPDF"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 6a607de6d37..45edfb72cde 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -126,7 +126,7 @@ class pdf_stdmovement extends ModelePDFMovement $this->name = "stdmouvement"; $this->description = $langs->trans("DocumentModelStandardPDF"); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 00e981dfdd6..2f2e28b5463 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -128,7 +128,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->name = "canelle"; $this->description = $langs->trans('SuppliersInvoiceModel'); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -148,7 +148,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->franchise=!$mysoc->tva_assuj; - // Defini position des colonnes + // Define column position $this->posxdesc=$this->marge_gauche+1; $this->posxtva=112; $this->posxup=126; diff --git a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php index d9e9112ec54..06fc7d2ae87 100644 --- a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php @@ -76,7 +76,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'SUPPLIER_ORDER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; @@ -233,7 +233,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders if ($conf->fournisseur->commande->dir_output) { $object->fetch_thirdparty(); - + if ($object->specimen) { $dir = $conf->fournisseur->commande->dir_output; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index 02b11366816..07070c261cc 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -131,7 +131,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->name = "cornas"; $this->description = $langs->trans('SuppliersCommandModel'); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 116b77117e4..61982a05621 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -131,7 +131,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->name = "muscadet"; $this->description = $langs->trans('SuppliersCommandModel'); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 81093d9adff..3670797da67 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -128,7 +128,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->name = "standard"; $this->description = $langs->trans('DocumentModelStandardPDF'); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -144,7 +144,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->franchise=!$mysoc->tva_assuj; - // Defini position des colonnes + // Define column position $this->posxdate=$this->marge_gauche+1; $this->posxreffacturefourn=30; $this->posxreffacture=65; diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 7b38ec52c0e..ac1868f6313 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 44fe533f0eb..2ed06067944 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -128,7 +128,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->name = "aurore"; $this->description = $langs->trans('DocModelAuroreDescription'); - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 80576bfcca0..f67cc02ff2d 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -71,7 +71,7 @@ class doc_generic_user_odt extends ModelePDFUser $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'USER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 023bc714ac3..750d523b4e2 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $this->description = $langs->trans("DocumentModelOdt"); $this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan - // Dimension page pour format A4 + // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index b6cb7dbfb7f..f0992160d09 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -20,7 +20,6 @@ * \file htdocs/ecm/dir_card.php * \ingroup ecm * \brief Card of a directory for ECM module - * \author Laurent Destailleur */ require '../main.inc.php'; diff --git a/htdocs/public/agenda/index.php b/htdocs/public/agenda/index.php index 112a07951b8..f55eb4d941b 100644 --- a/htdocs/public/agenda/index.php +++ b/htdocs/public/agenda/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/agenda/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/donations/index.php b/htdocs/public/donations/index.php index 08e7650a152..7404698becd 100644 --- a/htdocs/public/donations/index.php +++ b/htdocs/public/donations/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/donations/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/index.php b/htdocs/public/index.php index e1030c9973a..a1eeeffe9c6 100644 --- a/htdocs/public/index.php +++ b/htdocs/public/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../master.inc.php'; diff --git a/htdocs/public/members/index.php b/htdocs/public/members/index.php index 42bfa7713cf..c31d0e10449 100644 --- a/htdocs/public/members/index.php +++ b/htdocs/public/members/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/members/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/paybox/index.php b/htdocs/public/paybox/index.php index 58d748aba72..60da64aad9d 100644 --- a/htdocs/public/paybox/index.php +++ b/htdocs/public/paybox/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/paybox/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 319c40f2c18..9524b1be9ed 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -21,7 +21,6 @@ * \file htdocs/public/paybox/newpayment.php * \ingroup paybox * \brief File to offer a way to make a payment for a particular Dolibarr entity - * \author Laurent Destailleur */ define("NOLOGIN", 1); // This means this output page does not require to be logged. diff --git a/htdocs/public/payment/index.php b/htdocs/public/payment/index.php index 21786830df6..b0772b576c0 100644 --- a/htdocs/public/payment/index.php +++ b/htdocs/public/payment/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/payment/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/paypal/index.php b/htdocs/public/paypal/index.php index 0cba12e6aa2..54e81788f49 100644 --- a/htdocs/public/paypal/index.php +++ b/htdocs/public/paypal/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/paypal/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/stripe/index.php b/htdocs/public/stripe/index.php index 6958940ea48..792aa7c5f10 100644 --- a/htdocs/public/stripe/index.php +++ b/htdocs/public/stripe/index.php @@ -19,7 +19,6 @@ * \file htdocs/public/stripe/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; diff --git a/htdocs/public/theme/common/index.php b/htdocs/public/theme/common/index.php index 2a9d8b8c2a9..3d4eec0ee31 100644 --- a/htdocs/public/theme/common/index.php +++ b/htdocs/public/theme/common/index.php @@ -20,7 +20,6 @@ * \file htdocs/public/theme/common/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../../master.inc.php'; diff --git a/htdocs/public/theme/index.php b/htdocs/public/theme/index.php index 6b5d38f5e94..bf856f24280 100644 --- a/htdocs/public/theme/index.php +++ b/htdocs/public/theme/index.php @@ -20,7 +20,6 @@ * \file htdocs/public/theme/index.php * \ingroup core * \brief A redirect page to an error - * \author Laurent Destailleur */ require '../../master.inc.php'; From d3b51979565f63a38900969c58d573fb08af1a1e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 20 Sep 2019 13:02:50 +0200 Subject: [PATCH 228/622] FIX new display for stripe account invert col and row for better display --- htdocs/societe/paymentmodes.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index a9f0d9aed0b..6154a8a7c3a 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1307,19 +1307,21 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); print ''."\n"; print ''; - print ''; - print ''; print ''; + print ''; + print ''; + print ''; print ''; + $currencybalance = array(); if (is_array($balance->available) && count($balance->available)) { foreach ($balance->available as $cpt) { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) $amount = $cpt->amount / 100; - else $amount = $cpt->amount; - print ''; + if (! in_array($cpt->currency, $arrayzerounitcurrency)) $currencybalance[$cpt->currency]->available=$cpt->amount / 100; + else $currencybalance[$cpt->currency]->available=$cpt->amount; + $currencybalance[$cpt->currency]->currency=$cpt->currency; } } @@ -1328,11 +1330,19 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' foreach ($balance->pending as $cpt) { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) $amount = $cpt->amount / 100; - else $amount = $cpt->amount; - print ''; + if (! in_array($cpt->currency, $arrayzerounitcurrency)) $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + else $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; } } + + if (is_array($currencybalance)) + { + foreach ($currencybalance as $cpt) + { + print ''; + } + } + print '
    '.$langs->trans('Status').''.$langs->trans('Amount').''.$langs->trans('Currency').''.$langs->trans('Available').''.$langs->trans('Pending').''.$langs->trans('Total').'
    '.$langs->trans("Available").''.price($amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
    '.$langs->trans("Pending").''.price($amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
    '.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
    '; print '
    '; } From 1e49fd0d45b259de9df24aa6cdd4401faafabb4b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 20 Sep 2019 15:07:58 +0200 Subject: [PATCH 229/622] Translate --- htdocs/adherents/subscription/card.php | 6 +++--- htdocs/core/modules/bank/doc/pdf_ban.modules.php | 6 +++--- .../modules/bank/doc/pdf_sepamandate.modules.php | 10 +++++----- htdocs/core/modules/cheque/doc/pdf_blochet.class.php | 2 +- .../modules/commande/doc/pdf_einstein.modules.php | 10 +++++----- .../modules/commande/doc/pdf_eratosthene.modules.php | 8 ++++---- .../core/modules/contract/doc/pdf_strato.modules.php | 4 ++-- .../modules/expedition/doc/pdf_espadon.modules.php | 8 ++++---- .../modules/expedition/doc/pdf_merou.modules.php | 2 +- .../modules/expedition/doc/pdf_rouget.modules.php | 6 +++--- .../expensereport/doc/pdf_standard.modules.php | 6 +++--- .../core/modules/facture/doc/pdf_crabe.modules.php | 8 ++++---- .../core/modules/facture/doc/pdf_sponge.modules.php | 6 +++--- .../modules/fichinter/doc/pdf_soleil.modules.php | 4 ++-- .../modules/livraison/doc/pdf_typhon.modules.php | 8 ++++---- .../modules/product/doc/pdf_standard.modules.php | 8 ++++---- .../core/modules/project/doc/pdf_beluga.modules.php | 6 +++--- .../modules/project/doc/pdf_timespent.modules.php | 6 +++--- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 10 +++++----- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 8 ++++---- .../modules/reception/doc/pdf_squille.modules.php | 6 +++--- .../core/modules/stock/doc/pdf_standard.modules.php | 8 ++++---- .../modules/stock/doc/pdf_stdmovement.modules.php | 8 ++++---- .../supplier_invoice/pdf/pdf_canelle.modules.php | 10 +++++----- .../supplier_order/pdf/pdf_cornas.modules.php | 8 ++++---- .../supplier_order/pdf/pdf_muscadet.modules.php | 10 +++++----- .../supplier_payment/doc/pdf_standard.modules.php | 4 ++-- .../supplier_proposal/doc/pdf_aurore.modules.php | 12 ++++++------ 28 files changed, 99 insertions(+), 99 deletions(-) diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index e44995b263f..21b5b68794f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -68,7 +68,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $cancel) { - // Charge objet actuel + // Load current object $result=$object->fetch($rowid); if ($result > 0) { @@ -101,7 +101,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc if (! $errmsg) { - // Modifie valeures + // Modify values $object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); $object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); $object->fk_type=$_POST["typeid"]; @@ -389,7 +389,7 @@ if ($rowid && $action != 'edit') } } - // Supprimer + // Delete if ($user->rights->adherent->cotisation->creer) { print '\n"; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 91fe828963c..9a6ee697833 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -197,7 +197,7 @@ class pdf_ban extends ModeleBankAccountDoc $nexY = $pdf->GetY(); $height_note=$nexY-($tab_top-2); - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -231,7 +231,7 @@ class pdf_ban extends ModeleBankAccountDoc } /* - * Pied de page + * Footer of the page */ $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -261,7 +261,7 @@ class pdf_ban extends ModeleBankAccountDoc $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index f66d005e6c3..c7206000982 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -109,7 +109,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files required by page + // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); if (! empty($conf->bank->dir_output)) @@ -194,7 +194,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $tab_top_newpage = 40; $tab_height_newpage = 210; - // Affiche notes + // Show notes if (! empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); @@ -202,7 +202,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $nexY = $pdf->GetY(); $height_note=$nexY-($tab_top-2); - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -374,7 +374,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); /* - * Pied de page + * Footer of the page */ $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -404,7 +404,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index eaf4047e107..70985902ad7 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -205,7 +205,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->result = array('fullpath'=>$file); $outputlangs->charset_output=$sav_charset_output; - return 1; // Pas d'erreur + return 1; // No error } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 4a81f94ed29..6f46a9b70a9 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -353,7 +353,7 @@ class pdf_einstein extends ModelePDFCommandes $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -388,7 +388,7 @@ class pdf_einstein extends ModelePDFCommandes $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -633,7 +633,7 @@ class pdf_einstein extends ModelePDFCommandes $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1156,11 +1156,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index afe1213fa23..eeb0fa930ac 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -383,7 +383,7 @@ class pdf_eratosthene extends ModelePDFCommandes $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -831,7 +831,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1343,13 +1343,13 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index d73ddd4297b..76dafb4f10a 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -279,7 +279,7 @@ class pdf_strato extends ModelePDFContract $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -556,7 +556,7 @@ class pdf_strato extends ModelePDFContract */ // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect takes a length in 3rd parameter and 4th parameter } /** diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 8f3441c332c..66a86e4345f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -320,7 +320,7 @@ class pdf_espadon extends ModelePdfExpedition $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -377,7 +377,7 @@ class pdf_espadon extends ModelePdfExpedition $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -788,13 +788,13 @@ class pdf_espadon extends ModelePdfExpedition $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index dbdfd722168..761201e1836 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -281,7 +281,7 @@ class pdf_merou extends ModelePdfExpedition $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d3e254c6132..96a166d4ff8 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -350,7 +350,7 @@ class pdf_rouget extends ModelePdfExpedition $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -407,7 +407,7 @@ class pdf_rouget extends ModelePdfExpedition $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -800,7 +800,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 2c24c4338c5..65db52ddce3 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -334,7 +334,7 @@ class pdf_standard extends ModeleExpenseReport $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -525,7 +525,7 @@ class pdf_standard extends ModeleExpenseReport $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -883,7 +883,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetDrawColor(128, 128, 128); - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); // line prend une position y en 3eme param if (empty($hidetop)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 7ec496d385b..fd684801096 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -420,7 +420,7 @@ class pdf_crabe extends ModelePDFFactures $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -455,7 +455,7 @@ class pdf_crabe extends ModelePDFFactures $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -1498,11 +1498,11 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 10bea53032f..7a41a72ba3b 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -414,7 +414,7 @@ class pdf_sponge extends ModelePDFFactures $nexY = max($pdf->GetY(), $nexY); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -1795,13 +1795,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 2b5158e6f48..aec300c634d 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -282,7 +282,7 @@ class pdf_soleil extends ModelePDFFicheinter $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -529,7 +529,7 @@ class pdf_soleil extends ModelePDFFicheinter */ // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidebottom)) { diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 4c10b7c7864..796f58a6743 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -334,7 +334,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -353,7 +353,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -623,7 +623,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->result = array('fullpath'=>$file); - return 1; // pas d'erreur + return 1; // No error } else { @@ -694,7 +694,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetFont('', '', $default_font_size - 2); // Output Rec - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 119ce6ad632..098adc71c57 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -328,7 +328,7 @@ class pdf_standard extends ModelePDFProduct $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -572,7 +572,7 @@ class pdf_standard extends ModelePDFProduct $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -630,11 +630,11 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 7721b29a1bf..1d7e30e7e6c 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -267,7 +267,7 @@ class pdf_beluga extends ModelePDFProjects $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2); @@ -679,7 +679,7 @@ class pdf_beluga extends ModelePDFProjects $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -717,7 +717,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetDrawColor(128, 128, 128); - // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param + // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); // line prend une position y en 3eme param diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index e4a32541aa9..2e475a05731 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -225,7 +225,7 @@ class pdf_timespent extends ModelePDFProjects $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -437,7 +437,7 @@ class pdf_timespent extends ModelePDFProjects $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -475,7 +475,7 @@ class pdf_timespent extends ModelePDFProjects $pdf->SetDrawColor(128, 128, 128); - // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param + // Draw rect of all tab (title + lines). Rect takes a length in 3rd parameter $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); // line prend une position y en 3eme param diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 59267e25272..c29fc14685a 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -415,7 +415,7 @@ class pdf_azur extends ModelePDFPropales $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -458,7 +458,7 @@ class pdf_azur extends ModelePDFPropales $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -818,7 +818,7 @@ class pdf_azur extends ModelePDFPropales $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1350,11 +1350,11 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index f5784ab1b2b..11c4ac111d1 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -392,7 +392,7 @@ class pdf_cyan extends ModelePDFPropales $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -933,7 +933,7 @@ class pdf_cyan extends ModelePDFPropales $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1457,13 +1457,13 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 4a16724d614..c3e287a4366 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -274,7 +274,7 @@ class pdf_squille extends ModelePdfReception $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -331,7 +331,7 @@ class pdf_squille extends ModelePdfReception $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -716,7 +716,7 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 08e0894bd04..bff8f8b4c43 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -558,7 +558,7 @@ class pdf_standard extends ModelePDFStock $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -738,7 +738,7 @@ class pdf_standard extends ModelePDFStock $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -796,7 +796,7 @@ class pdf_standard extends ModelePDFStock $pdf->SetFont('', 'B', $default_font_size - 3); // Output Rect - //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); $pdf->SetDrawColor(220, 26, 26); @@ -807,7 +807,7 @@ class pdf_standard extends ModelePDFStock if (empty($hidetop)) { - //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities("Ref"), '', 'L'); } diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 45edfb72cde..e589654feb3 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -732,7 +732,7 @@ class pdf_stdmovement extends ModelePDFMovement $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -794,7 +794,7 @@ class pdf_stdmovement extends ModelePDFMovement $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -852,7 +852,7 @@ class pdf_stdmovement extends ModelePDFMovement $pdf->SetFont('', 'B', $default_font_size - 3); // Output Rect - //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); $pdf->SetDrawColor(220, 26, 26); @@ -864,7 +864,7 @@ class pdf_stdmovement extends ModelePDFMovement //Ref mouv if (empty($hidetop)) { - //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxidref, $tab_top+1); $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); } diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 2f2e28b5463..a2393d7f63e 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -340,7 +340,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -358,7 +358,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -590,7 +590,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -858,11 +858,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index 07070c261cc..ffa0d9edc08 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -355,7 +355,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -785,7 +785,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1141,7 +1141,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter foreach ($this->cols as $colKey => $colDef) { @@ -1165,7 +1165,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders } if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter } } diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 61982a05621..9201a586d31 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -388,7 +388,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); @@ -406,7 +406,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -687,7 +687,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1043,11 +1043,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 3670797da67..3f2dca2757d 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -502,7 +502,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -619,7 +619,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 2ed06067944..e39e8434a8b 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -24,7 +24,7 @@ /** * \file htdocs/core/modules/propale/doc/pdf_azur.modules.php * \ingroup propale - * \brief Fichier de la classe permettant de generer les propales au modele Azur + * \brief File of the class allowing to generate the supplier propals to the Aurore model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Class to generate PDF proposal Azur + * Class to generate PDF supplier proposal Aurore */ class pdf_aurore extends ModelePDFSupplierProposal { @@ -391,7 +391,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param + // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); @@ -685,7 +685,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->result = array('fullpath'=>$file); - return 1; // Pas d'erreur + return 1; // No error } else { @@ -1201,11 +1201,11 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); From 44ba0deae69c4dc291bff0c04edfc55dbe588a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 20 Sep 2019 17:58:22 +0200 Subject: [PATCH 230/622] fix badge linked resources on fichinter --- htdocs/core/lib/fichinter.lib.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 8f8dea33b97..c17080d53f5 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -66,19 +66,20 @@ function fichinter_prepare_head($object) if ($conf->resource->enabled) { require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; - $nbResource = 0; - $objectres=new Dolresource($db); - if (is_array($objectres->available_resources)) - { - foreach ($objectres->available_resources as $modresources => $resources) - { - $resources=(array) $resources; // To be sure $resources is an array - foreach($resources as $resource_obj) - { - $linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj); - } - } - } + $objectres = new Dolresource($db); + $linked_resources = $objectres->getElementResources('fichinter', $object->id); + $nbResource = (is_array($linked_resources)?count($linked_resources):0); + // if (is_array($objectres->available_resources)) + // { + // foreach ($objectres->available_resources as $modresources => $resources) + // { + // $resources=(array) $resources; // To be sure $resources is an array + // foreach($resources as $resource_obj) + // { + // $linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj); + // } + // } + // } $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); From 86e8abde65635e41479af3dd250014ff10108f92 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 22 Sep 2019 11:18:54 +0200 Subject: [PATCH 231/622] Fix warning --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2eead6da81d..9c2f8ea737c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; */ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '') { - global $user,$conf,$langs,$dolibarr_main_db_name; + global $user,$conf,$langs,$dolibarr_main_db_name, $mysoc; $mainmenu=(empty($_SESSION["mainmenu"])?'':$_SESSION["mainmenu"]); $leftmenu=(empty($_SESSION["leftmenu"])?'':$_SESSION["leftmenu"]); From 14c98bea157941f4cbaafb985b108f41ecbaff02 Mon Sep 17 00:00:00 2001 From: oscim Date: Sun, 22 Sep 2019 11:34:28 +0200 Subject: [PATCH 232/622] Update livraison.class.php for correct display object link in card other object (shipping) --- htdocs/livraison/class/livraison.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 093a1c3ab1e..aa1f59cdfc4 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -844,6 +844,12 @@ class Livraison extends CommonObject elseif ($statut==0) return $langs->trans($this->statuts[$statut]); elseif ($statut==1) return $langs->trans($this->statuts[$statut]); } + elseif ($mode == 3) + { + if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'),'statut5'); + if ($statut==0) return img_picto($langs->trans('StatusDeliveryDraft'),'statut0'); + if ($statut==1) return img_picto($langs->trans('StatusDeliveryValidated'),'statut4'); + } elseif ($mode == 4) { if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5').' '.$langs->trans('StatusDeliveryCanceled'); From aed017deab26924d048f169d8b7e25186ce1e743 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 22 Sep 2019 09:36:18 +0000 Subject: [PATCH 233/622] Fixing style errors. --- htdocs/livraison/class/livraison.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index aa1f59cdfc4..afc1d89538c 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -846,9 +846,9 @@ class Livraison extends CommonObject } elseif ($mode == 3) { - if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'),'statut5'); - if ($statut==0) return img_picto($langs->trans('StatusDeliveryDraft'),'statut0'); - if ($statut==1) return img_picto($langs->trans('StatusDeliveryValidated'),'statut4'); + if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5'); + if ($statut==0) return img_picto($langs->trans('StatusDeliveryDraft'), 'statut0'); + if ($statut==1) return img_picto($langs->trans('StatusDeliveryValidated'), 'statut4'); } elseif ($mode == 4) { From 98acfd6929369ff11a0e6fb2f1583b16b4c36b4a Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 22 Sep 2019 11:57:33 +0200 Subject: [PATCH 234/622] Add basic stats to new dashboard --- htdocs/index.php | 51 ++++++++++++++++++++++++++++-- htdocs/theme/eldy/info-box.inc.php | 28 ++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index d50b5248fab..9151ead38b8 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -514,47 +514,55 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { 'project' => array( 'groupName' => 'Projects', + 'globalStatsKey' => 'projects', 'stats' => array('project', 'project_task'), ), 'propal' => array( 'groupName' => 'Proposals', + 'globalStatsKey' => 'proposals', 'stats' => array('propal_opened', 'propal_signed'), ), 'commande' => array( 'groupName' => 'Orders', + 'globalStatsKey' => 'orders', 'stats' => array('commande'), ), 'facture' => array( 'groupName' => 'Invoices', + 'globalStatsKey' => 'invoices', 'stats' => array('facture'), ), 'contrat' => array( 'groupName' => 'Contracts', + 'globalStatsKey' => 'Contracts', 'stats' => array('contrat_inactive', 'contrat_active'), ), 'supplier_proposal' => array( 'groupName' => 'SupplierProposals', + 'globalStatsKey' => 'askprice', 'stats' => array('supplier_proposal_opened', 'supplier_proposal_signed'), ), 'order_supplier' => array( 'groupName' => 'SuppliersOrders', + 'globalStatsKey' => 'supplier_orders', 'stats' => array('order_supplier'), ), 'invoice_supplier' => array( 'groupName' => 'BillsSuppliers', + 'globalStatsKey' => 'supplier_invoices', 'stats' => array('invoice_supplier'), ), @@ -567,18 +575,21 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { 'Adherent' => array( 'groupName' => 'Members', + 'globalStatsKey' => 'members', 'stats' => array('Adherent'), ), 'ExpenseReport' => array( 'groupName' => 'ExpenseReport', + 'globalStatsKey' => 'expensereports', 'stats' => array('ExpenseReport'), ), 'Holiday' => array( 'groupName' => 'Holidays', + 'globalStatsKey' => 'holidays', 'stats' => array('Holiday'), ), @@ -672,12 +683,46 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { if (!empty($boards)) { $groupName = $langs->trans($groupElement['groupName']); $groupKeyLowerCase = strtolower($groupKey); + $nbTotalForGroup = 0; + + // global stats + $globalStatsKey = false; + if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])){ // can be filled by hook + $globalStatsKey = $groupElement['globalStatsKey']; + $groupElement['globalStats'] = array(); + + if(in_array($globalStatsKey, $keys)) + { + // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links + $keyIndex = array_search($globalStatsKey, $keys); + + $classe=$classes[$keyIndex]; + if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe])) + { + $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey]?$boardloaded[$classe]->nb[$globalStatsKey]:0; + $nbTotal = doubleval($groupElement['globalStats']['total']); + if($nbTotal>=10000){ $nbTotal = round($nbTotal/1000 , 2) .'k'; } + $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')'; + $groupElement['globalStats']['total'] = $nbTotal; + $groupElement['globalStats']['link'] = $links[$keyIndex]; + } + } + } + $openedDashBoard .= '
    ' . "\n"; $openedDashBoard .= '
    ' . "\n"; - $openedDashBoard .= ' ' . "\n"; - $openedDashBoard .= '
    ' . "\n"; - $openedDashBoard .= ' ' . $groupName . '' . "\n"; + $openedDashBoard.= ' '."\n"; + $openedDashBoard.= ' '."\n"; + + if(!empty($groupElement['globalStats'])){ + $openedDashBoard.= ' '.$nbTotal.''."\n"; + } + + $openedDashBoard.= ' '."\n"; + $openedDashBoard .= '
    ' . "\n"; + + $openedDashBoard .= ' '.$groupName.'' . "\n"; foreach ($boards as $board) { if (!empty($board->labelShort)) { diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 3586d310dfa..34254812848 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -8,6 +8,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> */ .info-box { display: block; + position: relative; min-height: 90px; background: #fff; width: 100%; @@ -54,6 +55,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> border-bottom-right-radius: 0; border-bottom-left-radius: 2px; display: block; + overflow: hidden; float: left; height: 90px; width: 90px; @@ -71,6 +73,32 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> .info-box-icon > img { max-width: 100%; } +.info-box-icon-text{ + box-sizing: border-box; + display: block; + position: absolute; + width: 90px; + bottom: 0px; + color: #ffffff; + background-color: rgba(0,0,0,0.1); + cursor: default; + + font-size: 10px; + line-height: 15px; + padding: 0px 3px; + text-align: center; + opacity: 0; + -webkit-transition: opacity 0.5s, visibility 0s 0.5s; + transition: opacity 0.5s, visibility 0s 0.5s; +} +.info-box-sm .info-box-icon-text{ + overflow: hidden; + width: 80px; +} +.info-box:hover .info-box-icon-text{ + opacity: 1; +} + .info-box-content { padding: 5px 10px; margin-left: 90px; From 0660229602b642a9b7188b0ee8501a586d856463 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 22 Sep 2019 10:05:13 +0000 Subject: [PATCH 235/622] Fixing style errors. --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 9151ead38b8..b18ba2cf3be 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -701,7 +701,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { { $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey]?$boardloaded[$classe]->nb[$globalStatsKey]:0; $nbTotal = doubleval($groupElement['globalStats']['total']); - if($nbTotal>=10000){ $nbTotal = round($nbTotal/1000 , 2) .'k'; } + if($nbTotal>=10000){ $nbTotal = round($nbTotal/1000, 2) .'k'; } $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')'; $groupElement['globalStats']['total'] = $nbTotal; $groupElement['globalStats']['link'] = $links[$keyIndex]; From 9e55fee6e44825e47204bec4d6fc55e35b185b25 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 22 Sep 2019 13:46:11 +0200 Subject: [PATCH 236/622] Prepare global stats replacement --- htdocs/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 9151ead38b8..a8158f6e473 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -662,7 +662,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // Show dashboard $nbworkboardempty = 0; - $isIntopOpenedDashBoard = array(); + $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array(); if (!empty($valid_dashboardlines)) { $openedDashBoard = ''; @@ -716,6 +716,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $openedDashBoard.= ' '."\n"; if(!empty($groupElement['globalStats'])){ + $globalStatInTopOpenedDashBoard[] = $groupElement['globalStats']; $openedDashBoard.= ' '.$nbTotal.''."\n"; } From 913c298a9178bd84870a4f64c78073a959e8fce8 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 22 Sep 2019 20:59:28 +0200 Subject: [PATCH 237/622] Auto remove basic stats if in new opened dashboard --- htdocs/index.php | 98 +++++++++++++++++++----------- htdocs/theme/eldy/info-box.inc.php | 7 +++ 2 files changed, 70 insertions(+), 35 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 45c7e1509e2..28a1a54e2ad 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -107,27 +107,21 @@ if (! empty($conf->global->MAIN_MOTD)) * Dashboard Dolibarr states (statistics) * Hidden for external users */ -$boxstat=''; + + +$boxstatItems = array(); +$boxstatFromHook = ''; // Load translation files required by page $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts')); if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { - $boxstat.='
    '; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.='
    '; - $boxstat.='
    '.$langs->trans("DolibarrStateBoard").'
    '; - $boxstat.='
    '; - $object=new stdClass(); $parameters=array(); $action=''; $reshook=$hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $boxstat.=$hookmanager->resPrint; + $boxstatFromHook=$hookmanager->resPrint; if (empty($reshook)) { @@ -318,6 +312,7 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT { if ($conditions[$key]) { + $boxstatItem = ''; $classe=$classes[$key]; // Search in cache if load_state_board is already realized if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe])) @@ -336,28 +331,17 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT if (!empty($langfile[$key])) $langs->load($langfile[$key]); $text=$langs->trans($titres[$key]); - $boxstat.=''; - $boxstat.='
    '; - $boxstat.=''.$text.'
    '; - $boxstat.=''.img_object("", $icons[$key], 'class="inline-block"').' '.($board->nb[$val]?$board->nb[$val]:0).''; - $boxstat.='
    '; - $boxstat.='
    '; + $boxstatItem.=''; + $boxstatItem.='
    '; + $boxstatItem.=''.$text.'
    '; + $boxstatItem.=''.img_object("", $icons[$key], 'class="inline-block"').' '.($board->nb[$val]?$board->nb[$val]:0).''; + $boxstatItem.='
    '; + $boxstatItem.='
    '; + + $boxstatItems[$val] = $boxstatItem; } } } - - $boxstat.='
    '; - $boxstat.='
    '; - $boxstat.='
    '; - $boxstat.='
    '; - $boxstat.='
    '; - $boxstat.='
    '; - $boxstat.='
    '; - $boxstat.='
    '; - - $boxstat.='
    '; - $boxstat.='
    '; } @@ -589,7 +573,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { 'Holiday' => array( 'groupName' => 'Holidays', - 'globalStatsKey' => 'holidays', + 'globalStatsKey' => 'holidays', 'stats' => array('Holiday'), ), @@ -710,18 +694,18 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } - $openedDashBoard .= '
    ' . "\n"; - $openedDashBoard .= '
    ' . "\n"; + $openedDashBoard.= '
    ' . "\n"; + $openedDashBoard.= '
    ' . "\n"; $openedDashBoard.= ' '."\n"; $openedDashBoard.= ' '."\n"; if(!empty($groupElement['globalStats'])){ - $globalStatInTopOpenedDashBoard[] = $groupElement['globalStats']; + $globalStatInTopOpenedDashBoard[] = $globalStatsKey; $openedDashBoard.= ' '.$nbTotal.''."\n"; } $openedDashBoard.= ' '."\n"; - $openedDashBoard .= '
    ' . "\n"; + $openedDashBoard .= '
    ' . "\n"; $openedDashBoard .= ' '.$groupName.'' . "\n"; @@ -900,6 +884,50 @@ $boxlist.=$resultboxes['boxlista']; $boxlist.= '
    '; + +if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) +{ + // Remove allready present info in new dash board + if(!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0){ + foreach ( $boxstatItems as $boxstatItemKey => $boxstatItemHtml) { + if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) { + unset($boxstatItems[$boxstatItemKey]); + } + } + } + + if(!empty($boxstatFromHook) || !empty($boxstatItems)){ + $boxstat.='
    '; + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; + $boxstat.='
    '; + $boxstat.='
    '.$langs->trans("DolibarrStateBoard").'
    '; + $boxstat.='
    '; + + $boxstat.=$boxstatFromHook; + + if(is_array($boxstatItems) && count($boxstatItems) > 0) + { + $boxstat.= implode('', $boxstatItems); + } + + $boxstat.='
    '; + $boxstat.='
    '; + $boxstat.='
    '; + $boxstat.='
    '; + $boxstat.='
    '; + $boxstat.='
    '; + $boxstat.='
    '; + $boxstat.='
    '; + + $boxstat.='
    '; + $boxstat.='
    '; + } +} + $boxlist.= '
    '; $boxlist.=$boxstat; diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 34254812848..a483b3d758d 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -91,6 +91,13 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> -webkit-transition: opacity 0.5s, visibility 0s 0.5s; transition: opacity 0.5s, visibility 0s 0.5s; } + +global->MAIN_DISABLE_GLOBAL_BOXSTATS) && !empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD)){ ?> +.info-box-icon-text{ + opacity: 1; +} + + .info-box-sm .info-box-icon-text{ overflow: hidden; width: 80px; From 3faca1dbd1d7b8d162c72126d20682dda5850622 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Sep 2019 21:09:01 +0200 Subject: [PATCH 238/622] Enhancement for SCA --- htdocs/stripe/class/stripe.class.php | 44 +++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9c0bc9ebae3..6379aa36746 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -654,7 +654,7 @@ class Stripe extends CommonObject * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card - * @return \Stripe\StripeCard|null Stripe Card or null if not found + * @return \Stripe\StripeCard|\Stripe\PaymentMethod|null Stripe Card or null if not found */ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) { @@ -680,10 +680,24 @@ class Stripe extends CommonObject { try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $card = $cu->sources->retrieve($cardref); + if (! preg_match('/^pm_/', $cardref)) + { + $card = $cu->sources->retrieve($cardref); + } + else + { + $card = \Stripe\PaymentMethod::retrieve($cardref); + } } else { - //$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided - $card = $cu->sources->retrieve($cardref); + if (! preg_match('/^pm_/', $cardref)) + { + //$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided + $card = $cu->sources->retrieve($cardref); + } + else { + //$card = \Stripe\PaymentMethod::retrieve($cardref, array("stripe_account" => $stripeacc)); // Don't know if this works + $card = \Stripe\PaymentMethod::retrieve($cardref); + } } } catch(Exception $e) @@ -707,12 +721,28 @@ class Stripe extends CommonObject //$a = \Stripe\Stripe::getApiKey(); //var_dump($a);var_dump($stripeacc);exit; - dol_syslog("Try to create card dataforcard = ".json_encode($dataforcard)); + dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $card = $cu->sources->create($dataforcard); + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $card = $cu->sources->create($dataforcard); + } + else + { + // TODO + dol_syslog("Error: This case is not supported", LOG_ERR); + } } else { - $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); + } + else + { + // TODO + dol_syslog("Error: This case is not supported", LOG_ERR); + } } if ($card) From cc5c6c0c76a7b8cef8ae69b842dde8ba4f171dc6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 22 Sep 2019 19:09:02 +0000 Subject: [PATCH 239/622] Fixing style errors. --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 28a1a54e2ad..bce3b9dc083 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -889,7 +889,7 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT { // Remove allready present info in new dash board if(!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0){ - foreach ( $boxstatItems as $boxstatItemKey => $boxstatItemHtml) { + foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) { if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) { unset($boxstatItems[$boxstatItemKey]); } From 31094936c1ab3524c0e07ee17d1b2c91a5a2a92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 23 Sep 2019 10:56:11 +0200 Subject: [PATCH 240/622] wip --- htdocs/core/boxes/box_contracts.php | 5 ++++- htdocs/core/boxes/box_factures_fourn.php | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 43ade84ad20..c304800f4c1 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -84,7 +84,8 @@ class box_contracts extends ModeleBoxes $thirdpartytmp=new Societe($db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql.= ", c.ref_customer, c.ref_supplier"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; @@ -117,6 +118,8 @@ class box_contracts extends ModeleBoxes $contractstatic->statut=$objp->fk_statut; $contractstatic->id=$objp->rowid; $contractstatic->ref=$objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; $result=$contractstatic->fetch_lines(); $thirdpartytmp->name = $objp->name; diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 9d2e8e995e3..ce355f53e1e 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -87,7 +87,7 @@ class box_factures_fourn extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_fournisseur,"; + $sql.= " s.code_fournisseur, s.email,"; $sql.= " s.logo,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; $sql.= " f.total_ht,"; @@ -133,6 +133,7 @@ class box_factures_fourn extends ModeleBoxes $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; $thirdpartytmp->fournisseur = 1; $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; From bf9f25fd74553a6bd2962f3505233b184a9f4953 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Sep 2019 11:35:11 +0200 Subject: [PATCH 241/622] Ehance getPaymentIntent to use it for offline payment --- htdocs/stripe/class/stripe.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 6379aa36746..c8a9c69a5ae 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -305,16 +305,18 @@ class Stripe extends CommonObject * @param string $currency_code Currency code * @param string $tag Tag * @param string $description Description - * @param Societe $object Object to pay with Stripe + * @param mixed $object Object to pay with Stripe * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt * @param int $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent * @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok) + * @param string $payment_method 'pm_....' (if known) + * @param string $off_session If we use an already known payment method to pay off line. * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create */ - public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false) + public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0) { global $conf; @@ -335,7 +337,7 @@ class Stripe extends CommonObject } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } - if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); + if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100); else $stripefee = round($fee); $paymentintent = null; @@ -411,6 +413,12 @@ class Stripe extends CommonObject // payment_method = // payment_method_types = array('card') //var_dump($dataforintent); + if ($off_session) + { + unset($dataforintent['setup_future_usage']); + $dataforintent["off_session"] = true; + } + if (! is_null($payment_method)) $dataforintent["payment_method"] = $payment_method; if ($conf->entity!=$conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) { @@ -491,7 +499,7 @@ class Stripe extends CommonObject } } - dol_syslog("getPaymentIntent return error=".$error, LOG_INFO, -1); + dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1); if (! $error) { From d5877e9c36fbda0040c67e6b63befbd558eb9480 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Sep 2019 11:36:45 +0200 Subject: [PATCH 242/622] FIX Bad currency var used in stripe for connect --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index abc875c370f..626f5533da4 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -325,7 +325,7 @@ class Stripe extends CommonObject } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } - if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); + if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100); else $stripefee = round($fee); $paymentintent = null; From 1584a4bf79b42b503e7cb39f37ebf20eba44c2e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Sep 2019 12:27:51 +0200 Subject: [PATCH 243/622] Add trigger event USER_SENTBYMAIL in agenda --- htdocs/core/class/events.class.php | 24 ------------------- .../mysql/data/llx_c_action_trigger.sql | 3 ++- .../install/mysql/migration/10.0.0-11.0.0.sql | 5 ++++ 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 57a076963fd..160e22f4c50 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -87,33 +87,9 @@ class Events // extends CommonObject array('id'=>'USER_NEW_PASSWORD', 'test'=>1), array('id'=>'USER_ENABLEDISABLE', 'test'=>1), array('id'=>'USER_DELETE', 'test'=>1), - /* array('id'=>'USER_SETINGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY - array('id'=>'USER_REMOVEFROMGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY */ array('id'=>'GROUP_CREATE', 'test'=>1), array('id'=>'GROUP_MODIFY', 'test'=>1), array('id'=>'GROUP_DELETE', 'test'=>1), - /* array('id'=>'ACTION_CREATE', 'test'=>$conf->societe->enabled), - array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled), - array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled), - array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_CLOSE_SIGNED', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_CLOSE_REFUSED', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled), - array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled), - array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled), - array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled), - array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled), - array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled), - array('id'=>'MEMBER_CREATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_MODIFY', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled), - */ ); diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index aaa96e3136a..0e2a1875e21 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -113,12 +113,13 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',165); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_SENTBYMAIL','Ticket message sent by email','Executed when a message is sent from the ticket record','ticket',166); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',167); --- actions not enabled by default (no constant created for that) when we enable module agenda +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_SENTBYMAIL','Email sent','Executed when an email is sent from user card','user',300); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',23); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_MODIFY','Intervention modified','Executed when a intervention is modified','ficheinter',19); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',142); +-- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',152); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 92dcdce1128..890411109f9 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -33,6 +33,11 @@ ALTER TABLE llx_account_bookkeeping ADD COLUMN date_export datetime DEFAULT NULL ALTER TABLE llx_expensereport ADD COLUMN paid smallint default 0 NOT NULL; UPDATE llx_expensereport set paid = 1 WHERE fk_statut = 6 and paid = 0; + +-- For v11 + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_SENTBYMAIL','Email sent','Executed when an email is sent from user card','user',300); + create table llx_entrepot_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, From 8ac0383fa020b029365cb6e12de68de35bb4a481 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Sep 2019 12:36:12 +0200 Subject: [PATCH 244/622] FIX Send email from expense report card. FIX Alias name is not into the email recipient label. --- htdocs/core/actions_sendmails.inc.php | 54 +++++++++++---------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 836652ea819..de3a43d9ce6 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -113,8 +113,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $result=$object->fetch($id); - $sendtosocid=0; // Thirdparty on object - if (method_exists($object, "fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) + $sendtosocid=0; // Id of related thirdparty + if (method_exists($object, "fetch_thirdparty") && ! in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact'))) { $result=$object->fetch_thirdparty(); if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok @@ -124,7 +124,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO elseif ($object->element == 'member' || $object->element == 'user') { $thirdparty=$object; - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; + if ($object->socid > 0) $sendtosocid=$object->socid; + } + elseif ($object->element == 'expensereport') + { + $tmpuser=new User($db); + $tmpuser->fetch($object->fk_user_author); + $thirdparty=$tmpuser; + if ($object->socid > 0) $sendtosocid=$object->socid; } elseif ($object->element == 'societe') { @@ -136,7 +143,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $contact=$object; if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; } - else dol_print_error('', 'Use actions_sendmails.in.php for an element/object that is not supported'); + else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported"); if (is_object($hookmanager)) { @@ -162,6 +169,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($receiver == '-1') $receiver=array(); else $receiver=array($receiver); } + $tmparray=array(); if (trim($_POST['sendto'])) { @@ -173,22 +181,23 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO foreach($receiver as $key=>$val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party + if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too) { - $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; + $tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>'; } // Recipient was provided from combo list - elseif ($val == 'contact') // Id of contact + elseif ($val == 'contact') // Key selected means current contact { - $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; + $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>'; } - elseif ($val) // Id du contact + elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $receiveruser=$_POST['receiveruser']; @@ -222,16 +231,16 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO foreach($receivercc as $key=>$val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party + if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too) { $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } // Recipient was provided from combo list - elseif ($val == 'contact') // Id of contact + elseif ($val == 'contact') // Key selected means current contact { $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; } - elseif ($val) // Id du contact + elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? @@ -414,27 +423,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$mailfile->sendfile(); if ($result) { - // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required - /* - if (! empty($conf->dolimail->enabled)) - { - $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? - if ($mid) - { - // set imap flag answered if it is an answered mail - $dolimail=new DoliMail($db); - $dolimail->id = $mid; - $res=$dolimail->set_prop($user, 'answered',1); - } - if ($imap==1) - { - // write mail to IMAP Server - $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); - if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); - else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); - } - }*/ - // Initialisation of datas of object to call trigger if (is_object($object)) { From 40f75b16d8fdb81a89266799846072f7b8970279 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Sep 2019 13:04:22 +0200 Subject: [PATCH 245/622] FIX Substitution of __PROJECT_XXX__ not done --- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/core/actions_massactions.inc.php | 4 ++ htdocs/core/lib/functions.lib.php | 46 ++++++++++++------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c3b698d3918..a52bdee82cc 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -676,7 +676,7 @@ class ActionComm extends CommonObject $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->contactid = $obj->fk_contact; // To have fetch_contact method working - $this->fk_project = $obj->fk_project; // To have fetch_project method working + $this->fk_project = $obj->fk_project; // To have fetch_projet method working $this->societe->id = $obj->fk_soc; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d54d2dd02ff..6cd98f00e48 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -384,6 +384,10 @@ if (! $error && $massaction == 'confirm_presend') foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object { // Make substitution in email content + if (! empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) + { + $objecttmp->fetch_projet(); + } $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id); $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b6b691117a5..268b206919c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3831,6 +3831,8 @@ function dol_print_error($db = '', $error = '', $errors = null) if (empty($dolibarr_main_prod)) print $out; else { + print 'This website is currently temporarly offline. This may be due to a maintenance operation. Current status of operation are on next line...

    '."\n"; + $langs->load("errors"); print $langs->trans("DolibarrHasDetectedError").'. '; print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); define("MAIN_CORE_ERROR", 1); @@ -3859,7 +3861,7 @@ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = $now=dol_now(); print '