diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index e54ac0bc31a..e081b126dfe 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -302,7 +302,7 @@ if (empty($reshook)) { $object->public = GETPOST("public", 'alpha'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) { $error++; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 9512492004c..2f3fd19240a 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -166,7 +166,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) { $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; $ret = $object->update($user); diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 38969d65182..8b0af655706 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -150,7 +150,7 @@ if ($action == 'update' && $user->rights->asset->write) $object->note = trim($comment); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; $ret = $object->update($user); diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index f4b7e12cc30..999956e574a 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -95,7 +95,7 @@ if ($action == 'update' && $user->rights->categorie->creer) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } if (!$error && empty($object->error)) { - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error && $object->update($user) > 0) { diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 2a0371d4615..e14878f5cfc 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -560,7 +560,7 @@ if (empty($reshook) && $action == 'update') } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 30e483fdfa9..6832a92216b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -239,7 +239,7 @@ if ($action == 'update') if (!$error) { // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); } if (!$error) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 71419fb7676..c517ddb2961 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1593,6 +1593,11 @@ if (empty($reshook)) $discount->tva_tx = $lines[$i]->tva_tx; $discount->fk_user = $user->id; $discount->description = $desc; + $discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice); + $discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht); + $discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva); + $discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc); + $discountid = $discount->create($user); if ($discountid > 0) { $result = $object->insert_discount($discountid); // This include link_to_invoice diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 0a07db12cbd..6b8758bc472 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -108,14 +108,6 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ -if (empty($object->id)) { - llxHeader(); - $langs->load('errors'); - echo '
'.$langs->trans("ErrorRecordNotFound").'
'; - llxFooter(); - exit; -} - $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index ccf6dca135c..abfbfabea21 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -38,29 +38,30 @@ $langs->loadLangs(array('companies', 'bills')); $id = GETPOST("facid", "int"); $ref = GETPOST("ref", 'alpha'); +$object = new Facture($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + /* * View */ -if (empty($object->id)) { - llxHeader(); - $langs->load('errors'); - echo '
'.$langs->trans("ErrorRecordNotFound").'
'; - llxFooter(); - exit; -} - $form = new Form($db); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); -$object = new Facture($db); -$object->fetch($id, $ref); -$object->fetch_thirdparty(); +if (empty($object->id)) { + $langs->load('errors'); + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; + llxFooter(); + exit; +} +$object->fetch_thirdparty(); $object->info($object->id); $head = facture_prepare_head($object); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fb27f03d72a..40b672cbd9e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -537,7 +537,7 @@ if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_status != '-1' && $search_status != '') diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 721d7c10111..92c0db1f55e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1936,7 +1936,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) - $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1968,7 +1968,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; // A string with some information on payment - 140 max - $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; return $XML_DEBITOR; @@ -1978,7 +1978,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) - $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.round($row_somme, 2).''.$CrLf; @@ -2015,7 +2015,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; // A string with some information on payment - 140 max - $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).''.$CrLf; // 140 max $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; return $XML_CREDITOR; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 06b5bb36c40..0c95ecb7fd4 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -403,7 +403,7 @@ if (empty($reshook)) $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 7397cf8b61f..45454485b70 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -95,7 +95,8 @@ $search_roles = GETPOST("search_roles", 'array'); $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); -if ($search_status == '') $search_status = 1; // always display active customer first +if ($search_status === '') $search_status = 1; // always display active customer first +if ($search_no_email === '') $search_no_email = -1; $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 1ee8dc4b0f2..70b79ffbefc 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1232,6 +1232,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' continue; } + if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) { + $nbignored++; + setEventMessage($langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref)); + continue; + } + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; @@ -1268,7 +1274,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + elseif ($nbok > 0) setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); $db->commit(); } else { $db->rollback(); diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index ceb221b4870..593f4fa4dbc 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -78,5 +78,9 @@ if (($action == 'set') && !empty($id)) { $format = 'int'; + $object->table_element = $tablename; + $object->id = $id; + $object->fields[$field] = array('type' => $format, 'enabled' => 1); + $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index aede17c657b..6cee5a01b67 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2004,7 +2004,8 @@ class ExtraFields foreach ($extralabels as $key => $value) { if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue; - if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key)) continue; + //when unticking boolean field, it's not set in POST + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') continue; $key_type = $this->attributes[$object->table_element]['type'][$key]; if ($key_type == 'separate') continue; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 944b5761bf6..16cbf52613f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1836,7 +1836,7 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id"; $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ac019f33bc2..ff1dcc535f3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4944,20 +4944,18 @@ function price2num($amount, $rounding = '', $option = 0) $nbofdectoround = ''; if ($rounding == 'MU') { $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; - } - elseif ($rounding == 'MT') { + } elseif ($rounding == 'MT') { $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; - } - elseif ($rounding == 'MS') { - $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; - } - elseif ($rounding == 'CU') { + } elseif ($rounding == 'MS') { + $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5; + } elseif ($rounding == 'CU') { $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8); // TODO Use param of currency - } - elseif ($rounding == 'CT') { + } elseif ($rounding == 'CT') { $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8); // TODO Use param of currency + } elseif (is_numeric($rounding)) { + $nbofdectoround = $rounding; } - elseif (is_numeric($rounding)) $nbofdectoround = $rounding; + //print " RR".$amount.' - '.$nbofdectoround.'
'; if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0. else return 'ErrorBadParameterProvidedToFunction'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 6a17f4b6d44..54c7d9060ab 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1927,7 +1927,7 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) { $prev_progress = 0; - if (method_exists($object, 'get_prev_progress')) + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index dd7de85430e..104c0d72bd1 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -159,7 +159,7 @@ if ($action == 'update') $object->modepaymentid = (int) GETPOST('modepayment', 'int'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if ($object->update($user) > 0) { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 83e87e9b0f6..ab5fbe05e03 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -461,7 +461,7 @@ if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode); if ($search_paymentcond > 0) $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond); diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 922c313840b..6f8b0830b2a 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -139,8 +139,11 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; $sql .= " WHERE cp.rowid > 0"; $sql .= " AND cp.statut = ".Holiday::STATUS_APPROVED; -$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; - +$sql .= " AND ("; +$sql .= " (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; +$sql .= " OR"; // For leave over several months +$sql .= " (date_format(cp.date_debut, '%Y-%m') < '".$db->escape($year_month)."' AND date_format(cp.date_fin, '%Y-%m') > '".$db->escape($year_month)."') "; +$sql .= " )"; if (!empty($search_ref)) { $sql .= natural_search('cp.ref', $search_ref); } diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index eb2cd89adf1..ef96e72cc9d 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays +ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 600563f6cfd..c1d51bea6b0 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -428,7 +428,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); - if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); + if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index a708ace0c22..813c765aa6f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -172,9 +172,9 @@ if (empty($reshook)) $object->phone = GETPOST("phone"); $object->fax = GETPOST("fax"); - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + if ($ret < 0) $error++; if (!$error) { $ret = $object->update($id, $user); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index cf3cc67bdc2..dd9e86f9737 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -464,7 +464,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 47e28939e05..fa9cd293e1a 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -490,7 +490,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index c925d7f0f62..64f77eead74 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -505,11 +505,6 @@ if ($includeproductswithoutdesiredqty == 'on') { $includeproductswithoutdesiredqtychecked = 'checked'; } -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index c73c7b1ca39..9ee5ad40fd5 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -132,7 +132,7 @@ if (!$user->rights->societe->client->voir && !$socid) { } if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); -if ($suser) $sql .= natural_search('u.login', $suser); +if ($suser) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); $sql .= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index d7c0f874383..1f1bbc96336 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -520,7 +520,6 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow //$tmparray = dol_getdate($dayinloop); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index df63c805948..3f496de2f66 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -266,7 +266,7 @@ if (empty($reshook)) $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 1b086ee2c69..54d6d09b230 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -102,7 +102,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) $object->progress = price2num(GETPOST('progress', 'alphanohtml')); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 40444faacb7..23e74a1cc36 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -876,7 +876,14 @@ if ($action == 'create') // Reception lines $numAsked = 0; + + /** + * @var array $suffix2numAsked map HTTP query parameter suffixes (like '1_0') to line indices so that + * extrafields from HTTP query can be assigned to the correct dispatch line + */ + $suffix2numAsked = array(); $dispatchLines = array(); + foreach ($_POST as $key => $value) { // If create form is coming from the button "Create Reception" of previous page @@ -884,14 +891,16 @@ if ($action == 'create') $reg = array(); if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $numAsked++; + $paramSuffix = $reg[1] . '_' . $reg[2]; + $suffix2numAsked[$paramSuffix] = $numAsked; // $numline=$reg[2] + 1; // line of product $numline = $numAsked; - $prod = "product_".$reg[1].'_'.$reg[2]; - $qty = "qty_".$reg[1].'_'.$reg[2]; - $ent = "entrepot_".$reg[1].'_'.$reg[2]; - $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount - $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; + $prod = "product_" . $paramSuffix; + $qty = "qty_" . $paramSuffix; + $ent = "entrepot_" . $paramSuffix; + $pu = "pu_" . $paramSuffix; // This is unit price including discount + $fk_commandefourndet = "fk_commandefourndet_" . $paramSuffix; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); } @@ -899,41 +908,51 @@ if ($action == 'create') if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $numAsked++; + $paramSuffix = $reg[1] . '_' . $reg[2]; + $suffix2numAsked[$paramSuffix] = $numAsked; // eat-by date dispatch // $numline=$reg[2] + 1; // line of product $numline = $numAsked; - $prod = 'product_batch_'.$reg[1].'_'.$reg[2]; - $qty = 'qty_'.$reg[1].'_'.$reg[2]; - $ent = 'entrepot_'.$reg[1].'_'.$reg[2]; - $pu = 'pu_'.$reg[1].'_'.$reg[2]; - $lot = 'lot_number_'.$reg[1].'_'.$reg[2]; - $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); - $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); - $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; + $prod = 'product_batch_' . $paramSuffix; + $qty = 'qty_' . $paramSuffix; + $ent = 'entrepot_' . $paramSuffix; + $pu = 'pu_' . $paramSuffix; + $lot = 'lot_number_' . $paramSuffix; + $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$paramSuffix.'month'], $_POST['dluo_'.$paramSuffix.'day'], $_POST['dluo_'.$paramSuffix.'year']); + $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$paramSuffix.'month'], $_POST['dlc_'.$paramSuffix.'day'], $_POST['dlc_'.$paramSuffix.'year']); + $fk_commandefourndet = 'fk_commandefourndet_'.$paramSuffix; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } // If create form is coming from same page post was sent but an error occured if (preg_match('/^productid([0-9]+)$/i', $key, $reg)) { $numAsked++; + $paramSuffix = $reg[1]; + $suffix2numAsked[$paramSuffix] = $numAsked; // eat-by date dispatch // $numline=$reg[2] + 1; // line of product $numline = $numAsked; - $prod = 'productid'.$reg[1]; - $comment = 'comment'.$reg[1]; - $qty = 'qtyl'.$reg[1]; - $ent = 'entl'.$reg[1]; - $pu = 'pul'.$reg[1]; - $lot = 'batch'.$reg[1]; - $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$reg[1].'month', 'int'), GETPOST('dluo'.$reg[1].'day', 'int'), GETPOST('dluo'.$reg[1].'year', 'int')); - $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$reg[1].'month', 'int'), GETPOST('dlc'.$reg[1].'day', 'int'), GETPOST('dlc'.$reg[1].'year', 'int')); - $fk_commandefourndet = 'fk_commandefournisseurdet'.$reg[1]; + $prod = 'productid'.$paramSuffix; + $comment = 'comment'.$paramSuffix; + $qty = 'qtyl'.$paramSuffix; + $ent = 'entl'.$paramSuffix; + $pu = 'pul'.$paramSuffix; + $lot = 'batch'.$paramSuffix; + $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$paramSuffix.'month', 'int'), GETPOST('dluo'.$paramSuffix.'day', 'int'), GETPOST('dluo'.$paramSuffix.'year', 'int')); + $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$paramSuffix.'month', 'int'), GETPOST('dlc'.$paramSuffix.'day', 'int'), GETPOST('dlc'.$paramSuffix.'year', 'int')); + $fk_commandefourndet = 'fk_commandefournisseurdet'.$paramSuffix; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST($comment), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } } + // If extrafield values are passed in the HTTP query, assign them to the correct dispatch line + // Note that if an extrafield with the same name exists in the origin supplier order line, the value + // from the HTTP query will be ignored + foreach ($suffix2numAsked as $suffix => $n) { + $dispatchLines[$n]['array_options'] = $extrafields->getOptionalsFromPost('commande_fournisseur_dispatch', '_' . $suffix, ''); + } print '