diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php
index da7e7c4c0fc..11362b4fb3c 100644
--- a/htdocs/compta/facture/info.php
+++ b/htdocs/compta/facture/info.php
@@ -39,6 +39,7 @@ $id = GETPOST("facid", "int");
$ref = GETPOST("ref", 'alpha');
$object = new Facture($db);
+
$extrafields = new ExtraFields($db);
// Fetch optionals attributes and labels
@@ -62,14 +63,6 @@ $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $field
* 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');
@@ -77,6 +70,13 @@ $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $help_url);
+if (empty($object->id)) {
+ $langs->load('errors');
+ echo ''.$langs->trans("ErrorRecordNotFound").'
';
+ llxFooter();
+ exit;
+}
+
$object->fetch_thirdparty();
$object->info($object->id);
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 8c79ef337f8..f120e7b67fe 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -2099,7 +2099,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') {
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 9a5ab68f898..5f945db12ff 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5346,7 +5346,7 @@ function price2num($amount, $rounding = '', $option = 0)
} 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;
+ $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') {
@@ -5354,6 +5354,7 @@ function price2num($amount, $rounding = '', $option = 0)
} elseif (is_numeric($rounding)) {
$nbofdectoround = (int) $rounding;
}
+
//print " RR".$amount.' - '.$nbofdectoround.'
';
if (dol_strlen($nbofdectoround)) {
$amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 1b051a6081f..1ad039882bf 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -2087,10 +2087,10 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm
return '';
}
if (empty($hidedetails) || $hidedetails > 1) {
- if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) {
+ if (!empty($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)) {
$prev_progress = 0;
- if (method_exists($object, 'get_prev_progress')) {
- $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
+ if (method_exists($object->lines[$i], 'get_prev_progress')) {
+ $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
}
$result = round($object->lines[$i]->situation_percent - $prev_progress, 1).'%';
} else {
diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php
index 1bb58ca98b0..c70124d9d18 100644
--- a/htdocs/holiday/month_report.php
+++ b/htdocs/holiday/month_report.php
@@ -147,8 +147,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/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php
index 803fb3bf5b7..de31f3f0283 100644
--- a/htdocs/mrp/mo_movements.php
+++ b/htdocs/mrp/mo_movements.php
@@ -468,7 +468,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$sql .= natural_search('e.rowid', $search_warehouse, 2);
}
if (!empty($search_user)) {
- $sql .= natural_search('u.login', $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);
diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php
index b6d5ae78407..c4316e981a0 100644
--- a/htdocs/product/stock/movement_card.php
+++ b/htdocs/product/stock/movement_card.php
@@ -489,7 +489,7 @@ 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);
+ $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user);
}
if (!empty($search_batch)) {
$sql .= natural_search('m.batch', $search_batch);
diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php
index b46eb9e0112..5b8315caf8c 100644
--- a/htdocs/product/stock/movement_list.php
+++ b/htdocs/product/stock/movement_list.php
@@ -543,7 +543,7 @@ 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);
+ $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user);
}
if (!empty($search_batch)) {
$sql .= natural_search('m.batch', $search_batch);
diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php
index 17490e330bb..6eacc788982 100644
--- a/htdocs/product/stock/replenishorders.php
+++ b/htdocs/product/stock/replenishorders.php
@@ -144,7 +144,7 @@ if ($snom) {
$sql .= natural_search('s.nom', $snom);
}
if ($suser) {
- $sql .= natural_search('u.login', $suser);
+ natural_search(array('u.lastname', 'u.firstname', 'u.login'), $suser);
}
if ($sttc) {
$sql .= natural_search('cf.total_ttc', $sttc, 1);
diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php
index 1de719796d2..e0f84f24df4 100644
--- a/htdocs/reception/card.php
+++ b/htdocs/reception/card.php
@@ -898,7 +898,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
@@ -906,55 +913,70 @@ 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' => price2num(GETPOST($qty), 'MS'), 'ent' => GETPOST($ent, 'int'), 'pu' => price2num(GETPOST($pu), 'MU'), 'comment' => GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'));
}
// with batch module enabled
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, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int'));
- $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int'));
- $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' => price2num(GETPOST($qty), 'MS'), 'ent' =>GETPOST($ent, 'int'), 'pu' => price2num(GETPOST($pu), 'MU'), '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, it means that 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' => price2num(GETPOST($qty), 'MS'), 'ent' =>GETPOST($ent, 'int'), 'pu' => price2num(GETPOST($pu), 'MU'), '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 '