Merge branch '13.0up' into 13.0
This commit is contained in:
commit
aa3f473ebc
@ -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++;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -108,14 +108,6 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer)
|
||||
* View
|
||||
*/
|
||||
|
||||
if (empty($object->id)) {
|
||||
llxHeader();
|
||||
$langs->load('errors');
|
||||
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
|
||||
llxFooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses');
|
||||
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
@ -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 '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
|
||||
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 '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
|
||||
llxFooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
$object->info($object->id);
|
||||
|
||||
$head = facture_prepare_head($object);
|
||||
|
||||
@ -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 != '')
|
||||
|
||||
@ -1936,7 +1936,7 @@ class BonPrelevement extends CommonObject
|
||||
$XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <PmtId>'.$CrLf;
|
||||
// Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
|
||||
$XML_DEBITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
$XML_DEBITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
$XML_DEBITOR .= ' </PmtId>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <InstdAmt Ccy="EUR">'.round($row_somme, 2).'</InstdAmt>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <DrctDbtTx>'.$CrLf;
|
||||
@ -1968,7 +1968,7 @@ class BonPrelevement extends CommonObject
|
||||
$XML_DEBITOR .= ' </DbtrAcct>'.$CrLf;
|
||||
$XML_DEBITOR .= ' <RmtInf>'.$CrLf;
|
||||
// A string with some information on payment - 140 max
|
||||
$XML_DEBITOR .= ' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).'</Ustrd>'.$CrLf; // 140 max
|
||||
$XML_DEBITOR .= ' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).'</Ustrd>'.$CrLf; // 140 max
|
||||
$XML_DEBITOR .= ' </RmtInf>'.$CrLf;
|
||||
$XML_DEBITOR .= ' </DrctDbtTxInf>'.$CrLf;
|
||||
return $XML_DEBITOR;
|
||||
@ -1978,7 +1978,7 @@ class BonPrelevement extends CommonObject
|
||||
$XML_CREDITOR .= ' <CdtTrfTxInf>'.$CrLf;
|
||||
$XML_CREDITOR .= ' <PmtId>'.$CrLf;
|
||||
// Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
|
||||
$XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
$XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||
$XML_CREDITOR .= ' </PmtId>'.$CrLf;
|
||||
$XML_CREDITOR .= ' <Amt>'.$CrLf;
|
||||
$XML_CREDITOR .= ' <InstdAmt Ccy="EUR">'.round($row_somme, 2).'</InstdAmt>'.$CrLf;
|
||||
@ -2015,7 +2015,7 @@ class BonPrelevement extends CommonObject
|
||||
$XML_CREDITOR .= ' </CdtrAcct>'.$CrLf;
|
||||
$XML_CREDITOR .= ' <RmtInf>'.$CrLf;
|
||||
// A string with some information on payment - 140 max
|
||||
$XML_CREDITOR .= ' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).'</Ustrd>'.$CrLf; // 140 max
|
||||
$XML_CREDITOR .= ' <Ustrd>'.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).'</Ustrd>'.$CrLf; // 140 max
|
||||
$XML_CREDITOR .= ' </RmtInf>'.$CrLf;
|
||||
$XML_CREDITOR .= ' </CdtTrfTxInf>'.$CrLf;
|
||||
return $XML_CREDITOR;
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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.'<br>';
|
||||
if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.
|
||||
else return 'ErrorBadParameterProvidedToFunction';
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
@ -1146,6 +1165,7 @@ if ($action == 'create')
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
$extralabelslines = $extrafields->attributes[$line->table_element];
|
||||
//Display lines extrafields
|
||||
if (is_array($extralabelslines) && count($extralabelslines) > 0)
|
||||
{
|
||||
@ -1162,6 +1182,9 @@ if ($action == 'create')
|
||||
$srcLine->fetch_optionals(); // fetch extrafields also available in orderline
|
||||
$line->fetch_optionals();
|
||||
|
||||
if (empty($line->array_options) && !empty($dispatchLines[$indiceAsked]['array_options'])) {
|
||||
$line->array_options = $dispatchLines[$indiceAsked]['array_options'];
|
||||
}
|
||||
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
|
||||
|
||||
print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), $indiceAsked);
|
||||
@ -1938,6 +1961,7 @@ if ($action == 'create')
|
||||
print "</tr>";
|
||||
|
||||
// Display lines extrafields
|
||||
$extralabelslines = $extrafields->attributes[$lines[$i]->table_element];
|
||||
if (is_array($extralabelslines) && count($extralabelslines) > 0)
|
||||
{
|
||||
$colspan = empty($conf->productbatch->enabled) ? 8 : 9;
|
||||
|
||||
@ -149,7 +149,7 @@ if (empty($reshook))
|
||||
$object->country_id = $country_id;
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
if ($search_ref) $sql .= natural_search('sp.ref', $search_ref);
|
||||
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
||||
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_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1);
|
||||
if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1);
|
||||
if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1);
|
||||
|
||||
@ -444,7 +444,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ if (empty($reshook)) {
|
||||
$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));
|
||||
|
||||
// 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 (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user