From ac7f1035e1c33f0525caae04e266febf80e65023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 3 Sep 2017 12:25:27 +0200 Subject: [PATCH 01/67] FIX #7325 Default VAT rate when editing template invoices is 0% Close #7325 --- htdocs/compta/facture/fiche-rec.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index a6b238ba3c7..5af3d71f3af 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -896,7 +896,7 @@ if ($action == 'create') $langs->load('projects'); print '' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   thirdparty->id).'">' . $langs->trans("AddProject") . ''; print ''; } @@ -963,7 +963,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid); // No date selector for template invoice } print "\n"; @@ -1307,7 +1307,7 @@ else { //$disableedit=1; //$disablemove=1; - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line @@ -1318,7 +1318,7 @@ else $var = true; // Add free products/services - $object->formAddObjectLine(0, $mysoc, $soc); // No date selector for template invoice + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook From eb9e8c9dfcb9f94e8c1f06d8b4ecfc881c265d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 3 Sep 2017 12:42:05 +0200 Subject: [PATCH 02/67] FIX #7000 Dashboard link for late pending payment supplier invoices do not work Close #7000 --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/list.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bb3d303b32e..3aa9051a5c6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1507,7 +1507,7 @@ class FactureFournisseur extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $response->label=$langs->trans("SupplierBillsToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=f.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"),"bill"); $facturestatic = new FactureFournisseur($this->db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 66411dc8422..706a78ccb1e 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -84,9 +84,12 @@ $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $toselect = GETPOST('toselect', 'array'); +$filter = GETPOST('filtre'); $option = GETPOST('option'); -if ($option == 'late') $filter = 'paye:0'; +if ($option == 'late') { + $filter = 'paye:0'; +} $search_all = GETPOST('sall'); $search_label = GETPOST("search_label","alpha"); From 1154f871f13bbcf9bcf931c94eb3175d16cf39b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:52:49 +0200 Subject: [PATCH 03/67] 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 5af3d71f3af..9e118a460a5 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -963,7 +963,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid); // No date selector for template invoice + $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "\n"; From 4dd58a94f3303cde838bb49066f39c137b8dd768 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:54:50 +0200 Subject: [PATCH 04/67] Update list.php --- htdocs/fourn/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 706a78ccb1e..6a0606dce86 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -84,7 +84,7 @@ $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $toselect = GETPOST('toselect', 'array'); -$filter = GETPOST('filtre'); +$filter = GETPOST('filtre','alpha'); $option = GETPOST('option'); if ($option == 'late') { From 237270a27eb52c60bc8898700c98a5e5ae997da1 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 5 Sep 2017 21:40:04 +0200 Subject: [PATCH 05/67] Add missing transfer of line extrafields in create invoice from supplier order --- htdocs/fourn/facture/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ac94d1b0e62..f1d684261d9 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -456,7 +456,13 @@ if (empty($reshook)) $date_end=$lines[$i]->date_fin_prevue; if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($db); + $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); + } // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( $desc, From f5e14c9d7060882595021306b42584c877e0db23 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 5 Sep 2017 21:41:49 +0200 Subject: [PATCH 06/67] Transfer of customer order line extrafield should only transfer fields available in target --- htdocs/compta/facture.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8a35fd7583d..33462e6370a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1153,7 +1153,9 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $extrafields = new ExtraFields($db); + $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); $array_options = $lines[$i]->array_options; } From 5a75e14a8ab3541a82ed8ca731e3d6874b570b3a Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 5 Sep 2017 22:50:34 +0200 Subject: [PATCH 07/67] Add supplier qty and supplier discount for export --- htdocs/core/modules/modProduct.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 154639f848d..6edcb0e2708 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -151,14 +151,14 @@ class modProduct extends DolibarrModules if ($mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'SuppliersPrices')); + if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'BuyingPrice','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric')); + if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.url'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product"); From 7c743eb7da87046c1416c6a3d04ed9d810e8539c Mon Sep 17 00:00:00 2001 From: fappels Date: Thu, 7 Sep 2017 21:04:15 +0200 Subject: [PATCH 08/67] Rename $extrafields because already used --- htdocs/compta/facture.php | 6 +++--- htdocs/fourn/facture/card.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 33462e6370a..f229b3d999c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1153,9 +1153,9 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $extrafields = new ExtraFields($db); - $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); - $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); + $targetExtraFields = new ExtraFields($db); + $targetExtraFieldLabels = $targetExtraFields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraFieldLabels); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index f1d684261d9..224a1443a4f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -459,9 +459,9 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($db); - $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); - $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); + $targetExtraFields = new ExtraFields($db); + $targetExtraFieldLabels = $targetExtraFields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraFieldLabels); } // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( From 8b9b99ac408239cd81f35aa24ce4d0d6b81f5d21 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 15 Sep 2017 13:02:49 +0200 Subject: [PATCH 09/67] fix : advance target emailing --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 453d1f75319..5307237919b 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -474,7 +474,7 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=t.rowid "; } if (array_key_exists('cust_categ', $arrayquery)) { - $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_societe=t.rowid "; + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_soc=t.rowid "; } if (!empty($arrayquery['cust_name'])) { From a8b4d216e5a8687ed8c8b496b282627b637e1105 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 23:21:42 +0200 Subject: [PATCH 10/67] Fix PHPCS --- htdocs/user/class/usergroup.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 1dac2e1672b..d0a82972325 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -71,9 +71,10 @@ class UserGroup extends CommonObject /** * Charge un objet group avec toutes ces caracteristiques (except ->members array) * - * @param int $id id du groupe a charger - * @param string $groupname name du groupe a charger - * @return int <0 if KO, >0 if OK + * @param int $id Id of group to load + * @param string $groupname Name of group to load + * @param boolean $load_members Load all members of the group + * @return int <0 if KO, >0 if OK */ function fetch($id='', $groupname='', $load_members = true) { @@ -136,8 +137,9 @@ class UserGroup extends CommonObject /** * Return array of groups objects for a particular user * - * @param int $userid User id to search - * @return array Array of groups objects + * @param int $userid User id to search + * @param boolean $load_members Load all members of the group + * @return array Array of groups objects */ function listGroupsForUser($userid, $load_members = true) { From ffb3823655d9d84ca023057e6c3a88e003efae51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 23:38:03 +0200 Subject: [PATCH 11/67] Allow null in stock alert threshold to be compatible with #7162 --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_product.sql | 2 +- htdocs/langs/en_US/stocks.lang | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 8900a07104a..0f32f1c731b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -41,6 +41,9 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; -- For 7.0 +ALTER TABLE llx_product MODIFY COLUMN seuil_stock_alerte integer DEFAULT NULL; +-- VPGSQL8.2 ALTER TABLE llx_product ALTER COLUMN seuil_stock_alerte SET DEFAULT NULL; + ALTER TABLE llx_facture_rec ADD COLUMN suspended integer DEFAULT 0; ALTER TABLE llx_facture_rec MODIFY COLUMN titre VARCHAR(100); diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 1769ec6bd3e..04267d22d3a 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -60,7 +60,7 @@ create table llx_product tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch management (eat-by or lot management) fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module) duration varchar(6), - seuil_stock_alerte integer DEFAULT 0, + seuil_stock_alerte integer DEFAULT NULL, url varchar(255), barcode varchar(255) DEFAULT NULL, -- barcode fk_barcode_type integer DEFAULT NULL, -- barcode type diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index f2115666a36..9525b43432d 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -71,7 +71,7 @@ NoPredefinedProductToDispatch=No predefined products for this object. So no disp DispatchVerb=Dispatch StockLimitShort=Limit for alert StockLimit=Stock limit for alert -StockLimitDesc="" (empty) default value means no alert.
"0" can be used with 'Stock can be negative' configuration. +StockLimitDesc=(empty) means no warning.
0 can be used for a warning as soon as stock is empty. PhysicalStock=Physical stock RealStock=Real Stock RealStockDesc=Physical or real stock is the stock you currently have into your internal warehouses/emplacements. From 8773a6860fc98d87e37d8ddc0dbfd02c232f8c8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 23:49:04 +0200 Subject: [PATCH 12/67] Fix HTML5 use of
is preferred to
--- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/journals_list.php | 2 +- .../accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/admin/bank.php | 2 +- htdocs/admin/compta.php | 2 +- htdocs/admin/dict.php | 2 +- .../class/PSWebServiceLibrary.class.php | 2 +- htdocs/admin/loan.php | 8 +- htdocs/admin/multicurrency.php | 4 +- htdocs/admin/payment.php | 2 +- htdocs/admin/stock.php | 18 ++-- htdocs/expensereport/card.php | 2 +- htdocs/holiday/card.php | 6 +- htdocs/install/check.php | 6 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/bills.lang | 2 +- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/multicurrency.lang | 2 +- htdocs/langs/en_US/other.lang | 6 +- htdocs/langs/en_US/stocks.lang | 4 +- htdocs/opensurvey/results.php | 2 +- htdocs/opensurvey/wizard/create_survey.php | 4 +- .../product/inventory/tpl/inventory.tpl.php | 100 ++++++++--------- .../stock/class/mouvementstock.class.php | 102 +++++++++--------- htdocs/product/stock/product.php | 1 - htdocs/projet/ganttchart.inc.php | 2 +- htdocs/resource/element_resource.php | 22 ++-- 28 files changed, 156 insertions(+), 157 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 9df72687da8..cf2b9080ee2 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -289,7 +289,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index fbacabda5d1..53569c50b00 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -185,7 +185,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } if (isset($_POST["country"]) && ($_POST["country"] <= 0)) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index fd988f9c637..2271fa73c0b 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -174,7 +174,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 2e125925860..fe4a004181d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -315,7 +315,7 @@ while ($i < min($num, $limit)) // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')'; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')'; print '' . ($line->debit ? price($line->debit) :''). ''; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index c42fd305eba..bf3b2e9ea92 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -399,7 +399,7 @@ print ''; -print '

'; +print '

'; /* diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 70bf15d03f3..507a6d86f24 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -162,7 +162,7 @@ foreach ($list as $key) print "\n"; -print '

'; +print '

'; print ''; llxFooter(); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 97bc3417100..913f4611a0e 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -662,7 +662,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 85783ae197d..10653df9dc0 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -286,7 +286,7 @@ class PrestaShopWebservice * $xml = $ws->get(array('resource' => 'orders', 'id' => 1)); * // Here in $xml, a SimpleXMLElement object you can parse * foreach ($xml->children()->children() as $attName => $attValue) - * echo $attName.' = '.$attValue.'
'; + * echo $attName.' = '.$attValue.'
'; * } * catch (PrestaShopWebserviceException $ex) * { diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index c3e8bad9f6d..65363f468e8 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -23,7 +23,7 @@ */ require '../main.inc.php'; - + // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; @@ -47,7 +47,7 @@ $list = array ( /* * Actions */ - + if ($action == 'update') { $error = 0; @@ -99,7 +99,7 @@ foreach ($list as $key) print ''; // Param - $label = $langs->trans($key); + $label = $langs->trans($key); print ''; // Value @@ -120,7 +120,7 @@ print ''; print ''; print "\n"; -print '
'; +print '
'; llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index c6d00501015..88a91feb083 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -235,7 +235,7 @@ print ''; */ print ''; -print '
'; +print '
'; if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) { @@ -293,7 +293,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) print ''; print ''; - print '
'; + print '
'; } diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 2ef7a500268..3246caeb411 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -233,7 +233,7 @@ foreach ($dirmodels as $reldir) print ''; -print "
"; +print "
"; print load_fiche_titre($langs->trans("OtherOptions"),'',''); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 36a4ec697e6..f7e18851306 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -246,7 +246,7 @@ $found++; /*if (! $found) { - + print ''; print ''.$langs->trans("NoModuleToManageStockDecrease").''; print "\n"; @@ -329,7 +329,7 @@ $found++; /*if (! $found) { - + print ''; print ''.$langs->trans("NoModuleToManageStockIncrease").''; print "\n"; @@ -433,7 +433,7 @@ if ($virtualdiffersfromphysical) } -print '
'; +print '
'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; @@ -441,7 +441,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''."\n"; print ''; print ''."\n"; - + // Example with a yes / no select print ''; print ''; @@ -454,7 +454,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''; - + // Example with a yes / no select print ''; print ''; @@ -467,7 +467,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''; - + // Example with a yes / no select print ''; print ''; @@ -480,7 +480,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''; - + print '
'.$langs->trans("Inventory").'  
'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'
'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'
'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'
'; } @@ -492,7 +492,7 @@ print "  \n"; print ''."\n"; if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - + print ''; print ''.$langs->trans("UseDispatchStatus").''; print ''; @@ -536,7 +536,7 @@ print '
'; If not used by a module, I still need to understand in which case user may need this now we can set rule on product page. if ($conf->global->PRODUIT_SOUSPRODUITS) { - + print ''; print ''.$langs->trans("IndependantSubProductStock").''; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 2b48f3d65b0..640521bcc28 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2084,7 +2084,7 @@ else print ''; print ''; print ''; - print '
'; + print '
'; print ''; } diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 8ee0fb64b40..7194aae65ac 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -823,7 +823,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create dol_fiche_head(); - //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; + //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; print ''; print ''; @@ -1281,14 +1281,14 @@ else } else { print '
'; print $langs->trans('ErrorUserViewCP'); - print '

'; + print '

'; print '
'; } } else { print '
'; print $langs->trans('ErrorIDFicheCP'); - print '

'; + print '

'; print '
'; } diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 2b09d1c9813..50409fb55e5 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -365,7 +365,7 @@ else print $langs->trans("InstallEasy")." "; print $langs->trans("ChooseYourSetupMode"); - print '

'; + print '

