*
* 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
@@ -35,7 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'multicurrency'));
-
$socid = 0;
if ($user->socid > 0) {
$socid = $user->socid;
@@ -45,7 +46,6 @@ if (!$user->rights->banque->transfer) {
}
$action = GETPOST('action', 'aZ09');
-$error = 0;
$hookmanager->initHooks(array('banktransfer'));
@@ -60,114 +60,140 @@ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if ($action == 'add') {
- $langs->load("errors");
+ $langs->load('errors');
+ $i = 1;
- $dateo = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
- $label = GETPOST('label', 'alpha');
- $amount = price2num(GETPOST('amount', 'alpha'), 'MT', 2);
- $amountto = price2num(GETPOST('amountto', 'alpha'), 'MT', 2);
+ while ($i < 20) {
+ $dateo[$i] = dol_mktime(12, 0, 0, GETPOST($i.'_month', 'int'), GETPOST($i.'_day', 'int'), GETPOST($i.'_year', 'int'));
+ $label[$i] = GETPOST($i.'_label', 'alpha');
+ $amount[$i] = intval(price2num(GETPOST($i.'_amount', 'alpha'), 'MT', 2));
+ $amountto[$i] = price2num(GETPOST($i.'_amountto', 'alpha'), 'MT', 2);
+ $accountfrom[$i] = intval(GETPOST($i.'_account_from', 'int'));
+ $accountto[$i] = intval(GETPOST($i.'_account_to', 'int'));
+ $type[$i] = GETPOST($i.'_type', 'int');
+ $errori[$i] = 0;
- if (!$label) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors');
+ $tabnum[$i] = 0;
+ if (!empty($label[$i]) || !empty($type[$i]) || !($amount[$i] <= 0) || !($accountfrom[$i] < 0) || !($accountto[$i] < 0)) {
+ $tabnum[$i] = 1;
+ }
+ $i++;
}
- if (!$amount) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
- }
- if (!GETPOST('account_from', 'int')) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), null, 'errors');
- }
- if (!GETPOST('account_to', 'int')) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferTo")), null, 'errors');
- }
- if (!$error) {
- require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
- $accountfrom = new Account($db);
- $accountfrom->fetch(GETPOST('account_from', 'int'));
+ $n = 1;
+ while ($n < 20) {
+ if ($tabnum[$n] === 1) {
+ if ($accountfrom[$n] < 0) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("TransferFrom")), null, 'errors');
+ }
+ if ($accountto[$n] < 0) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("TransferTo")), null, 'errors');
+ }
+ if (!$type[$n]) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("Type")), null, 'errors');
+ }
+ if (!$dateo[$n]) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("Date")), null, 'errors');
+ }
- $accountto = new Account($db);
- $accountto->fetch(GETPOST('account_to', 'int'));
+ if (!($label[$n])) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' . $langs->transnoentities("Description")), null, 'errors');
+ }
+ if (!($amount[$n])) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("Amount")), null, 'errors');
+ }
- if ($accountto->currency_code == $accountfrom->currency_code) {
- $amountto = $amount;
- } else {
- if (!$amountto) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors');
- }
- }
- if ($amountto < 0) {
- $error++;
- setEventMessages($langs->trans("AmountMustBePositive"), null, 'errors');
- }
-
- if ($accountto->id == $accountfrom->id) {
- $error++;
- setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors');
- }
-
- if (empty($error)) {
- $db->begin();
-
- $bank_line_id_from = 0;
- $bank_line_id_to = 0;
- $result = 0;
-
- // By default, electronic transfert from bank to bank
- $typefrom = 'PRE';
- $typeto = 'VIR';
- if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) {
- // This is transfer of change
- $typefrom = 'LIQ';
- $typeto = 'LIQ';
- }
-
- if (!$error) {
- $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, price2num(-1 * $amount), '', '', $user);
- }
- if (!($bank_line_id_from > 0)) {
- $error++;
- }
- if (!$error) {
- $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, $amountto, '', '', $user);
- }
- if (!($bank_line_id_to > 0)) {
- $error++;
- }
-
- if (!$error) {
- $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert');
- }
- if (!($result > 0)) {
- $error++;
- }
- if (!$error) {
- $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert');
- }
- if (!($result > 0)) {
- $error++;
- }
-
- if (!$error) {
- $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount, $langs->transnoentitiesnoconv("Currency".$conf->currency));
- $mesgs = str_replace('{s1}', ''.$accountfrom->label.'', $mesgs);
- $mesgs = str_replace('{s2}', ''.$accountto->label.'', $mesgs);
- setEventMessages($mesgs, null, 'mesgs');
- $db->commit();
- } else {
- setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors');
- $db->rollback();
+ if (!$errori[$n]) {
+ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+
+ $accountfrom = new Account($db);
+ $accountfrom->fetch(GETPOST($n.'_account_from', 'int'));
+
+ $accountto = new Account($db);
+ $accountto->fetch(GETPOST($n.'_account_to', 'int'));
+
+ if ($accountto->currency_code == $accountfrom->currency_code) {
+ $amountto[$n] = $amount[$n];
+ } else {
+ if (!$amountto[$n]) {
+ $error[$n]++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")).' #'.$n, null, 'errors');
+ }
+ }
+ if ($amountto[$n] < 0) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors');
+ }
+
+ if ($accountto->id == $accountfrom->id) {
+ $errori[$n]++;
+ setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors');
+ }
+ }
+
+ if ($errori[$n] == 0) {
+ $db->begin();
+
+ $bank_line_id_from = 0;
+ $bank_line_id_to = 0;
+ $result = 0;
+
+ // By default, electronic transfert from bank to bank
+ $typefrom = $type[$n];
+ $typeto = $type[$n];
+ if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) {
+ // This is transfer of change
+ $typefrom = 'LIQ';
+ $typeto = 'LIQ';
+ }
+
+ if (!$errori[$n]) {
+ $bank_line_id_from = $accountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user);
+ }
+ if (!($bank_line_id_from > 0)) {
+ $errori[$n]++;
+ }
+ if (!$errori[$n]) {
+ $bank_line_id_to = $accountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user);
+ }
+ if (!($bank_line_id_to > 0)) {
+ $errori[$n]++;
+ }
+
+ if (!$errori[$n]) {
+ $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert');
+ }
+ if (!($result > 0)) {
+ $errori++;
+ }
+ if (!$errori[$n]) {
+ $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert');
+ }
+ if (!($result > 0)) {
+ $errori[$n]++;
+ }
+ if (!$errori[$n]) {
+ $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency));
+ $mesgs = str_replace('{s1}', ''.$accountfrom->label.'', $mesgs);
+ $mesgs = str_replace('{s2}', ''.$accountto->label.'', $mesgs);
+ setEventMessages($mesgs, null, 'mesgs');
+ $db->commit();
+ } else {
+ setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors');
+ $db->rollback();
+ }
}
}
+ $n++;
}
}
-
-
/*
* View
*/
@@ -179,6 +205,7 @@ llxHeader('', $title, $help_url);
print '
+ ';
// End of page
llxFooter();
+
$db->close();
diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php
index 4b3c9b31322..41aa42195dc 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_list.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_list.php
@@ -211,7 +211,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 825de33bec6..d0c8ea7f1f5 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -300,7 +300,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index a7bc1e713ff..533d2a8a42e 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -425,7 +425,7 @@ if (isModEnabled('mailing')) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index b55e09bd252..50e26a55a68 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -279,7 +279,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php
index 945552753ea..81cb6599ea9 100644
--- a/htdocs/core/boxes/box_birthdays.php
+++ b/htdocs/core/boxes/box_birthdays.php
@@ -85,19 +85,19 @@ class box_birthdays extends ModeleBoxes
if ($user->rights->user->user->lire) {
$tmparray = dol_getdate(dol_now(), true);
- $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, 'birth' as typea, u.email, u.statut as status";
+ $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, date_format(u.birth, '%d') as daya, 'birth' as typea, u.email, u.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
$sql .= ' UNION ';
- $sql .= "SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, 'employment' as typea, u.email, u.statut as status";
+ $sql .= "SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, date_format(u.dateemployment, '%d') as daya, 'employment' as typea, u.email, u.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.dateemployment', 0, $tmparray['mon'], 0);
- $sql .= " ORDER BY DAY(datea) ASC";
+ $sql .= " ORDER BY daya ASC";
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php
index b59ea822731..9c02341a489 100644
--- a/htdocs/core/class/html.formmargin.class.php
+++ b/htdocs/core/class/html.formmargin.class.php
@@ -98,7 +98,7 @@ class FormMargin
}
$pv = $line->total_ht;
- $pa_ht = (($pv < 0 || ($pv == 0 && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
+ $pa_ht = (($pv < 0 || ($pv == 0 && $object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { // Special case for old situation mode
if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION)
|| ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) {
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index e0d7a8741a5..6c43c945b65 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -248,10 +248,15 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
public $export_icon;
+ /**
+ * @var array export enabled
+ */
+ public $export_enabled;
public $export_permission;
public $export_fields_array;
public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:login:rowid'
public $export_entities_array;
+ public $export_examplevalues_array;
public $export_help_array;
public $export_special_array; // special or computed field
public $export_dependencies_array;
@@ -273,9 +278,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
public $import_label;
public $import_icon;
-
public $import_entities_array;
public $import_tables_array;
+ public $import_tables_creator_array;
public $import_fields_array;
public $import_fieldshidden_array;
public $import_convertvalue_array;
diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php
index 4a8680502ae..d4900e18540 100644
--- a/htdocs/core/modules/modCategorie.class.php
+++ b/htdocs/core/modules/modCategorie.class.php
@@ -142,16 +142,16 @@ class modCategorie extends DolibarrModules
if (isModEnabled("societe")) {
$typeexample .= ($typeexample ? " / " : "")."4=Contact";
}
- if (!empty($conf->bank->enabled)) {
+ if (isModEnabled('bank')) {
$typeexample .= ($typeexample ? " / " : "")."5=Bank account";
}
if (isModEnabled('project')) {
$typeexample .= ($typeexample ? " / " : "")."6=Project";
}
- if (!empty($conf->user->enabled)) {
+ if (isModEnabled('user')) {
$typeexample .= ($typeexample ? " / " : "")."7=User";
}
- if (!empty($conf->bank->enabled)) {
+ if (isModEnabled('bank')) {
$typeexample .= ($typeexample ? " / " : "")."8=Bank line";
}
if (isModEnabled('stock')) {
@@ -411,7 +411,7 @@ class modCategorie extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7];
$this->export_label[$r] = 'CatUsersList';
$this->export_icon[$r] = $this->picto;
- $this->export_enabled[$r] = '!empty($conf->user->enabled)';
+ $this->export_enabled[$r] = 'isModEnabled("user")';
$this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export"));
$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'UserID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname');
$this->export_TypeFields_array[$r] = array('cat.rowid'=>"Numeric", 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.login'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text');
@@ -594,7 +594,7 @@ class modCategorie extends DolibarrModules
}
// 7 Users
- if (!empty($conf->user->enabled)) {
+ if (isModEnabled('user')) {
$r++;
$this->import_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7];
$this->import_label[$r] = "CatUsersLinks"; // Translation key
diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php
index 4a67003180f..5892cda191b 100644
--- a/htdocs/eventorganization/conferenceorbooth_list.php
+++ b/htdocs/eventorganization/conferenceorbooth_list.php
@@ -524,7 +524,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
//$sql .= ", COUNT(rc.rowid) as anotherfield";
diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php
index b9037a366c3..8f55a4e558c 100644
--- a/htdocs/eventorganization/conferenceorboothattendee_list.php
+++ b/htdocs/eventorganization/conferenceorboothattendee_list.php
@@ -274,7 +274,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (!empty($confOrBooth->id)) {
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index bcccc5b9aa3..c3d5fe0fb7d 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -4052,7 +4052,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result > 0) {
+ if ($result) {
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) {
diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php
index d45334eba9e..2c5f8d4980e 100644
--- a/htdocs/fourn/facture/list-rec.php
+++ b/htdocs/fourn/facture/list-rec.php
@@ -278,7 +278,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn_rec as f';
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 2baa2cade8c..5302d5de3b2 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -431,7 +431,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php
index 0be113d8205..ddcb4b55bd6 100644
--- a/htdocs/holiday/list.php
+++ b/htdocs/holiday/list.php
@@ -309,7 +309,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php
index a9749c46d7e..5dbddbd6ec6 100644
--- a/htdocs/hrm/evaluation_list.php
+++ b/htdocs/hrm/evaluation_list.php
@@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php
index b347c32848c..dad366d14f1 100644
--- a/htdocs/hrm/job_list.php
+++ b/htdocs/hrm/job_list.php
@@ -226,7 +226,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php
index 35f47f2a187..3b3931fcf64 100644
--- a/htdocs/hrm/position.php
+++ b/htdocs/hrm/position.php
@@ -363,7 +363,7 @@ if ($job->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
- $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+ $sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
@@ -906,7 +906,7 @@ function DisplayPositionList()
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
- $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+ $sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php
index f5740834da7..4644382416e 100644
--- a/htdocs/hrm/position_list.php
+++ b/htdocs/hrm/position_list.php
@@ -232,7 +232,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t LEFT JOIN ".MAIN_DB_PREFIX.$userstatic->table_element." as u on t.fk_user = u.rowid, ".MAIN_DB_PREFIX."hrm_job as j";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php
index 21adb375060..07084815b13 100644
--- a/htdocs/hrm/skill_list.php
+++ b/htdocs/hrm/skill_list.php
@@ -235,7 +235,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
//$sql .= ", COUNT(rc.rowid) as anotherfield";
diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql
index 1299e5f3a13..54d1d4cb33c 100644
--- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql
+++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql
@@ -373,4 +373,7 @@ UPDATE llx_c_country SET numeric_code = '262' WHERE code_iso = 'DJI';
UPDATE llx_c_country SET numeric_code = '894' WHERE code_iso = 'ZMB';
UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = 'ZWE';
+-- Generate documents on product batch
+ALTER TABLE llx_product_lot ADD COLUMN model_pdf varchar(255) AFTER scrapping_date;
+ALTER TABLE llx_product_lot ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
diff --git a/htdocs/install/mysql/tables/llx_product_lot.sql b/htdocs/install/mysql/tables/llx_product_lot.sql
index 4e6914884ac..03a1ebec09a 100644
--- a/htdocs/install/mysql/tables/llx_product_lot.sql
+++ b/htdocs/install/mysql/tables/llx_product_lot.sql
@@ -31,6 +31,8 @@ CREATE TABLE llx_product_lot (
scrapping_date datetime NULL, -- date when we decided to scrap all products of this lot
barcode varchar(180) DEFAULT NULL, -- barcode
fk_barcode_type integer DEFAULT NULL, -- barcode type
+ model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
datec datetime,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer,
diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php
index c107ba9e492..d7995ef275b 100644
--- a/htdocs/intracommreport/list.php
+++ b/htdocs/intracommreport/list.php
@@ -220,7 +220,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= $hookmanager->resPrint;
diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php
index b70b7df6bf3..7e12bee4dc4 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_list.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_list.php
@@ -241,7 +241,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 1eb57fb4dae..0214b73292d 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -522,6 +522,7 @@ GoIntoTranslationMenuToChangeThis=A translation has been found for the key with
WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior.
Field=Field
ProductDocumentTemplates=Document templates to generate product document
+ProductBatchDocumentTemplates=Document templates to generate product lots document
FreeLegalTextOnExpenseReports=Free legal text on expense reports
WatermarkOnDraftExpenseReports=Watermark on draft expense reports
ProjectIsRequiredOnExpenseReports=The project is mandatory for entering an expense report
diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang
index 78cc1d43820..1d6704b2858 100644
--- a/htdocs/langs/en_US/members.lang
+++ b/htdocs/langs/en_US/members.lang
@@ -201,7 +201,7 @@ LastMemberDate=Latest membership date
LatestSubscriptionDate=Latest contribution date
MemberNature=Nature of the member
MembersNature=Nature of the members
-Public=Information is public
+Public=%s can publish my membership in the public register
NewMemberbyWeb=New member added. Awaiting approval
NewMemberForm=New member form
SubscriptionsStatistics=Contributions statistics
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index e0cdd1f8ab4..8af27e60caf 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -289,7 +289,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
//$sql .= ", COUNT(rc.rowid) as anotherfield";
diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php
index 30b9d288562..d1d50441ea2 100644
--- a/htdocs/mrp/mo_list.php
+++ b/htdocs/mrp/mo_list.php
@@ -229,7 +229,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php
index 955bb7a5197..f03608929a5 100644
--- a/htdocs/partnership/partnership_list.php
+++ b/htdocs/partnership/partnership_list.php
@@ -312,7 +312,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/product/admin/product_lot.php b/htdocs/product/admin/product_lot.php
index 19b2b32eac6..d7eb1b5fe50 100644
--- a/htdocs/product/admin/product_lot.php
+++ b/htdocs/product/admin/product_lot.php
@@ -36,6 +36,9 @@ if (!$user->admin || (empty($conf->productbatch->enabled)))
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
+$label = GETPOST('label', 'alpha');
+$scandir = GETPOST('scan_dir', 'alpha');
+$type = 'product_batch';
$error = 0;
@@ -88,6 +91,65 @@ if ($action == 'updateMaskLot') {
if ($value == '1' && $conf->global->PRODUCTBATCH_SN_ADDONS !== 'mod_sn_advanced') {
dolibarr_set_const($db, "PRODUCTBATCH_SN_ADDON", 'mod_sn_advanced', 'chaine', 0, '', $conf->entity);
}
+} elseif ($action == 'set') {
+ // Activate a model
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+} elseif ($action == 'del') {
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0) {
+ if ($conf->global->FACTURE_ADDON_PDF == "$value") {
+ dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
+ }
+ }
+} elseif ($action == 'specimen') {
+ $modele = GETPOST('module', 'alpha');
+
+ $product_batch = new Productlot($db);
+ $product_batch->initAsSpecimen();
+
+ // Search template files
+ $file = '';
+ $classname = '';
+ $filefound = 0;
+ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+ foreach ($dirmodels as $reldir) {
+ $file = dol_buildpath($reldir . "core/modules/product_batch/doc/pdf_" . $modele . ".modules.php", 0);
+ if (file_exists($file)) {
+ $filefound = 1;
+ $classname = "pdf_" . $modele;
+ break;
+ }
+ }
+
+ if ($filefound) {
+ require_once $file;
+
+ $module = new $classname($db);
+
+ if ($module->write_file($product_batch, $langs) > 0) {
+ header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=product_batch&file=SPECIMEN.pdf");
+ return;
+ } else {
+ setEventMessages($module->error, $module->errors, 'errors');
+ dol_syslog($module->error, LOG_ERR);
+ }
+ } else {
+ setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+ dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+ }
+} elseif ($action == 'setdoc') {
+ // Set default model
+ if (dolibarr_set_const($db, "PRODUCT_BATCH_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
+ // La constante qui a ete lue en avant du nouveau set
+ // on passe donc par une variable pour avoir un affichage coherent
+ $conf->global->PRODUCT_BATCH_ADDON_PDF = $value;
+ }
+
+ // On active le modele
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0) {
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+ }
}
/*
@@ -299,6 +361,141 @@ if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
print "
\n";
}
+// Module to build doc
+$def = array();
+$sql = "SELECT nom";
+$sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
+$sql .= " WHERE type = '" . $db->escape($type) . "'";
+$sql .= " AND entity = " . $conf->entity;
+$resql = $db->query($sql);
+if ($resql) {
+ $i = 0;
+ $num_rows = $db->num_rows($resql);
+ while ($i < $num_rows) {
+ $array = $db->fetch_array($resql);
+ array_push($def, $array[0]);
+ $i++;
+ }
+} else {
+ dol_print_error($db);
+}
+
+print '
';
+
+print load_fiche_titre($langs->trans("ProductBatchDocumentTemplates"), '', '');
+
+print '';
+print '
';
+print '';
+print '| ' . $langs->trans("Name") . ' | ';
+print '' . $langs->trans("Description") . ' | ';
+print '' . $langs->trans("Status") . " | \n";
+print '' . $langs->trans("Default") . " | \n";
+print ' | ';
+print '' . $langs->trans("Preview") . ' | ';
+print "
\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir) {
+ foreach (array('', '/doc') as $valdir) {
+ $dir = dol_buildpath($reldir . "core/modules/product_batch" . $valdir);
+ if (is_dir($dir)) {
+ $handle = opendir($dir);
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ $filelist[] = $file;
+ }
+ closedir($handle);
+ arsort($filelist);
+
+ foreach ($filelist as $file) {
+ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
+ if (file_exists($dir . '/' . $file)) {
+ $name = substr($file, 4, dol_strlen($file) - 16);
+ $classname = substr($file, 0, dol_strlen($file) - 12);
+
+ require_once $dir . '/' . $file;
+ $module = new $classname($db);
+
+ $modulequalified = 1;
+ if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
+ $modulequalified = 0;
+ }
+ if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
+ $modulequalified = 0;
+ }
+
+ if ($modulequalified) {
+ print '| ';
+ print (empty($module->name) ? $name : $module->name);
+ print " | \n";
+ if (method_exists($module, 'info')) {
+ print $module->info($langs);
+ } else {
+ print $module->description;
+ }
+ print ' | ';
+
+ // Active
+ if (in_array($name, $def)) {
+ print '' . "\n";
+ print '';
+ print img_picto($langs->trans("Enabled"), 'switch_on');
+ print '';
+ print ' | ';
+ } else {
+ print '' . "\n";
+ print 'scandir) . '&label=' . urlencode($module->name) . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '';
+ print " | ";
+ }
+
+ // Defaut
+ print '';
+ if (getDolGlobalString('PRODUCT_BATCH_ADDON_PDF') == $name) {
+ print img_picto($langs->trans("Default"), 'on');
+ } else {
+ print 'scandir) . '&label=' . urlencode($module->name) . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'off') . '';
+ }
+ print ' | ';
+
+ // Info
+ $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name;
+ $htmltooltip .= '
' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown"));
+ if ($module->type == 'pdf') {
+ $htmltooltip .= '
' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur;
+ }
+ $htmltooltip .= '
' . $langs->trans("FeaturesSupported") . ':';
+ $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1);
+ $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1);
+
+
+ print '';
+ print $form->textwithpicto('', $htmltooltip, 1, 0);
+ print ' | ';
+
+ // Preview
+ print '';
+ if ($module->type == 'pdf') {
+ print '' . img_object($langs->trans("Preview"), 'contract') . '';
+ } else {
+ print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+ }
+ print ' | ';
+
+ print "
\n";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+print '
';
+print '
';
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php
index 88e590c478b..fda3f60602b 100644
--- a/htdocs/product/inventory/list.php
+++ b/htdocs/product/inventory/list.php
@@ -222,7 +222,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php
index 7d12acae368..da2f412af17 100644
--- a/htdocs/product/stock/class/productlot.class.php
+++ b/htdocs/product/stock/class/productlot.class.php
@@ -98,6 +98,8 @@ class Productlot extends CommonObject
//'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1', 'visible'=>5, 'position'=>100),
//'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_QUALITYCONTROL)?1:0', 'visible'=>5, 'position'=>110),
'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62),
+ 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 215),
+ 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => -1, 'position' => 310),
'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'),
@@ -295,6 +297,8 @@ class Productlot extends CommonObject
$sql .= " t.scrapping_date,";
//$sql .= " t.commissionning_date,";
//$sql .= " t.qc_frequency,";
+ $sql .= " t.model_pdf,";
+ $sql .= " t.last_main_doc,";
$sql .= " t.datec,";
$sql .= " t.tms,";
$sql .= " t.fk_user_creat,";
@@ -329,6 +333,8 @@ class Productlot extends CommonObject
$this->scrapping_date = $this->db->jdate($obj->scrapping_date);
//$this->commissionning_date = $this->db->jdate($obj->commissionning_date);
//$this->qc_frequency = $obj->qc_frequency;
+ $this->model_pdf = $obj->model_pdf;
+ $this->last_main_doc = $obj->last_main_doc;
$this->datec = $this->db->jdate($obj->datec);
$this->tms = $this->db->jdate($obj->tms);
@@ -999,9 +1005,14 @@ class Productlot extends CommonObject
*/
public function initAsSpecimen()
{
- $this->id = 0;
+ global $conf;
- $this->entity = null;
+ // Initialise parametres
+ $this->id = 0;
+ $this->ref = 'SPECIMEN';
+ $this->specimen = 1;
+
+ $this->entity = $conf->entity;
$this->fk_product = null;
$this->batch = '';
$this->eatby = '';
@@ -1012,4 +1023,37 @@ class Productlot extends CommonObject
$this->fk_user_modif = null;
$this->import_key = '';
}
+
+ /**
+ * Create a document onto disk according to template module.
+ *
+ * @param string $modele Force model to use ('' to not force)
+ * @param Translate $outputlangs Object langs to use for output
+ * @param int $hidedetails Hide details of lines
+ * @param int $hidedesc Hide description
+ * @param int $hideref Hide ref
+ * @return int 0 if KO, 1 if OK
+ */
+ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ global $conf, $user, $langs;
+
+ $langs->loadLangs(array('stocks', 'productbatch', "products"));
+ $outputlangs->loadLangs(array('stocks', 'productbatch', "products"));
+
+ // Positionne le modele sur le nom du modele a utiliser
+ if (!dol_strlen($modele)) {
+ $modele = '';
+
+ if (!empty($this->model_pdf)) {
+ $modele = $this->model_pdf;
+ } elseif (!empty($conf->global->PRODUCT_BATCH_ADDON_PDF)) {
+ $modele = $conf->global->PRODUCT_BATCH_ADDON_PDF;
+ }
+ }
+
+ $modelpath = "core/modules/product_batch/doc/";
+
+ return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ }
}
diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php
index c0b055352c0..4da0c259bc9 100644
--- a/htdocs/product/stock/movement_list.php
+++ b/htdocs/product/stock/movement_list.php
@@ -617,7 +617,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php
index a39d92f93aa..c33997010fb 100644
--- a/htdocs/product/stock/productlot_card.php
+++ b/htdocs/product/stock/productlot_card.php
@@ -568,7 +568,7 @@ if ($action != 'presend') {
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $usercanread; // If you can read, you can build the PDF to read content
$delallowed = $usercancreate; // If you can create/edit, you can remove a file on card
- print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->default_lang, '', $object);
+ print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', $langs->default_lang, '', $object);
}
print '';
diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php
index 8981d1cff56..302a02ba108 100644
--- a/htdocs/product/stock/productlot_list.php
+++ b/htdocs/product/stock/productlot_list.php
@@ -225,7 +225,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_list.php b/htdocs/product/stock/stocktransfer/stocktransfer_list.php
index 72c538a58c6..2a57b3f2f94 100644
--- a/htdocs/product/stock/stocktransfer/stocktransfer_list.php
+++ b/htdocs/product/stock/stocktransfer/stocktransfer_list.php
@@ -178,17 +178,17 @@ $title = $langs->trans('StockTransferList');
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
-foreach ($object->fields as $key => $val) {
- $sql .= "t.".$key.", ";
-}
+$sql .= $object->getFieldList('t');
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
+ }
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index d0075b57ed7..1d38e5214d5 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -444,7 +444,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 17a58f3a1e9..fe7d2a093fd 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -1562,7 +1562,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
- $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+ $sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX."element_time as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id";
diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php
index ce6eb58d02e..2655af04012 100644
--- a/htdocs/public/members/new.php
+++ b/htdocs/public/members/new.php
@@ -692,7 +692,9 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
print '
| '.$langs->trans("URLPhoto").' | |
'."\n";
// Public
- print '| '.$langs->trans("Public").' | |
'."\n";
+ $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
+ $publiclabel = $langs->trans("Public", $conf->global->MAIN_INFO_SOCIETE_NOM, $linkofpubliclist);
+ print '| '.$publiclabel.' | |
'."\n";
// Other attributes
$parameters['tpl_context']='public'; // define template context to public
diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php
index 05524716cad..789e9564c87 100644
--- a/htdocs/recruitment/recruitmentcandidature_list.php
+++ b/htdocs/recruitment/recruitmentcandidature_list.php
@@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php
index 4cb2d845828..fe2d2a5d612 100644
--- a/htdocs/recruitment/recruitmentjobposition_list.php
+++ b/htdocs/recruitment/recruitmentjobposition_list.php
@@ -213,7 +213,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= ", COUNT(rc.rowid) as nbapplications";
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index 1eac833560c..71b6d8cff0d 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -352,7 +352,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 1186cf7a914..0eded67a603 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -715,7 +715,8 @@ class User extends CommonObject
'skill@hrm' => 'all@hrm', // skill / job / position objects rights are for the moment grouped into right level "all"
'job@hrm' => 'all@hrm', // skill / job / position objects rights are for the moment grouped into right level "all"
'position@hrm' => 'all@hrm', // skill / job / position objects rights are for the moment grouped into right level "all"
- 'facturerec' => 'facture'
+ 'facturerec' => 'facture',
+ 'margins' => 'margin',
);
if (!empty($moduletomoduletouse[$module])) {
diff --git a/htdocs/user/list.php b/htdocs/user/list.php
index 3ea1307224c..47962e14c66 100644
--- a/htdocs/user/list.php
+++ b/htdocs/user/list.php
@@ -379,7 +379,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php
index c2f2b3e9a15..a83ecf7be89 100644
--- a/htdocs/variants/list.php
+++ b/htdocs/variants/list.php
@@ -227,7 +227,7 @@ $morecss = array();
// Build and execute select
// --------------------------------------------------------------------
$sql = "SELECT ";
-$sql .= " COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products,";
+$sql .= " COUNT(DISTINCT pav.rowid) AS nb_of_values, COUNT(DISTINCT pac2v.fk_prod_combination) AS nb_products";
$sql .= $object->getFieldList("t");
// Add fields from extrafields
//if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -238,7 +238,7 @@ $sql .= $object->getFieldList("t");
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
//if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
diff --git a/htdocs/webhook/target_list.php b/htdocs/webhook/target_list.php
index de7417d61de..d28221c0e3d 100644
--- a/htdocs/webhook/target_list.php
+++ b/htdocs/webhook/target_list.php
@@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
//$sql .= ", COUNT(rc.rowid) as anotherfield";
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php
index 699bc52045b..47e93d8294b 100644
--- a/htdocs/workstation/workstation_list.php
+++ b/htdocs/workstation/workstation_list.php
@@ -231,7 +231,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
-$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {