';
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index 2b6ee6ce068..8f61261bc11 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -19,11 +19,11 @@
* along with this program. If not, see .
*/
- /**
- * \file htdocs/compta/accounting-files.php
- * \ingroup compta
- * \brief Page to show portoflio and files of a thirdparty and download it
- */
+/**
+ * \file htdocs/compta/accounting-files.php
+ * \ingroup compta
+ * \brief Page to show portoflio and files of a thirdparty and download it
+ */
if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
if (!defined('NOTOKENRENEWAL')) {
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 6116db707e2..6d7f7f6010e 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -967,7 +967,7 @@ if ($action == 'create') {
// Title
print '
'.$langs->trans("Title").'
';
- print '';
+ print '';
print '
';
// Third party
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 2bfb250df83..290467a9d54 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -2130,7 +2130,7 @@ class FactureLigneRec extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET";
- $sql .= " fk_facture = ".$this->fk_facture;
+ $sql .= " fk_facture = ".((int) $this->fk_facture);
$sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
$sql .= ", description='".$this->db->escape($this->desc)."'";
$sql .= ", price=".price2num($this->price);
@@ -2142,10 +2142,10 @@ class FactureLigneRec extends CommonInvoiceLine
$sql .= ", localtax2_tx=".price2num($this->localtax2_tx);
$sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'";
$sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null");
- $sql .= ", product_type=".$this->product_type;
- $sql .= ", remise_percent='".price2num($this->remise_percent)."'";
- $sql .= ", subprice='".price2num($this->subprice)."'";
- $sql .= ", info_bits='".price2num($this->info_bits)."'";
+ $sql .= ", product_type=".((int) $this->product_type);
+ $sql .= ", remise_percent=".price2num($this->remise_percent);
+ $sql .= ", subprice=".price2num($this->subprice);
+ $sql .= ", info_bits=".price2num($this->info_bits);
$sql .= ", date_start_fill=".(int) $this->date_start_fill;
$sql .= ", date_end_fill=".(int) $this->date_end_fill;
if (empty($this->skip_update_total)) {
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 573ed2230f5..22e5bb3f1a6 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -1275,9 +1275,9 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
$model = $objecttmp->model_pdf;
$ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records
// To be sure vars is defined
- $hidedetails = !empty($hidedetails) ? $hidedetails : 0;
- $hidedesc = !empty($hidedesc) ? $hidedesc : 0;
- $hideref = !empty($hideref) ? $hideref : 0;
+ $hidedetails = !empty($hidedetails) ? $hidedetails : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
+ $hidedesc = !empty($hidedesc) ? $hidedesc : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
+ $hideref = !empty($hideref) ? $hideref : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$moreparams = !empty($moreparams) ? $moreparams : null;
$result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@@ -1426,13 +1426,13 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) {
// To be sure vars is defined
if (empty($hidedetails)) {
- $hidedetails = 0;
+ $hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
}
if (empty($hidedesc)) {
- $hidedesc = 0;
+ $hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
}
if (empty($hideref)) {
- $hideref = 0;
+ $hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
}
if (empty($moreparams)) {
$moreparams = null;
diff --git a/htdocs/core/commonfieldsinimport.inc.php b/htdocs/core/commonfieldsinimport.inc.php
new file mode 100644
index 00000000000..60716b8b109
--- /dev/null
+++ b/htdocs/core/commonfieldsinimport.inc.php
@@ -0,0 +1,63 @@
+db);
+
+ // Add common fields
+ foreach ($tmpobject->fields as $keyfield => $valuefield) {
+ $fieldname = $keyforalias.'.'.$keyfield;
+ $fieldlabel = ucfirst($valuefield['label']);
+ $typeFilter = "Text";
+ $typefield = preg_replace('/\(.*$/', '', $valuefield['type']); // double(24,8) -> double
+ switch ($typefield) {
+ case 'int':
+ case 'integer':
+ case 'double':
+ case 'price':
+ $typeFilter = "Numeric";
+ break;
+ case 'date':
+ case 'datetime':
+ case 'timestamp':
+ $typeFilter = "Date";
+ break;
+ case 'boolean':
+ $typeFilter = "Boolean";
+ break;
+ /*
+ * case 'sellist':
+ * $tmp='';
+ * $tmpparam=jsonOrUnserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ * if ($tmpparam['options'] && is_array($tmpparam['options'])) {
+ * $tmpkeys=array_keys($tmpparam['options']);
+ * $tmp=array_shift($tmpkeys);
+ * }
+ * if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
+ * break;
+ */
+ }
+ $helpfield = '';
+ if (!empty($valuefield['help'])) {
+ $helpfield = preg_replace('/\(.*$/', '', $valuefield['help']);
+ }
+ if ($valuefield['enabled']) {
+ $this->import_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->import_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->import_entities_array[$r][$fieldname] = $keyforelement;
+ $this->import_help_array[$r][$fieldname] = $helpfield;
+ }
+ }
+} else {
+ dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
+}
+// End add common fields
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index f23a66bbee4..66e54a4fc3c 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -106,7 +106,7 @@ abstract class DoliDB implements Database
*/
public function idate($param, $gm = 'tzserver')
{
- // TODO $param should be gmt, so we should add $gm to 'gmt' instead of default 'tzserver'
+ // TODO $param should be gmt, so we should have default $gm to 'gmt' instead of default 'tzserver'
return dol_print_date($param, "%Y-%m-%d %H:%M:%S", $gm);
}
diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php
index fc2210eabd8..b31b02c3460 100644
--- a/htdocs/core/extrafieldsinexport.inc.php
+++ b/htdocs/core/extrafieldsinexport.inc.php
@@ -12,7 +12,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) {
// Add extra fields
$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields";
-$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC';
+$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC';
//print $sql;
$resql = $this->db->query($sql);
if ($resql) { // This can fail when class is used on old database (during migration for example)
diff --git a/htdocs/core/extrafieldsinimport.inc.php b/htdocs/core/extrafieldsinimport.inc.php
new file mode 100644
index 00000000000..4845d9a6d44
--- /dev/null
+++ b/htdocs/core/extrafieldsinimport.inc.php
@@ -0,0 +1,75 @@
+db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC';
+//print $sql;
+$resql = $this->db->query($sql);
+if ($resql) { // This can fail when class is used on old database (during migration for example)
+ while ($obj = $this->db->fetch_object($resql)) {
+ $fieldname = $keyforaliasextra.'.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ $typefield = preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double
+ switch ($typefield) {
+ case 'int':
+ case 'integer':
+ case 'double':
+ case 'price':
+ $typeFilter = "Numeric";
+ break;
+ case 'date':
+ case 'datetime':
+ case 'timestamp':
+ $typeFilter = "Date";
+ break;
+ case 'boolean':
+ $typeFilter = "Boolean";
+ break;
+ case 'checkbox':
+ case 'select':
+ if (!empty($conf->global->EXPORT_LABEL_FOR_SELECT)) {
+ $tmpparam = jsonOrUnserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...)
+ if ($tmpparam['options'] && is_array($tmpparam['options'])) {
+ $typeFilter = "Select:".$obj->param;
+ }
+ }
+ break;
+ case 'sellist':
+ $tmp = '';
+ $tmpparam = jsonOrUnserialize($obj->param); // $tmp may be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ if (is_array($tmpparam) && array_key_exists('options', $tmpparam) && $tmpparam['options'] && is_array($tmpparam['options'])) {
+ $tmpkeys = array_keys($tmpparam['options']);
+ $tmp = array_shift($tmpkeys);
+ }
+ if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
+ $typeFilter = "List:".$tmp;
+ }
+ break;
+ }
+ if ($obj->type != 'separate') {
+ // If not a computed field
+ if (empty($obj->fieldcomputed)) {
+ $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
+ $this->import_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->import_entities_array[$r][$fieldname] = $keyforelement;
+ } else {
+ // If this is a computed field
+ $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
+ $this->import_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute';
+ $this->import_entities_array[$r][$fieldname] = $keyforelement;
+ }
+ }
+ }
+}
+// End add axtra fields
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 99921ac5fb0..b8b6d1c728a 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -41,7 +41,9 @@
*/
function societe_prepare_head(Societe $object)
{
- global $db, $langs, $conf, $user, $hookmanager;
+ global $db, $langs, $conf, $user;
+ global $hookmanager;
+
$h = 0;
$head = array();
diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php
index c101001af4c..17b5a9bb16a 100644
--- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php
+++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php
@@ -176,7 +176,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO
*/
- public function getNextValue($objproduct = null, $type = '')
+ public function getNextValue($objproduct, $type = '')
{
global $db, $conf;
diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php
index c7a69a82caa..ef34b145e52 100644
--- a/htdocs/core/modules/facture/mod_facture_mars.php
+++ b/htdocs/core/modules/facture/mod_facture_mars.php
@@ -150,7 +150,7 @@ class mod_facture_mars extends ModeleNumRefFactures
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
- * @return string Value
+ * @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php
index 621bb8e6d2d..7a572615a21 100644
--- a/htdocs/core/modules/facture/mod_facture_mercure.php
+++ b/htdocs/core/modules/facture/mod_facture_mercure.php
@@ -171,7 +171,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$this->error = $numFinal;
}
- return $numFinal;
+ return $numFinal;
}
diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php
index 55f6dd816d1..9660be93266 100644
--- a/htdocs/core/modules/facture/mod_facture_terre.php
+++ b/htdocs/core/modules/facture/mod_facture_terre.php
@@ -185,7 +185,7 @@ class mod_facture_terre extends ModeleNumRefFactures
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
- * @return string Next ref value or last ref if $mode is 'last'
+ * @return string Next ref value or last ref if $mode is 'last', <= 0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
@@ -259,6 +259,8 @@ class mod_facture_terre extends ModeleNumRefFactures
} else {
dol_print_error('', 'Bad parameter for getNextValue');
}
+
+ return 0;
}
/**
diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php
index e188f66b1ad..480c532cc1f 100644
--- a/htdocs/core/modules/facture/modules_facture.php
+++ b/htdocs/core/modules/facture/modules_facture.php
@@ -132,10 +132,11 @@ abstract class ModeleNumRefFactures
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Objet societe
- * @param Facture $facture Objet facture
+ * @param Facture $invoice Objet facture
+ * @param string $mode 'next' for next value or 'last' for last value
* @return string Value
*/
- public function getNextValue($objsoc, $facture)
+ public function getNextValue($objsoc, $invoice, $mode = 'next')
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php
index 8cf79227d4f..185ef4cf73b 100644
--- a/htdocs/core/modules/fichinter/modules_fichinter.php
+++ b/htdocs/core/modules/fichinter/modules_fichinter.php
@@ -122,9 +122,11 @@ abstract class ModeleNumRefFicheinter
/**
* Return the next assigned value
*
- * @return string Value
+ * @param Societe $objsoc Object thirdparty
+ * @param Object $object Object we need next value for
+ * @return string Value if KO, <0 if KO
*/
- public function getNextValue()
+ public function getNextValue($objsoc = 0, $object = '')
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php
index 84d6638a27e..a1647a67953 100644
--- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php
+++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php
@@ -117,11 +117,11 @@ class mod_holiday_immaculate extends ModelNumRefHolidays
/**
* Return next value
*
- * @param Societe $user user object
+ * @param Societe $objsoc third party object
* @param Object $holiday holiday object
* @return string Value if OK, 0 if KO
*/
- public function getNextValue($user, $holiday)
+ public function getNextValue($objsoc, $holiday)
{
global $db, $conf;
@@ -134,7 +134,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays
return 0;
}
- $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $user, $holiday->date_create);
+ $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $objsoc, $holiday->date_create);
return $numFinal;
}
diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php
index 65b08f4bba8..7b6e13ea992 100644
--- a/htdocs/core/modules/holiday/modules_holiday.php
+++ b/htdocs/core/modules/holiday/modules_holiday.php
@@ -126,10 +126,10 @@ class ModelNumRefHolidays
* Return next value
*
* @param Societe $objsoc third party object
- * @param Object $contract contract object
- * @return string Value
+ * @param Object $holiday Holiday object
+ * @return string Value if OK, 0 if KO
*/
- public function getNextValue($objsoc, $contract)
+ public function getNextValue($objsoc, $holiday)
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 947dd3d18d3..e45630df298 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -324,7 +324,8 @@ class ImportCsv extends ModeleImports
//dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid);
//var_dump($array_match_file_to_database);
- //var_dump($arrayrecord);
+ //var_dump($arrayrecord); exit;
+
$array_match_database_to_file = array_flip($array_match_file_to_database);
$sort_array_match_file_to_database = $array_match_file_to_database;
ksort($sort_array_match_file_to_database);
@@ -367,12 +368,15 @@ class ImportCsv extends ModeleImports
//dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]);
}
- // array of fields to column index
+ // Define array to convert fields ('c.ref', ...) into column index (1, ...)
$arrayfield = array();
foreach ($sort_array_match_file_to_database as $key => $val) {
$arrayfield[$val] = ($key - 1);
}
+ // $arrayrecord start at key 0
+ // $sort_array_match_file_to_database start at key 1
+
// Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom)
foreach ($sort_array_match_file_to_database as $key => $val) {
$fieldalias = preg_replace('/\..*$/i', '', $val);
@@ -595,9 +599,24 @@ class ImportCsv extends ModeleImports
if (!empty($classModForNumber) && !empty($pathModForNumber) && is_readable(DOL_DOCUMENT_ROOT.$pathModForNumber)) {
require_once DOL_DOCUMENT_ROOT.$pathModForNumber;
$modForNumber = new $classModForNumber;
- $defaultref = $modForNumber->getNextValue(null, null);
+
+ $tmpobject = null;
+ // Set the object when we can
+ if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) {
+ $pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject'];
+ require_once DOL_DOCUMENT_ROOT.$pathForObject;
+ $tmpclassobject = $objimport->array_import_convertvalue[0][$val]['classobject'];
+ $tmpobject = new $tmpclassobject($this->db);
+ foreach ($arrayfield as $tmpkey => $tmpval) { // $arrayfield is array('c.ref'=>0, ...)
+ if (in_array($tmpkey, array('t.date', 'c.date_commande'))) {
+ $tmpobject->date = dol_stringtotime($arrayrecord[$arrayfield[$tmpkey]]['val'], 1);
+ }
+ }
+ }
+
+ $defaultref = $modForNumber->getNextValue(null, $tmpobject);
}
- if (is_numeric($defaultref) && $defaultref <= 0) {
+ if (is_numeric($defaultref) && $defaultref <= 0) { // If error
$defaultref = '';
}
$newval = $defaultref;
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index 3747e8f6847..9fa5cbf2c44 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -367,7 +367,8 @@ class ImportXlsx extends ModeleImports
//dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid);
//var_dump($array_match_file_to_database);
- //var_dump($arrayrecord);
+ //var_dump($arrayrecord); exit;
+
$array_match_database_to_file = array_flip($array_match_file_to_database);
$sort_array_match_file_to_database = $array_match_file_to_database;
ksort($sort_array_match_file_to_database);
@@ -410,12 +411,15 @@ class ImportXlsx extends ModeleImports
//dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]);
}
- // array of fields to column index
+ // Define array to convert fields ('c.ref', ...) into column index (1, ...)
$arrayfield = array();
foreach ($sort_array_match_file_to_database as $key => $val) {
- $arrayfield[$val] = ($key - 1);
+ $arrayfield[$val] = ($key);
}
+ // $arrayrecord start at key 1
+ // $sort_array_match_file_to_database start at key 1
+
// Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom)
foreach ($sort_array_match_file_to_database as $key => $val) {
$fieldalias = preg_replace('/\..*$/i', '', $val);
@@ -619,7 +623,7 @@ class ImportXlsx extends ModeleImports
$this->thirpartyobject->get_codecompta('supplier');
$newval = $this->thirpartyobject->code_compta_fournisseur;
if (empty($newval)) {
- $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
+ $arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
}
//print 'code_compta_fournisseur='.$newval;
}
@@ -636,9 +640,24 @@ class ImportXlsx extends ModeleImports
if (!empty($classModForNumber) && !empty($pathModForNumber) && is_readable(DOL_DOCUMENT_ROOT.$pathModForNumber)) {
require_once DOL_DOCUMENT_ROOT.$pathModForNumber;
$modForNumber = new $classModForNumber;
- $defaultref = $modForNumber->getNextValue(null, null);
+
+ $tmpobject = null;
+ // Set the object with the date property when we can
+ if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) {
+ $pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject'];
+ require_once DOL_DOCUMENT_ROOT.$pathForObject;
+ $tmpclassobject = $objimport->array_import_convertvalue[0][$val]['classobject'];
+ $tmpobject = new $tmpclassobject($this->db);
+ foreach ($arrayfield as $tmpkey => $tmpval) { // $arrayfield is array('c.ref'=>1, ...)
+ if (in_array($tmpkey, array('t.date', 'c.date_commande'))) {
+ $tmpobject->date = dol_stringtotime($arrayrecord[$arrayfield[$tmpkey]]['val'], 1);
+ }
+ }
+ }
+
+ $defaultref = $modForNumber->getNextValue(null, $tmpobject);
}
- if (is_numeric($defaultref) && $defaultref <= 0) {
+ if (is_numeric($defaultref) && $defaultref <= 0) { // If error
$defaultref = '';
}
$newval = $defaultref;
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index d8ba1f98146..9aac30fe8a5 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -196,10 +196,10 @@ class modCommande extends DolibarrModules
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country',
'co.code'=>"CountryCode", 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id",
'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_commande'=>"OrderDate",
- 'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.remise_percent'=>"GlobalDiscount", 'c.total_ht'=>"TotalHT",
+ 'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.total_ht'=>"TotalHT",
'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
- 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
+ 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC",
'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel'
);
@@ -220,7 +220,7 @@ class modCommande extends DolibarrModules
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',
// 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",
- // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
+ // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.total_ht'=>"Numeric",
// 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",
// 'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",
// 'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'
@@ -228,7 +228,7 @@ class modCommande extends DolibarrModules
$this->export_TypeFields_array[$r] = array(
's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text',
's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.date_creation'=>"Date",
- 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric",
+ 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.total_ht'=>"Numeric",
'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text',
'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric",
'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text',
@@ -238,8 +238,8 @@ class modCommande extends DolibarrModules
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company',
'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"order",
'c.ref'=>"order", 'c.ref_client'=>"order", 'c.fk_soc'=>"order", 'c.date_creation'=>"order", 'c.date_commande'=>"order", 'c.amount_ht'=>"order",
- 'c.remise_percent'=>"order", 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",
- 'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.label'=>"order_line", 'cd.description'=>"order_line",
+ 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",
+ 'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.description'=>"order_line",
'cd.product_type'=>'order_line', 'cd.tva_tx'=>"order_line", 'cd.qty'=>"order_line", 'cd.total_ht'=>"order_line", 'cd.total_tva'=>"order_line",
'cd.total_ttc'=>"order_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'
);
@@ -296,18 +296,17 @@ class modCommande extends DolibarrModules
$this->import_entities_array[$r] = array();
$this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields');
$this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id
+ $import_sample = array();
$this->import_fields_array[$r] = array(
'c.ref' => 'Ref*',
'c.ref_client' => 'RefCustomer',
'c.fk_soc' => 'ThirdPartyName*',
'c.fk_projet' => 'ProjectId',
'c.date_creation' => 'DateCreation',
- 'c.date_valid' => 'DateValid',
- 'c.date_commande' => 'DateOrder',
+ 'c.date_valid' => 'DateValidation',
+ 'c.date_commande' => 'OrderDate*',
'c.fk_user_modif' => 'ModifiedById',
'c.fk_user_valid' => 'ValidatedById',
- 'c.fk_statut' => 'Status*',
- 'c.remise_percent' => 'GlobalDiscount',
'c.total_tva' => 'TotalTVA',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
@@ -317,7 +316,8 @@ class modCommande extends DolibarrModules
'c.date_livraison' => 'DeliveryDate',
'c.fk_cond_reglement' => 'Payment Condition',
'c.fk_mode_reglement' => 'Payment Mode',
- 'c.model_pdf' => 'Model'
+ 'c.model_pdf' => 'Model',
+ 'c.fk_statut' => 'Status*'
);
if (!empty($conf->multicurrency->enabled)) {
@@ -327,51 +327,48 @@ class modCommande extends DolibarrModules
$this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
-
- // Add extra fields
$import_extrafield_sample = array();
- $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commande' AND entity IN (0, ".$conf->entity.")";
- $resql = $this->db->query($sql);
+ $keyforselect = 'commande';
+ $keyforelement = 'order';
+ $keyforaliasextra = 'extra';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
- if ($resql) {
- while ($obj = $this->db->fetch_object($resql)) {
- $fieldname = 'extra.'.$obj->name;
- $fieldlabel = ucfirst($obj->label);
- $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
- $import_extrafield_sample[$fieldname] = $fieldlabel;
- }
- }
- // End add extra fields
-
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande'];
- $this->import_regex_array[$r] = [
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande');
+ $this->import_regex_array[$r] = array(
'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'
- ];
-
- $this->import_updatekeys_array[$r] = ['c.ref' => 'Ref'];
- $this->import_convertvalue_array[$r] = [
- 'c.fk_soc' => [
+ );
+ $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
+ $this->import_updatekeys_array[$r] = array('c.ref' => 'Ref');
+ $this->import_convertvalue_array[$r] = array(
+ 'c.ref' => array(
+ 'rule'=>'getrefifauto',
+ 'class'=>(empty($conf->global->COMMANDE_ADDON) ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON),
+ 'path'=>"/core/modules/commande/".(empty($conf->global->COMMANDE_ADDON) ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON).'.php',
+ 'classobject'=>'Commande',
+ 'pathobject'=>'/commande/class/commande.class.php',
+ ),
+ 'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
- ],
- 'c.fk_user_valid' => [
+ ),
+ 'c.fk_user_valid' => array(
'rule' => 'fetchidfromref',
'file' => '/user/class/user.class.php',
'class' => 'User',
'method' => 'fetch',
'element' => 'user'
- ],
- 'c.fk_mode_reglement' => [
+ ),
+ 'c.fk_mode_reglement' => array(
'rule' => 'fetchidfromcodeorlabel',
'file' => '/compta/paiement/class/cpaiement.class.php',
'class' => 'Cpaiement',
'method' => 'fetch',
'element' => 'cpayment'
- ],
- ];
+ ),
+ );
//Import CPV Lines
$r++;
@@ -381,15 +378,13 @@ class modCommande extends DolibarrModules
$this->import_entities_array[$r] = array();
$this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields');
$this->import_fields_array[$r] = array(
- 'cd.fk_commande' => 'SalesOrder*',
- 'cd.fk_parent_line' => 'PrParentLine',
+ 'cd.fk_commande' => 'CustomerOrder*',
+ 'cd.fk_parent_line' => 'ParentLine',
'cd.fk_product' => 'IdProduct',
- 'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
- 'cd.remise' => 'Reduc.',
'cd.price' => 'Price',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
@@ -410,17 +405,11 @@ class modCommande extends DolibarrModules
$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
- // Add extra fields
- $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")";
- $resql = $this->db->query($sql);
- if ($resql) {
- while ($obj = $this->db->fetch_object($resql)) {
- $fieldname = 'extra.'.$obj->name;
- $fieldlabel = ucfirst($obj->label);
- $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
- }
- }
- // End add extra fields
+ $import_extrafield_sample = array();
+ $keyforselect = 'commandedet';
+ $keyforelement = 'orderline';
+ $keyforaliasextra = 'extra';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commandedet'];
$this->import_regex_array[$r] = [
diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php
index 72838e92079..b64ecca6cc1 100644
--- a/htdocs/core/modules/modFacture.class.php
+++ b/htdocs/core/modules/modFacture.class.php
@@ -276,7 +276,7 @@ class modFacture extends DolibarrModules
'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
'none.rest'=>"NumericCompute",
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
- 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
+ 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text',
$alias_product_perentity . '.accountancy_code_sell'=>'Text',
@@ -289,7 +289,7 @@ class modFacture extends DolibarrModules
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
- 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",
+ 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line",
'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",
'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line',
'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product',
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index befeb143ec9..708cd1fb408 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -612,7 +612,13 @@ class modFournisseur extends DolibarrModules
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('f.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
- //'c.ref'=>array('rule'=>'getrefifauto'),
+ 'f.ref' => array(
+ 'rule'=>'getrefifauto',
+ 'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
+ 'path'=>"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).'.php',
+ 'classobject'=>'FactureFournisseur',
+ 'pathobject'=>'/fourn/class/fournisseur.facture.class.php',
+ ),
'f.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
'f.fk_account' => array('rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'),
);
@@ -626,9 +632,8 @@ class modFournisseur extends DolibarrModules
$this->import_tables_array[$r] = array('fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields');
$this->import_fields_array[$r] = array(
'fd.fk_facture_fourn' => 'InvoiceRef*',
- 'fd.fk_parent_line' => 'FacParentLine',
+ 'fd.fk_parent_line' => 'ParentLine',
'fd.fk_product' => 'IdProduct',
- 'fd.label' => 'Label',
'fd.description' => 'LineDescription',
'fd.pu_ht' => 'PriceUHT',
'fd.pu_ttc' => 'PriceUTTC',
@@ -670,7 +675,6 @@ class modFournisseur extends DolibarrModules
'fd.fk_facture_fourn' => '(PROV001)',
'fd.fk_parent_line' => '',
'fd.fk_product' => '',
- 'fd.label' => '',
'fd.description' => 'Test Product',
'fd.pu_ht' => '50000',
'fd.pu_ttc' => '50000',
@@ -720,7 +724,6 @@ class modFournisseur extends DolibarrModules
'c.source' => 'Source',
'c.fk_statut' => 'Status*',
'c.billed' => 'Billed(0/1)',
- 'c.remise_percent' => 'GlobalDiscount',
'c.total_tva' => 'TotalTVA',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
@@ -762,6 +765,13 @@ class modFournisseur extends DolibarrModules
$this->import_updatekeys_array[$r] = array('c.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
+ 'c.ref' => array(
+ 'rule'=>'getrefifauto',
+ 'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
+ 'path'=>"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).'.php',
+ 'classobject'=>'CommandeFournisseur',
+ 'pathobject'=>'/fourn/class/fournisseur.commande.class.php',
+ ),
'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
@@ -788,14 +798,12 @@ class modFournisseur extends DolibarrModules
$this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields');
$this->import_fields_array[$r] = array(
'cd.fk_commande' => 'PurchaseOrder*',
- 'cd.fk_parent_line' => 'PrParentLine',
+ 'cd.fk_parent_line' => 'ParentLine',
'cd.fk_product' => 'IdProduct',
- 'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
- 'cd.remise' => 'Reduc.',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
'cd.total_tva' => 'LineTotalVAT',
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index 4f0633cd578..3419d4c866e 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -190,10 +190,10 @@ class modPropale extends DolibarrModules
$this->export_fields_array[$r] = array(
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer",
- 'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount",
+ 'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal",
'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
- 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
+ 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC",
'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel'
);
@@ -214,14 +214,14 @@ class modPropale extends DolibarrModules
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text',
// 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",
- // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
+ // 'c.fin_validite'=>"Date",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
// 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",
// 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
//);
$this->export_TypeFields_array[$r] = array(
's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text',
's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date",
- 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',
+ 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',
'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric",
'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text',
'c.entity'=>'List:entity:label:rowid',
@@ -229,9 +229,9 @@ class modPropale extends DolibarrModules
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"propal", 'c.ref'=>"propal", 'c.ref_client'=>"propal",
- 'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal",
+ 'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.total_ht'=>"propal",
'c.total_ttc'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line',
- 'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",
+ 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",
'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'
);
$this->export_dependencies_array[$r] = array('propal_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
@@ -293,7 +293,6 @@ class modPropale extends DolibarrModules
'c.datec' => 'DateCreation',
'c.datep' => 'DatePropal',
'c.fin_validite' => 'DateEndPropal',
- 'c.remise_percent' => 'GlobalDiscount',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
'c.fk_statut' => 'Status*',
@@ -330,7 +329,6 @@ class modPropale extends DolibarrModules
'c.datec' => '2020-01-01',
'c.datep' => '2020-01-01',
'c.fin_validite' => '2020-01-01',
- 'c.remise_percent' => '',
'c.total_ht' => '0',
'c.total_ttc' => '0',
'c.fk_statut' => '1',
@@ -344,16 +342,23 @@ class modPropale extends DolibarrModules
'c.multicurrency_total_ttc' => '0'
];
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
- $this->import_updatekeys_array[$r] = ['c.ref'=>'Ref'];
- $this->import_convertvalue_array[$r] = [
- 'c.fk_soc' => [
+ $this->import_updatekeys_array[$r] = array('c.ref'=>'Ref');
+ $this->import_convertvalue_array[$r] = array(
+ 'c.ref' => array(
+ 'rule'=>'getrefifauto',
+ 'class'=>(empty($conf->global->PROPALE_ADDON) ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON),
+ 'path'=>"/core/modules/propale/".(empty($conf->global->PROPALE_ADDON) ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON).'.php',
+ 'classobject'=>'Propal',
+ 'pathobject'=>'/comm/propal/class/propal.class.php',
+ ),
+ 'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
- ]
- ];
+ )
+ );
//Import Proposal Lines
$r++;
@@ -367,15 +372,13 @@ class modPropale extends DolibarrModules
);
$this->import_fields_array[$r] = array(
'cd.fk_propal' => 'Proposal*',
- 'cd.fk_parent_line' => 'PrParentLine',
+ 'cd.fk_parent_line' => 'ParentLine',
'cd.fk_product' => 'IdProduct',
- 'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.product_type' => 'TypeOfLineServiceOrProduct',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
- 'cd.remise' => 'Reduc.',
'cd.price' => 'Price',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
@@ -411,13 +414,11 @@ class modPropale extends DolibarrModules
'cd.fk_propal' => 'PROV(0001)',
'cd.fk_parent_line' => '',
'cd.fk_product' => '',
- 'cd.label' => '',
'cd.description' => 'Line description',
'cd.product_type' => '1',
'cd.tva_tx' => '0',
'cd.qty' => '2',
'cd.remise_percent' => '0',
- 'cd.remise' => '0',
'cd.price' => '',
'cd.subprice' => '5000',
'cd.total_ht' => '10000',
diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php
index d44a261a16b..d56178697f5 100644
--- a/htdocs/core/modules/product_batch/mod_lot_advanced.php
+++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php
@@ -128,7 +128,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
/**
* Return next free value
*
- * @param Societe $objsoc Object Societe
+ * @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
diff --git a/htdocs/core/modules/product_batch/mod_lot_free.php b/htdocs/core/modules/product_batch/mod_lot_free.php
index def14bd37b3..d6b24945ab0 100644
--- a/htdocs/core/modules/product_batch/mod_lot_free.php
+++ b/htdocs/core/modules/product_batch/mod_lot_free.php
@@ -93,11 +93,11 @@ class mod_lot_free extends ModeleNumRefBatch
/**
* Return an example of result returned by getNextValue
*
- * @param product $objproduct Object product
- * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
+ * @param Societe $objsoc Object thirdparty
+ * @param Object $object Object we need next value for
* @return string Return next value
*/
- public function getNextValue($objproduct = 0, $type = -1)
+ public function getNextValue($objsoc, $object)
{
global $langs;
return '';
diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php
index 59de1965a6e..fc8d1389a00 100644
--- a/htdocs/core/modules/product_batch/mod_lot_standard.php
+++ b/htdocs/core/modules/product_batch/mod_lot_standard.php
@@ -111,11 +111,11 @@ class mod_lot_standard extends ModeleNumRefBatch
/**
* Return next free value
*
- * @param Product $objprod Object product
+ * @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
- public function getNextValue($objprod, $object)
+ public function getNextValue($objsoc, $object)
{
global $db, $conf;
diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php
index abe094220d2..6ee931d51a9 100644
--- a/htdocs/core/modules/product_batch/mod_sn_advanced.php
+++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php
@@ -128,11 +128,11 @@ class mod_sn_advanced extends ModeleNumRefBatch
/**
* Return next free value
*
- * @param Product $objprod Object product
+ * @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
- public function getNextValue($objprod, $object)
+ public function getNextValue($objsoc, $object)
{
global $db, $conf;
diff --git a/htdocs/core/modules/product_batch/mod_sn_free.php b/htdocs/core/modules/product_batch/mod_sn_free.php
index 67d39ec085a..f6b2417d34b 100644
--- a/htdocs/core/modules/product_batch/mod_sn_free.php
+++ b/htdocs/core/modules/product_batch/mod_sn_free.php
@@ -92,11 +92,11 @@ class mod_sn_free extends ModeleNumRefBatch
/**
* Return an example of result returned by getNextValue
*
- * @param product $objproduct Object product
- * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
+ * @param Societe $objsoc Object thirdparty
+ * @param Object $object Object we need next value for
* @return string Return next value
*/
- public function getNextValue($objproduct = 0, $type = -1)
+ public function getNextValue($objsoc, $object)
{
global $langs;
return '';
diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php
index 845044c39f3..d6c109cff81 100644
--- a/htdocs/core/modules/product_batch/mod_sn_standard.php
+++ b/htdocs/core/modules/product_batch/mod_sn_standard.php
@@ -111,7 +111,7 @@ class mod_sn_standard extends ModeleNumRefBatch
/**
* Return next free value
*
- * @param Societe $objsoc Object product
+ * @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php
index bbfc0daee45..6570f2c864a 100644
--- a/htdocs/core/modules/reception/mod_reception_beryl.php
+++ b/htdocs/core/modules/reception/mod_reception_beryl.php
@@ -96,10 +96,10 @@ class mod_reception_beryl extends ModelNumRefReception
* Return next value
*
* @param Societe $objsoc Third party object
- * @param Object $shipment Shipment object
+ * @param Object $reception Reception object
* @return string Value if OK, 0 if KO
*/
- public function getNextValue($objsoc, $shipment)
+ public function getNextValue($objsoc, $reception)
{
global $db, $conf;
diff --git a/htdocs/core/modules/reception/modules_reception.php b/htdocs/core/modules/reception/modules_reception.php
index 145a04fbd31..f519974382b 100644
--- a/htdocs/core/modules/reception/modules_reception.php
+++ b/htdocs/core/modules/reception/modules_reception.php
@@ -110,10 +110,10 @@ abstract class ModelNumRefReception
* Returns next value assigned
*
* @param Societe $objsoc Third party object
- * @param Object $shipment Shipment object
+ * @param Object $reception Reception object
* @return string Value
*/
- public function getNextValue($objsoc, $shipment)
+ public function getNextValue($objsoc, $reception)
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
index acb3ad8fa2a..546596ab640 100644
--- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
+++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
@@ -120,7 +120,7 @@ abstract class ModeleNumRefSuppliersInvoices
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value if OK, 0 if KO
*/
- public function getNextValue($objsoc, $object, $mode)
+ public function getNextValue($objsoc, $object, $mode = 'next')
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php
index 6fe3cb8883d..51c4e5f07d3 100644
--- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php
+++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php
@@ -120,9 +120,11 @@ abstract class ModeleNumRefSuppliersOrders
/** Returns next value assigned
*
- * @return string Valeur
+ * @param Societe $objsoc Object third party
+ * @param Object $object Object
+ * @return string Valeur
*/
- public function getNextValue()
+ public function getNextValue($objsoc = 0, $object = '')
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
index b225899cef2..2e618b3ece3 100644
--- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
+++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
@@ -120,9 +120,9 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
/**
* Return next value
*
- * @param Societe $objsoc Object third party
- * @param Propal $supplier_proposal Object commercial proposal
- * @return string Next value
+ * @param Societe $objsoc Object third party
+ * @param SupplierProposal $supplier_proposal Object commercial proposal
+ * @return string Next value
*/
public function getNextValue($objsoc, $supplier_proposal)
{
diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
index e7db54062cb..57cba16c01b 100644
--- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
+++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
@@ -120,9 +120,9 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
/**
* Return next value
*
- * @param Societe $objsoc Object third party
- * @param Propal $supplier_proposal Object supplier_proposal
- * @return string Value if OK, 0 if KO
+ * @param Societe $objsoc Object third party
+ * @param SupplierProposal $supplier_proposal Object commercial proposal
+ * @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $supplier_proposal)
{
diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php
index 0b6f0b3725d..5a3d9e2280a 100644
--- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php
+++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php
@@ -124,11 +124,11 @@ abstract class ModeleNumRefSupplierProposal
/**
* Renvoi prochaine valeur attribuee
*
- * @param Societe $objsoc Object third party
- * @param Propal $propal Object commercial proposal
- * @return string Valeur
+ * @param Societe $objsoc Object third party
+ * @param SupplierProposal $supplier_proposal Object commercial proposal
+ * @return string Valeur
*/
- public function getNextValue($objsoc, $propal)
+ public function getNextValue($objsoc, $supplier_proposal)
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php
index b3d26b39511..7e46c10a341 100644
--- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php
+++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php
@@ -119,7 +119,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value if KO, <0 if KO
*/
- public function getNextValue($objsoc = 0, $invoice = null, $mode = 'next')
+ public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
{
global $db, $conf;
diff --git a/htdocs/core/modules/takepos/modules_takepos.php b/htdocs/core/modules/takepos/modules_takepos.php
index b9fae565647..24fa70b7f28 100644
--- a/htdocs/core/modules/takepos/modules_takepos.php
+++ b/htdocs/core/modules/takepos/modules_takepos.php
@@ -89,9 +89,12 @@ abstract class ModeleNumRefTakepos
/**
* Renvoi prochaine valeur attribuee
*
- * @return string Valeur
+ * @param Societe $objsoc Object thirdparty
+ * @param Facture $invoice Object invoice
+ * @param string $mode 'next' for next value or 'last' for last value
+ * @return string Value if KO, <0 if KO
*/
- public function getNextValue()
+ public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
{
global $langs;
return $langs->trans('NotAvailable');
diff --git a/htdocs/core/modules/ticket/modules_ticket.php b/htdocs/core/modules/ticket/modules_ticket.php
index 1d2bc944022..c8561382436 100644
--- a/htdocs/core/modules/ticket/modules_ticket.php
+++ b/htdocs/core/modules/ticket/modules_ticket.php
@@ -115,11 +115,11 @@ abstract class ModeleNumRefTicket
/**
* Renvoi prochaine valeur attribuee
*
- * @param Societe $objsoc Object third party
- * @param Project $project Object project
- * @return string Valeur
+ * @param Societe $objsoc Object third party
+ * @param Ticket $ticket Object ticket
+ * @return string Valeur
*/
- public function getNextValue($objsoc, $project)
+ public function getNextValue($objsoc, $ticket)
{
global $langs;
return $langs->trans("NotAvailable");
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index a39a14dbab4..c89723af2b9 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1336,6 +1336,15 @@ if (empty($reshook)) {
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
+
+ unset($qty);
+ unset($value_unit_ht);
+ unset($value_unit);
+ unset($vatrate);
+ unset($comments);
+ unset($fk_c_type_fees);
+ unset($fk_project);
+ unset($date);
}
//header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php
index f77dd5638f7..abbf0db90fe 100644
--- a/htdocs/fourn/class/fournisseur.facture-rec.class.php
+++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php
@@ -299,40 +299,34 @@ class FactureFournisseurRec extends CommonInvoice
$sql .= ') VALUES (';
$sql .= "'".$this->db->escape($this->titre)."'";
$sql .= ", '".$this->db->escape($this->ref_supplier)."'";
- $sql .= ', ' . (int) $conf->entity;
- $sql .= ', ' . (int) $facfourn_src->socid;
+ $sql .= ", ".((int) $conf->entity);
+ $sql .= ", ".((int) $facfourn_src->socid);
$sql .= ", '".$this->db->idate($now)."'";
- $sql .= ', ' . (int) $this->suspended;
- if (!empty(GETPOST('libelle'))) {
- $sql .= ", '" . $this->db->escape(GETPOST('libelle')) . "'";
- } elseif (! empty($this->libelle)) {
- $sql .= ", '" . $this->db->escape($this->libelle) . "'";
- } else {
- $sql .= ", ''";
- }
- $sql .= ', ' .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount
- $sql .= ', ' .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0');
- $sql .= ', ' . (int) $user->id;
- $sql .= ', ' .(!empty($this->fk_project) ? $this->fk_project : 'NULL'); // Fields declarded on creation
- $sql .= ', ' .(!empty($facfourn_src->fk_account) ? $facfourn_src->fk_account : 'NULL');
- $sql .= ', ' .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL');
- $sql .= ', ' .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL');
- $sql .= ", '".($facfourn_src->date_echeance > 0 ? $this->db->idate($facfourn_src->date_echeance) : 'NULL')."'"; // date_lim_reglement
- $sql .= ', ' .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL'); // Fields declarded on creation
- $sql .= ', ' .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL'); // Fields declarded on creation
- $sql .= ', ' .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL'); // Fields declarded on creation
- $sql .= ', ' . (int) $facfourn_src->fk_multicurrency;
+ $sql .= ", ".((int) $this->suspended);
+ $sql .= ", '".$this->db->escape($this->libelle)."'";
+ $sql .= ", " .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount
+ $sql .= ", " .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0');
+ $sql .= ", " .((int) $user->id);
+ $sql .= ", " .(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL');
+ $sql .= ", " .(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL');
+ $sql .= ", " .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL');
+ $sql .= ", " .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL');
+ $sql .= ", ".($facfourn_src->date_echeance > 0 ? "'".$this->db->idate($facfourn_src->date_echeance)."'" : 'NULL'); // date_lim_reglement
+ $sql .= ", " .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL');
+ $sql .= ", " .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL');
+ $sql .= ", " .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL');
+ $sql .= ", " . (int) $facfourn_src->fk_multicurrency;
$sql .= ", '".$this->db->escape($facfourn_src->multicurrency_code)."'";
- $sql .= ', ' . (float) $facfourn_src->multicurrency_tx;
- $sql .= ', ' . (int) $this->usenewprice; // Fields declarded on creation
- $sql .= ', ' . (int) $this->frequency; // Fields declarded on creation
- $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; // Fields declarded on creation
- $sql .= ', ' .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); // Fields declarded on creation
- $sql .= ', ' .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); // Fields declarded on creation
- $sql .= ', ' . (int) $this->nb_gen_done; // Fields declarded on creation
- $sql .= ', ' . (int) $this->nb_gen_max; // Fields declarded on creation
- $sql .= ', ' . (int) $this->auto_validate; // Fields declarded on creation
- $sql .= ', ' . (int) $this->generate_pdf; // Fields declarded on creation
+ $sql .= ", " . (float) $facfourn_src->multicurrency_tx;
+ $sql .= ", " . (int) $this->usenewprice;
+ $sql .= ", " . (int) $this->frequency;
+ $sql .= ", '".$this->db->escape($this->unit_frequency)."'";
+ $sql .= ", " .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL');
+ $sql .= ", " .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL');
+ $sql .= ", " . (int) $this->nb_gen_done;
+ $sql .= ", " . (int) $this->nb_gen_max;
+ $sql .= ", " . (int) $this->auto_validate;
+ $sql .= ", " . (int) $this->generate_pdf;
$sql .= ')';
if ($this->db->query($sql)) {
@@ -475,44 +469,43 @@ class FactureFournisseurRec extends CommonInvoice
$error = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET";
- $sql .= ' titre = "' . (!empty($this->titre) ? $this->titre .'",' : '"",') ;
- $sql .= ' ref_supplier = "'. (!empty($this->ref_supplier) ? $this->ref_supplier .'",' : '" ",');
- $sql .= " entity = ". (!empty($this->entity) ? $this->entity : 1) . ',';
+ $sql .= " titre = '" . (!empty($this->titre) ? $this->db->escape($this->titre) : "")."'," ;
+ $sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
+ $sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ',';
if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ',';
- $sql .= ' tms = "'. date('Y-m-d H:i:s', dol_now()) . '",';
- $sql .= " suspended = ". (!empty($this->suspended) ? $this->suspended : 0) . ',';
- $sql .= ' libelle = "'. (!empty($this->libelle) ? $this->libelle : 'NULL') . '",';
- $sql .= " amount = ". (!empty($this->amount) ? $this->amount : 0.00) . ',';
- $sql .= " remise = ". (!empty($this->remise) ? $this->remise : 'NULL') . ',';
- $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? $this->vat_src_code : 'NULL') . ',';
- $sql .= " localtax1 = ". (!empty($this->localtax1) ? $this->localtax1 : 0.00) . ',';
- $sql .= " localtax2 = ". (!empty($this->localtax2) ? $this->localtax2 : 0.00) . ',';
- $sql .= " total_ht = ". (!empty($this->total_ht) ? $this->total_ht : 0.00) . ',';
- $sql .= " total_tva = ". (!empty($this->total_tva) ? $this->total_tva : 0.00) . ',';
- $sql .= " total_ttc = ". (!empty($this->total_ttc) ? $this->total_ttc : 0.00) . ',';
- $sql .= " fk_user_modif = ". $user->id . ',';
- $sql .= " fk_projet = ". (!empty($this->fk_project) ? $this->fk_project : 'NULL') . ',';
- $sql .= " fk_account = ". (!empty($this->fk_account) ? $this->fk_account : 'NULL') . ',';
- $sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? $this->mode_reglement_id : 'NULL') . ',';
- $sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? $this->cond_reglement_id : 'NULL') . ',';
- $sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? '"'.date("Y-m-d H:i:s", $this->date_lim_reglement).'"' : 'NULL') . ',';
- $sql .= ' note_private = "'. (!empty($this->note_private) ? $this->note_private : '') . '",';
- $sql .= ' note_public = "'. (!empty($this->note_public) ? $this->note_public : '') . '",';
- $sql .= ' modelpdf = "'. (!empty($this->model_pdf) ? $this->model_pdf : 'NULL') . '",';
- $sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL') . ',';
- $sql .= ' multicurrency_code = "'. (!empty($this->multicurrency_code) ? $this->multicurrency_code : 'NULL') . '",';
- $sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1) . ',';
- $sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? $this->multicurrency_total_ht : 0.00) . ',';
- $sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? $this->multicurrency_total_tva : 0.00) . ',';
- $sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? $this->multicurrency_total_ttc : 0.00) . ',';
- $sql .= " usenewprice = ". (!empty($this->usenewprice) ? $this->usenewprice : 0) . ',';
- $sql .= " frequency = ". (!empty($this->frequency) ? $this->frequency : 0). ',';
- $sql .= ' unit_frequency = "'. (!empty($this->unit_frequency) ? $this->unit_frequency : 0). '",';
- $sql .= " date_when = ". (!empty($this->date_when) ? '"'.date("Y-m-d H:i:s", $this->date_when).'"' : 0) . ',';
- $sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? '"'.date("Y-m-d H:i:s", $this->date_last_gen).'"' : 0) . ',';
- $sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? $this->nb_gen_done : 0) . ',';
- $sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? $this->nb_gen_max : 0) . ',';
- $sql .= " auto_validate = ". (!empty($this->auto_validate) ? $this->auto_validate : 0);
+ $sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ',';
+ $sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ",";
+ $sql .= " amount = ". (!empty($this->amount) ? ((float) $this->amount) : 0.00) . ',';
+ $sql .= " remise = ". (!empty($this->remise) ? ((float) $this->remise) : 'NULL') . ',';
+ $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->vat_src_code."'" : 'NULL') . ',';
+ $sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ',';
+ $sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ',';
+ $sql .= " total_ht = ". (!empty($this->total_ht) ? ((float) $this->total_ht) : 0.00) . ',';
+ $sql .= " total_tva = ". (!empty($this->total_tva) ? ((float) $this->total_tva) : 0.00) . ',';
+ $sql .= " total_ttc = ". (!empty($this->total_ttc) ? ((float) $this->total_ttc) : 0.00) . ',';
+ $sql .= " fk_user_modif = ". ((int) $user->id) . ',';
+ $sql .= " fk_projet = ". (!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL') . ',';
+ $sql .= " fk_account = ". (!empty($this->fk_account) ? ((int) $this->fk_account) : 'NULL') . ',';
+ $sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? ((int) $this->mode_reglement_id) : 'NULL') . ',';
+ $sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : 'NULL') . ',';
+ $sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL') . ',';
+ $sql .= " note_private = '". (!empty($this->note_private) ? $this->db->escape($this->note_private) : '') . "',";
+ $sql .= " note_public = '". (!empty($this->note_public) ? $this->db->escape($this->note_public) : '') . "',";
+ $sql .= " modelpdf = ". (!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL') . ",";
+ $sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? ((int) $this->fk_multicurrency) : 'NULL') . ',';
+ $sql .= " multicurrency_code = ". (!empty($this->multicurrency_code) ? "'".$this->db->escape($this->multicurrency_code)."'" : 'NULL') . ",";
+ $sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? ((float) $this->multicurrency_tx) : 1) . ',';
+ $sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? ((float) $this->multicurrency_total_ht) : 0.00) . ',';
+ $sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? ((float) $this->multicurrency_total_tva) : 0.00) . ',';
+ $sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? ((float) $this->multicurrency_total_ttc) : 0.00) . ',';
+ $sql .= " usenewprice = ". (!empty($this->usenewprice) ? ((int) $this->usenewprice) : 0) . ',';
+ $sql .= " frequency = ". (!empty($this->frequency) ? ((int) $this->frequency) : 0). ',';
+ $sql .= " unit_frequency = '". (!empty($this->unit_frequency) ? $this->db->escape($this->unit_frequency) : ''). "',";
+ $sql .= " date_when = ". (!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL') . ',';
+ $sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL') . ',';
+ $sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? ((int) $this->nb_gen_done) : 0) . ',';
+ $sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? ((int) $this->nb_gen_max) : 0) . ',';
+ $sql .= " auto_validate = ". (!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0);
$sql .= " WHERE rowid = ". (int) $this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@@ -1766,14 +1759,15 @@ class FactureFournisseurRec extends CommonInvoice
return -2;
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null');
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET frequency = ".($frequency ? ((int) $this->db->escape($frequency)) : "NULL");
if (!empty($unit)) {
- $sql .= ', unit_frequency = '.$this->db->escape($unit);
+ $sql .= ", unit_frequency = '".$this->db->escape($unit)."'";
}
- $sql .= ' WHERE rowid = ' . (int) $this->id;
+ $sql .= " WHERE rowid = ".((int) $this->id);
+
+ dol_syslog(get_class($this).'::setFrequencyAndUnit', LOG_DEBUG);
- dol_syslog(get_class($this). '::setFrequencyAndUnit', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->frequency = $frequency;
if (!empty($unit)) {
@@ -1781,7 +1775,7 @@ class FactureFournisseurRec extends CommonInvoice
}
return 1;
} else {
- dol_print_error($this->db);
+ $this->error = $this->db->lasterror();
return -1;
}
}
@@ -1796,17 +1790,18 @@ class FactureFournisseurRec extends CommonInvoice
public function setNextDate($date, $increment_nb_gen_done = 0)
{
if (!$this->table_element) {
- dol_syslog(get_class($this). '::setNextDate was called on objet with property table_element not defined', LOG_ERR);
+ dol_syslog(get_class($this).'::setNextDate was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET date_when = ' .($date ? "'".$this->db->idate($date)."'" : 'null');
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET date_when = " .($date ? "'".$this->db->idate($date)."'" : "NULL");
if ($increment_nb_gen_done > 0) {
- $sql .= ', nb_gen_done = nb_gen_done + 1';
+ $sql .= ", nb_gen_done = nb_gen_done + 1";
}
- $sql .= ' WHERE rowid = ' . (int) $this->id;
+ $sql .= " WHERE rowid = " . (int) $this->id;
+
+ dol_syslog(get_class($this).'::setNextDate', LOG_DEBUG);
- dol_syslog(get_class($this). '::setNextDate', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->date_when = $date;
if ($increment_nb_gen_done > 0) {
@@ -1814,7 +1809,7 @@ class FactureFournisseurRec extends CommonInvoice
}
return 1;
} else {
- dol_print_error($this->db);
+ $this->error = $this->db->lasterror();
return -1;
}
}
@@ -1828,7 +1823,7 @@ class FactureFournisseurRec extends CommonInvoice
public function setMaxPeriod($nb)
{
if (!$this->table_element) {
- dol_syslog(get_class($this). '::setMaxPeriod was called on objet with property table_element not defined', LOG_ERR);
+ dol_syslog(get_class($this).'::setMaxPeriod was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
@@ -1836,11 +1831,12 @@ class FactureFournisseurRec extends CommonInvoice
$nb = 0;
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET nb_gen_max = '. (int) $nb;
- $sql .= ' WHERE rowid = ' . (int) $this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET nb_gen_max = ". (int) $nb;
+ $sql .= " WHERE rowid = " . (int) $this->id;
+
+ dol_syslog(get_class($this).'::setMaxPeriod', LOG_DEBUG);
- dol_syslog(get_class($this). '::setMaxPeriod', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->nb_gen_max = $nb;
return 1;
@@ -1859,15 +1855,16 @@ class FactureFournisseurRec extends CommonInvoice
public function setAutoValidate($validate)
{
if (!$this->table_element) {
- dol_syslog(get_class($this). '::setAutoValidate was called on objet with property table_element not defined', LOG_ERR);
+ dol_syslog(get_class($this).'::setAutoValidate was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET auto_validate = '.((int) $validate);
- $sql .= ' WHERE rowid = ' . (int) $this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET auto_validate = ".((int) $validate);
+ $sql .= " WHERE rowid = " . (int) $this->id;
+
+ dol_syslog(get_class($this).'::setAutoValidate', LOG_DEBUG);
- dol_syslog(get_class($this). '::setAutoValidate', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->auto_validate = $validate;
return 1;
@@ -1886,15 +1883,16 @@ class FactureFournisseurRec extends CommonInvoice
public function setGeneratePdf($validate)
{
if (!$this->table_element) {
- dol_syslog(get_class($this). '::setGeneratePdf was called on objet with property table_element not defined', LOG_ERR);
+ dol_syslog(get_class($this).'::setGeneratePdf was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET generate_pdf = '. (int) $validate;
- $sql .= ' WHERE rowid = ' . (int) $this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET generate_pdf = ". (int) $validate;
+ $sql .= " WHERE rowid = " . (int) $this->id;
+
+ dol_syslog(get_class($this).'::setGeneratePdf', LOG_DEBUG);
- dol_syslog(get_class($this). '::setGeneratePdf', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->generate_pdf = $validate;
return 1;
@@ -1913,15 +1911,16 @@ class FactureFournisseurRec extends CommonInvoice
public function setModelPdf($model)
{
if (!$this->table_element) {
- dol_syslog(get_class($this). '::setModelPdf was called on objet with property table_element not defined', LOG_ERR);
+ dol_syslog(get_class($this).'::setModelPdf was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET modelpdf = '".$this->db->escape($model)."'";
- $sql .= ' WHERE rowid = ' . (int) $this->id;
+ $sql .= " WHERE rowid = " . (int) $this->id;
+
+ dol_syslog(get_class($this).'::setModelPdf', LOG_DEBUG);
- dol_syslog(get_class($this). '::setModelPdf', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->model_pdf = $model;
return 1;
@@ -2144,8 +2143,8 @@ class FactureFournisseurLigneRec extends CommonObjectLine
$sql .= ' fk_facture_fourn = ' . (int) $this->fk_facture_fourn;
$sql .= ', fk_parent_line = ' . (int) $this->fk_parent;
$sql .= ', fk_product = ' . (int) $this->fk_product;
- $sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'null');
- $sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'null');
+ $sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'NULL');
+ $sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'NULL');
$sql .= ", description = '" . $this->db->escape($this->description) . "'";
$sql .= ', pu_ht = ' . price2num($this->pu_ht);
$sql .= ', pu_ttc = ' . price2num($this->pu_ttc);
@@ -2153,27 +2152,26 @@ class FactureFournisseurLigneRec extends CommonObjectLine
$sql .= ", remise_percent = '" . price2num($this->remise_percent) . "'";
$sql .= ', fk_remise_except = ' . (int) $this->fk_remise_except;
$sql .= ", vat_src_code = '" . $this->db->escape($this->vat_src_code) . "'";
- $sql .= ', tva_tx =' . price2num($this->tva_tx);
+ $sql .= ', tva_tx = ' . price2num($this->tva_tx);
$sql .= ', localtax1_tx = ' . price2num($this->localtax1_tx);
$sql .= ", localtax1_type = '" . $this->db->escape($this->localtax1_type) . "'";
$sql .= ', localtax2_tx = ' . price2num($this->localtax2_tx);
$sql .= ", localtax2_type = '" . $this->db->escape($this->localtax2_type) . "'";
if (empty($this->skip_update_total)) {
- $sql .= ', total_ht =' . price2num($this->total_ht);
- $sql .= ', total_tva =' . price2num($this->total_tva);
- $sql .= ', total_localtax1 =' . price2num($this->total_localtax1);
- $sql .= ', total_localtax2 =' . price2num($this->total_localtax2);
- $sql .= ', total_ttc =' . price2num($this->total_ttc);
+ $sql .= ', total_ht = ' . price2num($this->total_ht);
+ $sql .= ', total_tva = ' . price2num($this->total_tva);
+ $sql .= ', total_localtax1 = ' . price2num($this->total_localtax1);
+ $sql .= ', total_localtax2 = ' . price2num($this->total_localtax2);
+ $sql .= ', total_ttc = ' . price2num($this->total_ttc);
}
- $sql .= ', product_type =' . (int) $this->product_type;
- $sql .= ', date_start =' . (int) $this->date_start;
- $sql .= ', date_end =' . (int) $this->date_end;
- $sql .= ", info_bits ='" . price2num($this->info_bits) . "'";
+ $sql .= ', product_type = ' . (int) $this->product_type;
+ $sql .= ', date_start = ' . (int) $this->date_start;
+ $sql .= ', date_end = ' . (int) $this->date_end;
+ $sql .= ", info_bits = " . ((int) $this->info_bits);
$sql .= ', special_code =' . (int) $this->special_code;
- $sql .= ', rang =' . (int) $this->rang;
- $sql .= ', fk_unit =' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
- $sql .= ', fk_user_modif =' . (int) $user;
-
+ $sql .= ', rang = ' . (int) $this->rang;
+ $sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
+ $sql .= ', fk_user_modif = ' . (int) $user;
$sql .= ' WHERE rowid = ' . (int) $this->id;
$this->db->begin();
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 68c08c9f234..eada0da8899 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -601,7 +601,6 @@ BILL_SUPPLIER_DELETEInDolibarr=Supplier invoice deleted
UnitPriceXQtyLessDiscount=Unit price x Qty - Discount
CustomersInvoicesArea=Customer billing area
SupplierInvoicesArea=Supplier billing area
-FacParentLine=Invoice Line Parent
SituationTotalRayToRest=Remainder to pay without taxe
PDFSituationTitle=Situation n° %d
SituationTotalProgress=Total progress %d %%
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 62d167ea233..7e57db2091b 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -244,6 +244,7 @@ Designation=Description
DescriptionOfLine=Description of line
DateOfLine=Date of line
DurationOfLine=Duration of line
+ParentLine=Parent line ID
Model=Doc template
DefaultModel=Default doc template
Action=Event
diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang
index ed25b5501dc..aa5ef73f7dc 100644
--- a/htdocs/langs/en_US/propal.lang
+++ b/htdocs/langs/en_US/propal.lang
@@ -101,7 +101,6 @@ ConfirmMassValidationQuestion=Are you sure you want to validate the selected rec
ConfirmMassSignatureQuestion=Are you sure you want to sign the selected records ?
IdProposal=Proposal ID
IdProduct=Product ID
-PrParentLine=Proposal Parent Line
LineBuyPriceHT=Buy Price Amount net of tax for line
SignPropal=Accept proposal
RefusePropal=Refuse proposal
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index d6e59e4b2bd..288fd88eae6 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -122,7 +122,7 @@ class MyObject extends CommonObject
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010),
- 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1),
+ 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>2000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1),
);
/**
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index 874d964ad6e..b1caea730f9 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -382,20 +382,35 @@ class modMyModule extends DolibarrModules
$r = 1;
/* BEGIN MODULEBUILDER IMPORT MYOBJECT */
/*
- $langs->load("mymodule@mymodule");
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
- $this->export_icon[$r]='myobject@mymodule';
- $keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
- include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
- $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
- include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
- $this->export_sql_end[$r] .=' WHERE 1 = 1';
- $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
- $r++; */
+ $langs->load("mymodule@mymodule");
+ $this->import_code[$r]=$this->rights_class.'_'.$r;
+ $this->import_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->import_icon[$r]='myobject@mymodule';
+ $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'mymodule_myobject', 'extra' => MAIN_DB_PREFIX.'mymodule_myobject_extrafields');
+ $this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id
+ $import_sample = array();
+ $keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
+ include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php';
+ $import_extrafield_sample = array();
+ $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'mymodule_myobject');
+ $this->import_regex_array[$r] = array();
+ $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
+ $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref');
+ $this->import_convertvalue_array[$r] = array(
+ 't.ref' => array(
+ 'rule'=>'getrefifauto',
+ 'class'=>(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON),
+ 'path'=>"/core/modules/commande/".(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON).'.php'
+ 'classobject'=>'MyObject',
+ 'pathobject'=>'/mymodule/class/myobject.class.php',
+ ),
+ 't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
+ 't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'),
+ 't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'),
+ );
+ $r++; */
/* END MODULEBUILDER IMPORT MYOBJECT */
}
diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php
index 1bfecac3f1d..009534b91b5 100644
--- a/htdocs/reception/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php
@@ -56,7 +56,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
} ?>
getNomUrl(1); ?>
-
+
ref_supplier); ?>
date_delivery, 'day'); ?>
rights->reception->lire) {
diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php
index 4ddab0b97c3..5637f0194ac 100644
--- a/test/phpunit/CodingPhpTest.php
+++ b/test/phpunit/CodingPhpTest.php
@@ -227,6 +227,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
if (! in_array($file['name'], array(
'objectline_view.tpl.php',
'extrafieldsinexport.inc.php',
+ 'extrafieldsinimport.inc.php',
'DolQueryCollector.php'
))) {
// Must not found $this->db->