'; $foundrecommandedchoice=0; @@ -534,13 +534,13 @@ else if (count($notavailable_choices)) { - print '
'; + print '
'; print ''; print '
'; foreach ($notavailable_choices as $choice) { print $choice; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0fe1040b389..0a512b6bfc0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -132,7 +132,7 @@ MaxNbOfLinesForBoxes=Max number of lines for widgets PositionByDefault=Default order Position=Position MenusDesc=Menu managers set content of the two menu bars (horizontal and vertical). -MenusEditorDesc=The menu editor allows you to define custom menu entries. Use it carefully to avoid instability and permanently unreachable menu entries.
Some modules add menu entries (in menu All mostly). If you remove some of these entries by mistake, you can restore them disabling and reenabling the module. +MenusEditorDesc=The menu editor allows you to define custom menu entries. Use it carefully to avoid instability and permanently unreachable menu entries.
Some modules add menu entries (in menu All mostly). If you remove some of these entries by mistake, you can restore them disabling and reenabling the module. MenuForUsers=Menu for users LangFile=.lang file System=System diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 3ffbcf87080..a7918fc702c 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -331,7 +331,7 @@ ListOfNextSituationInvoices=List of next situation invoices FrequencyPer_d=Every %s days FrequencyPer_m=Every %s months FrequencyPer_y=Every %s years -toolTipFrequency=Examples:
Set 7, Day: give a new invoice every 7 days
Set 3, Month: give a new invoice every 3 month +toolTipFrequency=Examples:
Set 7, Day: give a new invoice every 7 days
Set 3, Month: give a new invoice every 3 month NextDateToExecution=Date for next invoice generation DateLastGeneration=Date of latest generation MaxPeriodNumber=Max nb of invoice generation diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 0cea69200dc..ca58f641e89 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -844,7 +844,7 @@ Select2NotFound=No result found Select2Enter=Enter Select2MoreCharacter=or more character Select2MoreCharacters=or more characters -Select2MoreCharactersMore=Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
+Select2MoreCharactersMore=Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
Select2LoadingMoreResults=Loading more results... Select2SearchInProgress=Search in progress... SearchIntoThirdparties=Thirdparties diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index a1e5025fa9d..fcf84791a1f 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -7,7 +7,7 @@ multicurrency_syncronize_error=Synchronisation error: %s MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE=Use date of document to find currency rate, instead of using latest known rate multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the latest known rate) CurrencyLayerAccount=CurrencyLayer API -CurrencyLayerAccount_help_to_synchronize=You sould create an account on their website to use this functionnality
Get your API key
If you use a free account you can't change the currency source (USD by default)
But if your main currency isn't USD you can use the alternate currency source to force you main currency

You are limited at 1000 synchronizations per month +CurrencyLayerAccount_help_to_synchronize=You sould create an account on their website to use this functionnality
Get your API key
If you use a free account you can't change the currency source (USD by default)
But if your main currency isn't USD you can use the alternate currency source to force you main currency

You are limited at 1000 synchronizations per month multicurrency_appId=API key multicurrency_appCurrencySource=Currency source multicurrency_alternateCurrencySource=Alternate currency source diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index b9ce8965d71..f1cca6a1696 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -3,7 +3,7 @@ SecurityCode=Security code NumberingShort=N° Tools=Tools TMenuTools=Tools -ToolsDesc=All miscellaneous tools not included in other menu entries are collected here.

All the tools can be reached in the left menu. +ToolsDesc=All miscellaneous tools not included in other menu entries are collected here.

