diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index bc7226edb22..7657e997ff6 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -212,7 +212,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " ".(!isset($this->position) ? 'NULL' : ((int) $this->position)).",";
$sql .= " ".(!isset($this->fk_country) ? 'NULL' : ((int) $this->fk_country)).",";
$sql .= " ".(!isset($this->active) ? 'NULL' : ((int) $this->active));
- $sql .= ", ".$conf->entity;
+ $sql .= ", ".((int) $conf->entity);
$sql .= ")";
$this->db->begin();
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 35178e43947..fc6acffb46f 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -274,7 +274,7 @@ class AccountingAccount extends CommonObject
$sql .= ", reconcilable";
$sql .= ") VALUES (";
$sql .= " '".$this->db->idate($now)."'";
- $sql .= ", ".$conf->entity;
+ $sql .= ", ".((int) $conf->entity);
$sql .= ", ".(empty($this->fk_pcg_version) ? 'NULL' : "'".$this->db->escape($this->fk_pcg_version)."'");
$sql .= ", ".(empty($this->pcg_type) ? 'NULL' : "'".$this->db->escape($this->pcg_type)."'");
$sql .= ", ".(empty($this->account_number) ? 'NULL' : "'".$this->db->escape($this->account_number)."'");
@@ -282,7 +282,7 @@ class AccountingAccount extends CommonObject
$sql .= ", ".(empty($this->label) ? "''" : "'".$this->db->escape($this->label)."'");
$sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'");
$sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category);
- $sql .= ", ".$user->id;
+ $sql .= ", ".((int) $user->id);
$sql .= ", ".(int) $this->active;
$sql .= ", ".(int) $this->reconcilable;
$sql .= ")";
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index e1a54edf3cd..d47078af06c 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -382,9 +382,9 @@ class BookKeeping extends CommonObject
$sql .= ", '".$this->db->escape($this->numero_compte)."'";
$sql .= ", ".(!empty($this->label_compte) ? ("'".$this->db->escape($this->label_compte)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->label_operation)."'";
- $sql .= ", ".$this->debit;
- $sql .= ", ".$this->credit;
- $sql .= ", ".$this->montant;
+ $sql .= ", ".((float) $this->debit);
+ $sql .= ", ".((float) $this->credit);
+ $sql .= ", ".((float) $this->montant);
$sql .= ", ".(!empty($this->sens) ? ("'".$this->db->escape($this->sens)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->fk_user_author)."'";
$sql .= ", '".$this->db->idate($now)."'";
@@ -893,9 +893,7 @@ class BookKeeping extends CommonObject
$sql .= ' ORDER BY t.numero_compte ASC';
}
- if (!empty($sortfield)) {
- $sql .= ", ".$sortfield." ".$sortorder;
- }
+ $sql .= $this->db->order($sortfield, $sortorder);
if (!empty($limit)) {
$sql .= $this->db->plimit($limit + 1, $offset);
}
diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php
index 9633157b5b7..96ab150dd24 100644
--- a/htdocs/accountancy/journal/expensereportsjournal.php
+++ b/htdocs/accountancy/journal/expensereportsjournal.php
@@ -610,7 +610,7 @@ if (empty($action) || $action == 'view') {
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "
global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off") ? " checked" : "").'> '.$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)." ";
print '';
print "";
$tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
@@ -803,7 +803,7 @@ print "";
print '
';
print '
';
print '';
-print ''.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).' '.$langs->trans("Description").' ';
+print ''.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).' '.$langs->trans("Description").' ';
print ' ';
print " \n";
if ($mysoc->useRevenueStamp()) {
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index ea8a80b17d6..b5e0c3ae28b 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -220,7 +220,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php
index 04d52c491b2..4fa7b2b79c7 100644
--- a/htdocs/admin/delivery.php
+++ b/htdocs/admin/delivery.php
@@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index c37c5ccd41f..2c0c42dbb14 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -48,8 +48,8 @@ $arrayofparameters = array(
'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1),
'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
- //'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
- //'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1),
+ 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
+ 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
@@ -445,7 +445,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index ee3d4f18562..32f82f5dad5 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php
index 0b6beb2abc6..1553f6887f8 100644
--- a/htdocs/admin/expensereport.php
+++ b/htdocs/admin/expensereport.php
@@ -228,7 +228,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 8b88b9a9ac8..bf4e2ea9eb6 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -312,7 +312,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index b878c40138e..4d9304472d5 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -284,7 +284,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
index 9dfb15477cc..81db1cbe58d 100644
--- a/htdocs/admin/holiday.php
+++ b/htdocs/admin/holiday.php
@@ -220,7 +220,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php
index 457303c9798..477f38fa663 100644
--- a/htdocs/admin/knowledgemanagement.php
+++ b/htdocs/admin/knowledgemanagement.php
@@ -396,7 +396,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php
index b1a9efc8648..37735a43ed3 100644
--- a/htdocs/admin/mailing.php
+++ b/htdocs/admin/mailing.php
@@ -132,6 +132,7 @@ print '';
print '';
print ''.$langs->trans("Parameter").' ';
print ''.$langs->trans("Value").' ';
+print ''.$langs->trans("Example").' ';
print " \n";
print '';
@@ -140,7 +141,8 @@ print ' ';
+print ''.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' ').' ';
+print '';
print '';
print $langs->trans("MailingEMailError").' ';
@@ -148,12 +150,14 @@ print ' ';
+print 'webmaster@example.com> ';
+print '';
print '';
print $langs->trans("MailingDelay").' ';
print ' ';
-print ' ';
+print ' ';
+print '';
// Constant to add salt into the unsubscribe and check read tag.
@@ -165,15 +169,17 @@ print ' ';
+print ' ';
+print '';
// default blacklist from mailing
print '';
-print '' . $langs->trans("DefaultBlacklistMailingStatus") . ' ';
+print '' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . ' ';
print '';
-$blacklist_setting=array(0=>$langs->trans('No'),1=>$langs->trans('Yes'),-1=>$langs->trans('DefaultStatusEmptyMandatory'));
+$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory'));
print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS);
print ' ';
+print ' ';
print ' ';
@@ -181,7 +187,8 @@ if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >=
print '';
print $langs->trans("MailAdvTargetRecipients").' ';
print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR');
- print ' ';
+ print ' ';
+ print '';
}
print '
';
diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php
index 08e257b0188..7cd3c095955 100644
--- a/htdocs/admin/mrp.php
+++ b/htdocs/admin/mrp.php
@@ -69,7 +69,7 @@ if ($action == 'updateMask') {
$modele = GETPOST('module', 'alpha');
$mo = new MO($db);
- $mrp->initAsSpecimen();
+ $mo->initAsSpecimen();
// Search template files
$file = ''; $classname = ''; $filefound = 0;
@@ -88,7 +88,7 @@ if ($action == 'updateMask') {
$module = new $classname($db);
- if ($module->write_file($mrp, $langs) > 0) {
+ if ($module->write_file($mo, $langs) > 0) {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf");
return;
} else {
@@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php
index b4b06d62e5e..089ddbafd23 100644
--- a/htdocs/admin/payment.php
+++ b/htdocs/admin/payment.php
@@ -178,7 +178,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index 4d02a2ddb7a..c11d5023e27 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -52,27 +52,60 @@ if ($cancel) {
}
if ($action == 'update') {
- if (GETPOSTISSET('MAIN_PDF_FORMAT')) dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_PDF_FORMAT')) {
+ dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_PDF_MARGIN_LEFT')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PDF_MARGIN_RIGHT')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PDF_MARGIN_BOTTOM')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_PDF_MARGIN_LEFT')) {
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_MARGIN_RIGHT')) {
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_RIGHT"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_MARGIN_TOP')) {
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_MARGIN_BOTTOM')) {
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_PROFID1_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PROFID2_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PROFID3_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PROFID4_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PROFID5_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PROFID6_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_PROFID1_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PROFID2_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PROFID3_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PROFID4_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PROFID5_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PROFID6_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_PDF_NO_SENDER_FRAME')) dolibarr_set_const($db, "MAIN_PDF_NO_SENDER_FRAME", GETPOST("MAIN_PDF_NO_SENDER_FRAME"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PDF_NO_RECIPENT_FRAME')) dolibarr_set_const($db, "MAIN_PDF_NO_RECIPENT_FRAME", GETPOST("MAIN_PDF_NO_RECIPENT_FRAME"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_PDF_NO_SENDER_FRAME')) {
+ dolibarr_set_const($db, "MAIN_PDF_NO_SENDER_FRAME", GETPOST("MAIN_PDF_NO_SENDER_FRAME"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_NO_RECIPENT_FRAME')) {
+ dolibarr_set_const($db, "MAIN_PDF_NO_RECIPENT_FRAME", GETPOST("MAIN_PDF_NO_RECIPENT_FRAME"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_PDF_HIDE_SENDER_NAME')) dolibarr_set_const($db, "MAIN_PDF_HIDE_SENDER_NAME", GETPOST("MAIN_PDF_HIDE_SENDER_NAME"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_PDF_HIDE_SENDER_NAME')) {
+ dolibarr_set_const($db, "MAIN_PDF_HIDE_SENDER_NAME", GETPOST("MAIN_PDF_HIDE_SENDER_NAME"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_TVAINTRA_NOT_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_TVAINTRA_NOT_IN_ADDRESS')) {
+ dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+ }
if (!empty($conf->projet->enabled)) {
if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') {
@@ -87,24 +120,50 @@ if ($action == 'update') {
}
}
- if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DESC')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS')) {
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DESC')) {
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) {
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_DOCUMENTS_LOGO_HEIGHT')) dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_INVERT_SENDER_RECIPIENT')) dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PDF_USE_ISO_LOCATION')) dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PDF_NO_CUSTOMER_CODE')) dolibarr_set_const($db, "MAIN_PDF_NO_CUSTOMER_CODE", GETPOST("MAIN_PDF_NO_CUSTOMER_CODE"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_DOCUMENTS_LOGO_HEIGHT')) {
+ dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_INVERT_SENDER_RECIPIENT')) {
+ dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_USE_ISO_LOCATION')) {
+ dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_NO_CUSTOMER_CODE')) {
+ dolibarr_set_const($db, "MAIN_PDF_NO_CUSTOMER_CODE", GETPOST("MAIN_PDF_NO_CUSTOMER_CODE"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) {
+ dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) {
+ dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE')) dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
- if (GETPOSTISSET('SHOW_SUBPRODUCT_REF_IN_PDF')) dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE')) {
+ dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('SHOW_SUBPRODUCT_REF_IN_PDF')) {
+ dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
- if (GETPOSTISSET('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) {
+ dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 3e75836e9fe..dcd91df0dbc 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -268,7 +268,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php
index e049985c61e..6367b80c150 100644
--- a/htdocs/admin/reception_setup.php
+++ b/htdocs/admin/reception_setup.php
@@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php
index 064fb5650a4..a86ca272b85 100644
--- a/htdocs/admin/security.php
+++ b/htdocs/admin/security.php
@@ -249,7 +249,7 @@ foreach ($arrayhandler as $key => $module) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print ''.$tmp.' ';
}
diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php
index c4958083181..a888a248d11 100644
--- a/htdocs/admin/supplier_invoice.php
+++ b/htdocs/admin/supplier_invoice.php
@@ -246,7 +246,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index 27629d99a82..cfa6c878a74 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -259,7 +259,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php
index 863674bab75..15210f89360 100644
--- a/htdocs/admin/supplier_payment.php
+++ b/htdocs/admin/supplier_payment.php
@@ -247,7 +247,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 869ee4ca4fb..980ebe10fff 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -247,7 +247,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index 58f6af55d60..16e5da99f60 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -513,7 +513,7 @@ if ($resql) {
$obj = $db->fetch_object($resql);
print '';
- print ''.$obj->name.' '."\n";
+ print ''.dol_escape_htmltag($obj->name).' '."\n";
print '';
if (isASecretKey($obj->name)) {
if (empty($dolibarr_main_prod)) {
diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php
index bfd2ae4b09b..c3778861ddf 100644
--- a/htdocs/admin/ticket.php
+++ b/htdocs/admin/ticket.php
@@ -266,7 +266,7 @@ foreach ($dirmodels as $reldir) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index 4fb4e05f771..2f18bab5896 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -541,7 +541,7 @@ if ($mode == 'searchkey') {
print $form->textwithpicto('', $htmltext, 1, 'info');
} elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) {
//print $key.'-'.$val;
- print ''.img_edit_add($langs->trans("Overwrite")).' ';
+ print ''.img_edit_add($langs->trans("TranslationOverwriteKey")).' ';
}
if (!empty($conf->global->MAIN_FEATURES_LEVEL)) {
diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php
index 1157000fd6b..f14393e2588 100755
--- a/htdocs/admin/workstation.php
+++ b/htdocs/admin/workstation.php
@@ -286,7 +286,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
$langs->load("errors");
print ''.$langs->trans($tmp).'
';
} elseif ($tmp == 'NotConfigured') {
- print $langs->trans($tmp);
+ print ''.$langs->trans($tmp).' ';
} else {
print $tmp;
}
diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php
index 99582b62047..f885677225e 100644
--- a/htdocs/api/class/api_access.class.php
+++ b/htdocs/api/class/api_access.class.php
@@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate
public function __isAllowed()
{
// phpcs:enable
- global $conf, $db;
+ global $conf, $db, $user;
$login = '';
$stored_key = '';
@@ -147,9 +147,15 @@ class DolibarrApiAccess implements iAuthenticate
if ($result <= 0) {
throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')');
}
+
$fuser->getrights();
+
+ // Set the property $user to the $user of API
static::$user = $fuser;
+ // Set also the global variable $user to the $user of API
+ $user = $fuser;
+
if ($fuser->socid) {
static::$role = 'external';
}
diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php
index 4a2e98fc666..ceaf6aa2ecc 100644
--- a/htdocs/asset/card.php
+++ b/htdocs/asset/card.php
@@ -81,6 +81,8 @@ $permissionnote = $user->rights->asset->write; // Used by the include of actions
$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
+$error = 0;
+
/*
* Actions
@@ -93,12 +95,17 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
- $error = 0;
+ $backurlforlist = DOL_URL_ROOT.'/asset/list.php';
- $backurlforlist = dol_buildpath('/asset/list.php', 1);
-
- // Actions cancel, add, update or delete
- include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = DOL_URL_ROOT.'/compta/bank/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
+ }
+ }
+ }
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php
index 335cd63115a..75b3030eac9 100644
--- a/htdocs/asset/class/asset_type.class.php
+++ b/htdocs/asset/class/asset_type.class.php
@@ -126,7 +126,7 @@ class AssetType extends CommonObject
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'";
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'";
$sql .= ", '".$this->db->escape($this->note)."'";
- $sql .= ", ".$conf->entity;
+ $sql .= ", ".((int) $conf->entity);
$sql .= ")";
dol_syslog("Asset_type::create", LOG_DEBUG);
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index 6f743172617..65175a86c5e 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -90,6 +90,7 @@ $hookmanager->initHooks(array('assettypecard', 'globalcard'));
$permissiontoadd = $user->rights->asset->setup_advance;
+
/*
* Actions
*/
@@ -396,7 +397,7 @@ if ($action == 'create') {
print dol_get_fiche_end();
- $form->buttonsSaveCancel("Add");
+ print $form->buttonsSaveCancel("Add");
print "\n";
}
@@ -502,12 +503,12 @@ if ($rowid > 0) {
// Edit
if ($user->rights->asset->write) {
- print '';
+ print '';
}
// Delete
if ($user->rights->asset->write) {
- print '';
+ print '';
}
print "";
diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index 385101c7468..2a15aa0965b 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -47,11 +47,17 @@ if ($search_showonlyerrors < 0) {
$search_showonlyerrors = 0;
}
+$search_startyear = GETPOST('search_startyear', 'int');
+$search_startmonth = GETPOST('search_startmonth', 'int');
+$search_startday = GETPOST('search_startday', 'int');
+$search_endyear = GETPOST('search_endyear', 'int');
+$search_endmonth = GETPOST('search_endmonth', 'int');
+$search_endday = GETPOST('search_endday', 'int');
$search_id = GETPOST('search_id', 'alpha');
$search_fk_user = GETPOST('search_fk_user', 'intcomma');
$search_start = -1;
-if (GETPOST('search_startyear') != '') {
- $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
+if ($search_startyear != '') {
+ $search_start = dol_mktime(0, 0, 0, $search_startmonth, $search_startday, $search_startyear);
}
$search_end = -1;
if (GETPOST('search_endyear') != '') {
@@ -321,22 +327,22 @@ if ($search_fk_user > 0) {
$param .= '&search_fk_user='.urlencode($search_fk_user);
}
if ($search_startyear > 0) {
- $param .= '&search_startyear='.urlencode(GETPOST('search_startyear', 'int'));
+ $param .= '&search_startyear='.urlencode($search_startyear);
}
if ($search_startmonth > 0) {
- $param .= '&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int'));
+ $param .= '&search_startmonth='.urlencode($search_startmonth);
}
if ($search_startday > 0) {
- $param .= '&search_startday='.urlencode(GETPOST('search_startday', 'int'));
+ $param .= '&search_startday='.urlencode($search_startday);
}
if ($search_endyear > 0) {
- $param .= '&search_endyear='.urlencode(GETPOST('search_endyear', 'int'));
+ $param .= '&search_endyear='.urlencode($search_endyear);
}
if ($search_endmonth > 0) {
- $param .= '&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int'));
+ $param .= '&search_endmonth='.urlencode($search_endmonth);
}
if ($search_endday > 0) {
- $param .= '&search_endday='.urlencode(GETPOST('search_endday', 'int'));
+ $param .= '&search_endday='.urlencode($search_endday);
}
if ($search_showonlyerrors > 0) {
$param .= '&search_showonlyerrors='.urlencode($search_showonlyerrors);
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index ea4b306ac12..e6ae5c78ae5 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -1299,7 +1299,7 @@ class BOMLine extends CommonObjectLine
}
}
if (count($sqlwhere) > 0) {
- $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
+ $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
}
if (!empty($sortfield)) {
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index 158627e274c..84300e76d98 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -103,7 +103,7 @@ class Categories extends DolibarrApi
if (!is_array($cats)) {
throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors));
}
- $this->category->childs = [];
+ $this->category->childs = array();
foreach ($cats as $cat) {
$this->category->childs[] = $this->_cleanObjectDatas($cat);
}
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index 065b4dfa83e..708fb3a3e83 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -205,10 +205,14 @@ foreach ($fulltree as $key => $val) {
$entry .= ''.img_view().' ';
$entry .= ' ';
$entry .= '';
- $entry .= ''.img_edit().' ';
+ if ($user->rights->categorie->creer) {
+ $entry .= '' . img_edit() . ' ';
+ }
$entry .= ' ';
$entry .= '';
- $entry .= ''.img_delete().' ';
+ if ($user->rights->categorie->supprimer) {
+ $entry .= '' . img_delete() . ' ';
+ }
$entry .= ' ';
$entry .= ' ';
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index a7dba92085a..e4ceccdb3fc 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -70,6 +70,10 @@ $offsetvalue = GETPOST('offsetvalue', 'int');
$offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
$remindertype = GETPOST('selectremindertype', 'aZ09');
$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
+$complete = GETPOST('complete', 'alpha'); // 'na' must be allowed
+if ($complete == 'na' || $complete == -2) {
+ $complete = -1;
+}
$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'));
$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'));
@@ -240,7 +244,7 @@ if (empty($reshook) && $action == 'add') {
exit;
}
- $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
+ $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
// Clean parameters
$datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
@@ -471,7 +475,7 @@ if (empty($reshook) && $action == 'update') {
$apmin = GETPOST('apmin', 'int');
$p2hour = GETPOST('p2hour', 'int');
$p2min = GETPOST('p2min', 'int');
- $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
+ $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
// Clean parameters
if ($aphour == -1) {
@@ -1074,15 +1078,15 @@ if ($action == 'create') {
// Status
print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").' ';
print '';
- $percent = GETPOST('complete')!=='' ? GETPOST('complete') : -1;
+ $percent = $complete !=='' ? $complete : -1;
if (GETPOSTISSET('status')) {
$percent = GETPOST('status');
} elseif (GETPOSTISSET('percentage')) {
- $percent = GETPOST('percentage');
+ $percent = GETPOST('percentage', 'int');
} else {
- if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) {
+ if ($complete == '0' || GETPOST("afaire") == 1) {
$percent = '0';
- } elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) {
+ } elseif ($complete == 100 || GETPOST("afaire") == 2) {
$percent = 100;
}
}
@@ -1340,7 +1344,7 @@ if ($id > 0) {
$result5 = $object->fetch_optionals();
if ($listUserAssignedUpdated || $donotclearsession) {
- $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
+ $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
@@ -1534,7 +1538,7 @@ if ($id > 0) {
// Status
print ' '.$langs->trans("Status").' / '.$langs->trans("Percentage").' ';
- $percent = GETPOST("percentage") ? GETPOST("percentage") : $object->percentage;
+ $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage;
$formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200');
print ' ';
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 19aff1699c8..e79edcf8e23 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -265,6 +265,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) {
$name = 'AGENDA_EXT_NAME'.$i;
$offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
$color = 'AGENDA_EXT_COLOR'.$i;
+ $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
$buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
if (!empty($conf->global->$source) && !empty($conf->global->$name)) {
// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
@@ -273,6 +274,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) {
'name'=>$conf->global->$name,
'offsettz' => (!empty($conf->global->$offsettz) ? $conf->global->$offsettz : 0),
'color'=>$conf->global->$color,
+ 'default'=>$conf->global->$default,
'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)
);
}
@@ -288,6 +290,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) {
$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
$color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i;
$enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i;
+ $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i;
$buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i;
if (!empty($user->conf->$source) && !empty($user->conf->$name)) {
// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
@@ -296,6 +299,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) {
'name'=>$user->conf->$name,
'offsettz' => (!empty($user->conf->$offsettz) ? $user->conf->$offsettz : 0),
'color'=>$user->conf->$color,
+ 'default'=>$user->conf->$default,
'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)
);
}
@@ -576,6 +580,15 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
if (is_array($showextcals) && count($showextcals) > 0) {
$s .= '';
- $out .= ''.img_picto($langs->trans($text_off), 'switch_off').' ';
- $out .= ''.img_picto($langs->trans($text_on), 'switch_on').' ';
+ $out .= ''.img_picto($langs->trans($text_off), 'switch_off').' ';
+ $out .= ''.img_picto($langs->trans($text_on), 'switch_on').' ';
return $out;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 483e890e369..dd22c804f23 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -692,14 +692,11 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
*
* @param string $paramname Name of parameter to found
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
- * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
- * @param mixed $options Options to pass to filter_var when $check is set to 'custom'
- * @param string $noreplace Force disable of replacement of __xxx__ strings.
* @return int Value found (int)
*/
-function GETPOSTINT($paramname, $method = 0, $filter = null, $options = null, $noreplace = 0)
+function GETPOSTINT($paramname, $method = 0)
{
- return (int) GETPOST($paramname, 'int', $method, $filter, $options, $noreplace);
+ return (int) GETPOST($paramname, 'int', $method, null, null, 0);
}
/**
@@ -2215,13 +2212,19 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
if (!empty($object->state)) {
$ret .= "\n".$object->state;
}
+ } elseif (isset($object->country_code) && in_array($object->country_code, array('JP'))) {
+ // JP: In romaji, title firstname name\n address lines \n [state,] town zip \n country
+ // See https://www.sljfaq.org/afaq/addresses.html
+ $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town));
+ $ret .= ($ret ? $sep : '').($object->state ? $object->state.', ' : '').$town.($object->zip ? ' ' : '').$object->zip;
} elseif (isset($object->country_code) && in_array($object->country_code, array('IT'))) {
- // IT: tile firstname name\n address lines \n zip (Code Departement) \n country
+ // IT: title firstname name\n address lines \n zip town state_code \n country
$ret .= ($ret ? $sep : '').$object->zip;
$town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town));
$ret .= ($town ? (($object->zip ? ' ' : '').$town) : '');
$ret .= (empty($object->state_code) ? '' : (' '.$object->state_code));
- } else { // Other: title firstname name \n address lines \n zip town \n country
+ } else {
+ // Other: title firstname name \n address lines \n zip town[, state] \n country
$town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town));
$ret .= !empty($object->zip) ? (($ret ? $sep : '').$object->zip) : '';
$ret .= ($town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$town) : '');
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index e3337c4266f..28b56efb20d 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -256,7 +256,7 @@ function getCustomerInvoicePieChart($socid = 0)
$i = 0;
$total = 0;
- $vals = [];
+ $vals = array();
while ($i < $num) {
$row = $db->fetch_row($resql);
@@ -279,14 +279,14 @@ function getCustomerInvoicePieChart($socid = 0)
$result .= '';
$objectstatic = new Facture($db);
- $array = [Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED, Facture::STATUS_ABANDONED];
- $dataseries = [];
+ $array = array(Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED, Facture::STATUS_ABANDONED);
+ $dataseries = array();
foreach ($array as $status) {
$objectstatic->statut = $status;
$objectstatic->paye = $status == Facture::STATUS_CLOSED ? -1 : 0;
- $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)];
+ $dataseries[] = array($objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == Facture::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
@@ -376,7 +376,7 @@ function getPurchaseInvoicePieChart($socid = 0)
$i = 0;
$total = 0;
- $vals = [];
+ $vals = array();
while ($i < $num) {
$row = $db->fetch_row($resql);
@@ -400,14 +400,14 @@ function getPurchaseInvoicePieChart($socid = 0)
$result .= '';
$objectstatic = new FactureFournisseur($db);
- $array = [FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED];
- $dataseries = [];
+ $array = array(FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED);
+ $dataseries = array();
foreach ($array as $status) {
$objectstatic->statut = $status;
$objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0;
- $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)];
+ $dataseries[] = array($objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == FactureFournisseur::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 73fc5295a99..0eba9dde1b5 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -207,7 +207,7 @@ function project_prepare_head(Project $project)
if ($conf->eventorganization->enabled && !empty($project->usage_organize_event)) {
$langs->load('eventorganization');
$head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id;
- $head[$h][1] = $langs->trans("ConferenceOrBoothTab");
+ $head[$h][1] = $langs->trans("EventOrganization");
// Enable caching of conf or booth count
$nbConfOrBooth = 0;
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index b297c81035e..4c36244a5bf 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -611,7 +611,7 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta
$feature = 'projet_task';
}
- $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salary', 'website'); // Test on entity only (Objects with no link to company)
+ $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for societe object
$checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet', 'project'); // Test for project object
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 26aa5df16ad..b1746c31d49 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -85,9 +85,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 10,
'id' => $id,
'idsel' => 'home',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => ' ',
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1),
'loadLangs' => array(),
'submenus' => array(),
);
@@ -110,9 +110,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 18,
'id' => $id,
'idsel' => 'members',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'member', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 0 : 1),
'loadLangs' => array(),
'submenus' => array(),
);
@@ -139,9 +139,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 20,
'id' => $id,
'idsel' => 'companies',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'company', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 0 : 1),
'loadLangs' => array("companies", "suppliers"),
'submenus' => array(),
);
@@ -166,9 +166,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 30,
'id' => $id,
'idsel' => 'products',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'product', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 0 : 1),
'loadLangs' => array("products"),
'submenus' => array(),
);
@@ -191,9 +191,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 31,
'id' => $id,
'idsel' => 'mrp',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'mrp', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 0 : 1),
'loadLangs' => array("mrp"),
'submenus' => array(),
);
@@ -216,9 +216,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 35,
'id' => $id,
'idsel' => 'project',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'project', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 0 : 1),
'loadLangs' => array("projects"),
'submenus' => array(),
);
@@ -265,9 +265,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 40,
'id' => $id,
'idsel' => 'commercial',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'contract', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 0 : 1),
'loadLangs' => array("commercial"),
'submenus' => array(),
);
@@ -299,9 +299,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 50,
'id' => $id,
'idsel' => 'billing',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'bill', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 0 : 1),
'loadLangs' => array("compta"),
'submenus' => array(),
);
@@ -324,9 +324,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 52,
'id' => $id,
'idsel' => 'bank',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'bank_account', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 0 : 1),
'loadLangs' => array("compta", "banks"),
'submenus' => array(),
);
@@ -349,9 +349,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 54,
'id' => $id,
'idsel' => 'accountancy',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'accountancy', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1),
'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"),
'submenus' => array(),
);
@@ -375,19 +375,25 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 80,
'id' => $id,
'idsel' => 'hrm',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'hrm', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 0 : 1),
'loadLangs' => array("holiday"),
'submenus' => array(),
);
- // Tickets and knwoledge base
+ // Tickets and knowledge base
$tmpentry = array(
- 'enabled'=>(!empty($conf->ticket->enabled) || !empty($conf->knwoledgemanagement->enabled)),
- 'perms'=>(!empty($user->rights->ticket->read) || !empty($user->rights->knwoledgemanagement->read)),
- 'module'=>'ticket|knwoledgemanagement'
+ 'enabled'=>(!empty($conf->ticket->enabled) || !empty($conf->knowledgemanagement->enabled)),
+ 'perms'=>(!empty($user->rights->ticket->read) || !empty($user->rights->knowledgemanagement->knowledgerecord->read)),
+ 'module'=>'ticket|knowledgemanagement'
);
+ $link = '';
+ if (!empty($conf->ticket->enabled)) {
+ $link = '/ticket/index.php?mainmenu=ticket&leftmenu=';
+ } else {
+ $link = '/knowledgemanagement/knowledgerecord_list.php?mainmenu=ticket&leftmenu=';
+ }
$menu_arr[] = array(
'name' => 'Ticket',
'link' => '/ticket/index.php?mainmenu=ticket&leftmenu=',
@@ -400,9 +406,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 88,
'id' => $id,
'idsel' => 'ticket',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'ticket', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "ticket") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 0 : 1),
'loadLangs' => array("other"),
'submenus' => array(),
);
@@ -425,9 +431,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
'position' => 90,
'id' => $id,
'idsel' => 'tools',
- 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"',
+ 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"',
'prefix' => img_picto('', 'tools', 'class="fa-fw paddingright"'),
- 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") ? 0 : 1),
+ 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 0 : 1),
'loadLangs' => array("other"),
'submenus' => array(),
);
@@ -1567,7 +1573,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Cash Control
if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) {
- $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run);
+ $permtomakecashfence = ($user->hasRight('cashdesk', 'run')|| $user->hasRight('takepos', 'run'));
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"'));
$newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence);
@@ -1733,7 +1739,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$titleboth = $langs->trans("LeadsOrProjects");
$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
- if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 0) {
+ if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
$titleboth = $langs->trans("Projects");
$titlenew = $langs->trans("NewProject");
}
@@ -1746,7 +1752,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/projet/index.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects', 0, '', '', '', img_picto('', 'project', 'class="pictofixedwidth"'));
$newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->rights->projet->creer);
- if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 0) {
+ if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
$newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : '').'&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list');
} elseif (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 1) {
$newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index e9688daf28e..50171253938 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -994,9 +994,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$note = json_encode(array('authorid'=>(is_object($user) ? $user->id : 0), 'ip'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'])));
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES";
- $sql .= " (".$this->db->encrypt($this->const_name, 1);
- $sql .= ", ".$this->db->encrypt('1', 1);
- $sql .= ", 0, ".$entity;
+ $sql .= " (".$this->db->encrypt($this->const_name);
+ $sql .= ", ".$this->db->encrypt('1');
+ $sql .= ", 0, ".((int) $entity);
$sql .= ", '".$this->db->escape($note)."')";
dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG);
@@ -1555,12 +1555,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$sql .= ", entity";
$sql .= ")";
$sql .= " VALUES (";
- $sql .= $this->db->encrypt($this->const_name."_TABS_".$i, 1);
+ $sql .= $this->db->encrypt($this->const_name."_TABS_".$i);
$sql .= ", 'chaine'";
- $sql .= ", ".$this->db->encrypt($newvalue, 1);
+ $sql .= ", ".$this->db->encrypt($newvalue);
$sql .= ", null";
$sql .= ", '0'";
- $sql .= ", ".$entity;
+ $sql .= ", ".((int) $entity);
$sql .= ")";
$resql = $this->db->query($sql);
@@ -1627,9 +1627,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
if ($row[0] == 0) { // If not found
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)";
$sql .= " VALUES (";
- $sql .= $this->db->encrypt($name, 1);
+ $sql .= $this->db->encrypt($name);
$sql .= ",'".$this->db->escape($type)."'";
- $sql .= ",".(($val != '') ? $this->db->encrypt($val, 1) : "''");
+ $sql .= ",".(($val != '') ? $this->db->encrypt($val) : "''");
$sql .= ",".($note ? "'".$this->db->escape($note)."'" : "null");
$sql .= ",'".$this->db->escape($visible)."'";
$sql .= ",".$entity;
@@ -2064,8 +2064,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$row = $this->db->fetch_row($result);
if ($row[0] == 0) {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)";
- $sql .= " VALUES ('".$this->db->escape($this->db->encrypt($name))."', 'chaine', '".$this->db->escape($this->db->encrypt($dir))."', 'Directory for module ".$this->name."', '0', ".((int) $conf->entity).")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, type, value, note, visible, entity)";
+ $sql .= " VALUES (".$this->db->encrypt($name).", 'chaine', ".$this->db->encrypt($dir).", '".$this->db->escape("Directory for module ".$this->name)."', '0', ".((int) $conf->entity).")";
dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);
$this->db->query($sql);
@@ -2141,8 +2141,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
if (isset($value['entity'])) {
$entity = $value['entity'];
}
- } else // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...)
- {
+ } else { // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...)
$newvalue = json_encode($value);
}
}
@@ -2156,9 +2155,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$sql .= ", entity";
$sql .= ")";
$sql .= " VALUES (";
- $sql .= "'".$this->db->escape($this->db->encrypt($this->const_name."_".strtoupper($key)))."'";
+ $sql .= " ".$this->db->encrypt($this->const_name."_".strtoupper($key));
$sql .= ", 'chaine'";
- $sql .= ", '".$this->db->escape($this->db->encrypt($newvalue))."'";
+ $sql .= ", ".$this->db->encrypt($newvalue);
$sql .= ", null";
$sql .= ", '0'";
$sql .= ", ".((int) $entity);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 13d83dbd3f1..0fe149af0df 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1221,6 +1221,14 @@ class pdf_crabe extends ModelePDFFactures
$default_font_size = pdf_getPDFFontSize($outputlangs);
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ $default_font_size--;
+ }
+
$tab2_top = $posy;
$tab2_hl = 4;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -1239,7 +1247,7 @@ class pdf_crabe extends ModelePDFFactures
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total") : ''), 0, 'L', 1);
$total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 2bd8fb2ecec..021f195c577 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -1143,7 +1143,7 @@ class pdf_sponge extends ModelePDFFactures
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
- $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
+ $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
}
if ($object->type != 2) {
@@ -1368,7 +1368,7 @@ class pdf_sponge extends ModelePDFFactures
$posy = $pdf->GetY();
}
- // cumul TVA précédent
+ // Cumulate preceding VAT
$index++;
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $posy);
@@ -1442,7 +1442,7 @@ class pdf_sponge extends ModelePDFFactures
// Total remise
$total_line_remise = 0;
foreach ($object->lines as $i => $line) {
- $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
+ $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this method to core/lib/pdf.lib
// Gestion remise sous forme de ligne négative
if ($line->total_ht < 0) {
$total_line_remise += -$line->total_ht;
@@ -1473,7 +1473,7 @@ class pdf_sponge extends ModelePDFFactures
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total") : ''), 0, 'L', 1);
$total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
@@ -2151,7 +2151,7 @@ class pdf_sponge extends ModelePDFFactures
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $mode = 'target';
+ $mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php
index 706c35a9f82..621bb8e6d2d 100644
--- a/htdocs/core/modules/facture/mod_facture_mercure.php
+++ b/htdocs/core/modules/facture/mod_facture_mercure.php
@@ -75,7 +75,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$tooltip .= $langs->trans("GenericMaskCodes5");
// Setting the prefix
- $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'): ';
+ $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
$texte .= ' ';
@@ -83,17 +83,17 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte .= ' ';
// Prefix setting of replacement invoices
- $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'): ';
+ $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
$texte .= ' ';
// Prefix setting of credit note
- $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'): ';
+ $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
$texte .= ' ';
// Prefix setting of deposit
- $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'): ';
+ $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'): ';
$texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
$texte .= ' ';
diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php
index bf7fc2777ae..ffd274c7096 100644
--- a/htdocs/core/modules/modApi.class.php
+++ b/htdocs/core/modules/modApi.class.php
@@ -245,8 +245,8 @@ class modApi extends DolibarrModules
{
// Remove old constants with entity fields different of 0
$sql = array(
- "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->db->escape($this->db->encrypt('MAIN_MODULE_API'))."'",
- "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->db->escape($this->db->encrypt('API_PRODUCTION_MODE'))."'"
+ "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_API'), // API can't be enabled per environment. Why ?
+ "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('API_PRODUCTION_MODE') // Not in production mode by default at activation
);
return $this->_remove($sql, $options);
diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php
index 71b40d5f19c..b166166b95f 100644
--- a/htdocs/core/modules/modBom.class.php
+++ b/htdocs/core/modules/modBom.class.php
@@ -326,12 +326,12 @@ class modBom extends DolibarrModules
$this->import_code[$r] = 'bom_'.$r;
$this->import_label[$r] = 'BillOfMaterials';
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = [];
- $this->import_tables_array[$r] = ['b' => MAIN_DB_PREFIX.'bom_bom', 'extra' => MAIN_DB_PREFIX.'bom_bom_extrafields'];
- $this->import_tables_creator_array[$r] = ['b' => 'fk_user_creat']; // Fields to store import user id
- $this->import_fields_array[$r] = [
- 'b.ref' => 'Document Ref*',
- 'b.label' => 'BomLabel*',
+ $this->import_entities_array[$r] = array();
+ $this->import_tables_array[$r] = array('b' => MAIN_DB_PREFIX.'bom_bom', 'extra' => MAIN_DB_PREFIX.'bom_bom_extrafields');
+ $this->import_tables_creator_array[$r] = array('b' => 'fk_user_creat'); // Fields to store import user id
+ $this->import_fields_array[$r] = array(
+ 'b.ref' => 'Ref*',
+ 'b.label' => 'Label*',
'b.fk_product' => 'ProductRef*',
'b.description' => 'Description',
'b.note_public' => 'Note',
@@ -346,12 +346,12 @@ class modBom extends DolibarrModules
'b.fk_user_valid' => 'ValidatedById',
'b.model_pdf' => 'Model',
'b.status' => 'Status*',
- 'b.bomtype' => 'BomType*'
-
- ];
+ 'b.bomtype' => 'Type*'
+ );
+ $import_sample = array();
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
@@ -365,61 +365,62 @@ class modBom extends DolibarrModules
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bom'];
- $this->import_regex_array[$r] = [
- 'b.ref' => '(CPV\d{4}-\d{4}|BOM\d{4}-\d{4}|PROV.{1,32}$)'
- ];
+ $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bom');
+ $this->import_regex_array[$r] = array(
+ 'b.ref' => ''
+ );
- $this->import_updatekeys_array[$r] = ['b.ref' => 'Ref'];
- $this->import_convertvalue_array[$r] = [
- 'b.fk_product' => [
+ $this->import_updatekeys_array[$r] = array('b.ref' => 'Ref');
+ $this->import_convertvalue_array[$r] = array(
+ 'b.fk_product' => array(
'rule' => 'fetchidfromref',
'file' => '/product/class/product.class.php',
'class' => 'Product',
'method' => 'fetch',
'element' => 'Product'
- ],
- 'b.fk_warehouse' => [
+ ),
+ 'b.fk_warehouse' => array(
'rule' => 'fetchidfromref',
'file' => '/product/stock/class/entrepot.class.php',
'class' => 'Entrepot',
'method' => 'fetch',
'element' => 'Warehouse'
- ],
- 'b.fk_user_valid' => [
+ ),
+ 'b.fk_user_valid' => array(
'rule' => 'fetchidfromref',
'file' => '/user/class/user.class.php',
'class' => 'User',
'method' => 'fetch',
'element' => 'user'
- ],
- 'b.fk_user_modif' => [
+ ),
+ 'b.fk_user_modif' => array(
'rule' => 'fetchidfromref',
'file' => '/user/class/user.class.php',
'class' => 'User',
'method' => 'fetch',
'element' => 'user'
- ],
- ];
+ ),
+ );
//Import BOM Lines
$r++;
$this->import_code[$r] = 'bom_lines_'.$r;
- $this->import_label[$r] = 'BillOfMaterialsLine';
+ $this->import_label[$r] = 'BillOfMaterialsLines';
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = [];
- $this->import_tables_array[$r] = ['bd' => MAIN_DB_PREFIX.'bom_bomline', 'extra' => MAIN_DB_PREFIX.'bom_bomline_extrafields'];
- $this->import_fields_array[$r] = [
- 'bd.fk_bom' => 'Document Ref*',
+ $this->import_entities_array[$r] = array();
+ $this->import_tables_array[$r] = array('bd' => MAIN_DB_PREFIX.'bom_bomline', 'extra' => MAIN_DB_PREFIX.'bom_bomline_extrafields');
+ $this->import_fields_array[$r] = array(
+ 'bd.fk_bom' => 'BOM*',
'bd.fk_product' => 'ProductRef',
'bd.fk_bom_child' => 'BOMChild',
'bd.description' => 'Description',
'bd.qty' => 'LineQty',
- 'bd.qty_frozen' => 'LineIsFrozen',
+ 'bd.qty_frozen' => 'LineIsFrozen',
'bd.disable_stock_change' => 'Disable Stock Change',
'bd.efficiency' => 'Efficiency',
'bd.position' => 'LinePosition'
- ];
+ );
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.")";
@@ -433,25 +434,25 @@ class modBom extends DolibarrModules
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bomline'];
- $this->import_regex_array[$r] = [];
- $this->import_updatekeys_array[$r] = ['bd.fk_bom' => 'BOM Id'];
- $this->import_convertvalue_array[$r] = [
- 'bd.fk_bom' => [
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bomline');
+ $this->import_regex_array[$r] = array();
+ $this->import_updatekeys_array[$r] = array('bd.fk_bom' => 'BOM Id');
+ $this->import_convertvalue_array[$r] = array(
+ 'bd.fk_bom' => array(
'rule' => 'fetchidfromref',
'file' => '/bom/class/bom.class.php',
'class' => 'BOM',
'method' => 'fetch',
'element' => 'bom'
- ],
- 'bd.fk_product' => [
+ ),
+ 'bd.fk_product' => array(
'rule' => 'fetchidfromref',
'file' => '/product/class/product.class.php',
'class' => 'Product',
'method' => 'fetch',
'element' => 'Product'
- ],
- ];
+ ),
+ );
}
/**
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index d9d30e8b7a1..ffcfef61a6e 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -285,11 +285,11 @@ class modCommande extends DolibarrModules
$this->import_code[$r] = 'commande_'.$r;
$this->import_label[$r] = 'CustomersOrders';
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = [];
- $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields'];
- $this->import_tables_creator_array[$r] = ['c' => 'fk_user_author']; // Fields to store import user id
- $this->import_fields_array[$r] = [
- 'c.ref' => 'Document Ref*',
+ $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
+ $this->import_fields_array[$r] = array(
+ 'c.ref' => 'Ref*',
'c.ref_client' => 'RefCustomer',
'c.fk_soc' => 'ThirdPartyName*',
'c.fk_projet' => 'ProjectId',
@@ -310,7 +310,7 @@ class modCommande extends DolibarrModules
'c.fk_cond_reglement' => 'Payment Condition',
'c.fk_mode_reglement' => 'Payment Mode',
'c.model_pdf' => 'Model'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';
@@ -321,7 +321,7 @@ class modCommande extends DolibarrModules
}
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
@@ -337,7 +337,6 @@ class modCommande extends DolibarrModules
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande'];
$this->import_regex_array[$r] = [
- 'c.ref' => '(CPV\d{4}-\d{4}|CO\d{4}-\d{4}|PROV.{1,32}$)',
'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'
];
@@ -371,10 +370,10 @@ class modCommande extends DolibarrModules
$this->import_code[$r] = 'commande_lines_'.$r;
$this->import_label[$r] = 'SaleOrderLines';
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = [];
- $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields'];
- $this->import_fields_array[$r] = [
- 'cd.fk_commande' => 'Document Ref*',
+ $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_product' => 'IdProduct',
'cd.label' => 'Label',
@@ -393,7 +392,7 @@ class modCommande extends DolibarrModules
'cd.date_end' => 'End Date',
'cd.buy_price_ht' => 'LineBuyPriceHT',
'cd.rang' => 'LinePosition'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index a36f219007b..6efebe9a82b 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -504,10 +504,10 @@ class modFournisseur extends DolibarrModules
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "SupplierInvoices"; // Translation key
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r] = ['f' => MAIN_DB_PREFIX.'facture_fourn', 'extra' => MAIN_DB_PREFIX.'facture_fourn_extrafields'];
- $this->import_tables_creator_array[$r] = ['f' => 'fk_user_author']; // Fields to store import user id
- $this->import_fields_array[$r] = [
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('f' => MAIN_DB_PREFIX.'facture_fourn', 'extra' => MAIN_DB_PREFIX.'facture_fourn_extrafields');
+ $this->import_tables_creator_array[$r] = array('f' => 'fk_user_author'); // Fields to store import user id
+ $this->import_fields_array[$r] = array(
'f.ref' => 'InvoiceRef*',
'f.ref_supplier' => 'RefSupplier',
'f.type' => 'Type*',
@@ -531,7 +531,7 @@ class modFournisseur extends DolibarrModules
'f.fk_mode_reglement' => 'Payment Mode',
'f.model_pdf' => 'Model',
'f.date_valid' => 'Validation Date'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['f.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';
@@ -540,7 +540,7 @@ class modFournisseur extends DolibarrModules
$this->import_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) {
@@ -552,9 +552,9 @@ class modFournisseur extends DolibarrModules
}
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn'];
- $this->import_regex_array[$r] = ['f.ref' => '(SI\d{4}-\d{4}|PROV.{1,32}$)', 'f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'];
- $import_sample = [
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn');
+ $this->import_regex_array[$r] = array('f.ref' => '(SI\d{4}-\d{4}|PROV.{1,32}$)', 'f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency');
+ $import_sample = array(
'f.ref' => '(PROV001)',
'f.ref_supplier' => 'Supplier1',
'f.type' => '0',
@@ -583,23 +583,23 @@ class modFournisseur extends DolibarrModules
'f.multicurrency_total_ht' => '1000',
'f.multicurrency_total_tva' => '0',
'f.multicurrency_total_ttc' => '1000'
- ];
+ );
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
- $this->import_updatekeys_array[$r] = ['f.ref' => 'Ref'];
- $this->import_convertvalue_array[$r] = [
+ $this->import_updatekeys_array[$r] = array('f.ref' => 'Ref');
+ $this->import_convertvalue_array[$r] = array(
//'c.ref'=>array('rule'=>'getrefifauto'),
- 'f.fk_soc' => ['rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'],
- 'f.fk_account' => ['rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'],
- ];
+ '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'),
+ );
//Import Supplier Invoice Lines
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "SupplierInvoiceLines"; // Translation key
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r] = ['fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields'];
- $this->import_fields_array[$r] = [
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $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_product' => 'IdProduct',
@@ -618,7 +618,7 @@ class modFournisseur extends DolibarrModules
'fd.date_start' => 'Start Date',
'fd.date_end' => 'End Date',
'fd.fk_unit' => 'Unit'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['fd.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['fd.multicurrency_subprice'] = 'CurrencyRate';
@@ -627,7 +627,7 @@ class modFournisseur extends DolibarrModules
$this->import_fields_array[$r]['fd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) {
@@ -639,9 +639,9 @@ class modFournisseur extends DolibarrModules
}
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn_det'];
- $this->import_regex_array[$r] = ['fd.product_type' => '[0|1]$', 'fd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', 'fd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'];
- $import_sample = [
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn_det');
+ $this->import_regex_array[$r] = array('fd.product_type' => '[0|1]$', 'fd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', 'fd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency');
+ $import_sample = array(
'fd.fk_facture_fourn' => '(PROV001)',
'fd.fk_parent_line' => '',
'fd.fk_product' => '',
@@ -665,23 +665,23 @@ class modFournisseur extends DolibarrModules
'fd.multicurrency_total_ht' => '50000',
'fd.multicurrency_total_tva' => '0',
'fd.multicurrency_total_ttc' => '50000'
- ];
+ );
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
- $this->import_updatekeys_array[$r] = ['fd.rowid' => 'Row Id', 'fd.fk_facture_fourn' => 'Invoice Id', 'fd.fk_product' => 'Product Id'];
- $this->import_convertvalue_array[$r] = [
- 'fd.fk_facture_fourn' => ['rule' => 'fetchidfromref', 'file' => '/fourn/class/fournisseur.facture.class.php', 'class' => 'FactureFournisseur', 'method' => 'fetch'],
- ];
+ $this->import_updatekeys_array[$r] = array('fd.rowid' => 'Row Id', 'fd.fk_facture_fourn' => 'Invoice Id', 'fd.fk_product' => 'Product Id');
+ $this->import_convertvalue_array[$r] = array(
+ 'fd.fk_facture_fourn' => array('rule' => 'fetchidfromref', 'file' => '/fourn/class/fournisseur.facture.class.php', 'class' => 'FactureFournisseur', 'method' => 'fetch'),
+ );
//Import Purchase Orders
$r++;
$this->import_code[$r] = 'commande_fournisseur_'.$r;
$this->import_label[$r] = 'SuppliersOrders';
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = [];
- $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'commande_fournisseur', 'extra' => MAIN_DB_PREFIX.'commande_fournisseur_extrafields'];
- $this->import_tables_creator_array[$r] = ['c' => 'fk_user_author']; // Fields to store import user id
- $this->import_fields_array[$r] = [
- 'c.ref' => 'Document Ref*',
+ $this->import_entities_array[$r] = array();
+ $this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'commande_fournisseur', 'extra' => MAIN_DB_PREFIX.'commande_fournisseur_extrafields');
+ $this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id
+ $this->import_fields_array[$r] = array(
+ 'c.ref' => 'Ref*',
'c.ref_supplier' => 'RefSupplier',
'c.fk_soc' => 'ThirdPartyName*',
'c.fk_projet' => 'ProjectId',
@@ -705,7 +705,7 @@ class modFournisseur extends DolibarrModules
'c.fk_cond_reglement' => 'Payment Condition',
'c.fk_mode_reglement' => 'Payment Mode',
'c.model_pdf' => 'Model'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';
@@ -716,7 +716,7 @@ class modFournisseur extends DolibarrModules
}
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
@@ -730,40 +730,39 @@ class modFournisseur extends DolibarrModules
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseur'];
- $this->import_regex_array[$r] = [
- 'c.ref' => '(PO\d{4}-\d{4}|PORDER.{1,32}$|PROV.{1,32}$)',
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseur');
+ $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_updatekeys_array[$r] = array('c.ref' => 'Ref');
+ $this->import_convertvalue_array[$r] = array(
+ 'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
- ],
- 'c.fk_mode_reglement' => [
+ ),
+ 'c.fk_mode_reglement' => array(
'rule' => 'fetchidfromcodeorlabel',
'file' => '/compta/paiement/class/cpaiement.class.php',
'class' => 'Cpaiement',
'method' => 'fetch',
'element' => 'cpayment'
- ],
- 'c.source' => ['rule' => 'zeroifnull'],
- ];
+ ),
+ 'c.source' => array('rule' => 'zeroifnull'),
+ );
- //Import PO Lines
+ // Import PO Lines
$r++;
$this->import_code[$r] = 'commande_fournisseurdet_'.$r;
$this->import_label[$r] = 'PurchaseOrderLines';
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = [];
- $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields'];
- $this->import_fields_array[$r] = [
- 'cd.fk_commande' => 'Document Ref*',
+ $this->import_entities_array[$r] = array();
+ $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_product' => 'IdProduct',
'cd.label' => 'Label',
@@ -783,7 +782,7 @@ class modFournisseur extends DolibarrModules
'cd.special_code' => 'Special Code',
'cd.rang' => 'LinePosition',
'cd.fk_unit' => 'Unit'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';
@@ -805,24 +804,24 @@ class modFournisseur extends DolibarrModules
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseurdet'];
- $this->import_regex_array[$r] = [
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande_fournisseurdet');
+ $this->import_regex_array[$r] = array(
'cd.product_type' => '[0|1]$',
'cd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product',
'cd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'
- ];
- $this->import_updatekeys_array[$r] = ['cd.fk_commande' => 'Purchase Order Id'];
- $this->import_convertvalue_array[$r] = [
- 'cd.fk_commande' => [
+ );
+ $this->import_updatekeys_array[$r] = array('cd.fk_commande' => 'Purchase Order Id');
+ $this->import_convertvalue_array[$r] = array(
+ 'cd.fk_commande' => array(
'rule' => 'fetchidfromref',
'file' => '/fourn/class/fournisseur.commande.class.php',
'class' => 'CommandeFournisseur',
'method' => 'fetch',
'element' => 'order_supplier'
- ],
- 'cd.info_bits' => ['rule' => 'zeroifnull'],
- 'cd.special_code' => ['rule' => 'zeroifnull'],
- ];
+ ),
+ 'cd.info_bits' => array('rule' => 'zeroifnull'),
+ 'cd.special_code' => array('rule' => 'zeroifnull'),
+ );
}
diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php
index 5957158e893..c3be87963c8 100644
--- a/htdocs/core/modules/modKnowledgeManagement.class.php
+++ b/htdocs/core/modules/modKnowledgeManagement.class.php
@@ -317,7 +317,7 @@ class modKnowledgeManagement extends DolibarrModules
// Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'$conf->knowledgemanagement->enabled',
// Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules
- 'perms'=>'1',
+ 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2,
@@ -337,7 +337,7 @@ class modKnowledgeManagement extends DolibarrModules
// Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'$conf->knowledgemanagement->enabled',
// Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules
- 'perms'=>'1',
+ 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2,
@@ -357,7 +357,7 @@ class modKnowledgeManagement extends DolibarrModules
// Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'$conf->knowledgemanagement->enabled',
// Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules
- 'perms'=>'1',
+ 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->write',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2
diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php
index ad14724d154..dfd292aa847 100644
--- a/htdocs/core/modules/modMailing.class.php
+++ b/htdocs/core/modules/modMailing.class.php
@@ -79,7 +79,7 @@ class modMailing extends DolibarrModules
$this->const[$r][0] = "MAILING_CONTACT_DEFAULT_BULK_STATUS";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "0";
- $this->const[$r][3] = 'Default black list mailing';
+ $this->const[$r][3] = 'Default value for field "Refuse bulk email" when creating a contact';
$this->const[$r][4] = 0;
$r++;
diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php
index 1cfbd76caf7..ac300fc26e3 100644
--- a/htdocs/core/modules/modMrp.class.php
+++ b/htdocs/core/modules/modMrp.class.php
@@ -263,31 +263,78 @@ class modMrp extends DolibarrModules
/* BEGIN MODULEBUILDER TOPMENU */
/* END MODULEBUILDER LEFTMENU MO */
+ $langs->loadLangs(array("mrp", "stocks"));
+
// Exports profiles provided by this module
$r = 1;
- /* BEGIN MODULEBUILDER EXPORT MO */
- /*
- $langs->load("mrp");
+
$this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
- $this->export_icon[$r]='mo@mrp';
- $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo';
- include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
- $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo';
+ $this->export_label[$r]='MOs'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->export_icon[$r]='mrp';
+ $this->export_fields_array[$r] = array(
+ 'm.rowid'=>"Id",
+ 'm.ref'=>"Ref",
+ 'm.label'=>"Label",
+ 'm.fk_project'=>'Project',
+ 'm.fk_bom'=>"Bom",
+ 'm.date_start_planned'=>"DateStartPlanned",
+ 'm.date_end_planned'=>"DateEndPlanned",
+ 'm.fk_product'=>"Product",
+ 'm.status'=>'Status',
+ 'm.model_pdf'=>'Model',
+ 'm.fk_user_valid'=>'ValidatedById',
+ 'm.fk_user_modif'=>'ModifiedById',
+ 'm.fk_user_creat'=>'CreatedById',
+ 'm.date_valid'=>'DateValidation',
+ 'm.note_private'=>'NotePrivate',
+ 'm.note_public'=>'Note',
+ 'm.fk_soc'=>'Tiers',
+ 'e.rowid'=>'WarehouseId',
+ 'e.ref'=>'WarehouseRef',
+ 'm.qty'=>'Qty',
+ 'm.date_creation'=>'DateCreation',
+ 'm.tms'=>'DateModification'
+ );
+ $keyforselect = 'mrp_mo';
+ $keyforelement = 'mrp_mo';
+ $keyforaliasextra = 'extra';
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.'mo as t';
- $this->export_sql_end[$r] .=' WHERE 1 = 1';
- $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';
- $r++; */
- /* END MODULEBUILDER EXPORT MO */
+ $this->export_TypeFields_array[$r] = array(
+ 'm.ref'=>"Text",
+ 'm.label'=>"Text",
+ 'm.fk_project'=>'Numeric',
+ 'm.fk_bom'=>"Numeric",
+ 'm.date_end_planned'=>"Date",
+ 'm.date_start_planned'=>"Date",
+ 'm.fk_product'=>"Numeric",
+ 'm.status'=>'Numeric',
+ 'm.model_pdf'=>'Text',
+ 'm.fk_user_valid'=>'Numeric',
+ 'm.fk_user_modif'=>'Numeric',
+ 'm.fk_user_creat'=>'Numeric',
+ 'm.date_valid'=>'Date',
+ 'm.note_private'=>'Text',
+ 'm.note_public'=>'Text',
+ 'm.fk_soc'=>'Numeric',
+ 'e.fk_warehouse'=>'Numeric',
+ 'e.ref'=>'Text',
+ 'm.qty'=>'Numeric',
+ 'm.date_creation'=>'Date',
+ 'm.tms'=>'Date'
+
+ );
+ $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'mrp_mo as m';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = m.fk_warehouse';
+ $this->export_sql_end[$r] .= ' WHERE m.entity IN ('.getEntity('mrp_mo').')'; // For product and service profile
// Imports profiles provided by this module
- $r = 1;
+ $r = 0;
+ $langs->load("mrp");
/* BEGIN MODULEBUILDER IMPORT MO */
/*
- $langs->load("mrp");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='mo@mrp';
@@ -302,6 +349,89 @@ class modMrp extends DolibarrModules
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';
$r++; */
/* END MODULEBUILDER IMPORT MO */
+ $r++;
+ $this->import_code[$r]=$this->rights_class.'_'.$r;
+ $this->import_label[$r]='MOs'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->import_icon[$r]='mrp';
+ $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
+ $this->import_tables_array[$r] = array('m'=>MAIN_DB_PREFIX.'mrp_mo', 'extra'=>MAIN_DB_PREFIX.'mrp_mo_extrafields');
+ $this->import_tables_creator_array[$r] = array('m'=>'fk_user_creat'); // Fields to store import user id
+ $this->import_fields_array[$r] = array(
+ 'm.ref' => "Ref*",
+ 'm.label' => "Label*",
+ 'm.fk_project'=>'Project',
+ 'm.fk_bom'=>"Bom",
+ 'm.date_start_planned'=>"DateStartPlanned",
+ 'm.date_end_planned'=>"DateEndPlanned",
+ 'm.fk_product'=>"Product*",
+ 'm.status'=>'Status',
+ 'm.model_pdf'=>'Model',
+ 'm.fk_user_valid'=>'ValidatedById',
+ 'm.fk_user_modif'=>'ModifiedById',
+ 'm.fk_user_creat'=>'CreatedById',
+ 'm.date_valid'=>'DateValid',
+ 'm.note_private'=>'NotePrivate',
+ 'm.note_public'=>'Note',
+ 'm.fk_soc'=>'Tiers',
+ 'm.fk_warehouse'=>'Warehouse',
+ 'm.qty'=>'Qty*',
+ 'm.date_creation'=>'DateCreation',
+ 'm.tms'=>'DateModification',
+ );
+ $import_sample = array();
+
+ // Add extra fields
+ $import_extrafield_sample = array();
+ $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'mrp_mo' 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 ? '*' : '');
+ $import_extrafield_sample[$fieldname] = $fieldlabel;
+ }
+ }
+ // End add extra fields
+
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'mrp_mo');
+ /*$this->import_regex_array[$r] = array(
+ 'm.ref' => ''
+ );*/
+
+ $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
+ $this->import_updatekeys_array[$r] = array('m.ref' => 'Ref');
+ $this->import_convertvalue_array[$r] = array(
+ 'm.fk_product' => array(
+ 'rule' => 'fetchidfromref',
+ 'file' => '/product/class/product.class.php',
+ 'class' => 'Product',
+ 'method' => 'fetch',
+ 'element' => 'Product'
+ ),
+ 'm.fk_warehouse' => array(
+ 'rule' => 'fetchidfromref',
+ 'file' => '/product/stock/class/entrepot.class.php',
+ 'class' => 'Entrepot',
+ 'method' => 'fetch',
+ 'element' => 'Warehouse'
+ ),
+ 'm.fk_user_valid' => array(
+ 'rule' => 'fetchidfromref',
+ 'file' => '/user/class/user.class.php',
+ 'class' => 'User',
+ 'method' => 'fetch',
+ 'element' => 'user'
+ ),
+ 'm.fk_user_modif' => array(
+ 'rule' => 'fetchidfromref',
+ 'file' => '/user/class/user.class.php',
+ 'class' => 'User',
+ 'method' => 'fetch',
+ 'element' => 'user'
+ ),
+ );
}
/**
diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php
index 66138c584b5..deefea6c2e8 100644
--- a/htdocs/core/modules/modProjet.class.php
+++ b/htdocs/core/modules/modProjet.class.php
@@ -66,7 +66,7 @@ class modProjet extends DolibarrModules
// Dependencies
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
- $this->requiredby = array(); // List of module ids to disable if this one is disabled
+ $this->requiredby = array('modEventOrganization'); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->phpmin = array(5, 6); // Minimum version of PHP required by module
$this->langfiles = array('projects');
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index 33a28c9ec11..b46671eae01 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -276,11 +276,11 @@ class modPropale extends DolibarrModules
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'Proposals'; // Translation key
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'propal', 'extra' => MAIN_DB_PREFIX.'propal_extrafields'];
- $this->import_tables_creator_array[$r] = ['c'=>'fk_user_author']; // Fields to store import user id
- $this->import_fields_array[$r] = [
- 'c.ref' => 'Document Ref*',
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'propal', 'extra' => MAIN_DB_PREFIX.'propal_extrafields');
+ $this->import_tables_creator_array[$r] = array('c'=>'fk_user_author'); // Fields to store import user id
+ $this->import_fields_array[$r] = array(
+ 'c.ref' => 'Ref*',
'c.ref_client' => 'RefCustomer',
'c.fk_soc' => 'ThirdPartyName*',
'c.datec' => 'DateCreation',
@@ -293,7 +293,7 @@ class modPropale extends DolibarrModules
'c.note_public' => 'Note',
'c.date_livraison' => 'DeliveryDate',
'c.fk_user_valid' => 'ValidatedById'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';
@@ -302,7 +302,7 @@ class modPropale extends DolibarrModules
$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propal' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) {
@@ -353,13 +353,13 @@ class modPropale extends DolibarrModules
$this->import_code[$r] = $this->rights_class.'line_'.$r;
$this->import_label[$r] = "ProposalLines"; // Translation key
$this->import_icon[$r] = $this->picto;
- $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r] = [
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array(
'cd' => MAIN_DB_PREFIX.'propaldet',
'extra' => MAIN_DB_PREFIX.'propaldet_extrafields'
- ];
- $this->import_fields_array[$r] = [
- 'cd.fk_propal' => 'Document Ref*',
+ );
+ $this->import_fields_array[$r] = array(
+ 'cd.fk_propal' => 'Proposal*',
'cd.fk_parent_line' => 'PrParentLine',
'cd.fk_product' => 'IdProduct',
'cd.label' => 'Label',
@@ -377,7 +377,7 @@ class modPropale extends DolibarrModules
'cd.date_start' => 'Start Date',
'cd.date_end' => 'End Date',
'cd.buy_price_ht' => 'LineBuyPriceHT'
- ];
+ );
if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';
@@ -386,7 +386,7 @@ class modPropale extends DolibarrModules
$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
- $import_extrafield_sample = [];
+ $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propaldet' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) {
@@ -398,9 +398,9 @@ class modPropale extends DolibarrModules
}
}
// End add extra fields
- $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propaldet'];
- $this->import_regex_array[$r] = ['cd.product_type' => '[0|1]$'];
- $import_sample = [
+ $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propaldet');
+ $this->import_regex_array[$r] = array('cd.product_type' => '[0|1]$');
+ $import_sample = array(
'cd.fk_propal' => 'PROV(0001)',
'cd.fk_parent_line' => '',
'cd.fk_product' => '',
@@ -424,17 +424,17 @@ class modPropale extends DolibarrModules
'cd.multicurrency_total_ht' => '10000',
'cd.multicurrency_total_tva' => '0',
'cd.multicurrency_total_ttc' => '10100'
- ];
+ );
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
- $this->import_updatekeys_array[$r] = ['cd.fk_propal' => 'Quotation Id', 'cd.fk_product' => 'Product Id'];
- $this->import_convertvalue_array[$r] = [
- 'cd.fk_propal' => [
+ $this->import_updatekeys_array[$r] = array('cd.fk_propal' => 'Quotation Id', 'cd.fk_product' => 'Product Id');
+ $this->import_convertvalue_array[$r] = array(
+ 'cd.fk_propal' => array(
'rule'=>'fetchidfromref',
'file'=>'/comm/propal/class/propal.class.php',
'class'=>'Propal',
'method'=>'fetch'
- ]
- ];
+ )
+ );
}
diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
new file mode 100644
index 00000000000..5f6a03f2caa
--- /dev/null
+++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
@@ -0,0 +1,1514 @@
+
+ * Copyright (C) 2005-2011 Regis Houssin
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2010-2014 Juanjo Menent
+ * Copyright (C) 2015 Marcos GarcÃa
+ * Copyright (C) 2017 Ferran Marcet
+ * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018 Frédéric France
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ * or see https://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/mrp/doc/pdf_vinci.php
+ * \ingroup mrp
+ * \brief File of class to generate MO document from vinci model
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+
+
+/**
+ * Class to generate the manufacturing orders with the vinci model
+ */
+class pdf_vinci extends ModelePDFMo
+{
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
+ /**
+ * @var string model name
+ */
+ public $name;
+
+ /**
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
+
+ /**
+ * @var string document type
+ */
+ public $type;
+
+ /**
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.6 = array(5, 6)
+ */
+ public $phpmin = array(5, 6);
+
+ /**
+ * Dolibarr version of the loaded document
+ * @var string
+ */
+ public $version = 'dolibarr';
+
+ /**
+ * @var int page_largeur
+ */
+ public $page_largeur;
+
+ /**
+ * @var int page_hauteur
+ */
+ public $page_hauteur;
+
+ /**
+ * @var array format
+ */
+ public $format;
+
+ /**
+ * @var int marge_gauche
+ */
+ public $marge_gauche;
+
+ /**
+ * @var int marge_droite
+ */
+ public $marge_droite;
+
+ /**
+ * @var int marge_haute
+ */
+ public $marge_haute;
+
+ /**
+ * @var int marge_basse
+ */
+ public $marge_basse;
+
+ /**
+ * Issuer
+ * @var Societe object that emits
+ */
+ public $emetteur;
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $conf, $langs, $mysoc;
+
+ // Load translation files required by the page
+ $langs->loadLangs(array("main", "bills"));
+
+ $this->db = $db;
+ $this->name = "vinci";
+ $this->description = $langs->trans('DocumentModelStandardPDF');
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+
+ // Page size for A4 format
+ $this->type = 'pdf';
+ $formatarray = pdf_getFormat();
+ $this->page_largeur = $formatarray['width'];
+ $this->page_hauteur = $formatarray['height'];
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
+
+ $this->option_logo = 1; // Display logo
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; //Available in several languages
+ $this->option_escompte = 0; // Displays if there has been a discount
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
+
+ // Get source company
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) {
+ $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
+ }
+
+ // Define position of columns
+ $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end
+ }
+
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param CommandeFournisseur $object Id of object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
+ */
+ public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ // phpcs:enable
+ global $user, $langs, $conf, $hookmanager, $mysoc;
+
+ if (!is_object($outputlangs)) {
+ $outputlangs = $langs;
+ }
+ // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+ if (!empty($conf->global->MAIN_USE_FPDF)) {
+ $outputlangs->charset_output = 'ISO-8859-1';
+ }
+
+ // Load translation files required by the page
+ $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
+
+ global $outputlangsbis;
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
+ }
+
+ if (!isset($object->lines) || !is_array($object->lines)) {
+ $object->lines = array();
+ }
+
+ $nblines = count($object->lines);
+
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ }
+
+ // Loop on each lines to detect if there is at least one image to show
+ $realpatharray = array();
+
+ if ($conf->mrp->dir_output) {
+ $object->fetch_thirdparty();
+
+ $deja_regle = 0;
+ $amount_credit_notes_included = 0;
+ $amount_deposits_included = 0;
+ //$amount_credit_notes_included = $object->getSumCreditNotesUsed();
+ //$amount_deposits_included = $object->getSumDepositsUsed();
+
+ // Definition of $dir and $file
+ if ($object->specimen) {
+ $dir = $conf->mrp->dir_output;
+ $file = $dir."/SPECIMEN.pdf";
+ } else {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->mrp->dir_output.'/'.$objectref;
+ $file = $dir."/".$objectref.".pdf";
+ }
+
+ if (!file_exists($dir)) {
+ if (dol_mkdir($dir) < 0) {
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ }
+
+ if (file_exists($dir)) {
+ // Add pdfgeneration hook
+ if (!is_object($hookmanager)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+ $hookmanager = new HookManager($this->db);
+ }
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+
+ $nblines = count($object->lines);
+
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
+ $heightforfooter += 6;
+ }
+ $pdf->SetAutoPageBreak(1, 0);
+
+ if (class_exists('TCPDF')) {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ // Set path to the background PDF File
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
+
+ $pdf->Open();
+ $pagenb = 0;
+ $pdf->SetDrawColor(128, 128, 128);
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("Mo"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Mo")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
+ $pdf->SetCompression(false);
+ }
+
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+
+ // Does we have at least one line with discount $this->atleastonediscount
+
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ $pagenb++;
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->SetTextColor(0, 0, 0);
+
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
+
+
+ // Affiche notes
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote)) {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
+
+ $pagenb = $pdf->getPage();
+ if ($notetoshow) {
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
+ $pageposbeforenote = $pagenb;
+
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+ $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
+ $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
+
+ $tab_top -= 2;
+
+ $pdf->startTransaction();
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ // Description
+ $pageposafternote = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+
+ if ($pageposafternote > $pageposbeforenote) {
+ $pdf->rollbackTransaction(true);
+
+ // prepar pages to receive notes
+ while ($pagenb < $pageposafternote) {
+ $pdf->AddPage();
+ $pagenb++;
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ // $this->_pagefoot($pdf,$object,$outputlangs,1);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ }
+
+ // back to start
+ $pdf->setPage($pageposbeforenote);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pageposafternote = $pdf->getPage();
+
+ $posyafter = $pdf->GetY();
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ //$posyafter = $tab_top_newpage;
+ }
+
+
+ // apply note frame to previus pages
+ $i = $pageposbeforenote;
+ while ($i < $pageposafternote) {
+ $pdf->setPage($i);
+
+
+ $pdf->SetDrawColor(128, 128, 128);
+ // Draw note frame
+ if ($i > $pageposbeforenote) {
+ $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ } else {
+ $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+ }
+
+ // Add footer
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+
+ $i++;
+ }
+
+ // apply note frame to last page
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ $height_note = $posyafter - $tab_top_newpage;
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ } else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ $posyafter = $pdf->GetY();
+ $height_note = $posyafter - $tab_top;
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
+ // not enough space, need to add page
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+
+ $posyafter = $tab_top_newpage;
+ }
+ }
+
+ $tab_height = $tab_height - $height_note;
+ $tab_top = $posyafter + 6;
+ } else {
+ $height_note = 0;
+ }
+
+ $nexY = $tab_top + 5;
+
+ // Use new auto collum system
+ $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
+
+ // Loop on each lines
+ $pageposbeforeprintlines = $pdf->getPage();
+ $pagenb = $pageposbeforeprintlines;
+
+ $bom = new BOM($this->db);
+ $bom -> fetch($object->fk_bom);
+
+ $nblines = count($bom->lines);
+
+ for ($i = 0; $i < $nblines; $i++) {
+ $curY = $nexY;
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetTextColor(0, 0, 0);
+
+ $prod = new Product($this->db);
+ $prod->fetch($bom->lines[$i]->fk_product);
+
+ // Define size of image if we need it
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) {
+ $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
+ }
+
+ $pdf->setTopMargin($tab_top_newpage);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
+
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
+
+ // We start with Photo of product line
+ if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ $pdf->setPage($pageposbefore + 1);
+
+ $curY = $tab_top_newpage;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ $showpricebeforepagebreak = 1;
+ } else {
+ $showpricebeforepagebreak = 0;
+ }
+ }
+
+ if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) {
+ $curX = $this->posxpicture - 1;
+ $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ // $pdf->Image does not increase value return by getY, so we save it manually
+ $posYAfterImage = $curY + $imglinesize['height'];
+ }
+ // Description of product line
+ $curX = $this->posxdesc - 1;
+ $showpricebeforepagebreak = 1;
+
+ if ($this->getColumnStatus('code')) {
+ $pdf->startTransaction(); //description
+ //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU);
+ $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ if ($pageposafter > $pageposbefore) { // There is a pagebreak
+ $pdf->rollbackTransaction(true);
+
+ //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU);
+ $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
+ if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $pdf->setPage($pageposafter + 1);
+ } else {
+ // We found a page break
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ $showpricebeforepagebreak = 1;
+ } else {
+ $showpricebeforepagebreak = 0;
+ }
+ }
+ } else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ $posYAfterDescription = $pdf->GetY();
+ }
+
+ $nexY = $pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $pdf->setPage($pageposbefore);
+ $pdf->setTopMargin($this->marge_haute);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+ // We suppose that a too long description is moved completely on next page
+ if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+ $pdf->setPage($pageposafter);
+ $curY = $tab_top_newpage;
+ }
+
+ if ($this->getColumnStatus('desc')) {
+ $pdf->startTransaction(); //description
+ $des = $prod -> description;
+ $descr = $des;//implode(" ", $des);
+
+ $this->printStdColumnContent($pdf, $curY, 'desc', $descr);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ if ($pageposafter > $pageposbefore) { // There is a pagebreak
+ $pdf->rollbackTransaction(true);
+
+ $this->printStdColumnContent($pdf, $curY, 'desc', $descr);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
+ if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) {
+ $pdf->useTemplate($tplidx);
+ }
+ //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $pdf->setPage($pageposafter + 1);
+ } else {
+ // We found a page break
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
+ $showpricebeforepagebreak = 1;
+ } else {
+ $showpricebeforepagebreak = 0;
+ }
+ }
+ } else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ $posYAfterDescription = max($posYAfterDescription, $pdf->GetY());
+ }
+
+ $nexY = max($nexY, $pdf->GetY());
+ $pageposafter = $pdf->getPage();
+ $pdf->setPage($pageposbefore);
+ $pdf->setTopMargin($this->marge_haute);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+ // We suppose that a too long description is moved completely on next page
+ if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+ $pdf->setPage($pageposafter);
+ $curY = $tab_top_newpage;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+
+ // Quantity
+ // Enough for 6 chars
+ if ($this->getColumnStatus('qty')) {
+ $qty = $bom->lines[$i]->qty;
+ $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Quantity
+ // Enough for 6 chars
+ if ($this->getColumnStatus('qtytot')) {
+ $qtytot = $object->qty * $bom->lines[$i]->qty;
+ $this->printStdColumnContent($pdf, $curY, 'qtytot', $qtytot);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Dimensions
+ if ($this->getColumnStatus('dim')) {
+ $array = array_filter(array($prod->length, $prod->width, $prod->height));
+ $dim = implode("x", $array);
+ $this->printStdColumnContent($pdf, $curY, 'dim', $dim);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+ }
+
+
+
+
+ // Show square
+ if ($pagenb == $pageposbeforeprintlines) {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ } else {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+
+ // Affiche zone infos
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+
+ // Affiche zone totaux
+ //$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+
+ // Affiche zone versements
+ if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
+ $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pied de page
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) {
+ $pdf->AliasNbPages();
+ }
+
+ $pdf->Close();
+
+ $pdf->Output($file, 'F');
+
+ // Add pdfgeneration hook
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ if (!empty($conf->global->MAIN_UMASK)) {
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+ }
+
+ $this->result = array('fullpath'=>$file);
+
+ return 1; // No error
+ } else {
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ } else {
+ $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
+ return 0;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Show payments table
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param CommandeFournisseur $object Object order
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
+ */
+ protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
+ {
+ // phpcs:enable
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Show miscellaneous information (payment mode, payment term, ...)
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param CommandeFournisseur $object Object to show
+ * @param int $posy Y
+ * @param Translate $outputlangs Langs object
+ * @return integer
+ */
+ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ {
+ // phpcs:enable
+ global $conf, $mysoc;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ // If France, show VAT mention if not applicable
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+
+ $posy = $pdf->GetY() + 4;
+ }
+
+ $posxval = 52;
+
+ // Show payments conditions
+ if (!empty($object->cond_reglement_code) || $object->cond_reglement) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentConditions").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
+ $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
+ $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy = $pdf->GetY() + 3;
+ }
+
+ // Show payment mode
+ if (!empty($object->mode_reglement_code)) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
+
+ $posy = $pdf->GetY() + 2;
+ }
+
+
+ return $posy;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Show total to pay
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
+ * @param int $posy Position depart
+ * @param Translate $outputlangs Objet langs
+ * @return int Position pour suite
+ */
+ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ {
+ // phpcs:enable
+ global $conf, $mysoc;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ // Tableau total
+ $col1x = 120;
+ $col2x = 170;
+ if ($this->page_largeur < 210) { // To work with US executive format
+ $col2x -= 20;
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+
+ $useborder = 0;
+ $index = 0;
+
+ // Total HT
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
+
+ // Show VAT by rates and total
+ $pdf->SetFillColor(248, 248, 248);
+
+ $this->atleastoneratenotnull = 0;
+ foreach ($this->tva as $tvakey => $tvaval) {
+ if ($tvakey > 0) { // On affiche pas taux 0
+ $this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl = '';
+
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey = str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ if (!$this->atleastoneratenotnull) { // If no vat at all
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
+
+ // Total LocalTax1
+ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) {
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
+ }
+
+ // Total LocalTax2
+ if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) {
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
+ }
+ } else {
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ //{
+ //Local tax 1
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) {
+ continue;
+ }
+
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) { // On affiche pas taux 0
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl = '';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey = str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
+ }
+
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ //{
+ //Local tax 2
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) {
+ continue;
+ }
+
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) { // On affiche pas taux 0
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl = '';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey = str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ }
+ }
+
+ // Total TTC
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+
+ $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
+
+ $creditnoteamount = 0;
+ $depositsamount = 0;
+ //$creditnoteamount=$object->getSumCreditNotesUsed();
+ //$depositsamount=$object->getSumDepositsUsed();
+ //print "x".$creditnoteamount."-".$depositsamount;exit;
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ if (!empty($object->paye)) {
+ $resteapayer = 0;
+ }
+
+ if ($deja_regle > 0) {
+ // Already paid + Deposits
+ $index++;
+
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
+
+ $index++;
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
+ }
+
+ $index++;
+ return ($tab2_top + ($tab2_hl * $index));
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Show table for lines
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param string $tab_top Top position of table
+ * @param string $tab_height Height of table (rectangle)
+ * @param int $nexY Y (not used)
+ * @param Translate $outputlangs Langs object
+ * @param int $hidetop Hide top bar of array
+ * @param int $hidebottom Hide bottom bar of array
+ * @param string $currency Currency code
+ * @return void
+ */
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
+ {
+ global $conf;
+
+ // Force to disable hidetop and hidebottom
+ $hidebottom = 0;
+ if ($hidetop) {
+ $hidetop = -1;
+ }
+
+ $currency = !empty($currency) ? $currency : $conf->currency;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ // Amount in (at tab_top - 1)
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ if (empty($hidetop)) {
+ //$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
+ $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+
+ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
+ }
+
+ $pdf->SetDrawColor(128, 128, 128);
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ // Output Rect
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+
+ foreach ($this->cols as $colKey => $colDef) {
+ if (!$this->getColumnStatus($colKey)) {
+ continue;
+ }
+
+ // get title label
+ $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
+
+ // Add column separator
+ if (!empty($colDef['border-left'])) {
+ $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
+ }
+
+ if (empty($hidetop)) {
+ $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]);
+
+ $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1];
+ $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']);
+ }
+ }
+
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Show top header of page.
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param CommandeFournisseur $object Object to show
+ * @param int $showaddress 0=no, 1=yes
+ * @param Translate $outputlangs Object lang for output
+ * @return void
+ */
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ {
+ global $langs, $conf, $mysoc;
+
+ $ltrdirection = 'L';
+ if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
+
+ // Load translation files required by the page
+ $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings"));
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ // Do not add the BACKGROUND as this is for suppliers
+ //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
+
+ //Affiche le filigrane brouillon - Print Draft Watermark
+ /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
+ {
+ pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
+ }*/
+ //Print content
+
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+
+ $posx = $this->page_largeur - $this->marge_droite - 100;
+ $posy = $this->marge_haute;
+
+ $pdf->SetXY($this->marge_gauche, $posy);
+
+ // Logo
+ $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ if ($this->emetteur->logo) {
+ if (is_readable($logo)) {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ } else {
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
+ }
+ } else {
+ $text = $this->emetteur->name;
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
+ }
+
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $title = $outputlangs->transnoentities("Mo")." ".$outputlangs->convToOutputCharset($object->ref);
+ $pdf->MultiCell(100, 3, $title, '', 'R');
+ $posy += 1;
+
+ if ($object->ref_supplier) {
+ $posy += 4;
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
+ $posy += 1;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
+ $object->fetch_projet();
+ if (!empty($object->project->ref)) {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT)) {
+ $object->fetch_projet();
+ if (!empty($object->project->ref)) {
+ $outputlangs->load("projects");
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $langs->load("projects");
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
+ }
+ }
+
+ if (!empty($object->date_approve)) {
+ $posy += 5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("MoDate")." : ".dol_print_date($object->date_approve, "day", false, $outputlangs, true), '', 'R');
+ } else {
+ $posy += 5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(255, 0, 0);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToApprove"), '', 'R');
+ }
+
+ // product info
+ $posy += 7;
+ $prodToMake = new Product($this->db);
+ $prodToMake->fetch($object->fk_product);
+ $pdf->SetFont('', 'B', $default_font_size + 1);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $prodToMake->ref, '', 'R');
+
+ $posy += 5;
+ $prodToMake = new Product($this->db);
+ $prodToMake->fetch($object->fk_product);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $prodToMake->description, '', 'R');
+
+ $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height));
+ $dim = implode("x", $array);
+ if (!empty($dim)) {
+ $posy += 5;
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $dim, '', 'R');
+ }
+
+ $posy += 5;
+ $prodToMake = new Product($this->db);
+ $prodToMake->fetch($object->fk_product);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("QtyToProduce").": " .$object->qty, '', 'R');
+
+
+ $pdf->SetTextColor(0, 0, 60);
+ $usehourmin = 'day';
+ if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
+ $usehourmin = 'dayhour';
+ }
+ if (!empty($object->delivery_date)) {
+ $posy += 4;
+ $pdf->SetXY($posx - 90, $posy);
+ $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R');
+ }
+
+ if ($object->thirdparty->code_fournisseur) {
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
+ }
+
+ // Get contact
+ if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0) {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
+ }
+
+ $posy += 1;
+ $pdf->SetTextColor(0, 0, 60);
+
+ $top_shift = 0;
+ // Show list of linked objects
+ $current_y = $pdf->getY();
+ $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+ if ($current_y < $pdf->getY()) {
+ $top_shift = $pdf->getY() - $current_y;
+ }
+
+ if ($showaddress) {
+ // Sender properties
+ $carac_emetteur = '';
+ // Add internal contact of proposal if defined
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0) {
+ $object->fetch_user($arrayidcontact[0]);
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ }
+
+ $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+
+ // Show sender
+ $posy = 42 + $top_shift;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx = $this->page_largeur - $this->marge_droite - 80;
+ }
+ $hautcadre = 40;
+
+ // Show sender frame
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy - 5);
+ $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
+
+ // Show sender name
+ $pdf->SetXY($posx + 2, $posy + 3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
+ $posy = $pdf->getY();
+
+ // Show sender information
+ $pdf->SetXY($posx + 2, $posy);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
+
+
+
+ // If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER'
+ $usecontact = false;
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
+ if (count($arrayidcontact) > 0) {
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
+ }
+
+ // Recipient name
+ if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ $thirdparty = $object->contact;
+ } else {
+ $thirdparty = $object->thirdparty;
+ }
+
+ //$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+
+ //$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
+
+ // Show recipient
+ //$widthrecbox = 100;
+ //if ($this->page_largeur < 210) {
+ // $widthrecbox = 84; // To work with US executive format
+ //}
+ //$posy = 42 + $top_shift;
+ //$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ //if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ // $posx = $this->marge_gauche;
+ //}
+ //
+ //// Show recipient frame
+ //$pdf->SetTextColor(0, 0, 0);
+ //$pdf->SetFont('', '', $default_font_size - 2);
+ //$pdf->SetXY($posx + 2, $posy - 5);
+ //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
+ //$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+ //
+ //// Show recipient name
+ //$pdf->SetXY($posx + 2, $posy + 3);
+ //$pdf->SetFont('', 'B', $default_font_size);
+ //$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
+ //
+ //$posy = $pdf->getY();
+ //
+ //// Show recipient information
+ //$pdf->SetFont('', '', $default_font_size - 1);
+ //$pdf->SetXY($posx + 2, $posy);
+ //$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
+ }
+
+ return $top_shift;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Show footer of page. Need this->emetteur object
+ *
+ * @param TCPDF $pdf PDF
+ * @param CommandeFournisseur $object Object to show
+ * @param Translate $outputlangs Object lang for output
+ * @param int $hidefreetext 1=Hide free text
+ * @return int Return height of bottom margin including footer text
+ */
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+ {
+ global $conf;
+ $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+ }
+
+
+
+ /**
+ * Define Array Column Field
+ *
+ * @param object $object common object
+ * @param Translate $outputlangs langs
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return null
+ */
+ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ global $conf, $hookmanager;
+
+ // Default field style for content
+ $this->defaultContentsFieldsStyle = array(
+ 'align' => 'R', // R,C,L
+ 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ // Default field style for content
+ $this->defaultTitlesFieldsStyle = array(
+ 'align' => 'C', // R,C,L
+ 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ /*
+ * For exemple
+ $this->cols['theColKey'] = array(
+ 'rank' => $rank, // int : use for ordering columns
+ 'width' => 20, // the column width in mm
+ 'title' => array(
+ 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ 'label' => ' ', // the final label : used fore final generated text
+ 'align' => 'L', // text alignement : R,C,L
+ 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'content' => array(
+ 'align' => 'L', // text alignement : R,C,L
+ 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
+ */
+ $rank = 0;
+ $this->cols['code'] = array(
+ 'rank' => $rank,
+ 'status' => false,
+ 'width' => 35, // in mm
+ 'title' => array(
+ 'textkey' => 'Ref'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ $this->cols['code']['status'] = true;
+
+ $rank = 1; // do not use negative rank
+ $this->cols['desc'] = array(
+ 'rank' => $rank,
+ 'width' => false, // only for desc
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Designation', // use lang key is usefull in somme case with module
+ 'align' => 'L',
+ // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ // 'label' => ' ', // the final label
+ 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'border-left' => true,
+ 'content' => array(
+ 'align' => 'L',
+ 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
+
+ $rank = $rank + 10;
+ $this->cols['photo'] = array(
+ 'rank' => $rank,
+ 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Photo',
+ 'label' => ' '
+ ),
+ 'content' => array(
+ 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'border-left' => false, // remove left line separator
+ );
+
+ if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
+ $this->cols['photo']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['dim'] = array(
+ 'rank' => $rank,
+ 'status' => false,
+ 'width' => 25, // in mm
+ 'title' => array(
+ 'textkey' => 'Size'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ $this->cols['dim']['status'] = true;
+
+ $rank = $rank + 10;
+ $this->cols['qty'] = array(
+ 'rank' => $rank,
+ 'width' => 16, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Qty'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ $this->cols['qty']['status'] = true;
+
+ $rank = $rank + 10;
+ $this->cols['qtytot'] = array(
+ 'rank' => $rank,
+ 'width' => 25, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'QtyTot'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ $this->cols['qtytot']['status'] = true;
+
+ // Add extrafields cols
+ if (!empty($object->lines)) {
+ $line = reset($object->lines);
+ $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+ }
+
+ $parameters = array(
+ 'object' => $object,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails,
+ 'hidedesc' => $hidedesc,
+ 'hideref' => $hideref
+ );
+
+ $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ } elseif (empty($reshook)) {
+ $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+ } else {
+ $this->cols = $hookmanager->resArray;
+ }
+ }
+}
diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
index 08345647b0f..3119ffa8dc5 100644
--- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
@@ -212,6 +212,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
if (!is_object($object->thirdparty)) {
$object->thirdparty = $mysoc; // If fetch_thirdparty fails, object has no socid (specimen)
}
+
$this->emetteur = $object->thirdparty;
if (!$this->emetteur->country_code) {
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
@@ -231,8 +232,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nblines = count($object->lines);
if ($conf->fournisseur->facture->dir_output) {
- $object->fetch_thirdparty();
-
$deja_regle = $object->getSommePaiement((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
$amount_credit_notes_included = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
$amount_deposits_included = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php
index 284407383d4..2f1c113fcf5 100644
--- a/htdocs/core/tpl/admin_extrafields_view.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php
@@ -84,18 +84,31 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
}
print '';
- print "".$extrafields->attributes[$elementtype]['pos'][$key]." \n";
- print "".$extrafields->attributes[$elementtype]['label'][$key]." \n"; // We don't translate here, we want admin to know what is the key not translated value
- print "".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])." \n";
- print "".$key." \n";
- print "".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]." \n";
- print ''.$extrafields->attributes[$elementtype]['size'][$key]." \n";
- print ''.dol_trunc($extrafields->attributes[$elementtype]['computed'][$key], 20)." \n";
+ // Position
+ print "".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])." \n";
+ // Label
+ print "".dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key])." \n"; // We don't translate here, we want admin to know what is the key not translated value
+ // Label translated
+ print ''.dol_escape_htmltag($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]))." \n";
+ // Key
+ print "".dol_escape_htmltag($key)." \n";
+ // Type
+ print "".dol_escape_htmltag($type2label[$extrafields->attributes[$elementtype]['type'][$key]])." \n";
+ // Size
+ print ''.dol_escape_htmltag($extrafields->attributes[$elementtype]['size'][$key])." \n";
+ // Computed field
+ print ''.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key])." \n";
+ // Is unique ?
print ''.yn($extrafields->attributes[$elementtype]['unique'][$key])." \n";
+ // Is mandatory ?
print ''.yn($extrafields->attributes[$elementtype]['required'][$key])." \n";
+ // Can always be editable ?
print ''.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])." \n";
- print ''.$extrafields->attributes[$elementtype]['list'][$key]." \n";
- print ''.$extrafields->attributes[$elementtype]['printable'][$key]." \n";
+ // Visible
+ print ''.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key])." \n";
+ // Print on PDF
+ print ''.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key])." \n";
+ // Summable
print ''.yn($extrafields->attributes[$elementtype]['totalizable'][$key])." \n";
if (!empty($conf->multicompany->enabled)) {
print '';
@@ -116,8 +129,8 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
print ' ';
}
print '';
- print ''.img_edit().' ';
- print ' '.img_delete().' ';
+ print ''.img_edit().' ';
+ print ' '.img_delete().' ';
print ' '."\n";
print " ";
}
diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php
index 00a38fde351..1257d473ced 100644
--- a/htdocs/core/tpl/contacts.tpl.php
+++ b/htdocs/core/tpl/contacts.tpl.php
@@ -89,7 +89,7 @@ if ($permission) {
?>