diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index f9e15e88fca..5a562fec537 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -511,7 +511,7 @@ foreach ($dirmodels as $reldir) { // Defaut print ''; - if (getDolGlobalString('MEMBER_ADDON_PDF') == $name) { + if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f76d439e49f..170b400b2a0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2614,7 +2614,15 @@ class Form } $sql = "SELECT "; - $sql .= $selectFields . $selectFieldsGrouped; + + // Add select from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectProductsListSelect', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint; + } else { + $sql .= $hookmanager->resPrint; + } if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { //Product category @@ -2660,7 +2668,13 @@ class Form $sql .= " DESC LIMIT 1) as price_by_qty"; $selectFields .= ", price_rowid, price_by_qty"; } - $sql .= " FROM " . $this->db->prefix() . "product as p"; + + $sql .= " FROM ".$this->db->prefix()."product as p"; + // Add from (left join) from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectProductsListFrom', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + if (count($warehouseStatusArray)) { $sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as ps on ps.fk_product = p.rowid"; $sql .= " LEFT JOIN " . $this->db->prefix() . "entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (" . getEntity('stock') . ")"; @@ -2932,6 +2946,7 @@ class Form protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { global $langs, $conf, $user; + global $hookmanager; $outkey = ''; $outval = ''; @@ -3217,6 +3232,14 @@ class Form } } + $parameters = array('objp'=>$objp); + $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $opt .= $hookmanager->resPrint; + } else { + $opt = $hookmanager->resPrint; + } + $opt .= "\n"; $optJson = array( 'key' => $outkey, diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 3a668d3c0c6..d7bfd4a3f21 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -69,6 +69,7 @@ class Notify 'BILL_PAYED', 'ORDER_CREATE', 'ORDER_VALIDATE', + 'ORDER_CLOSE', 'PROPAL_VALIDATE', 'PROPAL_CLOSE_SIGNED', 'PROPAL_CLOSE_REFUSED', @@ -503,6 +504,13 @@ class Notify $labeltouse = $conf->global->ORDER_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; + case 'ORDER_CLOSE': + $link = ''.$newref.''; + $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); + $object_type = 'order'; + $labeltouse = $conf->global->ORDER_CLOSE_TEMPLATE; + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderClose", $link); + break; case 'PROPAL_VALIDATE': $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); @@ -783,6 +791,12 @@ class Notify $object_type = 'order'; $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; + case 'ORDER_CLOSE': + $link = ''.$newref.''; + $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); + $object_type = 'order'; + $mesg = $langs->transnoentitiesnoconv("EMailTextOrderClose", $link); + break; case 'PROPAL_VALIDATE': $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2eda8cbbdcc..ce639624f1a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1936,14 +1936,14 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $sql .= " ORDER BY description DESC"; dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + $resql_models = $db->query($sql); + if ($resql_models) { + $num = $db->num_rows($resql_models); $i = 0; while ($i < $num) { $found = 1; - $obj = $db->fetch_object($resql); + $obj = $db->fetch_object($resql_models); // If this generation module needs to scan a directory, then description field is filled // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 199baf1e1c7..8ad5ef94b2f 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -96,6 +96,8 @@ class ImportCsv extends ModeleImports public function __construct($db, $datatoimport) { global $conf, $langs; + + parent::__construct(); $this->db = $db; $this->separator = (GETPOST('separator') ?GETPOST('separator') : (empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); @@ -870,6 +872,10 @@ class ImportCsv extends ModeleImports $filters[] = $col.' = '.$data[$key]; } } + if (!empty($tablewithentity_cache[$tablename])) { + $where[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + $filters[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + } $sqlSelect .= " WHERE ".implode(' AND ', $where); $resql = $this->db->query($sqlSelect); @@ -906,6 +912,10 @@ class ImportCsv extends ModeleImports } $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); + if (!empty($tablewithentity_cache[$tablename])) { + $sqlSelect .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + } + $resql = $this->db->query($sqlSelect); if ($resql) { $res = $this->db->fetch_object($resql); @@ -951,6 +961,10 @@ class ImportCsv extends ModeleImports $sqlend = " WHERE " . implode(' AND ', $where); } + if (!empty($tablewithentity_cache[$tablename])) { + $sqlend .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + } + $sql = $sqlstart.$sqlend; // Run update request diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 949c6bd9258..4ced5a7dff4 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -106,6 +106,8 @@ class ImportXlsx extends ModeleImports public function __construct($db, $datatoimport) { global $conf, $langs; + + parent::__construct(); $this->db = $db; // this is used as an extension from the example file code, so we have to put xlsx here !!! @@ -916,6 +918,10 @@ class ImportXlsx extends ModeleImports $filters[] = $col.' = '.$data[$key]; } } + if (!empty($tablewithentity_cache[$tablename])) { + $where[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + $filters[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + } $sqlSelect .= " WHERE " . implode(' AND ', $where); $resql = $this->db->query($sqlSelect); @@ -953,6 +959,10 @@ class ImportXlsx extends ModeleImports } $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); + if (!empty($tablewithentity_cache[$tablename])) { + $sqlSelect .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + } + $resql = $this->db->query($sqlSelect); if ($resql) { $res = $this->db->fetch_object($resql); @@ -998,6 +1008,10 @@ class ImportXlsx extends ModeleImports $sqlend = " WHERE " . implode(' AND ', $where); } + if (!empty($tablewithentity_cache[$tablename])) { + $sqlend .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + } + $sql = $sqlstart . $sqlend; // Run update request diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index fa4a5ad3692..5fe408f6dd5 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -75,14 +75,53 @@ class ModeleImports public $libversion = array(); + /** + * @var array Element mapping from table name + */ + public static $mapTableToElement = array( + 'actioncomm' => 'agenda', + 'adherent' => 'member', + 'adherent_type' => 'member_type', + //'bank_account' => 'bank_account', + 'categorie' => 'category', + //'commande' => 'commande', + //'commande_fournisseur' => 'commande_fournisseur', + 'contrat' => 'contract', + 'entrepot' => 'stock', + //'expensereport' => 'expensereport', + 'facture' => 'invoice', + //'facture_fourn' => 'facture_fourn', + 'fichinter' => 'intervention', + //'holiday' => 'holiday', + //'product' => 'product', + 'product_price' => 'productprice', + 'product_fournisseur_price' => 'productsupplierprice', + 'projet' => 'project', + //'propal' => 'propal', + //'societe' => 'societe', + 'socpeople' => 'contact', + //'supplier_proposal' => 'supplier_proposal', + //'ticket' => 'ticket', + ); /** * Constructor */ public function __construct() { - } + global $hookmanager; + if (is_object($hookmanager)) { + $hookmanager->initHooks(array('import')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('constructModeleImports', $parameters, $this); + if ($reshook >= 0 && !empty($hookmanager->resArray)) { + foreach ($hookmanager->resArray as $mapList) { + self::$mapTableToElement[$mapList['table']] = $mapList['element']; + } + } + } + } /** * getDriverId @@ -267,4 +306,22 @@ class ModeleImports { return $this->libversion[$key]; } + + /** + * Get element from table name with prefix + * + * @param string $tableNameWithPrefix Table name with prefix + * @return string Element name or table element as default + */ + public function getElementFromTableWithPrefix($tableNameWithPrefix) + { + $tableElement = preg_replace('/^'.preg_quote($this->db->prefix(), '/').'/', '', $tableNameWithPrefix); + $element = $tableElement; + + if (isset(self::$mapTableToElement[$tableElement])) { + $element = self::$mapTableToElement[$tableElement]; + } + + return $element; + } } diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e3b7be2c42a..b587922b71d 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -362,6 +362,7 @@ class PaiementFourn extends Paiement $newlang = ''; $outputlangs = $langs; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $invoice->fetch_thirdparty(); $newlang = $invoice->thirdparty->default_lang; } if (!empty($newlang)) { diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index cd9d2a6589c..d4fb27b508e 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -41,6 +41,7 @@ notiftofixedemail=To fixed mail notiftouserandtofixedemail=To user and fixed mail Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_SENTBYMAIL=Sales order sent by mail +Notify_ORDER_CLOSE=Sales order delivered Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email Notify_ORDER_SUPPLIER_VALIDATE=Purchase order recorded Notify_ORDER_SUPPLIER_APPROVE=Purchase order approved @@ -205,6 +206,7 @@ EMailTextProposalClosedSignedWeb=Proposal %s has been closed signed on portal pa EMailTextProposalClosedRefused=Proposal %s has been closed refused. EMailTextProposalClosedRefusedWeb=Proposal %s has been closed refuse on portal page. EMailTextOrderValidated=Order %s has been validated. +EMailTextOrderClose=Order %s has been delivered. EMailTextOrderApproved=Order %s has been approved. EMailTextOrderValidatedBy=Order %s has been recorded by %s. EMailTextOrderApprovedBy=Order %s has been approved by %s. diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index adba3a192d2..535febb1f14 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -40,6 +40,7 @@ notiftofixedemail=aux e-mails définis notiftouserandtofixedemail=Aux utilisateurs et e-mails définis Notify_ORDER_VALIDATE=Validation commande client Notify_ORDER_SENTBYMAIL=Envoi commande client par email +Notify_ORDER_CLOSE=Commande client livrée Notify_ORDER_SUPPLIER_SENTBYMAIL=Envoi commande fournisseur par email Notify_ORDER_SUPPLIER_VALIDATE=Commande fournisseur enregistrée Notify_ORDER_SUPPLIER_APPROVE=Commande fournisseur approuvée @@ -217,6 +218,7 @@ EMailTextProposalClosedSignedWeb=La proposition %s a été clôturée signée vi EMailTextProposalClosedRefused=La proposition %s a été fermée refusée. EMailTextProposalClosedRefusedWeb=La proposition %s a été fermée et refusée sur la page du portail. EMailTextOrderValidated=La commande %s a été validée. +EMailTextOrderClose=La commande %s a été livrée. EMailTextOrderApproved=La commande %s a été approuvée. EMailTextOrderValidatedBy=La commande %s a été enregistrée par %s EMailTextOrderApprovedBy=La commande %s a été approuvée par %s.