All the tools can be reached in the left menu. Birthday=Birthday BirthdayDate=Birthday date DateToBirth=Date of birth @@ -162,9 +162,9 @@ SizeUnitinch=inch SizeUnitfoot=foot SizeUnitpoint=point BugTracker=Bug tracker -SendNewPasswordDesc=This form allows you to request a new password. It will be sent to your email address.
Change will become effective once you click on the confirmation link in the email.
Check your inbox. +SendNewPasswordDesc=This form allows you to request a new password. It will be sent to your email address.
Change will become effective once you click on the confirmation link in the email.
Check your inbox. BackToLoginPage=Back to login page -AuthenticationDoesNotAllowSendNewPassword=Authentication mode is %s.
In this mode, Dolibarr can't know nor change your password.
Contact your system administrator if you want to change your password. +AuthenticationDoesNotAllowSendNewPassword=Authentication mode is %s.
In this mode, Dolibarr can't know nor change your password.
Contact your system administrator if you want to change your password. EnableGDLibraryDesc=Install or enable GD library on your PHP installation to use this option. ProfIdShortDesc=Prof Id %s is an information depending on third party country.
For example, for country %s, it's code %s. DolibarrDemo=Dolibarr ERP/CRM demo diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 9525b43432d..cda14147ece 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -49,7 +49,7 @@ EnhancedValue=Value PMPValue=Weighted average price PMPValueShort=WAP EnhancedValueOfWarehouses=Warehouses value -UserWarehouseAutoCreate=Create a warehouse automatically when creating a user +UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user AllowAddLimitStockByWarehouse=Allow to add limit and desired stock per couple (product, warehouse) instead of per product IndependantSubProductStock=Product stock and subproduct stock are independant QtyDispatched=Quantity dispatched @@ -175,7 +175,7 @@ SelectFournisseur=Supplier filter inventoryOnDate=Inventory INVENTORY_DISABLE_VIRTUAL=Allow to not destock child product from a kit on inventory INVENTORY_USE_MIN_PA_IF_NO_LAST_PA=Use the buy price if no last buy price can be found -INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT=Stock mouvment have date of inventory +INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT=Stock movement have date of inventory inventoryChangePMPPermission=Allow to change PMP value for a product ColumnNewPMP=New unit PMP OnlyProdsInStock=Do not add product without stock diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 2ce78a2f8c7..49f26e47cb0 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -600,7 +600,7 @@ if (GETPOST('ajoutsujet')) } if ($user->rights->opensurvey->write) { - print '
'.$langs->trans("PollAdminDesc", img_picto('','delete'), $langs->trans("Add")).'
'; + print '
'.$langs->trans("PollAdminDesc", img_picto('','delete'), $langs->trans("Add")).'
'; } $nbcolonnes=substr_count($object->sujet,',')+1; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 787bb7969fa..0dfc2505ce3 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -178,11 +178,11 @@ print ' '. $langs->trans( if ($_SESSION['allow_comments']) $allow_comments = 'checked'; if (isset($_POST['allow_comments'])) $allow_comments=GETPOST('allow_comments')?'checked':''; -print ' '.$langs->trans('CanComment').'
'."\n"; +print ' '.$langs->trans('CanComment').'
'."\n"; if ($_SESSION['allow_spy']) $allow_spy = 'checked'; if (isset($_POST['allow_spy'])) $allow_spy=GETPOST('allow_spy')?'checked':''; -print ' '.$langs->trans('CanSeeOthersVote').'
'."\n"; +print ' '.$langs->trans('CanSeeOthersVote').'
'."\n"; if (GETPOST('choix_sondage')) { diff --git a/htdocs/product/inventory/tpl/inventory.tpl.php b/htdocs/product/inventory/tpl/inventory.tpl.php index 05de0f4c002..c09328c3363 100644 --- a/htdocs/product/inventory/tpl/inventory.tpl.php +++ b/htdocs/product/inventory/tpl/inventory.tpl.php @@ -1,12 +1,12 @@ @@ -76,37 +76,37 @@ - + - +
- +
Cet inventaire est validé
- + - +
$row) { - + + foreach ($lines as $k=>$row) { + $total_pmp+=$row['pmp_stock']; $total_pa+=$row['pa_stock']; $total_pmp_actual+=$row['pmp_actual']; $total_pa_actual+=$row['pa_actual']; - + if($i%20 === 0) { _headerList($view); @@ -126,18 +126,18 @@ if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ echo ''; $total_current_pa+=$row['current_pa_stock']; - } - + } + ?> rights->stock->changePMP)) { - echo ''; + echo ''; } ?> @@ -145,8 +145,8 @@ if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ echo ''; $total_current_pa_actual+=$row['current_pa_actual']; - } - + } + ?> @@ -154,25 +154,25 @@ -
'.price($row['current_pa_stock']).'    - + '.$row['pmp_new'].''.$row['pmp_new'].''.price($row['current_pa_actual']).'
- + status != 1) { ?>
trans('Modify') ?> - rights->stock->changePMP)) { echo ''.$langs->trans('ApplyPMP').''; } - + if ($can_validate == 1) { ?> trans('RegulateStock') ?> @@ -193,13 +193,13 @@ trans('Delete') ?> - +

Date de création : getDate('datec') ?> -
Dernière mise à jour : getDate('tms') ?>

- +
Dernière mise à jour : getDate('tms') ?>

+ + - diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 3e3eb4c28a7..2ddc9f29464 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -38,13 +38,13 @@ class MouvementStock extends CommonObject * @var string Name of table without prefix where object is stored */ public $table_element = 'stock_mouvement'; - + public $product_id; public $warehouse_id; public $qty; public $type; - + public $tms = ''; public $datem = ''; public $price; @@ -54,8 +54,8 @@ class MouvementStock extends CommonObject public $origintype; public $inventorycode; public $batch; - - + + /** * Constructor @@ -67,7 +67,7 @@ class MouvementStock extends CommonObject $this->db = $db; } - + /** * Add a movement of stock (in one direction only) * @@ -173,7 +173,7 @@ class MouvementStock extends CommonObject { $tmparray=dol_getdate($eatby, true); $eatbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility + if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility { // If found and eatby/sellby defined into table and provided and differs, return error $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour')); @@ -201,7 +201,7 @@ class MouvementStock extends CommonObject $this->errors = $productlot->errors; $this->db->rollback(); return -5; - } + } } } if ($obj->sellby) @@ -241,7 +241,7 @@ class MouvementStock extends CommonObject } } } - + $i++; } } @@ -270,7 +270,7 @@ class MouvementStock extends CommonObject return -1; } } - + // Define if we must make the stock change (If product type is a service or if stock is used also for services) $movestock=0; if ($product->type != Product::TYPE_SERVICE || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1; @@ -297,7 +297,7 @@ class MouvementStock extends CommonObject $this->errors[] = $langs->trans('qtyToTranferLotIsNotEnough'); $this->db->rollback(); return -8; - } + } } else { @@ -310,8 +310,8 @@ class MouvementStock extends CommonObject return -8; } } - } - + } + if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after { if(!empty($this->origin)) { // This is set by caller for tracking reason @@ -467,7 +467,7 @@ class MouvementStock extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.", "; $sql.= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql.= " WHERE rowid = ".$fk_product; - + dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) @@ -476,7 +476,7 @@ class MouvementStock extends CommonObject $error = -4; } } - + // If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. $sql="DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; @@ -511,7 +511,7 @@ class MouvementStock extends CommonObject } } - + /** * Load object in memory from the database @@ -523,7 +523,7 @@ class MouvementStock extends CommonObject public function fetch($id) { dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.tms,"; @@ -548,20 +548,20 @@ class MouvementStock extends CommonObject //} else { $sql .= ' AND t.rowid = ' . $id; //} - + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); if ($numrows) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; - + $this->product_id = $obj->fk_product; $this->warehouse_id = $obj->fk_entrepot; $this->qty = $obj->value; $this->type = $obj->type_mouvement; - + $this->tms = $this->db->jdate($obj->tms); $this->datem = $this->db->jdate($obj->datem); $this->price = $obj->price; @@ -574,18 +574,18 @@ class MouvementStock extends CommonObject $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); } - + // Retrieve all extrafields for invoice // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals($this->id,$extralabels); - + // $this->fetch_lines(); - + $this->db->free($resql); - + if ($numrows) { return 1; } else { @@ -594,13 +594,13 @@ class MouvementStock extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - + return - 1; } } - - - + + + /** * Create movement in database for all subproducts @@ -675,7 +675,7 @@ class MouvementStock extends CommonObject function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='', $eatby='', $sellby='', $batch='', $id_product_batch=0) { global $conf; - + $skip_batch = empty($conf->productbatch->enabled); return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); @@ -756,7 +756,7 @@ class MouvementStock extends CommonObject /** * Create or update batch record (update table llx_product_batch). No check is done here, done by parent. * - * @param array|int $dluo Could be either + * @param array|int $dluo Could be either * - int if row id of product_batch table * - or complete array('fk_product_stock'=>, 'batchnumber'=>) * @param int $qty Quantity of product with batch number. May be a negative amount. @@ -765,13 +765,13 @@ class MouvementStock extends CommonObject private function createBatch($dluo, $qty) { global $user; - + $pdluo=new Productbatch($this->db); $result=0; // Try to find an existing record with same batch number or id - if (is_numeric($dluo)) + if (is_numeric($dluo)) { $result=$pdluo->fetch($dluo); if (empty($pdluo->id)) @@ -782,21 +782,21 @@ class MouvementStock extends CommonObject $result = -2; } } - else if (is_array($dluo)) + else if (is_array($dluo)) { - if (isset($dluo['fk_product_stock'])) + if (isset($dluo['fk_product_stock'])) { $vfk_product_stock=$dluo['fk_product_stock']; $vbatchnumber = $dluo['batchnumber']; - + $result = $pdluo->find($vfk_product_stock,'','',$vbatchnumber); // Search on batch number only (eatby and sellby are deprecated here) } - else + else { dol_syslog(get_class($this)."::createBatch array param dluo must contain at least key fk_product_stock".$error, LOG_ERR); $result = -1; } - } + } else { dol_syslog(get_class($this)."::createBatch error invalid param dluo".$error, LOG_ERR); @@ -810,7 +810,7 @@ class MouvementStock extends CommonObject { //print "Avant ".$pdluo->qty." Apres ".($pdluo->qty + $qty)."
"; $pdluo->qty += $qty; - if ($pdluo->qty == 0) + if ($pdluo->qty == 0) { $result=$pdluo->delete($user,1); } else { @@ -824,7 +824,7 @@ class MouvementStock extends CommonObject $pdluo->eatby = $veatby; $pdluo->sellby = $vsellby; $pdluo->batch = $vbatchnumber; - + $result=$pdluo->create($user,1); if ($result < 0) { @@ -833,21 +833,21 @@ class MouvementStock extends CommonObject } } } - + return $result; } /** * Return Url link of origin object - * + * * @param int $fk_origin Id origin * @param int $origintype Type origin * @return string */ - function get_origin($fk_origin, $origintype) + function get_origin($fk_origin, $origintype) { $origin=''; - + switch ($origintype) { case 'commande': require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -888,20 +888,20 @@ class MouvementStock extends CommonObject } if (empty($origin) || ! is_object($origin)) return ''; - + if ($origin->fetch($fk_origin) > 0) { return $origin->getNomUrl(1); } return ''; } - + /** * Set attribute origin to object - * + * * @param string $origin_element type of element * @param int $origin_id id of element - * + * * @return void */ function setOrigin($origin_element, $origin_id) @@ -940,7 +940,7 @@ class MouvementStock extends CommonObject // There is no specific properties. All data into insert are provided as method parameter. } - + /** * Return a link (with optionaly the picto) * Use this->id,this->lastname, this->firstname @@ -962,7 +962,7 @@ class MouvementStock extends CommonObject $label = '' . $langs->trans("Movement") . ' '.$this->id.''; $label.= '
'; $label.= '' . $langs->trans('Label') . ': ' . $this->label; - $label.= '
' . $langs->trans('Qty') . ': ' .$this->qty; + $label.= '
' . $langs->trans('Qty') . ': ' .$this->qty; $label.= '
'; $link = 'id . $linkend; return $result; } - + /** * Return label statut * @@ -989,7 +989,7 @@ class MouvementStock extends CommonObject { return $this->LibStatut($mode); } - + /** * Renvoi le libelle d'un status donne * diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 01df409361c..2963f5e278d 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -946,7 +946,6 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print '

'; print_titre($langs->trans('AddNewProductStockWarehouse')); - //print '
'; print '
'; print ''; diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index 2600fbd02fc..70ac20680b6 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -195,7 +195,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
pGroup
(optional) indicates whether this is a group task (parent) - Numeric; 0 = normal task, 1 = standard group task, 2 = combined group task*
pParent
(required) identifies a parent pID, this causes this task to be a child of identified task. Numeric, top level tasks should have pParent set to 0
pOpen
(required) indicates whether a standard group task is open when chart is first drawn. Value must be set for all items but is only used by standard group tasks. Numeric, 1 = open, 0 = closed
-
pDepend
(optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item
Each id can optionally be followed by a dependency type suffix. Valid values are:
'FS' - Finish to Start (default if suffix is omitted)
'SF' - Start to Finish
'SS' - Start to Start
'FF' - Finish to Finish
If present the suffix must be added directly to the id e.g. '123SS'
+
pDepend
(optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item
Each id can optionally be followed by a dependency type suffix. Valid values are:
'FS' - Finish to Start (default if suffix is omitted)
'SF' - Start to Finish
'SS' - Start to Start
'FF' - Finish to Finish
If present the suffix must be added directly to the id e.g. '123SS'
pCaption
(optional) caption that will be added after task bar if CaptionType set to "Caption"
pNotes
(optional) Detailed task information that will be displayed in tool tip for this task
pGantt
(required) javascript JSGantt.GanttChart object from which to take settings. Defaults to "g" for backwards compatibility
diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 9c89b516eff..550fa9a6898 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -238,13 +238,13 @@ else } } $morehtmlref.=''; - + dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); print '
'; - + print '
'; - + print ''; // Type @@ -315,7 +315,7 @@ else print '
'; print '
'; - + dol_fiche_end(); } } @@ -364,16 +364,16 @@ else $fichinter = new Fichinter($db); $fichinter->fetch($element_id, $element_ref); $fichinter->fetch_thirdparty(); - - if (is_object($fichinter)) + + if (is_object($fichinter)) { $head=fichinter_prepare_head($fichinter); dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"), -1, 'intervention'); // Intervention card $linkback = ''.$langs->trans("BackToList").''; - - + + $morehtmlref='
'; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -414,9 +414,9 @@ else } } $morehtmlref.='
'; - + dol_banner_tab($fichinter, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '&element='.$element, 0, '', '', 1); - + dol_fiche_end(); } } @@ -440,7 +440,7 @@ else { $element_prop = getElementProperties($resource_obj); - //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; + //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; $path = ''; if(strpos($resource_obj,'@')) From 087e22ab945211a85ce641025315d9861757c2e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 00:14:39 +0200 Subject: [PATCH 13/67] Fix bad status picto --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index fe36e0e02f4..a694891cc82 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1446,7 +1446,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= } // Status - $out.=''.$actionstatic->LibStatut($histo[$key]['percent'],3,1,$histo[$key]['datestart']).''; + $out.=''.$actionstatic->LibStatut($histo[$key]['percent'],3,0,$histo[$key]['datestart']).''; // Actions $out.=''; From f4de75afc39b19cd61136edfac2639814c21ee53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 00:49:00 +0200 Subject: [PATCH 14/67] FIX Position of signature on strato template --- .../contract/doc/pdf_strato.modules.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 646d00afe7b..d076456011c 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -397,7 +397,7 @@ class pdf_strato extends ModelePDFContract @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; } else @@ -465,17 +465,20 @@ class pdf_strato extends ModelePDFContract if (empty($hidebottom)) { - $pdf->SetXY(20,230); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); + $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); + $posy = $tab_top + $tab_height + 3 + 3; - $pdf->SetXY(20,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); - $pdf->SetXY(110,230); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); + $pdf->SetXY($this->marge_gauche, $posy + 5); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); - $pdf->SetXY(110,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY($posmiddle + 5, $posy); + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); + + $pdf->SetXY($posmiddle + 5, $posy + 5); + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); } } From b13dbf1f06fa194fa49b6af269e9d3998395f7e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 00:49:46 +0200 Subject: [PATCH 15/67] Clean code. Make selection of template working even if public. --- htdocs/comm/action/listactions.php | 34 +++--- htdocs/core/class/html.formmail.class.php | 14 +-- htdocs/core/lib/company.lib.php | 136 +++++++++++----------- htdocs/core/lib/functions.lib.php | 8 +- 4 files changed, 97 insertions(+), 95 deletions(-) diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index c77c4279439..78e73fe0717 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -371,6 +371,7 @@ if ($resql) print ''; print ''; + print ''; print ''; print ''; print ''; @@ -382,7 +383,6 @@ if ($resql) print ''; print ''; if (! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) print ''; - print ''; print ''; print $formactions->form_select_status_action('formaction',$status,1,'status',1,2); print ''; @@ -395,7 +395,8 @@ if ($resql) print ''; print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("ActionsOwnedByShort",$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder); print_liste_field_titre("DateStart",$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder); @@ -403,7 +404,6 @@ if ($resql) print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Contact",$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); if (! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) print_liste_field_titre("LinkedObject",$_SERVER["PHP_SELF"],"a.fk_element",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("ActionsOwnedByShort",$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre(""); print "\n"; @@ -437,13 +437,23 @@ if ($resql) print ''; - // Action (type) + // Ref print ''; print $actionstatic->getNomUrl(1,-1); print ''; - // Action (type) - print ''; + // User owner + print ''; + if ($obj->fk_user_action > 0) + { + $userstatic->fetch($obj->fk_user_action); + print $userstatic->getNomUrl(-1); + } + else print ' '; + print ''; + + // Label + print ''; print $actionstatic->label; print ''; @@ -482,7 +492,7 @@ if ($resql) print ''; // Third party - print ''; + print ''; if ($obj->socid) { $societestatic->id=$obj->socid; @@ -520,16 +530,6 @@ if ($resql) print ''; } - // User owner - print ''; - if ($obj->fk_user_action > 0) - { - $userstatic->fetch($obj->fk_user_action); - print $userstatic->getNomUrl(-1); - } - else print ' '; - print ''; - // Status/Percent $datep=$db->jdate($obj->datep); print ''.$actionstatic->LibStatut($obj->percent,3,0,$datep).''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 932cc211d12..8f86ec8cb60 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -296,7 +296,7 @@ class FormMail extends Form } $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); //var_dump($this->param["models"]); - //var_dump($arraydefaultmessage); + //var_dump($model_id); $out.= "\n".'
'."\n"; if ($this->withform == 1) @@ -835,11 +835,11 @@ class FormMail extends Form /** - * Return template of email - * Search into table c_email_templates + * Return templates of email with type = $type_template or type = 'all' + * This search into table c_email_templates. * * @param DoliDB $db Database handler - * @param string $type_template Get message for key module + * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object * @param int $id Id template to find @@ -852,9 +852,9 @@ class FormMail extends Form $sql = "SELECT label, topic, content, content_lines, lang"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE type_template='".$db->escape($type_template)."'"; + $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; - $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; + $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if (!empty($id)) $sql.= " AND rowid=".$id; @@ -873,7 +873,7 @@ class FormMail extends Form $ret['content_lines']=$obj->content_lines; $ret['lang']=$obj->lang; } - else + else // If there is no template at all { $defaultmessage=''; if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index fe36e0e02f4..159e7a6435a 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -618,7 +618,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin $projecttmp = new Project($db); $i=0; - $var=true; + while ($i < $num) { $obj = $db->fetch_object($result); @@ -629,7 +629,6 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin if ($user->rights->projet->lire && $userAccess > 0) { - $var = !$var; print ''; // Ref @@ -665,7 +664,6 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin } else { - $var = false; print ''.$langs->trans("None").''; } $db->free($result); @@ -712,6 +710,14 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.lastname"; + 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 + { + $search_status = ''; + $search_name = ''; + $search_addressphone = ''; + $search_array_options=array(); + } + $i=-1; $contactstatic = new Contact($db); @@ -741,29 +747,14 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''; print ''; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".''."\n"; $param="socid=".$object->id; if ($search_status != '') $param.='&search_status='.$search_status; if ($search_name != '') $param.='&search_name='.urlencode($search_name); - $colspan=9; - print ''; - print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Poste",$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder); - print_liste_field_titre( $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"p.statut","",$param,'',$sortfield,$sortorder); - // Add to agenda - if (! empty($conf->agenda->enabled) && ! empty($user->rights->agenda->myactions->create)) - { - $colspan++; - print_liste_field_titre(''); - } - // Edit - print_liste_field_titre(''); - print "\n"; - - $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.civility, p.poste, p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.email, p.skype, p.statut, p.photo,"; $sql .= " p.civility as civility_id, p.address, p.zip, p.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; @@ -778,43 +769,59 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $num = $db->num_rows($result); - $var=true; + $colspan=9; + + if ($num || (GETPOST('button_search','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search_x','alpha'))) + { + print ''; + + // Photo - Name + print ''; + + // Position + print ''; + + // Address - Phone - Email + print ''; + + // Status + print ''; + + // Add to agenda + if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + { + $colspan++; + print ''; + } + + // Action + print ''; + + print ""; + } + + print ''; + print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Poste",$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder); + print_liste_field_titre( $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"p.statut","",$param,'',$sortfield,$sortorder); + // Add to agenda + if (! empty($conf->agenda->enabled) && ! empty($user->rights->agenda->myactions->create)) print_liste_field_titre(''); + // Edit + print_liste_field_titre(''); + print "\n"; + if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) { - print ''; - - // Photo - Name - print ''; - - // Position - print ''; - - // Address - Phone - Email - print ''; - - // Status - print ''; - - // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - { - $colspan++; - print ''; - } - - // Edit - print ''; - - print ""; - - $i=0; + $i=0; while ($i < $num) { @@ -890,11 +897,12 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') } else { - print ""; + print ''; print ''; print "\n"; } print "\n
'; + print ''; + print ''; + print ''; + print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0,1),'1'=>$contactstatic->LibStatut(1,1)),$search_status); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; - print ''; - print ''; - print ' '; - print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0,1),'1'=>$contactstatic->LibStatut(1,1)),$search_status); - print ' '; - print ''; - print '
'.$langs->trans("None").'
\n"; + print '
'; print ''."\n"; @@ -943,12 +951,8 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='') if ($num > 0) { - $var=true; - foreach ($addressstatic->lines as $address) { - $var = !$var; - print ''; print ''; @@ -1115,7 +1119,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= { $i = 0 ; $num = $db->num_rows($resql); - $var=true; + while ($i < $num) { $obj = $db->fetch_object($resql); @@ -1162,7 +1166,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= } } - // Add also event from emailings. FIXME This should be replaced by an automatic event + // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. if (! empty($conf->mailing->enabled) && ! empty($objcon->email)) { $langs->load("mails"); @@ -1183,7 +1187,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= { $i = 0 ; $num = $db->num_rows($resql); - $var=true; + while ($i < $num) { $obj = $db->fetch_object($resql); @@ -1304,7 +1308,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo - $out.=""; + $out.=''; // Done or todo if ($donetodo) @@ -1446,7 +1450,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= } // Status - $out.=''.$actionstatic->LibStatut($histo[$key]['percent'],3,1,$histo[$key]['datestart']).''; + $out.=''.$actionstatic->LibStatut($histo[$key]['percent'],3,0,$histo[$key]['datestart']).''; // Actions $out.=''; @@ -1503,12 +1507,10 @@ function show_subsidiaries($conf,$langs,$db,$object) print ""; $i=0; - $var=true; while ($i < $num) { $obj = $db->fetch_object($result); - $var = !$var; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f24cf0338c5..b712e5059b3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3414,13 +3414,13 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m if ($field1 != $sortfield1) // We are on another field { - if (preg_match('/^DESC/', $sortorder)) $out.= ''; - else $out.= ''; + if (preg_match('/^DESC/', $sortorder)) $out.= ''; + else $out.= ''; } else // We are of first sorting criteria { - if (preg_match('/^ASC/', $sortorder)) $out.= ''; - else $out.= ''; + if (preg_match('/^ASC/', $sortorder)) $out.= ''; + else $out.= ''; } } From bb6b3db0ac8016e47ee1a104e3b8d952349c8a91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 00:49:00 +0200 Subject: [PATCH 16/67] FIX Position of signature on strato template Conflicts: htdocs/core/modules/contract/doc/pdf_strato.modules.php --- .../contract/doc/pdf_strato.modules.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index c06882fa121..77904beac0b 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -463,17 +463,20 @@ class pdf_strato extends ModelePDFContract if (empty($hidebottom)) { - $pdf->SetXY(20,230); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); + $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); + $posy = $tab_top + $tab_height + 3 + 3; - $pdf->SetXY(20,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); - $pdf->SetXY(110,230); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); + $pdf->SetXY($this->marge_gauche, $posy + 5); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); - $pdf->SetXY(110,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY($posmiddle + 5, $posy); + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); + + $pdf->SetXY($posmiddle + 5, $posy + 5); + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); } } From a4086b52ef6882105f3f90e9f87624cd8b0e4533 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 01:34:15 +0200 Subject: [PATCH 17/67] NEW Can send email from contract card --- htdocs/contrat/card.php | 116 ++++++++++-------- htdocs/core/actions_sendmails.inc.php | 2 +- htdocs/core/class/events.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 +- ...terface_50_modAgenda_ActionsAuto.class.php | 21 +++- .../mysql/data/llx_c_action_trigger.sql | 1 + .../install/mysql/migration/6.0.0-7.0.0.sql | 3 + .../install/mysql/tables/llx_actioncomm.sql | 18 +-- htdocs/langs/en_US/agenda.lang | 1 + 9 files changed, 100 insertions(+), 68 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5b109c7b0d7..7af70e10337 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -965,6 +965,7 @@ if (empty($reshook)) $trackid='cont'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') @@ -2052,62 +2053,73 @@ else $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if ($object->statut == 0 && $nbofservices) + if (empty($reshook)) { - if ($user->rights->contrat->creer) print ''; - else print ''; - } - if ($object->statut == 1) - { - if ($user->rights->contrat->creer) print ''; - else print ''; - } + // Send + if ($object->statut == 1) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { + print ''; + } else + print ''; + } - if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) - { - $langs->load("bills"); - if ($user->rights->facture->creer) print ''; - else print ''; - } + if ($object->statut == 0 && $nbofservices) + { + if ($user->rights->contrat->creer) print ''; + else print ''; + } + if ($object->statut == 1) + { + if ($user->rights->contrat->creer) print ''; + else print ''; + } - if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) - { - $langs->load("orders"); - if ($user->rights->commande->creer) print ''; - else print ''; - } + if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + { + $langs->load("bills"); + if ($user->rights->facture->creer) print ''; + else print ''; + } - // Clone - if ($user->rights->contrat->creer) { - print ''; - } + if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + { + $langs->load("orders"); + if ($user->rights->commande->creer) print ''; + else print ''; + } - if ($object->nbofservicesclosed > 0) - { - print ''; - } - if ($object->nbofservicesclosed < $nbofservices) - { - //if (! $numactive) - //{ - print ''; - //} - //else - //{ - // print ''; - //} - } + // Clone + if ($user->rights->contrat->creer) { + print ''; + } - // On peut supprimer entite si - // - Droit de creer + mode brouillon (erreur creation) - // - Droit de supprimer - if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) - { - print ''; - } - else - { - print ''; + if ($object->nbofservicesclosed > 0) + { + print ''; + } + if ($object->nbofservicesclosed < $nbofservices) + { + //if (! $numactive) + //{ + print ''; + //} + //else + //{ + // print ''; + //} + } + + // On peut supprimer entite si + // - Droit de creer + mode brouillon (erreur creation) + // - Droit de supprimer + if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) + { + print ''; + } + else + { + print ''; + } } print ""; @@ -2193,7 +2205,7 @@ else print '
'; print '
'; print '
'; - print load_fiche_titre($langs->trans('SendContractByMail')); + print load_fiche_titre($langs->trans('SendByMail')); dol_fiche_head(''); @@ -2207,7 +2219,7 @@ else $formmail->fromid = $user->id; } - $formmail->trackid='ord'.$object->id; + $formmail->trackid='cont'.$object->id; if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index a16e0437952..a1cd0eb39ec 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -424,7 +424,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); - if ($result < 0) { + if ($result < 0) { $error++; $errors=$interface->errors; } } diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 5a88956e5bc..abdbb1689f8 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -48,7 +48,7 @@ class Events // extends CommonObject var $dateevent; var $description; - // List of all events supported by triggers + // List of all Audit/Security events supported by triggers var $eventstolog=array( array('id'=>'USER_LOGIN', 'test'=>1), array('id'=>'USER_LOGIN_FAILED', 'test'=>1), diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 8f86ec8cb60..9079f98ad3b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -330,7 +330,7 @@ class FormMail extends Form if (count($modelmail_array)>0) { $out.= '
'."\n"; - $out.= $langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); + $out.= ''.$langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); $out.= '   '; $out.= ''; @@ -499,7 +499,7 @@ class FormMail extends Form { $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoselected=GETPOST("receiver"); // Array of selected value + $withtoselected=GETPOST("receiver",'none'); // Array of selected value if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') { $withtoselected = array_keys($tmparray); diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 4e09fef4d43..0f9826ea0e0 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -1,10 +1,10 @@ +/* Copyright (C) 2005-2017 Laurent Destailleur * Copyright (C) 2009-2011 Regis Houssin * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2013 Cedric GROSS - * Copyright (C) 2014 Marcos García - * Copyright (C) 2015 Bahfir Abbes + * 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 @@ -111,6 +111,21 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } + elseif ($action == 'CONTRACT_SENTBYMAIL') + { + $langs->load("agenda"); + $langs->load("other"); + $langs->load("contract"); + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref); + if (empty($object->actionmsg)) + { + $object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref); + } + + // Parameters $object->sendtoid defined by caller + //$object->sendtoid=0; + } elseif ($action == 'PROPAL_VALIDATE') { $langs->load("agenda"); diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index d25963e8c3a..94202f6570f 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -65,6 +65,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier',17); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_CANCELED','Supplier invoice cancelled','Executed when a supplier invoice is cancelled','invoice_supplier',17); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_SENTBYMAIL','Contract sent by mail','Executed when a contract is sent by mail','contrat',18); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 0f32f1c731b..5af427242f4 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -245,6 +245,8 @@ ALTER TABLE llx_extrafields MODIFY COLUMN langs varchar(64); ALTER TABLE llx_holiday_config MODIFY COLUMN name varchar(128); ALTER TABLE llx_holiday_config ADD UNIQUE INDEX idx_holiday_config (name); +ALTER TABLE llx_actioncomm MODIFY COLUMN label varchar(255) NOT NULL; + ALTER TABLE llx_payment_various ADD COLUMN fk_projet integer DEFAULT NULL after accountancy_code; UPDATE llx_const set name = 'ONLINE_PAYMENT_MESSAGE_OK' where name = 'PAYPAL_MESSAGE_OK'; @@ -259,6 +261,7 @@ UPDATE llx_accounting_account SET pcg_type = 'EXPENSE' where pcg_type = 'CHARGE' UPDATE llx_accounting_account SET pcg_type = 'INCOME' where pcg_type = 'VENTAS_E_INGRESOS'; UPDATE llx_accounting_account SET pcg_type = 'EXPENSE' where pcg_type = 'COMPRAS_GASTOS'; +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_SENTBYMAIL','Contract sent by mail','Executed when a contract is sent by mail','contrat',18); CREATE TABLE llx_projet_task_comment ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index dc5c50c288f..fdde835ad51 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -52,17 +52,17 @@ create table llx_actioncomm location varchar(128), durationp real, -- planed duration - label varchar(256) NOT NULL, -- label/title of event or topic of email + label varchar(255) NOT NULL, -- label/title of event or topic of email note text, -- note of event or content of email - email_subject varchar(256), -- when event was an email, we store here the subject. content is stored into note. - email_msgid varchar(256), -- when event was an email, we store here the msgid - email_from varchar(256), -- when event was an email, we store here the from - email_sender varchar(256), -- when event was an email, we store here the sender - email_to varchar(256), -- when event was an email, we store here the email_to - email_tocc varchar(256), -- when event was an email, we store here the email_tocc - email_tobcc varchar(256), -- when event was an email, we store here the email_tobcc - errors_to varchar(256), -- when event was an email, we store here the erros_to + email_subject varchar(255), -- when event was an email, we store here the subject. content is stored into note. + email_msgid varchar(255), -- when event was an email, we store here the msgid + email_from varchar(255), -- when event was an email, we store here the from + email_sender varchar(255), -- when event was an email, we store here the sender + email_to varchar(255), -- when event was an email, we store here the email_to + email_tocc varchar(255), -- when event was an email, we store here the email_tocc + email_tobcc varchar(255), -- when event was an email, we store here the email_tobcc + errors_to varchar(255), -- when event was an email, we store here the erros_to recurid varchar(128), -- used to store event id to link each other all the repeating event record recurrule varchar(128), -- contains string with ical format recurring rule like 'FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=19' or 'FREQ=WEEKLY;BYDAY=MO' diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 25449981587..f88fc541b13 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -66,6 +66,7 @@ OrderApprovedInDolibarr=Order %s approved OrderRefusedInDolibarr=Order %s refused OrderBackToDraftInDolibarr=Order %s go back to draft status ProposalSentByEMail=Commercial proposal %s sent by EMail +ContractSentByEMail=Contract %s sent by EMail OrderSentByEMail=Customer order %s sent by EMail InvoiceSentByEMail=Customer invoice %s sent by EMail SupplierOrderSentByEMail=Supplier order %s sent by EMail From 5e4b500b5d48266fb520b8b5e7dfe850b1031176 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 02:22:55 +0200 Subject: [PATCH 18/67] Fix signature was changed during insert --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f18827bdd67..2b6cbb22e92 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -351,7 +351,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO '__EMAIL__' => $sendto, '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', '__REF__' => (is_object($object)?$object->ref:''), - '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'') + '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'') /* not available on all object /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''), '__LASTNAME__'=>(is_object($object)?$object->lastname:''), From 961d475a9d72655b780169f3183cce269128f226 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 03:13:44 +0200 Subject: [PATCH 19/67] More complete substitution system. Add __CONTRACT_NEXT_EXPIRATION_DATE__ and __CONTRACT_NEXT_EXPIRATION_DATETIME__ --- htdocs/contrat/card.php | 16 ++++-- htdocs/core/actions_massactions.inc.php | 38 +++++-------- htdocs/core/actions_sendmails.inc.php | 36 +++++++------ htdocs/core/class/html.formmail.class.php | 58 ++++++++++---------- htdocs/core/lib/functions.lib.php | 65 +++++++++++++++++------ htdocs/societe/card.php | 9 ++-- 6 files changed, 131 insertions(+), 91 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7af70e10337..0e8722d20b8 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2241,9 +2241,19 @@ else $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; - // Tableau des substitutions + // Array of substitutions + $formmail->withsubstit='AvailableVariables'; $formmail->setSubstitFromObject($object); - $formmail->substit ['__CONTRACTREF__'] = $object->ref; + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->statut != 4) continue; + if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue; + } + $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); + $formmail->substit['__PERSONALIZED__']=''; + $formmail->substit['__CONTACTCIVNAME__']=''; $custcontact = ''; $contactarr = array(); @@ -2255,7 +2265,7 @@ else { if ($contact['libelle'] == $langs->trans('TypeContact_contract_external_CUSTOMER')) { // TODO Use code and not label $contactstatic = new Contact($db); - $contactstatic->fetch($contact ['id']); + $contactstatic->fetch($contact['id']); $custcontact = $contactstatic->getFullName($langs, 1); } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 6750aa5de38..26b5cbe3460 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -275,28 +275,18 @@ if (! $error && $massaction == 'confirm_presend') if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO); if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO); + $objecttmp=new $objectclass($db); + $objecttmp->thirdparty = $thirdparty; - $substitutionarray=array( - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__ID__' => join(', ',array_keys($listofqualifiedid)), - '__EMAIL__' => $thirdparty->email, - '__CHECK_READ__' => '', - '__FACREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__ORDERREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__PROPREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__REF__' => join(', ',$listofqualifiedref), - '__REFCLIENT__' => $thirdparty->name, - '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'') - /* not available on all object - /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''), - '__LASTNAME__'=>(is_object($object)?$object->lastname:''), - '__FULLNAME__'=>(is_object($object)?$object->getFullName($langs):''), - '__ADDRESS__'=>(is_object($object)?$object->address:''), - '__ZIP__'=>(is_object($object)?$object->zip:''), - '__TOWN_'=>(is_object($object)?$object->town:''), - '__COUNTRY__'=>(is_object($object)?$object->country:''), - */ - ); + // Make substitution in email content + $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); + $substitutionarray['__ID__'] = join(', ',array_keys($listofqualifiedid)); + $substitutionarray['__EMAIL__'] = $thirdparty->email; + $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__REF__'] = join(', ',$listofqualifiedref); + + $parameters=array('mode'=>'formemail'); + complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); $subject=make_substitutions($subject, $substitutionarray); $message=make_substitutions($message, $substitutionarray); @@ -458,15 +448,15 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se $outputlangs->setDefaultLang($newlang); } - if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) + if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { // Create output dir if not exists dol_mkdir($diroutputmassaction); - + // Defined name of merged file $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); $filename=preg_replace('/\s/','_',$filename); - + // Save merged file if ($filter=='paye:0') { diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index a1cd0eb39ec..4986a093bac 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -344,23 +344,25 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } - $substitutionarray=array( - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__ID__' => (is_object($object)?$object->id:''), - '__EMAIL__' => $sendto, - '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', - '__REF__' => (is_object($object)?$object->ref:''), - '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'') - /* not available on all object - /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''), - '__LASTNAME__'=>(is_object($object)?$object->lastname:''), - '__FULLNAME__'=>(is_object($object)?$object->getFullName($langs):''), - '__ADDRESS__'=>(is_object($object)?$object->address:''), - '__ZIP__'=>(is_object($object)?$object->zip:''), - '__TOWN_'=>(is_object($object)?$object->town:''), - '__COUNTRY__'=>(is_object($object)?$object->country:''), - */ - ); + // Make substitution in email content + $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); + $substitutionarray['__EMAIL__'] = $sendto; + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'':''; + // Add specific substitution for contracts + if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) + { + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->statut != 4) continue; + if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue; + } + $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); + } + + $parameters=array('mode'=>'formemail'); + complete_substitutions_array($substitutionarray, $langs, $object, $parameters); $subject=make_substitutions($subject, $substitutionarray); $message=make_substitutions($message, $substitutionarray); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 9079f98ad3b..9bfe00e6575 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -359,13 +359,14 @@ class FormMail extends Form // Substitution array if (! empty($this->withsubstit)) { - $out.= ''; + $out.= ''; $help=""; foreach($this->substit as $key => $val) { - $help.=$key.' -> '.$langs->trans($val).'
'; + $help.=$key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'
'; } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help); + if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage + else $out.= $form->textwithpicto($langs->trans($this->withsubstit), $help, 1, 'help', '', 0, 2, 'substittooltip'); // New usage $out.= "\n"; } @@ -997,17 +998,19 @@ class FormMail extends Form /** - * Set substit array from object + * Set substit array from object. This is call when suggesting the email template into forms to send email. + * TODO Replace with getCommonSubstitutionArray with param onlykey = 2 * - * @param CommonObject $object Object to use - * @param Translate $outputlangs Object lang + * @param CommonObject $object Object to use + * @param Translate $outputlangs Object lang * @return void + * @see getCommonSubstitutionArray */ function setSubstitFromObject($object, $outputlangs=null) { global $conf, $user; $this->substit['__REF__'] = $object->ref; - $this->substit['__REFCLIENT__'] = isset($object->ref_client) ? $object->ref_client : ''; + $this->substit['__REFCLIENT__'] = isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : ''); $this->substit['__REFSUPPLIER__'] = isset($object->ref_supplier) ? $object->ref_supplier : ''; $this->substit['__DATE_YMD__'] = isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : ''; @@ -1027,7 +1030,7 @@ class FormMail extends Form $this->substit['__PERSONALIZED__'] = ''; $this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending - // Create dinamic tags for __EXTRAFIELD_FIELD__ + // Create dynamic tags for __EXTRAFIELD_FIELD__ $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals($object->id, $extralabels); @@ -1035,7 +1038,7 @@ class FormMail extends Form $this->substit['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; } - //Fill substit_lines with each object lines content + // Fill substit_lines with each object lines content if (is_array($object->lines)) { foreach ($object->lines as $line) @@ -1073,13 +1076,14 @@ class FormMail extends Form } /** - * Get list of substition keys available for emails. - * This include the complete_substitutions_array. TODO Include the getCommonSubstitutionArray(). + * Get list of substitution keys available for emails. + * This include the complete_substitutions_array. * * @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ... + * @param Object $object Object if applicable * @return array Array of substitution values for emails. */ - static function getAvailableSubstitKey($mode='formemail') + static function getAvailableSubstitKey($mode='formemail', $object=null) { global $conf, $langs; @@ -1088,20 +1092,20 @@ class FormMail extends Form if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { $vars=array( - '__REF__', - '__REFCLIENT__', - '__REFSUPPLIER__', - '__THIRDPARTY_ID__', - '__THIRDPARTY_NAME__', - '__PROJECT_ID__', - '__PROJECT_REF__', - '__PROJECT_NAME__', - '__CONTACTCIVNAME__', - '__AMOUNT__', - '__AMOUNT_WO_TAX__', - '__AMOUNT_VAT__', - '__PERSONALIZED__', // Paypal link will be added here in form mode - '__SIGNATURE__', + '__REF__'=>'__REF__', + '__REFCLIENT__'=>'__REFCLIENT__', + '__REFSUPPLIER__'=>'__REFSUPPLIER__', + '__THIRDPARTY_ID__'=>'__THIRDPARTY_ID__', + '__THIRDPARTY_NAME__'=>'__THIRDPARTY_NAME__', + '__PROJECT_ID__'=>'__PROJECT_ID__', + '__PROJECT_REF__'=>'__PROJECT_REF__', + '__PROJECT_NAME__'=>'__PROJECT_NAME__', + '__CONTACTCIVNAME__'=>'__CONTACTCIVNAME__', + '__AMOUNT__'=>'__AMOUNT__', + '__AMOUNT_WO_TAX__'=>'__AMOUNT_WO_TAX__', + '__AMOUNT_VAT__'=>'__AMOUNT_VAT__', + '__PERSONALIZED__'=>'__PERSONALIZED__', // Paypal link will be added here in form mode + '__SIGNATURE__'=>'__SIGNATURE__', ); if ($mode == 'formwithlines') { @@ -1179,7 +1183,7 @@ class FormMail extends Form } $parameters=array('mode'=>$mode); - $tmparray=getCommonSubstitutionArray($langs); + $tmparray=getCommonSubstitutionArray($langs, 0, null, $object); complete_substitutions_array($tmparray, $langs, null, $parameters); foreach($tmparray as $key => $val) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b712e5059b3..79d982371b7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5186,25 +5186,32 @@ function dol_concatdesc($text1,$text2,$forxml=false) /** - * Return array of possible common substitutions. + * Return array of possible common substitutions. This includes several families like: 'system', 'mycompany', 'object', 'objectamount', 'date', 'user' * * @param Translate $outputlangs Output language - * @param int $onlykey Do not calculate heavy values of keys (performance enhancement when we need only the keys) - * @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'objectamount', 'date', 'user', ...) + * @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are trunc and html sanitized (to use for help tooltip) + * @param array $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...) * @param Object $object Object for keys on object * @return array Array of substitutions + * @see setSubstitFromObject */ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null) { - global $conf, $mysoc, $user; + global $db, $conf, $mysoc, $user; $substitutionarray=array(); + if (empty($exclude) || ! in_array('system', $exclude)) + { + $substitutionarray=array_merge($substitutionarray, array( + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT + )); + } if (empty($exclude) || ! in_array('mycompany', $exclude)) { $substitutionarray=array_merge($substitutionarray, array( - '__MYCOMPANY_NAME__' => $mysoc->name, - '__MYCOMPANY_EMAIL__' => $mysoc->email, + '__MYCOMPANY_NAME__' => $mysoc->name, + '__MYCOMPANY_EMAIL__' => $mysoc->email, '__MYCOMPANY_PROFID1__' => $mysoc->idprof1, '__MYCOMPANY_PROFID2__' => $mysoc->idprof2, '__MYCOMPANY_PROFID3__' => $mysoc->idprof3, @@ -5215,17 +5222,42 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id )); } + if (is_object($object) && (empty($exclude) || ! in_array('object', $exclude))) + { + $substitutionarray['__ID__'] = $object->id; + $substitutionarray['__REF__'] = $object->ref; + $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '')); + $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : ''); + + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + + $substitutionarray['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:''); + $substitutionarray['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); + $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); + + // Create dynamic tags for __EXTRAFIELD_FIELD__ + if ($object->table_element && $object->id > 0) + { + $extrafieldstmp = new ExtraFields($db); + $extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); + $object->fetch_optionals($object->id, $extralabels); + foreach ($extrafieldstmp->attribute_label as $key => $label) { + $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; + } + } + } if (empty($exclude) || ! in_array('objectamount', $exclude)) { - if (is_object($object)) // For backward compatibility - { - $substitutionarray['__TOTAL_TTC__'] =is_object($object)?$object->total_ttc:''; - $substitutionarray['__TOTAL_HT__'] =is_object($object)?$object->total_ht:''; - $substitutionarray['__TOTAL_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; - } - $substitutionarray['__AMOUNT__'] =is_object($object)?$object->total_ttc:''; - $substitutionarray['__AMOUNT_WO_TAX__']=is_object($object)?$object->total_ht:''; - $substitutionarray['__AMOUNT_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '') : ''; + $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '') : ''; + $substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:''; + $substitutionarray['__AMOUNT_WO_TAX__']= is_object($object)?$object->total_ht:''; + $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + // For backward compatibility + $substitutionarray['__TOTAL_TTC__'] = is_object($object)?$object->total_ttc:''; + $substitutionarray['__TOTAL_HT__'] = is_object($object)?$object->total_ht:''; + $substitutionarray['__TOTAL_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; } if (empty($exclude) || ! in_array('date', $exclude)) @@ -5265,7 +5297,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob '__USER_LASTNAME__' => $user->lastname, '__USER_FIRSTNAME__' => $user->firstname, '__USER_FULLNAME__' => $user->getFullName($outputlangs), - '__USER_SUPERVISOR_ID__' => $user->fk_user + '__USER_SUPERVISOR_ID__' => $user->fk_user, + '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($user->signature), 30) : $user->signature) : '') )); } if (! empty($conf->multicompany->enabled)) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 45101a79d45..7b4bae14a14 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2484,10 +2484,11 @@ else $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; - // Tableau des substitutions - //$formmail->setSubstitFromObject($object); - $formmail->substit['__THIRDPARTY_NAME__']=$object->name; - $formmail->substit['__SIGNATURE__']=$user->signature; + // Array of substitutions + $formmail->withsubstit='AvailableVariables'; + $formmail->setSubstitFromObject($object); + $formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one + $formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; From a6b600c8a1c37d12e0e4ae5e2f2c171a75c10fb4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 03:54:23 +0200 Subject: [PATCH 20/67] Fix regression in unit tests --- htdocs/api/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 5d8763c7bfe..2730c6c0242 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -37,9 +37,9 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not lo if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -$DOLAPIENTITY = $_SERVER['HTTP_DOLAPIENTITY']; -$entity=(! empty($DOLAPIENTITY) ? (int) $DOLAPIENTITY : (! empty($DOLAPIENTITY) ? (int) $DOLAPIENTITY : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); +// Force entity if a value provided int HTTP header. Otherwise, will use the entity of user of token used. +if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']); + $res=0; if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php'; From c2e1e2491d3ebeff0fa77dca79a2f5729bf5865e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 16 Sep 2017 06:53:29 +0200 Subject: [PATCH 21/67] Accountancy - Finish moving admin to specific menu & some cleaning --- htdocs/accountancy/admin/export.php | 23 +---- htdocs/accountancy/admin/index.php | 19 +--- htdocs/core/lib/accounting.lib.php | 36 +------- htdocs/core/menus/init_menu_auguria.sql | 21 +++-- htdocs/core/menus/standard/eldy.lib.php | 61 +++---------- htdocs/core/modules/modAccounting.class.php | 91 ++++--------------- .../install/mysql/migration/6.0.0-7.0.0.sql | 13 +++ 7 files changed, 62 insertions(+), 202 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 433448fa688..9a8a659db99 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -37,10 +37,10 @@ $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); -// Security check -if (empty($user->admin) && empty($user->rights->accounting->chartofaccount)) +// Security access +if (empty($user->rights->accounting->chartofaccount)) { - accessforbidden(); + accessforbidden(); } $action = GETPOST('action', 'alpha'); @@ -53,13 +53,6 @@ $main_option = array ( $model_option = array ( 'ACCOUNTING_EXPORT_SEPARATORCSV', 'ACCOUNTING_EXPORT_DATE' - /* - 'ACCOUNTING_EXPORT_PIECE', - 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT', - 'ACCOUNTING_EXPORT_LABEL', - 'ACCOUNTING_EXPORT_AMOUNT', - 'ACCOUNTING_EXPORT_DEVISE' - */ ); /* @@ -121,17 +114,13 @@ llxHeader(); $form = new Form($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +// $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); -$head = admin_accounting_prepare_head(); - print '
'; print ''; print ''; -dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron'); - $var = true; /* @@ -245,8 +234,6 @@ if ($num2) { print "\n"; } -dol_fiche_end(); - print '
'; print '
'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b6aceb52ad4..bc078c062c6 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -37,10 +37,9 @@ $langs->load("compta"); $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); -$langs->load("salaries"); -// Security check -if (empty($user->admin)) +// Security access +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -160,18 +159,13 @@ llxHeader(); $form = new Form($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +//$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); -$head = admin_accounting_prepare_head($accounting); - print '
'; print ''; print ''; -dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron'); - - // Default mode for calculating turnover (parameter ACCOUNTING_MODE) print ''; @@ -287,18 +281,11 @@ foreach ($list as $key) print '
'; - - - -dol_fiche_end(); - print '
'; print '
'; print '
'; -print '
'.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'
'; - print '
'; print '
'; diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 0fccf6ccd9a..b0b6dc6855c 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -23,40 +23,6 @@ * \brief Library of accountancy functions */ -/** - * Prepare array with list of admin tabs - * - * @param AccountingAccount $object Object instance we show card - * @return array Array of tabs to show - */ -function admin_accounting_prepare_head(AccountingAccount $object=null) -{ - global $langs, $conf; - - $h = 0; - $head = array (); - - $head[$h][0] = dol_buildpath('/accountancy/admin/index.php', 1); - $head[$h][1] = $langs->trans("Miscellaneous"); - $head[$h][2] = 'general'; - $h ++; - - $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/export.php'; - $head[$h][1] = $langs->trans("ExportOptions"); - $head[$h][2] = 'export'; - $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); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin'); - - complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin', 'remove'); - - return $head; -} - /** * Prepare array with list of tabs * diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 47ec0741127..917cfd74891 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -217,18 +217,21 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2453__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_general', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'General', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 41, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuBankAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 52, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuBankAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 51, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 80, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2463__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 90, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/admin/dict.php?id=10&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 52, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 53, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 54, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2463__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 55, __ENTITY__); + + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2464__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_export', 2451__+MAX_llx_menu__, '/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ExportOptions', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); -- Accounting period insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__); -- Binding diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 45ac75d5e40..becd3d35905 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -969,37 +969,30 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Chart of account $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 10); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 20); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 30); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 31); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 20); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 30); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 40); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); if (! empty($conf->banque->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuBankAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 42); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/compta/bank/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuBankAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51); } if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52); } if (! empty($conf->tax->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53); } if (! empty($conf->expensereport->enabled)) { - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54); } - /* not required yet, already supported by default account - if (! empty($conf->loan->enabled)) - { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/loan.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuLoanAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_loan', 45); - } - if (! empty($conf->don->enabled)) - { - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47); - }*/ - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60); // Fiscal year if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods. @@ -1083,36 +1076,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } else dol_print_error($db); $db->free($resql); - - /* - $sql = "SELECT rowid, label, accountancy_journal"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND clos = 0"; - $sql.= " ORDER BY label"; - - $resql = $db->query($sql); - if ($resql) - { - $numr = $db->num_rows($resql); - $i = 0; - - if ($numr > 0) - while ($i < $numr) - { - $objp = $db->fetch_object($resql); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/bankjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_account='.$objp->rowid,$langs->trans("Journal").' - '.dol_trunc($objp->label,10),2,$user->rights->accounting->comptarapport->lire); - $i++; - } - } - else dol_print_error($db); - $db->free($resql); - - // Add other journal - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/sellsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/purchasesjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/expensereportsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("ExpenseReportsJournal"),2,$user->rights->accounting->comptarapport->lire); - */ } // General Ledger diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 496d054d86c..3f8a7c092b8 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -35,12 +35,12 @@ class modAccounting extends DolibarrModules * Constructor. Define names, constants, directories, boxes, permissions * * @param DoliDB $db Database handler - */ + */ function __construct($db) { global $conf; - $this->db = $db; + $this->db = $db; $this->numero = 50400; $this->family = "financial"; @@ -60,7 +60,7 @@ class modAccounting extends DolibarrModules $this->dirs = array('/accounting/temp'); // Config pages - $this->config_page_url = array('index.php@accountancy'); + $this->config_page_url = array(); // Dependencies $this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled @@ -84,116 +84,57 @@ class modAccounting extends DolibarrModules "1", "With this constants on, bank account number is always required" ); - $this->const[1] = array( - "ACCOUNTING_EXPORT_SEPARATORCSV", - "string", - "," - ); - $this->const[2] = array( + $this->const[3] = array( "ACCOUNTING_ACCOUNT_SUSPENSE", "chaine", "471" ); - $this->const[3] = array( - "ACCOUNTING_SELL_JOURNAL", - "chaine", - "VTE" - ); $this->const[4] = array( - "ACCOUNTING_PURCHASE_JOURNAL", - "chaine", - "ACH" - ); - $this->const[5] = array( - "ACCOUNTING_SOCIAL_JOURNAL", - "chaine", - "SOC" - ); - $this->const[6] = array( - "ACCOUNTING_MISCELLANEOUS_JOURNAL", - "chaine", - "OD" - ); - $this->const[7] = array( "ACCOUNTING_ACCOUNT_TRANSFER_CASH", "chaine", "58" ); - $this->const[8] = array( + $this->const[5] = array( "CHARTOFACCOUNTS", "chaine", "2" ); - $this->const[9] = array( + $this->const[6] = array( "ACCOUNTING_EXPORT_MODELCSV", "chaine", "1" ); - $this->const[10] = array( + $this->const[7] = array( "ACCOUNTING_LENGTH_GACCOUNT", "chaine", "" ); - $this->const[11] = array( + $this->const[8] = array( "ACCOUNTING_LENGTH_AACCOUNT", "chaine", "" ); - $this->const[13] = array( + $this->const[9] = array( "ACCOUNTING_LIST_SORT_VENTILATION_TODO", "yesno", "1" ); - $this->const[14] = array( + $this->const[10] = array( "ACCOUNTING_LIST_SORT_VENTILATION_DONE", "yesno", "1" ); - /* - $this->const[15] = array ( - "ACCOUNTING_GROUPBYACCOUNT", - "yesno", - "1" - ); - */ - $this->const[16] = array ( + $this->const[11] = array ( "ACCOUNTING_EXPORT_DATE", "chaine", "%d%m%Y" ); - /* - $this->const[17] = array ( - "ACCOUNTING_EXPORT_PIECE", - "yesno", - "1" + $this->const[12] = array( + "ACCOUNTING_EXPORT_SEPARATORCSV", + "string", + "," ); - $this->const[18] = array ( - "ACCOUNTING_EXPORT_GLOBAL_ACCOUNT", - "yesno", - "1" - ); - $this->const[19] = array ( - "ACCOUNTING_EXPORT_LABEL", - "yesno", - "1" - ); - $this->const[20] = array ( - "ACCOUNTING_EXPORT_AMOUNT", - "yesno", - "1" - ); - $this->const[21] = array ( - "ACCOUNTING_EXPORT_DEVISE", - "yesno", - "1" - ); - */ - $this->const[22] = array( - "ACCOUNTING_EXPENSEREPORT_JOURNAL", - "chaine", - "ER" - ); - $this->const[23] = array( + $this->const[13] = array( "ACCOUNTING_EXPORT_FORMAT", "chaine", "csv" diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 5af427242f4..79b0bf8d37b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -274,6 +274,19 @@ CREATE TABLE llx_projet_task_comment ( import_key varchar(125) DEFAULT NULL )ENGINE=innodb; +-- Accountancy - Remove old constants +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_SELL_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_PURCHASE_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_SOCIAL_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_MISCELLANEOUS_JOURNAL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_GROUPBYACCOUNT')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_GLOBAL_ACCOUNT')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_LABEL')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_AMOUNT')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_DEVISE')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_PIECE')__; +DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPENSEREPORT_JOURNAL')__; + -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; From baa32f6ed893f68603dd459acdb77801f135b9de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 09:13:57 +0200 Subject: [PATCH 22/67] FIX Responsive --- htdocs/core/class/html.form.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c022dab7d78..a1a0255d8ee 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5552,6 +5552,8 @@ class Form print '
'; print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); + + print '
'; print ''; print ''; @@ -5645,6 +5647,7 @@ class Form } print '
'; + print '
'; return $nbofdifferenttypes; } From 4e7e6cc65867de9d126aa5d7d88891c1376339f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 09:15:10 +0200 Subject: [PATCH 23/67] Fix W3C --- htdocs/compta/facture/list.php | 3 ++- htdocs/core/actions_massactions.inc.php | 4 ++-- htdocs/core/actions_sendmails.inc.php | 4 ++-- htdocs/core/class/html.formmail.class.php | 24 +++++++++++++++-------- htdocs/core/lib/functions.lib.php | 9 ++++++--- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 15a79d7fdd9..539bdca0036 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -687,7 +687,8 @@ if ($resql) $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; - // Tableau des substitutions + // Array of substitution + // TODO Use getCommonSubstitutionArray like in actions_sendmails.inc.php $formmail->substit['__REF__']='__REF__'; // We want to keep the tag $formmail->substit['__SIGNATURE__']=$user->signature; $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 26b5cbe3460..e5833295480 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -264,8 +264,8 @@ if (! $error && $massaction == 'confirm_presend') } $replyto = $from; - $subject = GETPOST('subject'); - $message = GETPOST('message'); + $subject = GETPOST('subject','none'); + $message = GETPOST('message','none'); $sendtocc = GETPOST('sentocc'); $sendtobcc = ''; if ($objectclass == 'Propale') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 4986a093bac..18c951c7763 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -258,7 +258,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; + $message = GETPOST('message','none'); + $subject = GETPOST('subject','none'); // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. // @@ -278,7 +279,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($action == 'send' || $action == 'relance') { - if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); if ($message) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 9bfe00e6575..2555c44b539 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -302,10 +302,18 @@ class FormMail extends Form if ($this->withform == 1) { $out.= '
'."\n"; - $out.= ''; + $out.= ''; + $out.= ''; $out.= ''; $out.= ''; - $out.= ''; + } + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + } } foreach ($this->param as $key=>$value) { @@ -360,6 +368,7 @@ class FormMail extends Form if (! empty($this->withsubstit)) { $out.= ''; + //$out.='
'; $help=""; foreach($this->substit as $key => $val) { @@ -368,6 +377,7 @@ class FormMail extends Form if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage else $out.= $form->textwithpicto($langs->trans($this->withsubstit), $help, 1, 'help', '', 0, 2, 'substittooltip'); // New usage $out.= "\n"; + //$out.='
'; } // From @@ -375,9 +385,7 @@ class FormMail extends Form { if (! empty($this->withfromreadonly)) { - $out.= ''; - $out.= ''; - $out.= ''.$langs->trans("MailFrom").''; + $out.= ''.$langs->trans("MailFrom").''; if (! ($this->fromtype === 'user' && $this->fromid > 0) && ! ($this->fromtype === 'company') @@ -430,10 +438,10 @@ class FormMail extends Form } } $out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails); + //$out.= ajax_combobox('fromtype'); } $out.= "\n"; - $out.= "\n"; } else { @@ -1076,7 +1084,7 @@ class FormMail extends Form } /** - * Get list of substitution keys available for emails. + * Get list of substitution keys available for emails. This is used for tooltips help. * This include the complete_substitutions_array. * * @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ... @@ -1183,7 +1191,7 @@ class FormMail extends Form } $parameters=array('mode'=>$mode); - $tmparray=getCommonSubstitutionArray($langs, 0, null, $object); + $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); complete_substitutions_array($tmparray, $langs, null, $parameters); foreach($tmparray as $key => $val) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 79d982371b7..90265b079aa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5255,9 +5255,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__AMOUNT_WO_TAX__']= is_object($object)?$object->total_ht:''; $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; // For backward compatibility - $substitutionarray['__TOTAL_TTC__'] = is_object($object)?$object->total_ttc:''; - $substitutionarray['__TOTAL_HT__'] = is_object($object)?$object->total_ht:''; - $substitutionarray['__TOTAL_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + if ($onlykey != 2) + { + $substitutionarray['__TOTAL_TTC__'] = is_object($object)?$object->total_ttc:''; + $substitutionarray['__TOTAL_HT__'] = is_object($object)?$object->total_ht:''; + $substitutionarray['__TOTAL_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + } } if (empty($exclude) || ! in_array('date', $exclude)) From 8986640a10e0a7c132a4dbc53d096d33908e4fd2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 09:13:57 +0200 Subject: [PATCH 24/67] FIX Responsive --- htdocs/core/class/html.form.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 44acfaaac6b..a684cff7165 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5500,6 +5500,8 @@ class Form print '
'; print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); + + print '
'; print ''; print ''; @@ -5593,6 +5595,7 @@ class Form } print '
'; + print '
'; return $nbofdifferenttypes; } From 058b690e25672f5346f70742ea3a1a9d970ff999 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 09:22:52 +0200 Subject: [PATCH 25/67] FIX menu enty when url is external link --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f3d89ec514e..e9876b31ece 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -266,7 +266,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode { // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; - if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) + if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) // Do not change url content for external links { $tmp=explode('?',$newTabMenu[$i]['url'],2); $url = $shorturl = $tmp[0]; @@ -301,7 +301,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode foreach($menu->liste as $menkey => $menuval) { if (empty($noout)) print_start_menu_entry($menuval['idsel'],$menuval['classname'],$menuval['enabled']); - if (empty($noout)) print_text_menu_entry($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) 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)); if (empty($noout)) print_end_menu_entry($menuval['enabled']); } From 5fd7cdff5c3178e475cb3dc457ae8e21d41cfb44 Mon Sep 17 00:00:00 2001 From: "Ahmad M. Zawawi" Date: Sat, 16 Sep 2017 10:53:16 +0300 Subject: [PATCH 26/67] Fix example comment typo --- dev/examples/code/create_user.php | 4 ++-- dev/examples/code/get_contracts.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/examples/code/create_user.php b/dev/examples/code/create_user.php index f745032f575..20173eb914a 100755 --- a/dev/examples/code/create_user.php +++ b/dev/examples/code/create_user.php @@ -60,14 +60,14 @@ $db->begin(); require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); -// Create invoice object +// Create user object $obj = new User($db); //$obj->initAsSpecimen(); $obj->login = 'ABCDEF'; $obj->nom = 'ABCDEF'; -// Create invoice +// Create user $idobject=$obj->create($user); if ($idobject > 0) { diff --git a/dev/examples/code/get_contracts.php b/dev/examples/code/get_contracts.php index 1262fe3eebd..fbe512300e8 100755 --- a/dev/examples/code/get_contracts.php +++ b/dev/examples/code/get_contracts.php @@ -67,7 +67,7 @@ $db->begin(); require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); -// Create invoice object +// Create contract object $obj = new Contrat($db); $obj->socid=$argv[1]; From bd7c4fe9400c76fdd5f9f1288537ec3eed58440c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 10:12:44 +0200 Subject: [PATCH 27/67] NEW Summary of last events on a card are sorted on decreasing date. --- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/core/class/html.formactions.class.php | 19 +++++++++++-------- htdocs/core/lib/functions.lib.php | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b59d47adb9e..306e5172e0e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -863,7 +863,7 @@ class ActionComm extends CommonObject * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='a.datep', $sortorder='DESC', $limit=0) { global $conf, $langs; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 15a9b781290..579520f7647 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -166,7 +166,10 @@ class FormActions require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); + $sortfield='a.datep'; + $sortorder='DESC'; + + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -192,19 +195,19 @@ class FormActions $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); - $page=0; $param=''; $sortfield='a.datep'; + $page=0; $param=''; $total = 0; print '
'; print ''; print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); - print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Action', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); print ''; print "\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 90265b079aa..9952af3841d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3353,16 +3353,16 @@ function dol_print_error_email($prefixcode, $errormessage='') * @param string $field Field to use for new sorting * @param string $begin ("" by defaut) * @param string $moreparam Add more parameters on sort url links ("" by default) - * @param string $td Options of attribute td ("" by defaut, example: 'align="center"') + * @param string $moreattrib Options of attribute td ("" by defaut, example: 'align="center"') * @param string $sortfield Current field used to sort * @param string $sortorder Current sort order * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag. * @param string $tooltip Tooltip * @return void */ -function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="", $prefix="", $tooltip="") +function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="") { - print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $td, $sortfield, $sortorder, $prefix, 0, $tooltip); + print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip); } /** From 695c231e78b40ff090cf6aea04046b9d409cdae2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 10:26:27 +0200 Subject: [PATCH 28/67] Update code comment --- htdocs/core/lib/functions.lib.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9952af3841d..92b594e58bf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4823,20 +4823,25 @@ function picto_required() /** - * Clean a string from all HTML tags and entities + * Clean a string from all HTML tags and entities. + * This function differs from strip_tags because: + * -
are replace with \n + * - if entities are found, they are decoded before the strip + * - you can decide to convert line feed into spaces * - * @param string $StringHtml String to clean + * @param string $stringtoclean String to clean * @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed * @param string $pagecodeto Encoding of input/output string * @return string String cleaned * - * @see dol_escape_htmltag + * @see dol_escape_htmltag strip_tags */ -function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') +function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8') { + // TODO Try to replace with strip_tags($stringtoclean) $pattern = "/<[^<>]+>/"; - $StringHtml = preg_replace('/]*>/', "\n", $StringHtml); - $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto); + $stringtoclean = preg_replace('/]*>/', "\n", $stringtoclean); + $temp = dol_html_entity_decode($stringtoclean,ENT_COMPAT,$pagecodeto); // Exemple of $temp: 0000-021 $temp = preg_replace($pattern,"",$temp); // pass 1 @@ -4852,8 +4857,8 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') { $temp = str_replace(" "," ",$temp); } - $CleanString = trim($temp); - return $CleanString; + + return trim($temp); } From b099e0a1354d4fdb8c60771d1752f7b80ae0d101 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 10:42:23 +0200 Subject: [PATCH 29/67] Fix translation of dolistore interface --- .../admin/dolistore/class/dolistore.class.php | 56 ++++++++++++------- htdocs/admin/modules.php | 6 +- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 8fa25cce1a8..aff21ce58e8 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -40,41 +40,52 @@ class Dolistore /** * Constructor - * - * @param array $options Options */ - function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + function __construct() { global $conf, $langs; - $this->start = $options['start']; - $this->end = $options['end']; - $this->per_page = $options['per_page']; - $this->categorie = $options['categorie']; - $this->search = $options['search']; - $this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace'; $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; $this->vat_rate = 1.2; // 20% de TVA $this->debug_api = false; - if ($this->end == 0) { + $langtmp = explode('_', $langs->defaultlang); + $lang = $langtmp[0]; + $lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1 + if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; + $this->lang = $lang_array[$lang]; + } + + /** + * Load data from remote Dolistore market place. + * This fills ->categories + * + * @param array $options Options + * @return void + */ + function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + { + global $conf, $langs; + + $this->start = $options['start']; + $this->end = $options['end']; + $this->per_page = $options['per_page']; + $this->categorie = $options['categorie']; + $this->search = $options['search']; + + if ($this->end == 0) { $this->end = $this->per_page; } - $langtmp = explode('_', $langs->defaultlang); - $lang = $langtmp[0]; - $lang_array = array('fr'=>1, 'en'=>2, 'es'=>3, 'it'=>4, 'de'=>5); - if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; - $this->lang = $lang_array[$lang]; // 1=fr 2=en ... - - try { + try { $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api); // Here we set the option array for the Webservice : we want products resources $opt = array(); $opt['resource'] = 'products'; + // make a search to limit the id returned. if ($this->search != '') { $opt2 = array(); @@ -102,7 +113,9 @@ class Dolistore $opt['sort'] = 'id_desc'; $opt['filter[active]'] = '[1]'; $opt['limit'] = "$this->start,$this->end"; - // Call + // $opt['filter[id]'] contais list of product id that are result of search + + // Call API to get the detail $xml = $this->api->get($opt); $this->products = $xml->products->children(); @@ -124,7 +137,12 @@ class Dolistore } } - + /** + * Return tree of Dolistore categories. $this->categories must have been loaded before. + * + * @param int $parent Id of parent category + * @return string + */ function get_categories($parent = 0) { if (!isset($this->categories)) die('not possible'); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ce67595a0f7..6b7d839592c 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -55,7 +55,7 @@ $options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int' $options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0); $options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0); $options['search'] = GETPOST('search_keyword', 'alpha'); -$dolistore = new Dolistore($options); +$dolistore = new Dolistore(); if (! $user->admin) @@ -832,6 +832,10 @@ if ($mode == 'marketplace') if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) { + // $options is array with filter criterias + //var_dump($options); + $dolistore->getRemoteData($options); + print ''.$langs->trans('DOLISTOREdescriptionLong').'

'; $previouslink = $dolistore->get_previous_link(); From 9077b5f3747eacd5df2d59575b6de68eb0c8bba9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 12:48:51 +0200 Subject: [PATCH 30/67] 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 0a512b6bfc0..5395acdd3d2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -313,7 +313,7 @@ SetupIsReadyForUse=Module deployment is finished. You must however enable and se NotExistsDirect=The alternative root directory is not defined to an existing directory.
InfDirAlt=Since version 3, it is possible to define an alternative root directory. This allows you to store, into a dedicated directory, plug-ins and custom templates.
Just create a directory at the root of Dolibarr (eg: custom).
InfDirExample=
Then declare it in the file conf.php
$dolibarr_main_url_root_alt='/custom'
$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
If these lines are commented with "#", to enable them, just uncomment by removing the "#" character. -YouCanSubmitFile=For this step, you can submit your package file here : +YouCanSubmitFile=For this step, you can submit the .zip file of module package here : CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and data: %s. LastStableVersion=Latest stable version From 0cf67944fa86428e2039347e3222138e727f4b62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 13:14:46 +0200 Subject: [PATCH 31/67] Clean code --- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/core/class/html.form.class.php | 6 +++--- htdocs/modulebuilder/template/myobject_list.php | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 306e5172e0e..4d1f0d571e1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -880,7 +880,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); - if ($limit) $sql.=$db->plimit($limit); + $sql.=$db->plimit($limit, 0); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 909b0f3ebc8..1faa0831c92 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -414,7 +414,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit, GETPOST('massaction','alpha')?1:0); if ($massaction == 'presend') { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a1a0255d8ee..7a84bc444c2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1082,7 +1082,7 @@ class Form $sql.=")"; } $sql.=$this->db->order("nom","ASC"); - if ($limit > 0) $sql.=$this->db->plimit($limit); + $sql.=$this->db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_thirdparty_list", LOG_DEBUG); @@ -1966,7 +1966,7 @@ class Form $sql.= ' GROUP BY'.$selectFields; } $sql.= $db->order("p.ref"); - $sql.= $db->plimit($limit); + $sql.= $db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG); @@ -2390,7 +2390,7 @@ class Form $sql.=')'; } $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; - $sql.= $db->plimit($limit); + $sql.= $db->plimit($limit, 0); // Build output string diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index a605e765290..c144c539dd4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -293,13 +293,13 @@ jQuery(document).ready(function() { $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +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) { $param.= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields foreach ($search_array_options as $key => $val) { From 52f89ef2c0f541bfae076cf89a8a3b3fb3029f8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 13:26:43 +0200 Subject: [PATCH 32/67] FIX Better protection to no send email when we change limit --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e5833295480..067d67ac28f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -52,7 +52,7 @@ if (! $error && count($toselect) > $maxformassaction) $error++; } -if (! $error && $massaction == 'confirm_presend' && GETPOST('modelselected')) // If we change the template, we must not send email, but keep on send email form +if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form { $massaction='presend'; } From e56b41c1ae9e539d5d15f691fe80d958fa25cf09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 13:28:13 +0200 Subject: [PATCH 33/67] Clean code --- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/comm/mailing/cibles.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index fe4a004181d..efc3d7f0eaa 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -209,7 +209,7 @@ print '' . $langs->trans("ViewFlatList") . ''; -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,$viewflat,'',$limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,$viewflat,'', $limit); // Reverse sort order if ( preg_match('/^asc/i', $sortorder) ) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 9669d8c0ff3..5a5ef5fa90c 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -425,7 +425,7 @@ if ($object->fetch($id) >= 0) if ($allowaddtarget) { $cleartext=$langs->trans("ToClearAllRecipientsClickHere").' '.'id.'" class="button reposition">'.$langs->trans("TargetsReset").''; } - print_barre_liste($langs->trans("MailSelectedRecipients"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$cleartext,$num,$nbtotalofrecords,'title_generic',0,'','',$limit); + print_barre_liste($langs->trans("MailSelectedRecipients"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$cleartext,$num,$nbtotalofrecords,'title_generic',0,'','', $limit); print ''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 1faa0831c92..909b0f3ebc8 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -414,7 +414,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit, GETPOST('massaction','alpha')?1:0); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); if ($massaction == 'presend') { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 0ded4d4cbae..2e7a46f3067 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1731,7 +1731,7 @@ else print ''; print ''; - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); + print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit); print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7a84bc444c2..e37932ea635 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -956,7 +956,7 @@ class Form */ function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0) { - return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit); + return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0, $limit); } /** From 97e8974fdf94c30d229438ab7e03d73c73093bcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 13:26:43 +0200 Subject: [PATCH 34/67] FIX Better protection to no send email when we change limit --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 68258025098..2d1d234f812 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -51,7 +51,7 @@ if (! $error && count($toselect) > $maxformassaction) $error++; } -if (! $error && $massaction == 'confirm_presend' && GETPOST('modelselected')) // If we change the template, we must not send email, but keep on send email form +if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form { $massaction='presend'; } From c7e841b3402b71534b137eab6f26dd90f1a02375 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 15:36:04 +0200 Subject: [PATCH 35/67] FIX Must use pdf format page as default for merging PDF. --- htdocs/core/actions_massactions.inc.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 067d67ac28f..c60f682f92c 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -398,6 +398,12 @@ if (! $error && $massaction == 'confirm_presend') if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { + if (empty($diroutputmassaction)) + { + dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); + exit; + } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -492,7 +498,13 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se } else { // Create empty PDF - $pdf=pdf_getInstance(); + $formatarray=pdf_getFormat(); + $page_largeur = $formatarray['width']; + $page_hauteur = $formatarray['height']; + $format = array($page_largeur,$page_hauteur); + + $pdf=pdf_getInstance($format); + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); From 630dc92a13685487ace0201d572ce3636fd74f7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 15:39:52 +0200 Subject: [PATCH 36/67] NEW Mass PDF Merging is available on contracts --- htdocs/comm/propal/list.php | 94 +----------- htdocs/commande/list.php | 98 +------------ htdocs/compta/facture/list.php | 96 +----------- htdocs/contrat/list.php | 41 +++++- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/lib/files.lib.php | 8 + htdocs/core/lib/functions.lib.php | 18 ++- .../contract/doc/pdf_strato.modules.php | 1 + htdocs/core/tpl/massactions_form.tpl.php | 138 ++++++++++++++++++ htdocs/expensereport/list.php | 10 ++ htdocs/fourn/commande/list.php | 99 +------------ htdocs/fourn/facture/list.php | 103 +------------ htdocs/langs/en_US/mails.lang | 2 +- htdocs/supplier_proposal/list.php | 98 +------------ 14 files changed, 241 insertions(+), 567 deletions(-) create mode 100644 htdocs/core/tpl/massactions_form.tpl.php diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 909b0f3ebc8..708b2209b9e 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -418,100 +418,12 @@ if ($resql) if ($massaction == 'presend') { - $langs->load("mails"); - - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new Propal($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - $topicmail="SendSupplierProposalRef"; $modelmail="supplier_proposal_send"; + $objecttmp=new Propal($db); + $trackid='ord'.$object->id; - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } if ($sall) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 13841b108d9..24b5570a82d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -661,102 +661,16 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); - // TODO Move this into an invluce if ($massaction == 'presend') { - $langs->load("mails"); + $topicmail="SendOrderRef"; + $modelmail="order_send"; + $objecttmp=new Commande($db); + $trackid='ord'.$object->id; - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new Commande($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - dol_fiche_head(null, '', ''); - - $topicmail="SendOrderRef"; - $modelmail="order_send"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } - elseif ($massaction == 'createbills') + if ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 539bdca0036..7b082128623 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -610,102 +610,12 @@ if ($resql) if ($massaction == 'presend') { - $langs->load("mails"); - - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new Facture($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - $topicmail="SendBillRef"; $modelmail="facture_send"; + $objecttmp=new Facture($db); + $trackid='inv'.$object->id; - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='inv'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Array of substitution - // TODO Use getCommonSubstitutionArray like in actions_sendmails.inc.php - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['facid']=join(',',$arrayofselected); - // TODO We should use $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } if ($sall) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index beba40103af..567bad63d91 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -29,8 +29,9 @@ */ require ("../main.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); +require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -81,6 +82,8 @@ $id=GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contrat', $id); +$diroutputmassaction=$conf->contrat->dir_output . '/temp/massgeneration/'.$user->id; + $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); @@ -184,7 +187,8 @@ if (empty($reshook)) */ $now=dol_now(); -$form=new Form($db); +$form = new Form($db); +$formfile = new FormFile($db); $formother = new FormOther($db); $socstatic = new Societe($db); $contracttmp = new Contrat($db); @@ -334,8 +338,8 @@ if ($resql) // List of mass actions available $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); @@ -352,6 +356,16 @@ if ($resql) print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit); + if ($massaction == 'presend') + { + $topicmail="SendContractRef"; + $modelmail="contract"; + $objecttmp=new Contrat($db); + $trackid='con'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; + } + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -750,6 +764,25 @@ if ($resql) print ''; print ''; + + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + /* + * Show list of available documents + */ + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->contrat->lire; + $delallowed=$user->rights->contrat->lire; + + print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } } else { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 2555c44b539..cfe3f0fed63 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -298,7 +298,7 @@ class FormMail extends Form //var_dump($this->param["models"]); //var_dump($model_id); - $out.= "\n".'
'."\n"; + $out.= "\n".'
'."\n"; if ($this->withform == 1) { $out.= '
'."\n"; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1cc0c209591..dbc09fa820b 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2283,6 +2283,14 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } + else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output)) + { + if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file)) + { + $accessallowed=1; + } + $original_file=$conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + } // Wrapping for interventions else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 92b594e58bf..ad7e05b9a9f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5234,12 +5234,18 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '')); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : ''); - $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); - $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + if (is_object($object->thirdparty) && $object->thirdparty->id > 0) + { + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + } - $substitutionarray['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:''); - $substitutionarray['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); - $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); + if (is_object($object->projet) && $object->projet->id > 0) + { + $substitutionarray['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:''); + $substitutionarray['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); + $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); + } // Create dynamic tags for __EXTRAFIELD_FIELD__ if ($object->table_element && $object->id > 0) @@ -5251,6 +5257,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; } } + + $substitutionarray['__ONLINE_PAYMENT_XXX__'] = 'todo'; } if (empty($exclude) || ! in_array('objectamount', $exclude)) { diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index d076456011c..2cea64a72a6 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -83,6 +83,7 @@ class pdf_strato extends ModelePDFContract // Dimension page pour format A4 $this->type = 'pdf'; $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; $this->format = array($this->page_largeur,$this->page_hauteur); diff --git a/htdocs/core/tpl/massactions_form.tpl.php b/htdocs/core/tpl/massactions_form.tpl.php new file mode 100644 index 00000000000..c8e329eaf4b --- /dev/null +++ b/htdocs/core/tpl/massactions_form.tpl.php @@ -0,0 +1,138 @@ + + * Copyright (C) 2013-2014 Laurent Destailleur + * Copyright (C) 2015 Marcos García + * + * 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/ + */ + +// Following var must be set: +// $arrayofselected = array of id selected +// $object +// $objecttmp=new Propal($db); +// $topicmail="SendSupplierProposalRef"; +// $modelmail="supplier_proposal_send"; +// $trackid='ord'.$object->id; + + +$langs->load("mails"); + + if (! GETPOST('cancel','alpha')) + { + $listofselectedid=array(); + $listofselectedthirdparties=array(); + $listofselectedref=array(); + foreach($arrayofselected as $toselectid) + { + $result=$objecttmp->fetch($toselectid); + if ($result > 0) + { + $listofselectedid[$toselectid]=$toselectid; + $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; + $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; + $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; + } + } + } + + print ''; + + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + dol_fiche_head(null, '', ''); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->withform=-1; + $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); + + if($formmail->fromtype === 'user'){ + $formmail->fromid = $user->id; + + } + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set + { + $formmail->trackid=$trackid; + } + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set + { + include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, $trackid); + } + $formmail->withfrom=1; + $liste=$langs->trans("AllRecipientSelected", count($listofselectedthirdparties)); + if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selected, we can suggest contacts + { + $liste=array(); + $thirdpartyid=array_shift($listofselectedthirdparties); + $soc=new Societe($db); + $soc->fetch($thirdpartyid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $formmail->withtoreadonly=0; + } + else + { + $formmail->withtoreadonly=1; + } + $formmail->withto=$liste; + $formmail->withtofree=0; + $formmail->withtocc=1; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); + $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + + // Make substitution in email content + $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); + $substitutionarray['__EMAIL__'] = $sendto; + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'':''; + $substitutionarray['__PERSONALIZED__'] = ''; + $substitutionarray['__CONTACTCIVNAME__'] = ''; + // Add specific substitution for contracts + if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) + { + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->statut != 4) continue; + if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue; + } + $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); + } + + $parameters=array('mode'=>'formemail'); + complete_substitutions_array($substitutionarray, $langs, $object, $parameters); + + // Tableau des substitutions + $formmail->substit=$substitutionarray; + + // Tableau des parametres complementaires du post + $formmail->param['action']=$action; + $formmail->param['models']=$modelmail; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); + $formmail->param['id']=join(',',$arrayofselected); + //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + print $formmail->get_form(); + +dol_fiche_end(); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index a02e23c3123..01be3eb04cc 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -322,6 +322,16 @@ if ($resql) $title = $langs->trans("ListTripsAndExpenses"); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + if ($massaction == 'presend') + { + $topicmail="SendInterventionRef"; + $modelmail="fichinter_send"; + $objecttmp=new Intervention($db); + $trackid='int'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; + } + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4794d72da6a..54c78e93d5b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -684,102 +684,17 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); - // TODO Move this into an invluce if ($massaction == 'presend') { - $langs->load("mails"); + $topicmail="SendOrderRef"; + $modelmail="order_supplier_send"; + $objecttmp=new CommandeFournisseur($db); + $trackid='sord'.$object->id; - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new CommandeFournisseur($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - dol_fiche_head(null, '', ''); - - $topicmail="SendOrderRef"; - $modelmail="order_send"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } - elseif ($massaction == 'createbills') + + if ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 11a0a8cfe63..8fae09c1adf 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -475,7 +475,7 @@ if ($resql) ); //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); - //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); + if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $i = 0; @@ -494,102 +494,15 @@ if ($resql) if ($massaction == 'presend') { - $langs->load("mails"); + $topicmail="SendBillRef"; + $modelmail="supplier_invoice_send"; + $objecttmp=new FactureFournisseur($db); + $trackid='sinv'.$object->id; - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new FactureFournisseur($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - - $topicmail="SendBillRef"; - $modelmail="supplier_invoice_send"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='sinv'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'sinv'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } - elseif ($massaction == 'createbills') + + if ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index a78b7bbc6c8..789b5a28fc9 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -69,7 +69,7 @@ EMailSentToNRecipients=EMail sent to %s recipients. EMailSentForNElements=EMail sent for %s elements. XTargetsAdded=%s recipients added into target list OnlyPDFattachmentSupported=If the PDF document was already generated for the object to send, it will be attached to email. If not, no email will be sent (also, note that only pdf documents are supported as attachment in mass sending in this version). -AllRecipientSelected=All thirdparties selected and if an email is set. +AllRecipientSelected=The %s thirdparties selected, and if an email is set. ResultOfMailSending=Result of mass EMail sending NbSelected=Nb selected NbIgnored=Nb ignored diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 96d1079b92a..7ad6c0d1b82 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -418,100 +418,12 @@ if ($resql) if ($massaction == 'presend') { - $langs->load("mails"); + $topicmail="SendSupplierProposalRef"; + $modelmail="supplier_proposal_send"; + $objecttmp=new SupplierProposal($db); + $trackid='spro'.$object->id; - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new SupplierProposal($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - - $topicmail="SendProposalRef"; - $modelmail="propal_send"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } if ($sall) From 318e285ba2fa81f0298d83f11957de80dddfbc55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 16:00:58 +0200 Subject: [PATCH 37/67] NEW Add protection to avoid to send to much emails using builk actions --- htdocs/core/tpl/massactions_form.tpl.php | 13 +++++++++++-- htdocs/langs/en_US/errors.lang | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/massactions_form.tpl.php b/htdocs/core/tpl/massactions_form.tpl.php index c8e329eaf4b..280a153acc7 100644 --- a/htdocs/core/tpl/massactions_form.tpl.php +++ b/htdocs/core/tpl/massactions_form.tpl.php @@ -132,7 +132,16 @@ $langs->load("mails"); $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); + if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB) + { + $langs->load("errors"); + print img_warning().' '.$langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB); + print ' - '.$langs->trans("GoBack").''; + $arrayofmassactions=array(); + } + else + { + print $formmail->get_form(); + } dol_fiche_end(); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 003eedeac8a..7ace47fb781 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -220,4 +220,5 @@ WarningPaymentDateLowerThanInvoiceDate=Payment date (%s) is earlier than invoice WarningTooManyDataPleaseUseMoreFilters=Too many data (more than %s lines). Please use more filters or set the constant %s to a higher limit. WarningSomeLinesWithNullHourlyRate=Some times were recorded by some users while their hourly rate was not defined. A value of 0 %s per hour was used but this may result in wrong valuation of time spent. WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security purpose you will have to login with your new login before next action. -WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language \ No newline at end of file +WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language +WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to %s when using the bulk actions on lists \ No newline at end of file From 0fec777d0e7e7568f3ca468583b2629301d90a77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 18:24:58 +0200 Subject: [PATCH 38/67] NEW On bulk email from a list, can uncheck "Join main document". NEW Show direct preview link on contract --- htdocs/comm/propal/list.php | 3 +- htdocs/commande/list.php | 3 +- htdocs/compta/facture/list.php | 15 +- htdocs/contrat/list.php | 7 + htdocs/core/actions_massactions.inc.php | 113 ++++++----- htdocs/core/class/html.formmail.class.php | 45 ++++- htdocs/core/tpl/massactions_form.tpl.php | 234 +++++++++++----------- htdocs/langs/en_US/mails.lang | 1 + htdocs/langs/en_US/main.lang | 1 + htdocs/societe/class/societe.class.php | 1 + htdocs/societe/list.php | 12 +- 11 files changed, 254 insertions(+), 181 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 708b2209b9e..e0f1caafc81 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -238,7 +238,7 @@ llxHeader('',$langs->trans('Proposal'),$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' p.rowid, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; @@ -725,6 +725,7 @@ if ($resql) $companystatic->name=$obj->name; $companystatic->client=$obj->client; $companystatic->code_client=$obj->code_client; + $companystatic->email=$obj->email; // Thirdparty if (! empty($arrayfields['s.nom']['checked'])) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 24b5570a82d..af83b353101 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -445,7 +445,7 @@ llxHeader('',$title,$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; @@ -1148,6 +1148,7 @@ if ($resql) $companystatic->code_client = $obj->code_client; $companystatic->name=$obj->name; $companystatic->client=$obj->client; + $companystatic->email=$obj->email; // Third party if (! empty($arrayfields['s.nom']['checked'])) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 7b082128623..46f8c76ae58 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -345,6 +345,7 @@ $formfile = new FormFile($db); $bankaccountstatic=new Account($db); $facturestatic=new Facture($db); $formcompany=new FormCompany($db); +$thirdpartystatic=new Societe($db); llxHeader('',$langs->trans('CustomersInvoices'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); @@ -355,7 +356,7 @@ $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.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) @@ -1010,12 +1011,12 @@ if ($resql) if (! empty($arrayfields['s.nom']['checked'])) { print '
'; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 567bad63d91..76b710bc5c8 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -600,6 +600,13 @@ if ($resql) print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; print ''; } + + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); + print ''; + print ''; } if (! empty($arrayfields['c.ref_customer']['checked'])) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c60f682f92c..4c3fe6af317 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -85,6 +85,7 @@ if (! $error && $massaction == 'confirm_presend') { $listofobjectid[$toselectid]=$toselectid; $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; + if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id; $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; } @@ -172,74 +173,90 @@ if (! $error && $massaction == 'confirm_presend') $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); $listofqualifiedid=array(); $listofqualifiedref=array(); + $thirdpartywithoutemail=array(); + foreach($listofobjectref[$thirdpartyid] as $objectid => $object) { //var_dump($thirdpartyid.' - '.$objectid.' - '.$object->statut); - - if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED) + if ($objectclass == 'Propal' && $object->statut == Propal::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'

'; + $resaction.='
'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$object->ref).'

'; continue; // Payment done or started or canceled } - if ($objectclass == 'Commande' && $object->statut == Commande::STATUS_DRAFT) + if ($objectclass == 'Commande' && $object->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction.='
'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction',$object->ref).'

