diff --git a/ChangeLog b/ChangeLog index d6c8e1c9e98..17adbf2a813 100644 --- a/ChangeLog +++ b/ChangeLog @@ -217,7 +217,7 @@ Following changes may create regressions for some external modules, but were nec ***** ChangeLog for 17.0.2 compared to 17.0.1 ***** - +FIX : Add hidden conf to add extrafields in canelle template : INVOICE_ADD_EXTRAFIELD_IN_NOTE FIX: #24414 FIX: #24798 Deleting member subscription is not possible FIX: add a test for updating date on task update in tab time consummed pro… diff --git a/dev/initdemo/mysqldump_dolibarr_17.0.0.sql b/dev/initdemo/mysqldump_dolibarr_17.0.0.sql index 71c7c8e50ea..c4af061da20 100644 --- a/dev/initdemo/mysqldump_dolibarr_17.0.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_17.0.0.sql @@ -1976,7 +1976,11 @@ CREATE TABLE `llx_c_holiday_types` ( LOCK TABLES `llx_c_holiday_types` WRITE; /*!40000 ALTER TABLE `llx_c_holiday_types` DISABLE KEYS */; -INSERT INTO `llx_c_holiday_types` VALUES (1,'LEAVE_SICK','Sick leave',0,0,0.00000,NULL,1,NULL),(2,'LEAVE_OTHER','Other leave',0,0,0.00000,NULL,1,NULL),(3,'LEAVE_PAID','Paid vacation',1,7,0.00000,NULL,1,NULL),(4,'LEAVE_RTT_FR','RTT',1,7,0.83000,1,0,NULL),(5,'LEAVE_PAID_FR','Paid vacation',1,30,2.08334,1,0,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (1,'LEAVE_SICK','Sick leave',0,0,0.00000,NULL,0,1,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (2,'LEAVE_OTHER','Other leave',0,0,0.00000,NULL,0,1,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (3,'LEAVE_PAID','Paid vacation',1,7,0.00000,NULL,0,1,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (4,'LEAVE_RTT_FR','RTT',1,7,0.83000,1,0,0,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (5,'LEAVE_PAID_FR','Paid vacation',1,30,2.08334,1,0,0,NULL); /*!40000 ALTER TABLE `llx_c_holiday_types` ENABLE KEYS */; UNLOCK TABLES; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index bc11bc8e4b1..b815a673d13 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1690,9 +1690,18 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("NewProp"), '', 'propal'); + $cond_reglement_id = $mode_reglement_id = 0; + $soc = new Societe($db); if ($socid > 0) { $res = $soc->fetch($socid); + + if (GETPOSTINT('cond_reglement_id') == 0) { + $cond_reglement_id = $soc->cond_reglement_id; + } + if (GETPOSTINT('mode_reglement_id') == 0) { + $mode_reglement_id = $soc->mode_reglement_id; + } } // Load objectsrc @@ -1764,6 +1773,15 @@ if ($action == 'create') { } } + // when payment term is empty (means not override by payment mode form a other object, like third-party), try to use default value + if (empty($cond_reglement_id)) { + $cond_reglement_id = GETPOST("cond_reglement_id", 'int'); + } + // when payment mode is empty (means not override by payment mode form a other object, like third-party), try to use default value + if (empty($mode_reglement_id)) { + $mode_reglement_id = GETPOST("mode_reglement_id", 'int'); + } + //Warehouse default if null if ($soc->fk_warehouse > 0) { $warehouse_id = $soc->fk_warehouse; @@ -1868,15 +1886,13 @@ if ($action == 'create') { print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); // at last resort we take the payment term id which may be filled by default values set (if not getpostisset) - $paymentTermId = (GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id', 'int') != 0) ? GETPOST('cond_reglement_id', 'int') : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : GETPOST('cond_reglement_id', 'int')); - print $form->getSelectConditionsPaiements($paymentTermId, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); + print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); print ''; // Mode of payment print ''.$langs->trans('PaymentMode').''; print img_picto('', 'bank', 'class="pictofixedwidth"'); - $paymentMethod = (GETPOSTISSET('mode_reglement_id') && GETPOST('mode_reglement_id', 'int') != 0) ? GETPOST('mode_reglement_id', 'int') : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : GETPOST('mode_reglement_id', 'int')); - print $form->select_types_paiements($paymentMethod, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); + print $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); print ''; // Bank Account diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 05a7ff7a823..2983f6e83ca 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2108,7 +2108,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; - $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -2166,9 +2166,10 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_end_validity != '' ? "'".$this->db->idate($date_end_validity)."'" : 'null'); - $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".((int) self::STATUS_DRAFT); + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); if (!$resql) { $this->errors[] = $this->db->error(); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 69c7ec4312c..ead429c7152 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -106,7 +106,7 @@ $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', $search_login = GETPOST('search_login', 'alpha'); $search_categ_cus = GETPOST("search_categ_cus", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int'); +$search_billed = GETPOST('search_billed', 'int'); $search_status = GETPOST('search_status', 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 72521509fe3..e6b51ec3c04 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -192,15 +192,16 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { } print ''; +for ($annee = $year_start; $annee <= $year_end; $annee++) { + $totsorties[$annee] = 0; + $totentrees[$annee] = 0; +} + for ($mois = 1; $mois < 13; $mois++) { print ''; print "".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B").""; for ($annee = $year_start; $annee <= $year_end; $annee++) { - if ($mois == 1) { - $totsorties[$annee] = 0; - $totentrees[$annee] = 0; - } $case = sprintf("%04s-%02s", $annee, $mois); print ' '; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 361b52998ec..1a09f72c604 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -434,11 +434,11 @@ if ($resql) { if ($num) { require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; - $bac = new CompanyBankAccount($db); while ($i < $num && $i < $limit) { $obj = $db->fetch_object($resql); + $bac = new CompanyBankAccount($db); // Must include the new in loop so the fetch is clean $bac->fetch(0, $obj->socid); $invoicestatic->id = $obj->rowid; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8561b7e252f..e8f42868947 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6618,6 +6618,11 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + case 'link': + if ($this->array_options["options_".$key] === '') { + $this->array_options["options_".$key] = null; + } + break; /* case 'link': $param_list = array_keys($attributeParam['options']); @@ -8443,16 +8448,19 @@ abstract class CommonObject { global $user; + $module = $this->module; $element = $this->element; + if ($element == 'facturerec') { $element = 'facture'; } elseif ($element == 'invoice_supplier_rec') { return $user->rights->fournisseur->facture; - } elseif ($element == 'evaluation') { - return $user->rights->hrm->evaluation; + } elseif ($module && !empty($user->rights->$module->$element)) { + // for modules built with ModuleBuilder + return $user->rights->$module->$element; } - return $user->rights->{$element}; + return $user->rights->$element; } /** diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a2d1552d1d2..afd4b57e916 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2088,7 +2088,7 @@ class ExtraFields continue; } - if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')))) { + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'checkbox', 'chkbxlst')))) { //when unticking boolean field, it's not set in POST continue; } @@ -2115,7 +2115,7 @@ class ExtraFields if (empty($enabled) || ( $onlykey === '@GETPOSTISSET' - && in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')) + && in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'checkbox', 'chkbxlst')) && in_array(abs($enabled), array(2, 5)) && ! GETPOSTISSET('options_' . $key) // Update hidden checkboxes and multiselect only if they are provided ) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 0b56169cf33..ac6bbc42e0d 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -243,7 +243,7 @@ class FormSetup */ public function saveConfFromPost($noMessageInUpdate = false) { - global $hookmanager; + global $hookmanager, $conf; $parameters = array(); $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfFromPost', $parameters, $this); // Note that $action and $object may have been modified by some hooks @@ -264,6 +264,10 @@ class FormSetup $this->db->begin(); $error = 0; foreach ($this->items as $item) { + if ($item->getType() == 'yesno' && !empty($conf->use_javascript_ajax)) { + continue; + } + $res = $item->setValueFromPost(); if ($res > 0) { $item->saveConfValue(); diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index 706af6bd110..20f0f585426 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -52,19 +52,8 @@ function establishment_prepare_head($object) $head[$h][2] = 'info'; $h++; - // $head[$h][0] = dol_buildpath("/hrm/admin/setup.php", 1); - // $head[$h][1] = $langs->trans("Settings"); - // $head[$h][2] = 'settings'; - // $h++; - - // $head[$h][0] = dol_buildpath("/hrm/admin/about.php", 1); - // $head[$h][1] = $langs->trans("About"); - // $head[$h][2] = 'about'; - // $h++; - complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm'); - complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment', 'remove'); return $head; @@ -77,7 +66,7 @@ function establishment_prepare_head($object) */ function hrm_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf; $langs->load('hrm'); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index f5572753854..7a7df6bf398 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -360,6 +360,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', } else { $objectid = $object; // $objectid can be X or 'X,Y,Z' } + if ($objectid == "-1") { + $objectid = 0; + } if ($objectid) { $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 1b65074a82e..0cdb8e9bfae 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -139,7 +139,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3102__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/list.php?mainmenu=products', 'List', 1, 'stocks', '$user->rights->stock->lire', '', 2, 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 ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/movement_list.php?mainmenu=products', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __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 ('', 'isModEnabled("stock") && isModEnabled("supplier_order")', __HANDLER__, 'left', 3105__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/replenish.php?mainmenu=products', 'Replenishments', 1, 'stocks', '$user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire', '', 2, 4, __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 ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3106__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/massstockmove.php?init=1&mainmenu=products', 'MassStockTransferShort', 1, 'stocks', '$user->rights->stock->mouvement->creer', '', 2, 5, __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 ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3106__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/stockatdate.php?mainmenu=products', 'StockAtDate', 1, 'stocks', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __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 ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3107__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/massstockmove.php?init=1&mainmenu=products', 'MassStockTransferShort', 1, 'stocks', '$user->rights->stock->mouvement->creer', '', 2, 5, __ENTITY__); -- Product - Categories insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("categorie")', __HANDLER__, 'left', 3200__+MAX_llx_menu__, 'products', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?mainmenu=products&leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->hasRight("categorie","lire")', '', 2, 4, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 961004c8ba8..091f2b7e969 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -375,7 +375,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t } if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { // Entry in accountancy journal for each bank account - $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', 'accountancy', 'accountancy', 10); + $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', 'accountancy', 'accountancy_journal', 10); // Multi journal $sql = "SELECT rowid, code, label, nature"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 247f06a90d1..f87e01f75cd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1677,7 +1677,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef // Journals if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { - $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', '', ''); + $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'accountancy_journal'); // Multi journal $sql = "SELECT rowid, code, label, nature"; diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 07405c9f7ad..3e947b6ed93 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -32,7 +32,7 @@ class mailing_partnership extends MailingTargets public $require_admin = 0; - public $require_module = array(); // This module allows to select by categories must be also enabled if category module is not activated + public $require_module = array('partnership'); // This module allows to select by categories must be also enabled if category module is not activated /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 39d2074d8e6..982d7a4ba85 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -364,6 +364,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Displays notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; + // Extrafields in note + if (!empty($conf->global->INVOICE_ADD_EXTRAFIELD_IN_NOTE)) { + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + } + if ($notetoshow) { $tab_top -= 2; diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 92bf4919255..54557539b26 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -326,6 +326,10 @@ if ($massaction == 'edit_extrafields') { if (!empty($extrafields_list)) { $myParamExtra = $object->showOptionals($extrafields, 'create'); + foreach ($extrafields_list as $extraKey => $extraLabel) { + $extrafields_list[$extraKey] = $langs->trans($extraLabel); + } + $formquestion[] = array( 'type' => 'other', 'value' => $form->selectarray('extrafield-key-to-update', $extrafields_list, GETPOST('extrafield-key-to-update'), 1) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 321a2a44672..aaf568fc724 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -423,7 +423,8 @@ if ($nolinesbefore) { $coldisplay++; ?> - "> + global->MAIN_OBJECTLINE_CREATE_EMPTY_QTY_BY_DEFAULT) ? 1 : ''); ?> + "> displayCanvasExists($action)) { print ''.$langs->trans("DefaultWarehouse").''; print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"'); print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse', 'int'), 'fk_default_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'minwidth300 widthcentpercentminusxx maxwidth500'); - print ' '; + print ' '; print ''; print ''; print ''; @@ -2034,7 +2034,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("DefaultWarehouse").''; print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"'); print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1); - print ' '; + print ' '; + print ''; print ''; /* print "".''.$langs->trans("StockLimit").''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b703340be37..cc773dcf6de 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3101,11 +3101,12 @@ class Product extends CommonObject if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) { // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice. $adeduire = 0; - $sql = "SELECT sum(fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd "; - $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid "; + $sql = "SELECT SUM(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd "; + $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid"; $sql .= " JOIN ".$this->db->prefix()."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; - $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid "; + $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid"; $sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id); + dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); $resql = $this->db->query($sql); if ($resql) { @@ -3122,11 +3123,12 @@ class Product extends CommonObject // For every order having invoice already validated we need to decrease stock cause it's in physical stock $adeduire = 0; - $sql = 'SELECT sum(fd.qty) as count FROM '.MAIN_DB_PREFIX.'facturedet as fd '; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture as f ON fd.fk_facture = f.rowid '; - $sql .= ' JOIN '.MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'commande as c ON el.fk_source = c.rowid '; - $sql .= ' WHERE c.fk_statut IN ('.$this->db->sanitize($filtrestatut).') AND f.fk_statut > '.Facture::STATUS_DRAFT.' AND fd.fk_product = '.((int) $this->id); + $sql = "SELECT sum(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd "; + $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON fd.fk_facture = f.rowid"; + $sql .= " JOIN ".MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; + $sql .= " JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid"; + $sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND f.fk_statut > ".Facture::STATUS_DRAFT." AND fd.fk_product = ".((int) $this->id); + dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); $resql = $this->db->query($sql); if ($resql) { @@ -3134,6 +3136,9 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); $adeduire += $obj->count; } + } else { + $this->error = $this->db->error(); + return -1; } $this->stats_commande['qty'] -= $adeduire; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 1fcd4e11792..5baf343556e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -201,7 +201,7 @@ if (empty($reshook)) { $object->label = GETPOST("libelle"); $object->fk_parent = GETPOST("fk_parent"); $object->fk_project = GETPOST('projectid'); - $object->description = GETPOST("desc"); + $object->description = GETPOST("desc", 'restricthtml'); $object->statut = GETPOST("statut"); $object->lieu = GETPOST("lieu"); $object->address = GETPOST("address"); diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 03e718b2c0b..4ac1aadc20f 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -270,17 +270,17 @@ if (!empty($searchCategoryWarehouseList)) { $listofcategoryid = ''; foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) { if (intval($searchCategoryWarehouse) == -2) { - $searchCategoryWarehouseSqlList[] = "NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse)"; + $searchCategoryWarehouseSqlList[] = " NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)"; } elseif (intval($searchCategoryWarehouse) > 0) { if ($searchCategoryWarehouseOperator == 0) { - $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; + $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; } else { $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); } } } if ($listofcategoryid) { - $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } if ($searchCategoryWarehouseOperator == 1) { if (!empty($searchCategoryWarehouseSqlList)) { diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 039c6ff9e4a..9fabf33fee7 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -579,7 +579,7 @@ print ''.$langs->trans("ReplenishmentStatusDesc").'< //$link = ''.$langs->trans("MenuNewWarehouse").''; -if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { +if (empty($fk_entrepot) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; } print '

'; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 7d9fce8aa48..0e16bf8d68b 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -145,8 +145,9 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined $sql .= " SUM(ps.reel) AS stock"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE w.entity IN (".getEntity('stock').")"; - $sql .= " AND w.rowid = ps.fk_entrepot"; + $sql .= " AND w.rowid = ps.fk_entrepot AND p.rowid = ps.fk_product"; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")"; } @@ -156,6 +157,12 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined if (! empty($search_fk_warehouse)) { $sql .= " AND ps.fk_entrepot IN (".$db->sanitize(join(",", $search_fk_warehouse)).")"; } + if ($search_ref) { + $sql .= natural_search("p.ref", $search_ref); + } + if ($search_nom) { + $sql .= natural_search("p.label", $search_nom); + } $sql .= " GROUP BY fk_product, fk_entrepot"; //print $sql; @@ -195,8 +202,9 @@ if ($date && $dateIsValid) { $sql = "SELECT sm.fk_product, sm.fk_entrepot, SUM(sm.value) AS stock, COUNT(sm.rowid) AS nbofmovement"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as sm"; $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE w.entity IN (".getEntity('stock').")"; - $sql .= " AND w.rowid = sm.fk_entrepot"; + $sql .= " AND w.rowid = sm.fk_entrepot AND p.rowid = sm.fk_product "; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")"; } @@ -211,7 +219,14 @@ if ($date && $dateIsValid) { if (!empty($search_fk_warehouse)) { $sql .= " AND sm.fk_entrepot IN (".$db->sanitize(join(",", $search_fk_warehouse)).")"; } + if ($search_ref) { + $sql .= " AND p.ref LIKE '%".$db->escape($search_ref)."%' "; + } + if ($search_nom) { + $sql .= " AND p.label LIKE '%".$db->escape($search_nom)."%' "; + } $sql .= " GROUP BY sm.fk_product, sm.fk_entrepot"; + $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index ba4dc956d08..80fbfb69bf0 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -1,8 +1,9 @@ * Copyright (C) 2007 Rodolphe Quiedeville - * Copyright (C) 2010-2012 Destailleur Laurent - * Copyright (C) 2014 Henry Florian + * Copyright (C) 2010-2012 Destailleur Laurent + * Copyright (C) 2014 Henry Florian + * Copyright (C) 2023 Benjamin Falière * * 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 @@ -136,6 +137,8 @@ if (empty($reshook)) { $object->label = GETPOST("libelle-" . $key); $object->description = dol_htmlcleanlastbr(GETPOST("desc-" . $key, 'restricthtml')); $object->other = dol_htmlcleanlastbr(GETPOST("other-" . $key, 'restricthtml')); + + $object->update($object->id, $user); } else { $object->multilangs[$key]["label"] = GETPOST("libelle-" . $key); $object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-" . $key, 'restricthtml')); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9c4e47037c2..ff29924edec 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -485,7 +485,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess); print ''; print ' '; -print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone'); print ''; print ''; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index bff135b713f..481652a5349 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -399,7 +399,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1); print ''; print ' '; -print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone'); print ''; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 1d3a6ef3c2c..daf1dd0ac7b 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -499,7 +499,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess); print ''; print ' '; -print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone'); print ''; print ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c281ea45e22..b5153689158 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -777,7 +777,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Budget - print ''.$langs->trans("Budget").''; + print ''.$langs->trans("Budget").''; print ''; print ' '.$langs->getCurrencySymbol($conf->currency); print ''; @@ -1148,7 +1148,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Budget - print ''.$langs->trans("Budget").''; + print ''.$langs->trans("Budget").''; print ''; print $langs->getCurrencySymbol($conf->currency); print ''; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 784ff436311..16d60a15033 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -411,7 +411,7 @@ if ($id > 0 || !empty($ref)) { print $form->select_dolusers((GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); print ''; print ''; - $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid'); + $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position'); print ''; print ''; print ''; @@ -436,7 +436,7 @@ if ($id > 0 || !empty($ref)) { $nbofcontacts = $form->num; print ''; print ''; - $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'rowid'); + $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'position'); print ''; print ' '/adherents/class/adherent.class.php', - 'Don' => '/don/class/don.class.php', + 'Don' => array('file' => '/don/class/don.class.php', 'enabled' => isModEnabled('don')), 'Societe' => '/societe/class/societe.class.php', //'Categorie' => '/categories/class/categorie.class.php', 'ActionComm' => '/comm/action/class/actioncomm.class.php', @@ -305,7 +305,7 @@ if (empty($reshook)) { 'Delivery' => '/delivery/class/delivery.class.php', 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', - 'Ticket' => '/ticket/class/ticket.class.php', + 'Ticket' => array('file' => '/ticket/class/ticket.class.php', 'enabled' => isModEnabled('ticket')), 'User' => '/user/class/user.class.php', 'Account' => '/compta/bank/class/account.class.php', 'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php' @@ -313,6 +313,13 @@ if (empty($reshook)) { //First, all core objects must update their tables foreach ($objects as $object_name => $object_file) { + if (is_array($object_file)) { + if (empty($object_file['enabled'])) { + continue; + } + $object_file = $object_file['file']; + } + require_once DOL_DOCUMENT_ROOT.$object_file; if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 8ea21b91c97..cf7b4d5d912 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -6466,7 +6466,7 @@ input.select2-input { } div.select2-drop-above { - background: var(--colorbackvmenu1);e + background: var(--colorbackvmenu1); -webkit-box-shadow: none !important; box-shadow: none !important; } diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 74208efda17..bfe700a588c 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -571,4 +571,3 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { border: 1px solid #e0e0e0; } } -} diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index acbf03b5ba9..afc2a685048 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -119,7 +119,8 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); //var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) -if (empty($user->rights->societe->client->voir) || $user->socid) { + +/*if (empty($user->rights->societe->client->voir) || $user->socid) { $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png'; } else { @@ -182,7 +183,7 @@ if (!$mesg) { $px3->SetTitle($langs->trans("AmountAverage")); $px3->draw($filename_avg, $fileurl_avg); -} +}*/