'; continue; } - - // Read document - // TODO Use future field $object->fullpathdoc to know where is stored default file - // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. - $filename=dol_sanitizeFileName($object->ref).'.pdf'; - $filedir=$uploaddir . '/' . dol_sanitizeFileName($object->ref); - $file = $filedir . '/' . $filename; - $mime = dol_mimetype($file); - - if (dol_is_file($file)) + if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED) { - if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) - { - $object->fetch_thirdparty(); - $sendto = $object->thirdparty->email; - } - - if (empty($sendto)) - { - //print "No recipient for thirdparty ".$object->thirdparty->name; - $nbignored++; - continue; - } - - if (dol_strlen($sendto)) - { - // Create form object - $attachedfiles=array( - 'paths'=>array_merge($attachedfiles['paths'],array($file)), - 'names'=>array_merge($attachedfiles['names'],array($filename)), - 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) - ); - } - - $listofqualifiedid[$objectid]=$object; - $listofqualifiedref[$objectid]=$object->ref; - } - else - { - $nbignored++; - $langs->load("errors"); - $resaction.='
'.$langs->trans('ErrorCantReadFile',$file).'

'; - dol_syslog('Failed to read file: '.$file, LOG_WARNING); - continue; + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'

'; + continue; // Payment done or started or canceled } + // Test recipient + if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) + { + $object->fetch_thirdparty(); + $sendto = $object->thirdparty->email; + } + + if (empty($sendto)) + { + //print "No recipient for thirdparty ".$object->thirdparty->name; + $nbignored++; + if (empty($thirdpartywithoutemail[$object->thirdparty->id])) + { + $resaction.='
'.$langs->trans('NoRecipientEmail',$object->thirdparty->name).'

'; + } + dol_syslog('No recipient for thirdparty: '.$object->thirdparty->name, LOG_WARNING); + $thirdpartywithoutemail[$object->thirdparty->id]=1; + continue; + } + + if ($_POST['addmaindocfile']) + { + // TODO Use future field $object->fullpathdoc to know where is stored default file + // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. + $filename=dol_sanitizeFileName($object->ref).'.pdf'; + $filedir=$uploaddir . '/' . dol_sanitizeFileName($object->ref); + $file = $filedir . '/' . $filename; + $mime = dol_mimetype($file); + + if (dol_is_file($file)) + { + // Create form object + $attachedfiles=array( + 'paths'=>array_merge($attachedfiles['paths'],array($file)), + 'names'=>array_merge($attachedfiles['names'],array($filename)), + 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) + ); + } + else + { + $nbignored++; + $langs->load("errors"); + $resaction.='
'.$langs->trans('ErrorCantReadFile',$file).'

'; + dol_syslog('Failed to read file: '.$file, LOG_WARNING); + continue; + } + } + + // Object of thirdparty qualified + $listofqualifiedid[$objectid]=$object; + $listofqualifiedref[$objectid]=$object->ref; + + //var_dump($listofqualifiedref); } - // Loop on each qualified objects of the thirdparty + // Send email if there is at least one qualified record if (count($listofqualifiedid) > 0) { $langs->load("commercial"); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index cfe3f0fed63..13c5e0cbccf 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -63,6 +63,7 @@ class FormMail extends Form var $withtoccc; var $withtopic; var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files + var $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) var $withbody; var $withfromreadonly; @@ -103,7 +104,8 @@ class FormMail extends Form $this->withtoccc=0; $this->witherrorsto=0; $this->withtopic=1; - $this->withfile=0; + $this->withfile=0; // 1=Add section "Attached files". 2=Can add files. + $this->withmaindocfile=0; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) $this->withbody=1; $this->withfromreadonly=1; @@ -220,6 +222,7 @@ class FormMail extends Form /** * Show the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files + * this->withmaindocfile * * @param string $addfileaction Name of action when posting file attachments * @param string $removefileaction Name of action when removing file attachments @@ -233,6 +236,7 @@ class FormMail extends Form /** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files + * this->withfile * this->param: Contains more parameteres like email templates info * * @param string $addfileaction Name of action when posting file attachments @@ -297,6 +301,7 @@ class FormMail extends Form $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); //var_dump($this->param["models"]); //var_dump($model_id); + //var_dump($arraydefaultmessage); $out.= "\n".'
'."\n"; if ($this->withform == 1) @@ -348,7 +353,7 @@ class FormMail extends Form elseif (! empty($this->param['models']) && in_array($this->param['models'], array( 'propal_send','order_send','facture_send', 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send', - 'invoice_supplier_send','thirdparty','all' + 'invoice_supplier_send','thirdparty','contract','all' ))) { $out.= '
'."\n"; @@ -641,9 +646,12 @@ class FormMail extends Form // Topic if (! empty($this->withtopic)) { - $defaulttopic=""; - if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic']; - elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic; + $defaulttopic=GETPOST('subject','none'); + if (! GETPOST('modelselected','alpha') || GETPOST('modelmailselected') != '-1') + { + if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic']; + elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic; + } $defaulttopic=make_substitutions($defaulttopic,$this->substit); @@ -669,9 +677,22 @@ class FormMail extends Form $out.= '
'; $out.= '
'; - $thirdparty=new Societe($db); - $thirdparty->id=$obj->socid; - $thirdparty->name=$obj->name; - $thirdparty->client=$obj->client; - $thirdparty->code_client=$obj->code_client; - print $thirdparty->getNomUrl(1,'customer'); + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->name=$obj->name; + $thirdpartystatic->client=$obj->client; + $thirdpartystatic->code_client=$obj->code_client; + $thirdpartystatic->email=$obj->email; + print $thirdpartystatic->getNomUrl(1,'customer'); print ''.$langs->trans("MailFile").''; + if (! empty($this->withmaindocfile)) + { + if ($this->withmaindocfile == 1) + { + $out.=''; + } + if ($this->withmaindocfile == -1) + { + $out.=''; + } + $out.=' '.$langs->trans("JoinMainDoc").'.
'; + } + if (is_numeric($this->withfile)) { - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out.= ''."\n"; $out.= '