| '.$langs->trans("DateActionEnd").' | ';
- if (!$object->fulldayevent) {
+ if (empty($object->fulldayevent)) {
print dol_print_date($object->datef, 'dayhour', 'tzuser');
} else {
print dol_print_date($object->datef, 'day', 'tzuser');
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index 340ac1dfc8c..9069b63179f 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -310,6 +310,8 @@ if ($object->fetch($id) >= 0) {
print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic');
//print '';
+
+ print '';
print ' ';
//print ' ';
@@ -323,7 +325,7 @@ if ($object->fetch($id) >= 0) {
//print '| | ';
print ' ';
//print " \n";
- print ' ';
+ print ' '; // End tr
clearstatcache();
@@ -424,9 +426,9 @@ if ($object->fetch($id) >= 0) {
print '';
if ($allowaddtarget) {
- print '';
+ print '';
} else {
- print '';
+ print '';
//print $langs->trans("MailNoChangePossible");
print " ";
}
@@ -445,6 +447,7 @@ if ($object->fetch($id) >= 0) {
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
+ print ' '; // End table
print '';
print '
';
@@ -535,7 +538,7 @@ if ($object->fetch($id) >= 0) {
$morehtmlcenter = '';
if ($allowaddtarget) {
- $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'';
+ $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'';
}
$morehtmlcenter .= ' id.'">'.$langs->trans("Download").'';
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index b6977940411..e4cc6a37c1c 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -42,6 +42,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+if (!empty($conf->margin->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
+}
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
@@ -223,6 +226,10 @@ $arrayfields = array(
'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>-1),
+ 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
+ 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
+ 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
+ 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
@@ -486,6 +493,10 @@ $form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
$formpropal = new FormPropal($db);
+$formmargin = null;
+if (!empty($conf->margin->enabled)) {
+ $formmargin = new FormMargin($db);
+}
$companystatic = new Societe($db);
$projectstatic = new Project($db);
$formcompany = new FormCompany($db);
@@ -1244,6 +1255,22 @@ if ($resql) {
if (!empty($arrayfields['sale_representative']['checked'])) {
print ' | ';
}
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print '';
+ print ' | ';
+ }
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print '';
+ print ' | ';
+ }
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print '';
+ print ' | ';
+ }
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print '';
+ print ' | ';
+ }
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -1392,6 +1419,18 @@ if ($resql) {
if (!empty($arrayfields['sale_representative']['checked'])) {
print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
}
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
$totalarray = array(
'nbfield' => 0,
'val' => array(
@@ -1437,6 +1476,17 @@ if ($resql) {
$i = 0;
$typenArray = null;
+ $with_margin_info = false;
+ if (!empty($conf->margin->enabled) && (
+ !empty($arrayfields['total_pa']['checked'])
+ || !empty($arrayfields['total_margin']['checked'])
+ || !empty($arrayfields['total_margin_rate']['checked'])
+ || !empty($arrayfields['total_mark_rate']['checked'])
+ )
+ ) {
+ $with_margin_info = true;
+ }
+
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
@@ -1487,6 +1537,12 @@ if ($resql) {
}
}
+ $marginInfo = array();
+ if ($with_margin_info === true) {
+ $objectstatic->fetch_lines();
+ $marginInfo = $formmargin->getMarginInfosArray($objectstatic);
+ }
+
print '';
if (!empty($arrayfields['p.ref']['checked'])) {
@@ -1887,6 +1943,39 @@ if ($resql) {
}
}
+ // Total buying or cost price
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print '| '.price($marginInfo['pa_total']).' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Total margin
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print ''.price($marginInfo['total_margin']).' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
+ }
+ $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
+ }
+ // Total margin rate
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print ''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Total mark rate
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print ''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index e3b2c64c92a..c315a4fcd61 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -626,7 +626,7 @@ class Commande extends CommonOrder
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql .= " SET fk_statut = ".self::STATUS_DRAFT."',";
+ $sql .= " SET fk_statut = ".self::STATUS_DRAFT.",";
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 717b57ae8b1..8d677625040 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -40,6 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+if (!empty($conf->margin->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
+}
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@@ -187,6 +190,10 @@ $arrayfields = array(
'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115),
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116),
+ 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
+ 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
+ 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
+ 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120),
'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125),
'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130),
@@ -407,6 +414,10 @@ $now = dol_now();
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
+$formmargin = null;
+if (!empty($conf->margin->enabled)) {
+ $formmargin = new FormMargin($db);
+}
$companystatic = new Societe($db);
$formcompany = new FormCompany($db);
$projectstatic = new Project($db);
@@ -1193,6 +1204,22 @@ if ($resql) {
if (!empty($arrayfields['sale_representative']['checked'])) {
print ' | ';
}
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print '';
+ print ' | ';
+ }
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print '';
+ print ' | ';
+ }
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print '';
+ print ' | ';
+ }
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print '';
+ print ' | ';
+ }
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
@@ -1354,6 +1381,18 @@ if ($resql) {
if (!empty($arrayfields['sale_representative']['checked'])) {
print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
}
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ }
$totalarray = array(
'nbfield' => 0,
@@ -1413,6 +1452,18 @@ if ($resql) {
$generic_product = new Product($db);
$userstatic = new User($db);
$i = 0;
+
+ $with_margin_info = false;
+ if (!empty($conf->margin->enabled) && (
+ !empty($arrayfields['total_pa']['checked'])
+ || !empty($arrayfields['total_margin']['checked'])
+ || !empty($arrayfields['total_margin_rate']['checked'])
+ || !empty($arrayfields['total_mark_rate']['checked'])
+ )
+ ) {
+ $with_margin_info = true;
+ }
+
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
@@ -1455,6 +1506,12 @@ if ($resql) {
$projectstatic->ref = $obj->project_ref;
$projectstatic->title = $obj->project_label;
+ $marginInfo = array();
+ if ($with_margin_info === true) {
+ $generic_commande->fetch_lines();
+ $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
+ }
+
print ' ';
// Ref
@@ -1462,11 +1519,6 @@ if ($resql) {
print '| ';
print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
- // Warning late icon and note
- if ($generic_commande->hasDelay()) {
- print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
- }
-
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
@@ -1590,6 +1642,10 @@ if ($resql) {
if (!empty($arrayfields['c.date_commande']['checked'])) {
print ' | ';
print dol_print_date($db->jdate($obj->date_commande), 'day');
+ // Warning late icon and note
+ if ($generic_commande->hasDelay()) {
+ print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
+ }
print ' | ';
if (!$i) {
$totalarray['nbfield']++;
@@ -1792,6 +1848,39 @@ if ($resql) {
}
}
+ // Total buying or cost price
+ if (!empty($arrayfields['total_pa']['checked'])) {
+ print ''.price($marginInfo['pa_total']).' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Total margin
+ if (!empty($arrayfields['total_margin']['checked'])) {
+ print ''.price($marginInfo['total_margin']).' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
+ }
+ $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
+ }
+ // Total margin rate
+ if (!empty($arrayfields['total_margin_rate']['checked'])) {
+ print ''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+ // Total mark rate
+ if (!empty($arrayfields['total_mark_rate']['checked'])) {
+ print ''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').' | ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
+
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 4e2665ceca3..da438af9e01 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1135,6 +1135,8 @@ if (empty($reshook)) {
$facture_source->fetchPreviousNextSituationInvoice();
}
}
+
+
$id = $object->create($user);
if ($id < 0) {
$error++;
@@ -1262,6 +1264,7 @@ if (empty($reshook)) {
$line->multicurrency_total_tva = -$line->multicurrency_total_tva;
$line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
+ $line->context['createcreditnotefrominvoice'] = 1;
$result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
$object->lines[] = $line; // insert new line in current object
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5344da8d06a..cc722bafca3 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1,22 +1,23 @@
- * Copyright (C) 2004-2013 Laurent Destailleur
- * Copyright (C) 2004 Sebastien Di Cintio
- * Copyright (C) 2004 Benoit Mortier
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2014 Regis Houssin
- * Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2010-2020 Juanjo Menent
- * Copyright (C) 2012-2014 Christophe Battarel
- * Copyright (C) 2012-2015 Marcos García
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2012-2014 Raphaël Doursenaud
- * Copyright (C) 2013 Cedric Gross
- * Copyright (C) 2013 Florian Henry
- * Copyright (C) 2016 Ferran Marcet
- * Copyright (C) 2018 Alexandre Spangaro
- * Copyright (C) 2018 Nicolas ZABOURI
+/* Copyright (C) 2002-2007 Rodolphe Quiedeville
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2004 Sebastien Di Cintio
+ * Copyright (C) 2004 Benoit Mortier
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2014 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2010-2020 Juanjo Menent
+ * Copyright (C) 2012-2014 Christophe Battarel
+ * Copyright (C) 2012-2015 Marcos García
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2012-2014 Raphaël Doursenaud
+ * Copyright (C) 2013 Cedric Gross
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2016 Ferran Marcet
+ * Copyright (C) 2018 Alexandre Spangaro
+ * Copyright (C) 2018 Nicolas ZABOURI
+ * Copyright (C) 2022 Sylvain Legrand
*
* 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
@@ -1166,6 +1167,9 @@ class Facture extends CommonInvoice
$object->fetch($fromid);
+ // Load source object
+ $objFrom = clone $object;
+
// Change socid if needed
if (!empty($this->socid) && $this->socid != $object->socid) {
$objsoc = new Societe($this->db);
@@ -1246,13 +1250,13 @@ class Facture extends CommonInvoice
$this->errors = $object->errors;
} else {
// copy internal contacts
- if ($object->copy_linked_contact($this, 'internal') < 0) {
+ if ($object->copy_linked_contact($objFrom, 'internal') < 0) {
$error++;
$this->error = $object->error;
$this->errors = $object->errors;
- } elseif ($this->socid == $object->socid) {
+ } elseif ($object->socid == $objFrom->socid) {
// copy external contacts if same company
- if ($object->copy_linked_contact($this, 'external') < 0) {
+ if ($object->copy_linked_contact($objFrom, 'external') < 0) {
$error++;
$this->error = $object->error;
$this->errors = $object->errors;
@@ -1263,7 +1267,7 @@ class Facture extends CommonInvoice
if (!$error) {
// Hook of thirdparty module
if (is_object($hookmanager)) {
- $parameters = array('objFrom'=>$this);
+ $parameters = array('objFrom'=>$objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php
index 0a526e39e1e..1821d4720af 100644
--- a/htdocs/compta/facture/index.php
+++ b/htdocs/compta/facture/index.php
@@ -43,9 +43,8 @@ if (isset($user->socid) && $user->socid > 0) {
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
// Maximum elements of the tables
-$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
-$maxLatestEditCount = 5;
-$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
+$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? $max : $conf->global->MAIN_MAXLIST_OVERLOAD;
+$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? $max : $conf->global->MAIN_MAXLIST_OVERLOAD;
/*
@@ -64,7 +63,7 @@ if ($tmp) {
print $tmp;
print ' ';
}
-$tmp = getCustomerInvoiceDraftTable($max, $socid);
+$tmp = getCustomerInvoiceDraftTable($maxDraftCount, $socid);
if ($tmp) {
print $tmp;
print ' ';
@@ -74,13 +73,13 @@ print '';
print '';
-$tmp = getCustomerInvoiceLatestEditTable($maxLatestEditCount, $socid);
+$tmp = getCustomerInvoiceLatestEditTable($max, $socid);
if ($tmp) {
print $tmp;
print ' ';
}
-$tmp = getCustomerInvoiceUnpaidOpenTable($max, $socid);
+$tmp = getCustomerInvoiceUnpaidOpenTable($maxOpenCount, $socid);
if ($tmp) {
print $tmp;
print ' ';
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index c244229c5f8..f526220c071 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1621,6 +1621,18 @@ if ($resql) {
$totalarray['val'] = array();
$totalarray['val']['f.total_ht'] = 0;
$totalarray['val']['f.total_ttc'] = 0;
+
+ $with_margin_info = false;
+ if (!empty($conf->margin->enabled) && (
+ !empty($arrayfields['total_pa']['checked'])
+ || !empty($arrayfields['total_margin']['checked'])
+ || !empty($arrayfields['total_margin_rate']['checked'])
+ || !empty($arrayfields['total_mark_rate']['checked'])
+ )
+ ) {
+ $with_margin_info = true;
+ }
+
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
@@ -1706,7 +1718,7 @@ if ($resql) {
$facturestatic->alreadypaid = $paiement;
$marginInfo = array();
- if (!empty($conf->margin->enabled)) {
+ if ($with_margin_info === true) {
$facturestatic->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($facturestatic);
}
@@ -2194,7 +2206,7 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
- // total mark rate
+ // Total mark rate
if (!empty($arrayfields['total_mark_rate']['checked'])) {
print ' '.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').' | ';
if (!$i) {
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 332f68c1293..c68a686d2bf 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -210,11 +210,11 @@ if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) {
print ' ';
print $tmpinvoice->getNomUrl(1, '');
print ' | ';
- print ' ';
if ($tmpinvoice->hasDelay()) {
+ print ' | ';
print img_warning($langs->trans("Late"));
+ print ' | ';
}
- print '';
print ' ';
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref);
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index 4b44959bc1a..15c45d6055b 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -6,7 +6,7 @@
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2018-2021 Frédéric France
* Copyright (C) 2019 Eric Seigne
- * Copyright (C) 2021 Open-Dsi
+ * Copyright (C) 2021-2022 Open-Dsi
*
* 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
@@ -47,7 +47,7 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ
$refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTISSET('invoice_type')) ? true : false;
$invoice_type = GETPOSTISSET('invoice_type') ? GETPOST('invoice_type', 'alpha') : '';
-$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'int') : -1;
+$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'alphanohtml') : -1;
include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php';
@@ -409,7 +409,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) {
print '| ';
print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%';
print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . '';
@@ -643,7 +643,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) {
print ' | ';
print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%';
print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . '';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 00cbfc4158a..bb3f2ae035d 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -1389,7 +1389,7 @@ class Contact extends CommonObject
* Return name of contact with link (and eventually picto)
* Use $this->id, $this->lastname, $this->firstname, this->civility_id
*
- * @param int $withpicto Include picto with link
+ * @param int $withpicto Include picto with link (1=picto + name, 2=picto only, -1=photo+name, -2=photo only)
* @param string $option Where the link point to
* @param int $maxlen Max length of
* @param string $moreparam Add more param into URL
@@ -1475,14 +1475,14 @@ class Contact extends CommonObject
$result .= $linkstart;
if ($withpicto) {
- if ($withpicto == -2) {
+ if ($withpicto < 0) {
$result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).'';
} else {
$result .= img_object(($notooltip ? '' : $label), ( $this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
}
if ($withpicto != 2 && $withpicto != -2) {
- $result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs));
+ $result .= ''.($maxlen ? dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)).'';
}
$result .= $linkend;
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 27e8cc6bf95..b2c9543453b 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -387,7 +387,7 @@ class Contrat extends CommonObject
if ($contratline->statut != ContratLigne::STATUS_OPEN) {
$contratline->context = $this->context;
- $result = $contratline->active_line($user, $date_start, -1, $comment);
+ $result = $contratline->active_line($user, $date_start, -1, $comment); // This call trigger LINECONTRACT_ACTIVATE
if ($result < 0) {
$error++;
$this->error = $contratline->error;
diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php
index 1814b476d06..ae4f7c41515 100644
--- a/htdocs/core/ajax/selectsearchbox.php
+++ b/htdocs/core/ajax/selectsearchbox.php
@@ -65,58 +65,58 @@ $arrayresult = array();
// Define $searchform
if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) {
- $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) {
- $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) {
- $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empty($conf->service->enabled) && $user->rights->service->lire))
&& empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) {
- $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
// search on lot/serial numbers
if ( ! empty($conf->productbatch->enabled) ) {
- $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
}
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->global->MAIN_SEARCHFORM_MRP_DISABLED)) {
- $arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) {
- $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) {
- $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) {
- $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) {
- $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) {
- $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) {
- $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) {
- $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) {
- $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_supplier_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_supplier_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
- $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_supplier_invoice', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_supplier_invoice', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
// Customer payments
@@ -125,7 +125,7 @@ if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUST
'position'=>170,
'img'=>'object_payment',
'label'=>$langs->trans("SearchIntoCustomerPayments", $search_boxvalue),
- 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoCustomerPayments", $search_boxvalue),
+ 'text'=>img_picto('', 'object_payment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerPayments", $search_boxvalue),
'url'=>DOL_URL_ROOT.'/compta/paiement/list.php?leftmenu=customers_bills_payment'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
@@ -135,7 +135,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S
'position'=>175,
'img'=>'object_payment',
'label'=>$langs->trans("SearchIntoVendorPayments", $search_boxvalue),
- 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoVendorPayments", $search_boxvalue),
+ 'text'=>img_picto('', 'object_payment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoVendorPayments", $search_boxvalue),
'url'=>DOL_URL_ROOT.'/fourn/paiement/list.php?leftmenu=suppliers_bills_payment'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
@@ -145,29 +145,29 @@ if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_
'position'=>180,
'img'=>'object_payment',
'label'=>$langs->trans("SearchIntoMiscPayments", $search_boxvalue),
- 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue),
+ 'text'=>img_picto('', 'object_payment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue),
'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) {
- $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) {
- $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) {
- $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
// HR
if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) {
- $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) {
- $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) {
- $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
+ $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
// Execute hook addSearchEntry
diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php
index 53cf5c79571..94695034cce 100644
--- a/htdocs/core/boxes/box_scheduled_jobs.php
+++ b/htdocs/core/boxes/box_scheduled_jobs.php
@@ -170,7 +170,7 @@ class box_scheduled_jobs extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="center"',
- 'textnoformat' => ($nbjobsinerror ? ' '.$nbjobsinerror.' ' : '0 ')
+ 'textnoformat' => ($nbjobsinerror ? ' '.$nbjobsinerror.' ' : '0 ')
);
} else {
$this->info_box_contents[0][0] = array(
diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php
index 4f448845e80..7b46b0a08b0 100644
--- a/htdocs/core/class/ccountry.class.php
+++ b/htdocs/core/class/ccountry.class.php
@@ -111,7 +111,7 @@ class Ccountry // extends CommonObject
// Put here code to add control on parameters values
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country(";
+ $sql = "INSERT INTO ".$this->db->prefix()."c_country(";
$sql .= "rowid,";
$sql .= "code,";
$sql .= "code_iso,";
@@ -135,7 +135,7 @@ class Ccountry // extends CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."c_country");
}
// Commit or rollback
@@ -169,7 +169,7 @@ class Ccountry // extends CommonObject
$sql .= " t.code_iso,";
$sql .= " t.label,";
$sql .= " t.active";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t";
+ $sql .= " FROM ".$this->db->prefix()."c_country as t";
if ($id) {
$sql .= " WHERE t.rowid = ".((int) $id);
} elseif ($code) {
@@ -235,7 +235,7 @@ class Ccountry // extends CommonObject
// Put here code to add control on parameters values
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET";
+ $sql = "UPDATE ".$this->db->prefix()."c_country SET";
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").",";
$sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
@@ -278,7 +278,7 @@ class Ccountry // extends CommonObject
global $conf, $langs;
$error = 0;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_country";
+ $sql = "DELETE FROM ".$this->db->prefix()."c_country";
$sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin();
diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php
index c2dd055522e..937ca6f7875 100644
--- a/htdocs/core/class/comment.class.php
+++ b/htdocs/core/class/comment.class.php
@@ -113,7 +113,7 @@ class Comment extends CommonObject
$error = 0;
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
+ $sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
$sql .= "description";
$sql .= ", datec";
$sql .= ", fk_element";
@@ -146,7 +146,7 @@ class Comment extends CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
+ $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
if (!$notrigger) {
// Call trigger
@@ -195,7 +195,7 @@ class Comment extends CommonObject
$sql .= " c.fk_user_modif,";
$sql .= " c.entity,";
$sql .= " c.import_key";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as c";
$sql .= " WHERE c.rowid = ".((int) $id);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@@ -254,7 +254,7 @@ class Comment extends CommonObject
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").",";
$sql .= " datec=".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").",";
@@ -315,7 +315,7 @@ class Comment extends CommonObject
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "DELETE FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid=".((int) $this->id);
$resql = $this->db->query($sql);
@@ -364,7 +364,7 @@ class Comment extends CommonObject
if (!empty($element_type) && !empty($fk_element)) {
$sql = "SELECT";
$sql .= " c.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as c";
$sql .= " WHERE c.fk_element = ".((int) $fk_element);
$sql .= " AND c.element_type = '".$this->db->escape($element_type)."'";
$sql .= " AND c.entity = ".$conf->entity;
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index 5d0242657ef..8a0ce49ce00 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -653,7 +653,7 @@ abstract class CommonDocGenerator
if ($columns != "") {
$columns = substr($columns, 0, strlen($columns) - 2);
- $resql = $this->db->query("SELECT ".$columns." FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields AS ex INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$this->db->escape($line->ref_supplier)."'");
+ $resql = $this->db->query("SELECT ".$columns." FROM ".$this->db->prefix()."product_fournisseur_price_extrafields AS ex INNER JOIN ".$this->db->prefix()."product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$this->db->escape($line->ref_supplier)."'");
if ($this->db->num_rows($resql) > 0) {
$resql = $this->db->fetch_object($resql);
diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php
index d0485acc5a9..e74d1428781 100644
--- a/htdocs/core/class/commonincoterm.class.php
+++ b/htdocs/core/class/commonincoterm.class.php
@@ -60,7 +60,7 @@ trait CommonIncoterm
$this->label_incoterms = '';
if (!empty($this->fk_incoterms)) {
- $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
+ $sql = "SELECT code FROM ".$this->db->prefix()."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
$result = $this->db->query($sql);
if ($result) {
$res = $this->db->fetch_object($result);
@@ -80,7 +80,7 @@ trait CommonIncoterm
*/
public function getIncotermsForPDF()
{
- $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
+ $sql = "SELECT code FROM ".$this->db->prefix()."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -106,7 +106,7 @@ trait CommonIncoterm
public function setIncoterms($id_incoterm, $location)
{
if ($this->id && $this->table_element) {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? ((int) $id_incoterm) : "null");
$sql .= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null");
$sql .= " WHERE rowid = ".((int) $this->id);
@@ -116,7 +116,7 @@ trait CommonIncoterm
$this->fk_incoterms = $id_incoterm;
$this->location_incoterms = $location;
- $sql = "SELECT libelle as label_incoterms FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
+ $sql = "SELECT libelle as label_incoterms FROM ".$this->db->prefix()."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
$res = $this->db->query($sql);
if ($res) {
$obj = $this->db->fetch_object($res);
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index 74ff2141820..29fd230a61b 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -130,8 +130,8 @@ abstract class CommonInvoice extends CommonObject
$field = 'fk_facturefourn';
}
- $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
+ $sql = "SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix().$table;
$sql .= " WHERE ".$field." = ".((int) $this->id);
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
@@ -226,10 +226,10 @@ abstract class CommonInvoice extends CommonObject
{
$idarray = array();
- $sql = 'SELECT rowid';
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "SELECT rowid";
+ $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE fk_facture_source = ".((int) $this->id);
- $sql .= ' AND type = 2';
+ $sql .= " AND type = 2";
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -253,10 +253,10 @@ abstract class CommonInvoice extends CommonObject
*/
public function getIdReplacingInvoice($option = '')
{
- $sql = 'SELECT rowid';
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "SELECT rowid";
+ $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE fk_facture_source = ".((int) $this->id);
- $sql .= ' AND type < 2';
+ $sql .= " AND type < 2";
if ($option == 'validated') {
$sql .= ' AND fk_statut = 1';
}
@@ -265,7 +265,7 @@ abstract class CommonInvoice extends CommonObject
// and another no, priority is given to the valid one.
// Should not happen (unless concurrent access and 2 people have created a
// replacement invoice for the same invoice at the same time)
- $sql .= ' ORDER BY fk_statut DESC';
+ $sql .= " ORDER BY fk_statut DESC";
$resql = $this->db->query($sql);
if ($resql) {
@@ -308,7 +308,7 @@ abstract class CommonInvoice extends CommonObject
}
$sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3;
- $sql .= " FROM ".MAIN_DB_PREFIX.$table." as pf, ".MAIN_DB_PREFIX.$table2." as p, ".MAIN_DB_PREFIX."c_paiement as t";
+ $sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t";
$sql .= " WHERE pf.".$field." = ".((int) $this->id);
$sql .= " AND pf.".$field2." = p.rowid";
$sql .= ' AND p.fk_paiement = t.id';
@@ -337,12 +337,12 @@ abstract class CommonInvoice extends CommonObject
$sql = '';
if ($this->element == 'facture' || $this->element == 'invoice') {
$sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type";
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
+ $sql .= ' FROM '.$this->db->prefix().'societe_remise_except as rc, '.$this->db->prefix().'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $this->id);
$sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
} elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') {
$sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type";
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
+ $sql .= ' FROM '.$this->db->prefix().'societe_remise_except as rc, '.$this->db->prefix().'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $this->id);
$sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
}
@@ -462,7 +462,7 @@ abstract class CommonInvoice extends CommonObject
$type = 'supplier_invoice';
}
- $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
+ $sql = " SELECT COUNT(ab.rowid) as nb FROM ".$this->db->prefix()."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@@ -601,8 +601,8 @@ abstract class CommonInvoice extends CommonObject
$cdr_type = 0;
$cdr_decalage = 0;
- $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage';
- $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
+ $sqltemp = "SELECT c.type_cdr, c.nbjour, c.decalage";
+ $sqltemp .= " FROM ".$this->db->prefix()."c_payment_term as c";
if (is_numeric($cond_reglement)) {
$sqltemp .= " WHERE c.rowid=".((int) $cond_reglement);
} else {
@@ -697,15 +697,15 @@ abstract class CommonInvoice extends CommonObject
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0, $this->socid);
- $sql = 'SELECT count(*)';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
+ $sql = "SELECT count(*)";
+ $sql .= " FROM ".$this->db->prefix()."prelevement_facture_demande";
if ($type == 'bank-transfer') {
- $sql .= ' WHERE fk_facture_fourn = '.((int) $this->id);
+ $sql .= " WHERE fk_facture_fourn = ".((int) $this->id);
} else {
- $sql .= ' WHERE fk_facture = '.((int) $this->id);
+ $sql .= " WHERE fk_facture = ".((int) $this->id);
}
- $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments
- $sql .= ' AND traite = 0';
+ $sql .= " AND ext_payment_id IS NULL"; // To exclude record done for some online payments
+ $sql .= " AND traite = 0";
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -728,7 +728,7 @@ abstract class CommonInvoice extends CommonObject
}
if (is_numeric($amount) && $amount != 0) {
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande(';
+ $sql = 'INSERT INTO '.$this->db->prefix().'prelevement_facture_demande(';
if ($type == 'bank-transfer') {
$sql .= 'fk_facture_fourn, ';
} else {
@@ -800,7 +800,7 @@ abstract class CommonInvoice extends CommonObject
public function demande_prelevement_delete($fuser, $did)
{
// phpcs:enable
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
+ $sql = 'DELETE FROM '.$this->db->prefix().'prelevement_facture_demande';
$sql .= ' WHERE rowid = '.((int) $did);
$sql .= ' AND traite = 0';
if ($this->db->query($sql)) {
@@ -857,7 +857,7 @@ abstract class CommonInvoice extends CommonObject
// Using TLV format
$s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$this->thirdparty->name;
$s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$this->thirdparty->tva_intra;
- $s .= pack('C1', 3).pack('C1', strlen($datestring)).$date;
+ $s .= pack('C1', 3).pack('C1', strlen($datestring)).$this->date;
$s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring;
$s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring;
$s .= ''; // Hash of xml invoice
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index c17e07bd17b..867020b915d 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -536,7 +536,7 @@ abstract class CommonObject
global $db, $conf;
$sql = "SELECT rowid, ref, ref_ext";
- $sql .= " FROM ".MAIN_DB_PREFIX.$element;
+ $sql .= " FROM ".$db->prefix().$element;
$sql .= " WHERE entity IN (".getEntity($element).")";
if ($id > 0) {
@@ -1041,7 +1041,7 @@ abstract class CommonObject
} else {
// We look for id type_contact
$sql = "SELECT tc.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
+ $sql .= " FROM ".$this->db->prefix()."c_type_contact as tc";
$sql .= " WHERE tc.element='".$this->db->escape($this->element)."'";
$sql .= " AND tc.source='".$this->db->escape($source)."'";
$sql .= " AND tc.code='".$this->db->escape($type_contact)."' AND tc.active=1";
@@ -1079,7 +1079,7 @@ abstract class CommonObject
$this->db->begin();
// Insert into database
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
+ $sql = "INSERT INTO ".$this->db->prefix()."element_contact";
$sql .= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql .= " VALUES (".$this->id.", ".((int) $fk_socpeople)." , ";
$sql .= "'".$this->db->idate($datecreate)."'";
@@ -1148,7 +1148,7 @@ abstract class CommonObject
{
// phpcs:enable
// Insert into database
- $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
+ $sql = "UPDATE ".$this->db->prefix()."element_contact set";
$sql .= " statut = ".$statut;
if ($type_contact_id) {
$sql .= ", fk_c_type_contact = ".((int) $type_contact_id);
@@ -1182,7 +1182,7 @@ abstract class CommonObject
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
+ $sql = "DELETE FROM ".$this->db->prefix()."element_contact";
$sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
@@ -1226,7 +1226,7 @@ abstract class CommonObject
$listId = implode(",", $temp);
}
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
+ $sql = "DELETE FROM ".$this->db->prefix()."element_contact";
$sql .= " WHERE element_id = ".((int) $this->id);
if (!empty($listId)) {
$sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")";
@@ -1267,13 +1267,13 @@ abstract class CommonObject
}
$sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email";
$sql .= ", tc.source, tc.element, tc.code, tc.libelle";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
- $sql .= ", ".MAIN_DB_PREFIX."element_contact ec";
+ $sql .= " FROM ".$this->db->prefix()."c_type_contact tc";
+ $sql .= ", ".$this->db->prefix()."element_contact ec";
if ($source == 'internal') {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."user t on ec.fk_socpeople = t.rowid";
}
if ($source == 'external' || $source == 'thirdparty') {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."socpeople t on ec.fk_socpeople = t.rowid";
}
$sql .= " WHERE ec.element_id = ".((int) $this->id);
$sql .= " AND ec.fk_c_type_contact = tc.rowid";
@@ -1348,7 +1348,7 @@ abstract class CommonObject
{
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql .= " tc.code, tc.libelle";
- $sql .= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)";
+ $sql .= " FROM (".$this->db->prefix()."element_contact as ec, ".$this->db->prefix()."c_type_contact as tc)";
$sql .= " WHERE ec.rowid =".((int) $rowid);
$sql .= " AND ec.fk_c_type_contact=tc.rowid";
$sql .= " AND tc.element = '".$this->db->escape($this->element)."'";
@@ -1393,7 +1393,7 @@ abstract class CommonObject
$tab = array();
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
+ $sql .= " FROM ".$this->db->prefix()."c_type_contact as tc";
$sql .= " WHERE tc.element='".$this->db->escape($this->element)."'";
if ($activeonly == 1) {
$sql .= " AND tc.active=1"; // only the active types
@@ -1453,7 +1453,7 @@ abstract class CommonObject
$tab = array();
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
+ $sql .= " FROM ".$this->db->prefix()."c_type_contact as tc";
$sqlWhere = array();
if (!empty($element)) {
@@ -1551,14 +1551,14 @@ abstract class CommonObject
}
$sql = "SELECT ec.fk_socpeople";
- $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec,";
+ $sql .= " FROM ".$this->db->prefix()."element_contact as ec,";
if ($source == 'internal') {
- $sql .= " ".MAIN_DB_PREFIX."user as c,";
+ $sql .= " ".$this->db->prefix()."user as c,";
}
if ($source == 'external') {
- $sql .= " ".MAIN_DB_PREFIX."socpeople as c,";
+ $sql .= " ".$this->db->prefix()."socpeople as c,";
}
- $sql .= " ".MAIN_DB_PREFIX."c_type_contact as tc";
+ $sql .= " ".$this->db->prefix()."c_type_contact as tc";
$sql .= " WHERE ec.element_id = ".((int) $id);
$sql .= " AND ec.fk_socpeople = c.rowid";
if ($source == 'internal') {
@@ -1674,7 +1674,7 @@ abstract class CommonObject
return 0;
}
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."' LIMIT 1";
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element." WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."' LIMIT 1";
$query = $this->db->query($sql);
@@ -1716,7 +1716,7 @@ abstract class CommonObject
if ($idtype > 0) {
if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { // If data not already loaded
$sql = "SELECT rowid, code, libelle as label, coder";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+ $sql .= " FROM ".$this->db->prefix()."c_barcode_type";
$sql .= " WHERE rowid = ".((int) $idtype);
dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -1853,7 +1853,7 @@ abstract class CommonObject
$result = false;
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table;
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$table;
$sql .= " WHERE ".$field." = '".$this->db->escape($key)."'";
if (!empty($element)) {
$sql .= " AND entity IN (".getEntity($element).")";
@@ -1886,7 +1886,7 @@ abstract class CommonObject
{
$result = false;
if (!empty($id) && !empty($field) && !empty($table)) {
- $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
+ $sql = "SELECT ".$field." FROM ".$this->db->prefix().$table;
$sql .= " WHERE rowid = ".((int) $id);
dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
@@ -1944,7 +1944,7 @@ abstract class CommonObject
$fk_user_field = 'fk_user_mod';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
+ $sql = "UPDATE ".$this->db->prefix().$table." SET ";
if ($format == 'text') {
$sql .= $field." = '".$this->db->escape($value)."'";
@@ -2044,20 +2044,20 @@ abstract class CommonObject
}
$restrictiononfksoc = empty($this->restrictiononfksoc) ? 0 : $this->restrictiononfksoc;
$sql = "SELECT MAX(te.".$fieldid.")";
- $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
+ $sql .= " FROM ".(empty($nodbprefix) ?$this->db->prefix():'').$this->table_element." as te";
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
- $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= ",".$this->db->prefix()."usergroup_user as ug";
}
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged);
- $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
+ $sql .= ", ".$this->db->prefix().$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
} elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
+ $sql .= ", ".$this->db->prefix()."societe as s"; // If we need to link to societe to limit select to socid
} elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
+ $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
}
if ($restrictiononfksoc && empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
}
$sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
if ($restrictiononfksoc == 1 && empty($user->rights->societe->client->voir) && !$socid) {
@@ -2114,20 +2114,20 @@ abstract class CommonObject
$this->ref_previous = $row[0];
$sql = "SELECT MIN(te.".$fieldid.")";
- $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
+ $sql .= " FROM ".(empty($nodbprefix) ?$this->db->prefix():'').$this->table_element." as te";
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
- $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= ",".$this->db->prefix()."usergroup_user as ug";
}
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged);
- $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
+ $sql .= ", ".$this->db->prefix().$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
} elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
+ $sql .= ", ".$this->db->prefix()."societe as s"; // If we need to link to societe to limit select to socid
} elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
+ $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
}
if ($restrictiononfksoc && empty($user->rights->societe->client->voir) && !$socid) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
}
$sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
if ($restrictiononfksoc == 1 && empty($user->rights->societe->client->voir) && !$socid) {
@@ -2226,7 +2226,7 @@ abstract class CommonObject
return -1;
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
if (!empty($this->fields['fk_project'])) { // Common case
if ($projectid) {
$sql .= " SET fk_project = ".((int) $projectid);
@@ -2269,6 +2269,8 @@ abstract class CommonObject
*/
public function setPaymentMethods($id)
{
+ global $user;
+
$error = 0; $notrigger = 0;
dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
@@ -2289,7 +2291,7 @@ abstract class CommonObject
$fieldname = 'fk_typepayment';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
$sql .= ' WHERE rowid='.((int) $this->id);
@@ -2333,7 +2335,7 @@ abstract class CommonObject
if ($this->statut >= 0 || $this->element == 'societe') {
$fieldname = 'multicurrency_code';
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = '".$this->db->escape($code)."'";
$sql .= ' WHERE rowid='.((int) $this->id);
@@ -2371,7 +2373,7 @@ abstract class CommonObject
if ($this->statut >= 0 || $this->element == 'societe') {
$fieldname = 'multicurrency_tx';
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = ".((float) $rate);
$sql .= ' WHERE rowid='.((int) $this->id);
@@ -2579,7 +2581,7 @@ abstract class CommonObject
$fieldname = 'cond_reglement_supplier';
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
$sql .= ' WHERE rowid='.((int) $this->id);
@@ -2621,7 +2623,7 @@ abstract class CommonObject
$fieldname = 'transport_mode_supplier';
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
$sql .= ' WHERE rowid='.((int) $this->id);
@@ -2656,7 +2658,7 @@ abstract class CommonObject
if ($this->statut >= 0 || $this->element == 'societe') {
$fieldname = 'retained_warranty_fk_cond_reglement';
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element;
$sql .= " SET ".$fieldname." = ".((int) $id);
$sql .= ' WHERE rowid='.((int) $this->id);
@@ -2689,7 +2691,7 @@ abstract class CommonObject
$fieldname = 'fk_address';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".((int) $id);
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET ".$fieldname." = ".((int) $id);
$sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = 0";
if ($this->db->query($sql)) {
@@ -2734,7 +2736,7 @@ abstract class CommonObject
}
dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')');
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET fk_shipping_method = ".((int) $shipping_method_id);
$sql .= " WHERE rowid=".((int) $this->id);
$resql = $this->db->query($sql);
@@ -2781,7 +2783,7 @@ abstract class CommonObject
}
dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')');
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET fk_warehouse = ".((int) $warehouse_id);
$sql .= " WHERE rowid=".((int) $this->id);
@@ -2812,7 +2814,7 @@ abstract class CommonObject
$newmodelpdf = dol_trunc($modelpdf, 255);
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'";
$sql .= " WHERE rowid = ".((int) $this->id);
@@ -2858,7 +2860,7 @@ abstract class CommonObject
}
dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')');
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET fk_account = ".((int) $fk_account);
$sql .= " WHERE rowid=".((int) $this->id);
@@ -2915,7 +2917,7 @@ abstract class CommonObject
// Count number of lines to reorder (according to choice $renum)
$nl = 0;
- $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
if (!$renum) {
$sql .= ' AND rang = 0';
@@ -2937,7 +2939,7 @@ abstract class CommonObject
$rows = array();
// We first search all lines that are parent lines (for multilevel details lines)
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
if ($fk_parent_line) {
$sql .= ' AND fk_parent_line IS NULL';
@@ -2985,7 +2987,7 @@ abstract class CommonObject
{
$rows = array();
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
$sql .= ' AND fk_parent_line = '.((int) $id);
$sql .= ' ORDER BY rang ASC';
@@ -3063,7 +3065,7 @@ abstract class CommonObject
$fieldposition = 'position';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
$sql .= ' WHERE rowid = '.((int) $rowid);
dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG);
@@ -3109,11 +3111,11 @@ abstract class CommonObject
$fieldposition = 'position';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
$sql .= ' AND rang = '.((int) ($rang - 1));
if ($this->db->query($sql)) {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
$sql .= ' WHERE rowid = '.((int) $rowid);
if (!$this->db->query($sql)) {
dol_print_error($this->db);
@@ -3140,11 +3142,11 @@ abstract class CommonObject
$fieldposition = 'position';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
$sql .= ' AND rang = '.((int) ($rang + 1));
if ($this->db->query($sql)) {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
$sql .= ' WHERE rowid = '.((int) $rowid);
if (!$this->db->query($sql)) {
dol_print_error($this->db);
@@ -3163,7 +3165,7 @@ abstract class CommonObject
*/
public function getRangOfLine($rowid)
{
- $sql = "SELECT rang FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT rang FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);
@@ -3182,7 +3184,7 @@ abstract class CommonObject
*/
public function getIdOfLine($rang)
{
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
$sql .= " AND rang = ".((int) $rang);
$resql = $this->db->query($sql);
@@ -3209,7 +3211,7 @@ abstract class CommonObject
// Search the last rang with fk_parent_line
if ($fk_parent_line) {
- $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT max(".$positionfield.") FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
$sql .= " AND fk_parent_line = ".((int) $fk_parent_line);
@@ -3225,7 +3227,7 @@ abstract class CommonObject
}
} else {
// If not, search the last rang of element
- $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT max(".$positionfield.") FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
@@ -3252,7 +3254,7 @@ abstract class CommonObject
return -1;
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'";
$sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".((int) $this->id);
@@ -3303,7 +3305,7 @@ abstract class CommonObject
} else {
$fieldusermod = "fk_user_modif";
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL");
$sql .= ", ".$fieldusermod." = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);
@@ -3427,7 +3429,7 @@ abstract class CommonObject
$sql .= ', situation_percent';
}
$sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql .= " FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
if ($exclspec) {
$product_field = 'product_type';
@@ -3475,7 +3477,7 @@ abstract class CommonObject
//var_dump($diff_when_using_price_ht.' '.$diff_on_current_total);
if ($diff_when_using_price_ht && $diff_on_current_total) {
- $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
+ $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
$resqlfix = $this->db->query($sqlfix);
if (!$resqlfix) {
@@ -3519,7 +3521,7 @@ abstract class CommonObject
dol_print_error('', $errmsg);
exit;
}
- $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid);
+ $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid);
dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix = $this->db->query($sqlfix);
if (!$resqlfix) {
@@ -3587,7 +3589,7 @@ abstract class CommonObject
}
if (empty($nodatabaseupdate)) {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.' SET';
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET';
$sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).",";
$sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).",";
$sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).",";
@@ -3668,7 +3670,7 @@ abstract class CommonObject
$this->db->begin();
$error = 0;
- $sql = "INSERT INTO " . MAIN_DB_PREFIX . "element_element (";
+ $sql = "INSERT INTO " . $this->db->prefix() . "element_element (";
$sql .= "fk_source";
$sql .= ", sourcetype";
$sql .= ", fk_target";
@@ -3775,8 +3777,8 @@ abstract class CommonObject
}*/
// Links between objects are stored in table element_element
- $sql = 'SELECT rowid, fk_source, sourcetype, fk_target, targettype';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'element_element';
+ $sql = "SELECT rowid, fk_source, sourcetype, fk_target, targettype";
+ $sql .= " FROM ".$this->db->prefix()."element_element";
$sql .= " WHERE ";
if ($justsource || $justtarget) {
if ($justsource) {
@@ -3794,7 +3796,7 @@ abstract class CommonObject
$sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')";
$sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')";
}
- $sql .= ' ORDER BY '.$orderby;
+ $sql .= " ORDER BY ".$orderby;
dol_syslog(get_class($this)."::fetchObjectLink", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -3962,7 +3964,7 @@ abstract class CommonObject
$this->db->begin();
$error = 0;
- $sql = "UPDATE " . MAIN_DB_PREFIX . "element_element SET ";
+ $sql = "UPDATE " . $this->db->prefix() . "element_element SET ";
if ($updatesource) {
$sql .= "fk_source = " . ((int) $sourceid);
$sql .= ", sourcetype = '" . $this->db->escape($sourcetype) . "'";
@@ -4051,7 +4053,7 @@ abstract class CommonObject
}
if (!$error) {
- $sql = "DELETE FROM " . MAIN_DB_PREFIX . "element_element";
+ $sql = "DELETE FROM " . $this->db->prefix() . "element_element";
$sql .= " WHERE";
if ($rowid > 0) {
$sql .= " rowid = " . ((int) $rowid);
@@ -4103,7 +4105,7 @@ abstract class CommonObject
global $db;
- $sql = "SELECT ".$field_select." FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
+ $sql = "SELECT ".$field_select." FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
$resql = $db->query($sql);
$TRes = array();
@@ -4132,7 +4134,7 @@ abstract class CommonObject
global $db;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
+ $sql = "DELETE FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
$resql = $db->query($sql);
if (empty($resql)) {
@@ -4185,7 +4187,7 @@ abstract class CommonObject
$fieldstatus = 'status';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
+ $sql = "UPDATE ".$this->db->prefix().$elementTable;
$sql .= " SET ".$fieldstatus." = ".((int) $status);
// If status = 1 = validated, update also fk_user_valid
// TODO Replace the test on $elementTable by doing a test on existence of the field in $this->fields
@@ -4286,7 +4288,7 @@ abstract class CommonObject
$ref = trim($ref);
$sql = "SELECT rowid, canvas";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE entity IN (".getEntity($this->element).")";
if (!empty($id)) {
$sql .= " AND rowid = ".((int) $id);
@@ -4319,7 +4321,7 @@ abstract class CommonObject
*/
public function getSpecialCode($lineid)
{
- $sql = "SELECT special_code FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "SELECT special_code FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE rowid = ".((int) $lineid);
$resql = $this->db->query($sql);
if ($resql) {
@@ -4361,7 +4363,7 @@ abstract class CommonObject
foreach ($arraytoscan as $table => $elementname) {
//print $id.'-'.$table.'-'.$elementname.' ';
// Check if third party can be deleted
- $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table;
+ $sql = "SELECT COUNT(*) as nb from ".$this->db->prefix().$table;
$sql .= " WHERE ".$this->fk_element." = ".((int) $id);
$resql = $this->db->query($sql);
if ($resql) {
@@ -4437,7 +4439,7 @@ abstract class CommonObject
$total_discount = 0.00;
$sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql .= " FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
dol_syslog(get_class($this).'::getTotalDiscount', LOG_DEBUG);
@@ -4577,7 +4579,7 @@ abstract class CommonObject
$extraparams = (!empty($this->extraparams) ? json_encode($this->extraparams) : null);
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET extraparams = ".(!empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
$sql .= " WHERE rowid = ".((int) $this->id);
@@ -5072,7 +5074,7 @@ abstract class CommonObject
// phpcs:enable
$this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources (";
+ $sql = "INSERT INTO ".$this->db->prefix()."element_resources (";
$sql .= "resource_id";
$sql .= ", resource_type";
$sql .= ", element_id";
@@ -5115,7 +5117,7 @@ abstract class CommonObject
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
+ $sql = "DELETE FROM ".$this->db->prefix()."element_resources";
$sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::delete_resource", LOG_DEBUG);
@@ -5435,7 +5437,7 @@ abstract class CommonObject
//var_dump($obj->update_main_doc_field);exit;
if ($update_main_doc_field && !empty($this->table_element)) {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath."/".$ecmfile->filename)."'";
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath."/".$ecmfile->filename)."'";
$sql .= " WHERE rowid = ".((int) $this->id);
$resql = $this->db->query($sql);
@@ -5599,7 +5601,7 @@ abstract class CommonObject
// Request to get translation values for object
$sql = "SELECT rowid, property, lang , value";
- $sql .= " FROM ".MAIN_DB_PREFIX."object_lang";
+ $sql .= " FROM ".$this->db->prefix()."object_lang";
$sql .= " WHERE type_object = '".$this->db->escape($element)."'";
$sql .= " AND fk_object = ".((int) $this->id);
@@ -5804,7 +5806,7 @@ abstract class CommonObject
$sql .= ", ".$name;
}
}
- $sql .= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields";
+ $sql .= " FROM ".$this->db->prefix().$table_element."_extrafields";
$sql .= " WHERE fk_object = ".((int) $rowid);
//dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose
@@ -5878,7 +5880,7 @@ abstract class CommonObject
dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG);
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".((int) $this->id);
+ $sql_del = "DELETE FROM ".$this->db->prefix().$table_element."_extrafields WHERE fk_object = ".((int) $this->id);
$resql = $this->db->query($sql_del);
if (!$resql) {
@@ -6078,10 +6080,10 @@ abstract class CommonObject
dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG);
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".((int) $this->id);
+ $sql_del = "DELETE FROM ".$this->db->prefix().$table_element."_extrafields WHERE fk_object = ".((int) $this->id);
$this->db->query($sql_del);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object";
+ $sql = "INSERT INTO ".$this->db->prefix().$table_element."_extrafields (fk_object";
foreach ($new_array_options as $key => $value) {
$attributeKey = substr($key, 8); // Remove 'options_' prefix
// Add field of attribut
@@ -6229,13 +6231,13 @@ abstract class CommonObject
foreach ($new_array_languages as $key => $langcodearray) { // $key = 'name', 'town', ...
foreach ($langcodearray as $langcode => $value) {
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."object_lang";
+ $sql_del = "DELETE FROM ".$this->db->prefix()."object_lang";
$sql_del .= " WHERE fk_object = ".((int) $this->id)." AND property = '".$this->db->escape($key)."' AND type_object = '".$this->db->escape($table_element)."'";
$sql_del .= " AND lang = '".$this->db->escape($langcode)."'";
$this->db->query($sql_del);
if ($value !== '') {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."object_lang (fk_object, property, type_object, lang, value";
+ $sql = "INSERT INTO ".$this->db->prefix()."object_lang (fk_object, property, type_object, lang, value";
$sql .= ") VALUES (".$this->id.", '".$this->db->escape($key)."', '".$this->db->escape($table_element)."', '".$this->db->escape($langcode)."', '".$this->db->escape($value)."'";
$sql .= ")";
@@ -6419,7 +6421,7 @@ abstract class CommonObject
$linealreadyfound = 0;
// Check if there is already a line for this object (in most cases, it is, but sometimes it is not, for example when extra field has been created after), so we must keep this overload)
- $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".((int) $this->id);
+ $sql = "SELECT COUNT(rowid) as nb FROM ".$this->db->prefix().$this->table_element."_extrafields WHERE fk_object = ".((int) $this->id);
$resql = $this->db->query($sql);
if ($resql) {
$tmpobj = $this->db->fetch_object($resql);
@@ -6430,9 +6432,9 @@ abstract class CommonObject
if ($linealreadyfound) {
if ($this->array_options["options_".$key] === null) {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null";
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = null";
} else {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'";
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'";
}
$sql .= " WHERE fk_object = ".((int) $this->id);
} else {
@@ -6761,7 +6763,7 @@ abstract class CommonObject
$sqlwhere = '';
$sql = "SELECT ".$keyList;
- $sql .= " FROM ".MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= " FROM ".$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
@@ -6777,7 +6779,7 @@ abstract class CommonObject
//We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) {
- $sql .= " as main, ".MAIN_DB_PREFIX.$InfoFieldList[0]."_extrafields as extra";
+ $sql .= " as main, ".$this->db->prefix().$InfoFieldList[0]."_extrafields as extra";
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
} else {
$sqlwhere .= " WHERE ".$InfoFieldList[4];
@@ -6913,7 +6915,7 @@ abstract class CommonObject
$sqlwhere = '';
$sql = "SELECT ".$keyList;
- $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
@@ -6929,7 +6931,7 @@ abstract class CommonObject
// We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) {
- $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
+ $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra';
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
} else {
$sqlwhere .= " WHERE ".$InfoFieldList[4];
@@ -7274,7 +7276,7 @@ abstract class CommonObject
}
$sql = "SELECT ".$keyList;
- $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main';
}
@@ -7357,7 +7359,7 @@ abstract class CommonObject
}
$sql = "SELECT ".$keyList;
- $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main';
}
@@ -8050,7 +8052,7 @@ abstract class CommonObject
public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
{
foreach ($tables as $table) {
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id);
+ $sql = 'UPDATE '.$db->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id);
if (!$db->query($sql)) {
if ($ignoreerrors) {
@@ -8774,7 +8776,7 @@ abstract class CommonObject
$this->db->begin();
if (!$error) {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "INSERT INTO ".$this->db->prefix().$this->table_element;
$sql .= " (".implode(", ", $keys).')';
$sql .= " VALUES (".implode(", ", $values).")"; // $values can contains 'abc' or 123
@@ -8790,13 +8792,13 @@ abstract class CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
+ $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
}
// If we have a field ref with a default value of (PROV)
if (!$error) {
if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && key_exists('default', $this->fields['ref']) && $this->fields['ref']['default'] == '(PROV)') {
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".((int) $this->id).")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".((int) $this->id);
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET ref = '(PROV".((int) $this->id).")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".((int) $this->id);
$resqlupdate = $this->db->query($sql);
if ($resqlupdate === false) {
@@ -8881,7 +8883,7 @@ abstract class CommonObject
}
$sql = "SELECT ".$fieldlist;
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= " FROM ".$this->db->prefix().$this->table_element.' as t';
if (!empty($id)) {
$sql .= ' WHERE t.rowid = '.((int) $id);
@@ -8936,7 +8938,7 @@ abstract class CommonObject
$objectline = new $objectlineclassname($this->db);
$sql = "SELECT ".$objectline->getFieldList('l');
- $sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as l";
+ $sql .= " FROM ".$this->db->prefix().$objectline->table_element." as l";
$sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id);
if ($morewhere) {
$sql .= $morewhere;
@@ -9026,7 +9028,7 @@ abstract class CommonObject
}*/
}
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode(', ', $tmp).' WHERE rowid='.((int) $this->id);
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element.' SET '.implode(', ', $tmp).' WHERE rowid='.((int) $this->id);
$this->db->begin();
if (!$error) {
@@ -9083,7 +9085,7 @@ abstract class CommonObject
if ($forcechilddeletion) { // Force also delete of childtables that should lock deletion in standard case when option force is off
foreach ($this->childtables as $table) {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table." WHERE ".$this->fk_element." = ".((int) $this->id);
+ $sql = "DELETE FROM ".$this->db->prefix().$table." WHERE ".$this->fk_element." = ".((int) $this->id);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->lasterror();
@@ -9137,7 +9139,7 @@ abstract class CommonObject
}
} else {
// Delete record in child table
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table." WHERE ".$this->fk_element." = ".((int) $this->id);
+ $sql = "DELETE FROM ".$this->db->prefix().$table." WHERE ".$this->fk_element." = ".((int) $this->id);
$resql = $this->db->query($sql);
if (!$resql) {
@@ -9177,7 +9179,7 @@ abstract class CommonObject
}
if (!$error) {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.((int) $this->id);
+ $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.' WHERE rowid='.((int) $this->id);
$resql = $this->db->query($sql);
if (!$resql) {
@@ -9216,7 +9218,7 @@ abstract class CommonObject
if (!empty($parentId) && !empty($parentField)) {
$this->db->begin();
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE ".$parentField." = ".(int) $parentId;
// Manage filters
@@ -9301,7 +9303,7 @@ abstract class CommonObject
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line;
+ $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line;
$sql .= " WHERE rowid = ".((int) $idline);
dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG);
@@ -9355,7 +9357,7 @@ abstract class CommonObject
$statusfield = 'fk_statut';
}
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET ".$statusfield." = ".((int) $status);
$sql .= " WHERE rowid = ".((int) $this->id);
@@ -9592,8 +9594,8 @@ abstract class CommonObject
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$categorystatic = new Categorie($this->db);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type])." (fk_categorie, fk_product)";
- $sql .= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]);
+ $sql = "INSERT INTO ".$this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type])." (fk_categorie, fk_product)";
+ $sql .= " SELECT fk_categorie, $toId FROM ".$this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]);
$sql .= " WHERE fk_product = ".((int) $fromId);
if (!$this->db->query($sql)) {
@@ -9641,8 +9643,8 @@ abstract class CommonObject
}
// Delete ecm_files extrafields
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files_extrafields WHERE fk_object IN (";
- $sql .= " SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
+ $sql = "DELETE FROM ".$this->db->prefix()."ecm_files_extrafields WHERE fk_object IN (";
+ $sql .= " SELECT rowid FROM ".$this->db->prefix()."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
$sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".((int) $conf->entity); // No need of getEntity here
$sql .= ")";
@@ -9653,7 +9655,7 @@ abstract class CommonObject
}
// Delete ecm_files
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files";
+ $sql = "DELETE FROM ".$this->db->prefix()."ecm_files";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
$sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".((int) $conf->entity); // No need of getEntity here
@@ -9666,8 +9668,8 @@ abstract class CommonObject
// Delete in database with mode 1
if ($mode == 1) {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields";
- $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? "" : "@".$this->module))."' AND src_object_id = ".((int) $this->id).")";
+ $sql = 'DELETE FROM '.$this->db->prefix()."ecm_files_extrafields";
+ $sql .= " WHERE fk_object IN (SELECT rowid FROM ".$this->db->prefix()."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? "" : "@".$this->module))."' AND src_object_id = ".((int) $this->id).")";
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->lasterror();
@@ -9675,7 +9677,7 @@ abstract class CommonObject
return false;
}
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files";
+ $sql = 'DELETE FROM '.$this->db->prefix()."ecm_files";
$sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? "" : "@".$this->module))."' AND src_object_id = ".((int) $this->id);
$resql = $this->db->query($sql);
if (!$resql) {
diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php
index d93d0b67ff9..487482a9b3c 100644
--- a/htdocs/core/class/commonobjectline.class.php
+++ b/htdocs/core/class/commonobjectline.class.php
@@ -93,7 +93,7 @@ abstract class CommonObjectLine extends CommonObject
$label_type = 'code';
}
- $sql = "SELECT ".$label_type.", code from ".MAIN_DB_PREFIX."c_units where rowid = ".((int) $this->fk_unit);
+ $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
$resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) {
diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php
index 33510186646..91b176f899d 100644
--- a/htdocs/core/class/coreobject.class.php
+++ b/htdocs/core/class/coreobject.class.php
@@ -183,7 +183,7 @@ class CoreObject extends CommonObject
$this->{$className} = array();
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element." = ".((int) $this->id);
+ $sql = "SELECT rowid FROM ".$this->db->prefix().$childTable." WHERE ".$this->fk_element." = ".((int) $this->id);
$res = $this->db->query($sql);
if ($res) {
diff --git a/htdocs/core/class/cproductnature.class.php b/htdocs/core/class/cproductnature.class.php
index 5b343b21dbc..d0c8a5d3933 100644
--- a/htdocs/core/class/cproductnature.class.php
+++ b/htdocs/core/class/cproductnature.class.php
@@ -102,7 +102,7 @@ class CProductNature // extends CommonObject
global $conf, $langs;
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
+ $sql = "INSERT INTO ".$this->db->prefix().$this->table_element."(";
$sql .= "rowid,";
$sql .= "code,";
$sql .= "label,";
@@ -125,7 +125,7 @@ class CProductNature // extends CommonObject
$this->db->rollback();
return -1;
} else {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
+ $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
$this->db->commit();
return $this->id;
}
@@ -148,7 +148,7 @@ class CProductNature // extends CommonObject
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.active";
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
$sql_where = array();
if ($id) {
$sql_where[] = " t.rowid = ".((int) $id);
@@ -197,12 +197,12 @@ class CProductNature // extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
- $sql = 'SELECT';
+ $sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.active";
- $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
@@ -267,7 +267,7 @@ class CProductNature // extends CommonObject
global $conf, $langs;
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " code=".(isset($this->code) ? ((int) $this->code) : "null").",";
$sql .= " label=".(isset($this->label) ? "'".$this->db->escape(trim($this->label))."'" : "null").",";
$sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null");
@@ -302,7 +302,7 @@ class CProductNature // extends CommonObject
global $conf, $langs;
$error = 0;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
+ $sql = "DELETE FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid=".(int) $this->id;
$this->db->begin();
diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php
index 2b9b1d6880e..36c3cb2c0fe 100644
--- a/htdocs/core/class/cstate.class.php
+++ b/htdocs/core/class/cstate.class.php
@@ -106,7 +106,7 @@ class Cstate // extends CommonObject
// Put here code to add control on parameters values
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements(";
+ $sql = "INSERT INTO ".$this->db->prefix()."c_departements(";
$sql .= "rowid,";
$sql .= "code_departement,";
$sql .= "nom,";
@@ -128,7 +128,7 @@ class Cstate // extends CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."c_departements");
}
// Commit or rollback
@@ -161,7 +161,7 @@ class Cstate // extends CommonObject
$sql .= " t.code_departement,";
$sql .= " t.nom,";
$sql .= " t.active";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t";
+ $sql .= " FROM ".$this->db->prefix()."c_departements as t";
if ($id) {
$sql .= " WHERE t.rowid = ".((int) $id);
} elseif ($code) {
@@ -219,7 +219,7 @@ class Cstate // extends CommonObject
// Put here code to add control on parameters values
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET";
+ $sql = "UPDATE ".$this->db->prefix()."c_departements SET";
$sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").",";
$sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").",";
$sql .= " active=".(isset($this->active) ? $this->active : "null")."";
@@ -260,7 +260,7 @@ class Cstate // extends CommonObject
global $conf, $langs;
$error = 0;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_departements";
+ $sql = "DELETE FROM ".$this->db->prefix()."c_departements";
$sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin();
diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php
index c8421c54b1f..6de7de7d5cb 100644
--- a/htdocs/core/class/ctypent.class.php
+++ b/htdocs/core/class/ctypent.class.php
@@ -105,7 +105,7 @@ class Ctypent // extends CommonObject
// Put here code to add control on parameters values
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_typent(";
+ $sql = "INSERT INTO ".$this->db->prefix()."c_typent(";
$sql .= "id,";
$sql .= "code,";
@@ -135,7 +135,7 @@ class Ctypent // extends CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."c_typent");
}
// Commit or rollback
@@ -170,7 +170,7 @@ class Ctypent // extends CommonObject
$sql .= " t.fk_country as country_id,";
$sql .= " t.active,";
$sql .= " t.module";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t";
+ $sql .= " FROM ".$this->db->prefix()."c_typent as t";
if ($id) {
$sql .= " WHERE t.id = ".((int) $id);
} elseif ($code) {
@@ -232,7 +232,7 @@ class Ctypent // extends CommonObject
// Put here code to add control on parameters values
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET";
+ $sql = "UPDATE ".$this->db->prefix()."c_typent SET";
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").",";
$sql .= " active=".(isset($this->active) ? $this->active : "null").",";
@@ -275,7 +275,7 @@ class Ctypent // extends CommonObject
global $conf, $langs;
$error = 0;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_typent";
+ $sql = "DELETE FROM ".$this->db->prefix()."c_typent";
$sql .= " WHERE id=".$this->id;
$this->db->begin();
diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php
index 891bf6bea10..32fe3164ad8 100644
--- a/htdocs/core/class/ctyperesource.class.php
+++ b/htdocs/core/class/ctyperesource.class.php
@@ -99,7 +99,7 @@ class Ctyperesource
// Put here code to add control on parameters values
// Insert request
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'(';
+ $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'(';
$sql .= 'code,';
$sql .= 'label';
@@ -125,7 +125,7 @@ class Ctyperesource
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
+ $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
@@ -163,12 +163,12 @@ class Ctyperesource
{
dol_syslog(__METHOD__, LOG_DEBUG);
- $sql = 'SELECT';
- $sql .= ' t.rowid,';
+ $sql = "SELECT";
+ $sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.active";
- $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
if ($id) {
$sql .= " WHERE t.id = ".((int) $id);
} elseif ($code) {
@@ -228,12 +228,12 @@ class Ctyperesource
{
dol_syslog(__METHOD__, LOG_DEBUG);
- $sql = 'SELECT';
- $sql .= ' t.rowid,';
+ $sql = "SELECT";
+ $sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.active";
- $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
// Manage filter
$sqlwhere = array();
@@ -307,7 +307,7 @@ class Ctyperesource
// Put here code to add a control on parameters values
// Update request
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
+ $sql = 'UPDATE '.$this->db->prefix().$this->table_element.' SET';
$sql .= ' code = '.(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").',';
$sql .= ' label = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").',';
@@ -376,7 +376,7 @@ class Ctyperesource
// If you need to delete child tables to, you can insert them here
if (!$error) {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
+ $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element;
$sql .= ' WHERE rowid='.((int) $this->id);
$resql = $this->db->query($sql);
diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php
index 7219f901c9f..d7571b8ca90 100644
--- a/htdocs/core/class/cunits.class.php
+++ b/htdocs/core/class/cunits.class.php
@@ -112,7 +112,7 @@ class CUnits // extends CommonObject
// Put here code to add control on parameters values
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units(";
+ $sql = "INSERT INTO ".$this->db->prefix()."c_units(";
$sql .= "rowid,";
$sql .= "code,";
$sql .= "label,";
@@ -138,7 +138,7 @@ class CUnits // extends CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."c_units");
}
// Commit or rollback
@@ -178,7 +178,7 @@ class CUnits // extends CommonObject
$sql .= " t.unit_type,";
$sql .= " t.scale,";
$sql .= " t.active";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
+ $sql .= " FROM ".$this->db->prefix()."c_units as t";
$sql_where = array();
if ($id) {
$sql_where[] = " t.rowid = ".((int) $id);
@@ -237,7 +237,7 @@ class CUnits // extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
- $sql = 'SELECT';
+ $sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.sortorder,";
@@ -246,7 +246,7 @@ class CUnits // extends CommonObject
$sql .= " t.unit_type,";
$sql .= " t.scale,";
$sql .= " t.active";
- $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t';
+ $sql .= " FROM ".$this->db->prefix()."c_units as t";
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
@@ -343,7 +343,7 @@ class CUnits // extends CommonObject
// Put here code to add control on parameters values
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET";
+ $sql = "UPDATE ".$this->db->prefix()."c_units SET";
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql .= " sortorder=".(isset($this->sortorder) ? "'".$this->db->escape($this->sortorder)."'" : "null").",";
$sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
@@ -389,7 +389,7 @@ class CUnits // extends CommonObject
global $conf, $langs;
$error = 0;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_units";
+ $sql = "DELETE FROM ".$this->db->prefix()."c_units";
$sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin();
@@ -471,7 +471,7 @@ class CUnits // extends CommonObject
{
$base = 10;
// TODO : add base col into unit dictionary table
- $unit = $this->db->getRow('SELECT scale, unit_type from '.MAIN_DB_PREFIX.'c_units WHERE rowid = '.intval($id));
+ $unit = $this->db->getRow("SELECT scale, unit_type from ".$this->db->prefix()."c_units WHERE rowid = ".intval($id));
if ($unit) {
// TODO : if base exist in unit dictionary table remove this convertion exception and update convertion infos in database exemple time hour currently scale 3600 will become scale 2 base 60
if ($unit->unit_type == 'time') {
diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php
index f6edb58207c..278b5d5e0e6 100644
--- a/htdocs/core/class/defaultvalues.class.php
+++ b/htdocs/core/class/defaultvalues.class.php
@@ -259,10 +259,10 @@ class DefaultValues extends CommonObject
$records = array();
- $sql = 'SELECT ';
+ $sql = "SELECT ";
$sql .= $this->getFieldList();
- $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
- $sql .= ' WHERE 1 = 1';
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
+ $sql .= " WHERE 1 = 1";
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 46789352bd7..7939965828a 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -139,9 +139,9 @@ class DiscountAbsolute
$sql .= " sr.datec,";
$sql .= " f.ref as ref_facture_source, f.type as type_facture_source,";
$sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as sr";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."facture as f ON sr.fk_facture_source = f.rowid";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."facture_fourn as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
$sql .= " WHERE sr.entity IN (".getEntity('invoice').")";
if ($rowid) {
$sql .= " AND sr.rowid = ".((int) $rowid);
@@ -251,7 +251,7 @@ class DiscountAbsolute
}
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except";
+ $sql = "INSERT INTO ".$this->db->prefix()."societe_remise_except";
$sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,";
$sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,";
$sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,";
@@ -267,7 +267,7 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."societe_remise_except");
return $this->id;
} else {
$this->error = $this->db->lasterror().' - sql='.$sql;
@@ -289,7 +289,7 @@ class DiscountAbsolute
// Check if we can remove the discount
if ($this->fk_facture_source) {
$sql = "SELECT COUNT(rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except";
$sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount
$sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit
$sql .= " AND fk_facture_source = ".((int) $this->fk_facture_source);
@@ -312,7 +312,7 @@ class DiscountAbsolute
// Check if we can remove the discount
if ($this->fk_invoice_supplier_source) {
$sql = "SELECT COUNT(rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except";
$sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount
$sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit
$sql .= " AND fk_invoice_supplier_source = ".((int) $this->fk_invoice_supplier_source);
@@ -335,7 +335,7 @@ class DiscountAbsolute
$this->db->begin();
// Delete but only if not used
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except ";
+ $sql = "DELETE FROM ".$this->db->prefix()."societe_remise_except ";
if ($this->fk_facture_source) {
$sql .= " WHERE fk_facture_source = ".((int) $this->fk_facture_source); // Delete all lines of same serie
} elseif ($this->fk_invoice_supplier_source) {
@@ -353,7 +353,7 @@ class DiscountAbsolute
if ($result) {
// If source of discount was a credit note or deposit, we change source statut.
if ($this->fk_facture_source) {
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
+ $sql = "UPDATE ".$this->db->prefix()."facture";
$sql .= " set paye=0, fk_statut=1";
$sql .= " WHERE (type = 2 or type = 3) AND rowid = ".((int) $this->fk_facture_source);
@@ -368,7 +368,7 @@ class DiscountAbsolute
return -1;
}
} elseif ($this->fk_invoice_supplier_source) {
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
+ $sql = "UPDATE ".$this->db->prefix()."facture_fourn";
$sql .= " set paye=0, fk_statut=1";
$sql .= " WHERE (type = 2 or type = 3) AND rowid = ".((int) $this->fk_invoice_supplier_source);
@@ -418,7 +418,7 @@ class DiscountAbsolute
return -2;
}
- $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
+ $sql = "UPDATE ".$this->db->prefix()."societe_remise_except";
if (!empty($this->discount_type)) {
if ($rowidline) {
$sql .= " SET fk_invoice_supplier_line = ".((int) $rowidline);
@@ -464,7 +464,7 @@ class DiscountAbsolute
public function unlink_invoice()
{
// phpcs:enable
- $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
+ $sql = "UPDATE ".$this->db->prefix()."societe_remise_except";
if (!empty($this->discount_type)) {
$sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL";
} else {
@@ -501,7 +501,7 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG);
$sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc";
$sql .= " WHERE rc.entity = ".$conf->entity;
$sql .= " AND rc.discount_type=".((int) $discount_type);
if (!empty($discount_type)) {
@@ -553,15 +553,15 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG);
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
- $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
- $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $invoice->id);
- $sql .= ' AND f.type = 3';
+ $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc, ".$this->db->prefix()."facture as f";
+ $sql .= " WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = ".((int) $invoice->id);
+ $sql .= " AND f.type = 3";
} elseif ($invoice->element == 'invoice_supplier') {
- $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
- $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $invoice->id);
- $sql .= ' AND f.type = 3';
+ $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc, ".$this->db->prefix()."facture_fourn as f";
+ $sql .= " WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = ".((int) $invoice->id);
+ $sql .= " AND f.type = 3";
} else {
$this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter";
dol_print_error($this->error);
@@ -594,15 +594,15 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG);
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
- $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
- $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $invoice->id);
- $sql .= " AND f.type IN (".$this->db->sanitize($invoice::TYPE_STANDARD.", ".$invoice::TYPE_CREDIT_NOTE.", ".$invoice::TYPE_SITUATION).')'; // Find discount coming from credit note or excess received
+ $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc, ".$this->db->prefix()."facture as f";
+ $sql .= " WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = ".((int) $invoice->id);
+ $sql .= " AND f.type IN (".$this->db->sanitize($invoice::TYPE_STANDARD.", ".$invoice::TYPE_CREDIT_NOTE.", ".$invoice::TYPE_SITUATION).")"; // Find discount coming from credit note or excess received
} elseif ($invoice->element == 'invoice_supplier') {
- $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
- $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $invoice->id);
- $sql .= " AND f.type IN (".$this->db->sanitize($invoice::TYPE_STANDARD.", ".$invoice::TYPE_CREDIT_NOTE).')'; // Find discount coming from credit note or excess paid
+ $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc, ".$this->db->prefix()."facture_fourn as f";
+ $sql .= " WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = ".((int) $invoice->id);
+ $sql .= " AND f.type IN (".$this->db->sanitize($invoice::TYPE_STANDARD.", ".$invoice::TYPE_CREDIT_NOTE).")"; // Find discount coming from credit note or excess paid
} else {
$this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter";
dol_print_error($this->error);
@@ -634,13 +634,13 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG);
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
- $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
- $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.((int) $invoice->id);
+ $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc";
+ $sql .= " WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = ".((int) $invoice->id);
} elseif ($invoice->element == 'invoice_supplier') {
- $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
- $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.((int) $invoice->id);
+ $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc";
+ $sql .= " WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = ".((int) $invoice->id);
} else {
$this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter";
dol_print_error($this->error);
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index 9db069ab290..7653fd24437 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -242,9 +242,9 @@ class dolReceiptPrinter extends Printer
$error = 0;
$line = 0;
$obj = array();
- $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
- $sql .= ' WHERE entity = '.$conf->entity;
+ $sql = "SELECT rowid, name, fk_type, fk_profile, parameter";
+ $sql .= " FROM ".$this->db->prefix()."printer_receipt";
+ $sql .= " WHERE entity = ".$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -310,9 +310,9 @@ class dolReceiptPrinter extends Printer
$error = 0;
$line = 0;
$obj = array();
- $sql = 'SELECT rowid, name, template';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
- $sql .= ' WHERE entity = '.$conf->entity;
+ $sql = "SELECT rowid, name, template";
+ $sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
+ $sql .= " WHERE entity = ".$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -391,7 +391,7 @@ class dolReceiptPrinter extends Printer
{
global $conf;
$error = 0;
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."printer_receipt";
+ $sql = "INSERT INTO ".$this->db->prefix()."printer_receipt";
$sql .= " (name, fk_type, fk_profile, parameter, entity)";
$sql .= " VALUES ('".$this->db->escape($name)."', ".((int) $type).", ".((int) $profile).", '".$this->db->escape($parameter)."', ".((int) $conf->entity).")";
$resql = $this->db->query($sql);
@@ -417,7 +417,7 @@ class dolReceiptPrinter extends Printer
global $conf;
$error = 0;
- $sql = "UPDATE ".MAIN_DB_PREFIX."printer_receipt";
+ $sql = "UPDATE ".$this->db->prefix()."printer_receipt";
$sql .= " SET name='".$this->db->escape($name)."'";
$sql .= ", fk_type=".((int) $type);
$sql .= ", fk_profile=".((int) $profile);
@@ -442,7 +442,7 @@ class dolReceiptPrinter extends Printer
{
global $conf;
$error = 0;
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt';
+ $sql = 'DELETE FROM '.$this->db->prefix().'printer_receipt';
$sql .= ' WHERE rowid='.((int) $printerid);
$resql = $this->db->query($sql);
if (!$resql) {
@@ -463,7 +463,7 @@ class dolReceiptPrinter extends Printer
{
global $conf;
$error = 0;
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template";
+ $sql = "INSERT INTO ".$this->db->prefix()."printer_receipt_template";
$sql .= " (name, template, entity) VALUES ('".$this->db->escape($name)."'";
$sql .= ", '".$this->db->escape($template)."', ".$conf->entity.")";
$resql = $this->db->query($sql);
@@ -484,7 +484,7 @@ class dolReceiptPrinter extends Printer
{
global $conf;
$error = 0;
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
+ $sql = 'DELETE FROM '.$this->db->prefix().'printer_receipt_template';
$sql .= " WHERE rowid = ".((int) $templateid);
$sql .= " AND entity = ".$conf->entity;
$resql = $this->db->query($sql);
@@ -508,7 +508,7 @@ class dolReceiptPrinter extends Printer
global $conf;
$error = 0;
- $sql = "UPDATE ".MAIN_DB_PREFIX."printer_receipt_template";
+ $sql = "UPDATE ".$this->db->prefix()."printer_receipt_template";
$sql .= " SET name='".$this->db->escape($name)."'";
$sql .= ", template='".$this->db->escape($template)."'";
$sql .= " WHERE rowid=".((int) $templateid);
@@ -807,8 +807,8 @@ class dolReceiptPrinter extends Printer
case 'DOL_PRINT_PAYMENT':
$sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql .= " cp.code";
- $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
+ $sql .= " FROM ".$this->db->prefix()."paiement_facture as pf, ".$this->db->prefix()."paiement as p";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."c_paiement as cp ON p.fk_paiement = cp.id";
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
$sql .= " ORDER BY p.datep";
$resql = $this->db->query($sql);
@@ -834,7 +834,7 @@ class dolReceiptPrinter extends Printer
}
break;
case 'DOL_VALUE_PLACE':
- $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref)));
+ $sql = "SELECT floor, label FROM ".$this->db->prefix()."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref)));
$resql = $this->db->query($sql);
$obj = $this->db->fetch_object($resql);
if ($obj) {
@@ -873,10 +873,10 @@ class dolReceiptPrinter extends Printer
{
global $conf;
$error = 0;
- $sql = 'SELECT template';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
- $sql .= ' WHERE rowid = '.((int) $templateid);
- $sql .= ' AND entity = '.$conf->entity;
+ $sql = "SELECT template";
+ $sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
+ $sql .= " WHERE rowid = ".((int) $templateid);
+ $sql .= " AND entity = ".$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_array($resql);
@@ -910,10 +910,10 @@ class dolReceiptPrinter extends Printer
return;
}
$error = 0;
- $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
- $sql .= ' WHERE rowid = '.((int) $printerid);
- $sql .= ' AND entity = '.((int) $conf->entity);
+ $sql = "SELECT rowid, name, fk_type, fk_profile, parameter";
+ $sql .= " FROM ".$this->db->prefix()."printer_receipt";
+ $sql .= " WHERE rowid = ".((int) $printerid);
+ $sql .= " AND entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_array($resql);
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index 0ee7eb118ac..517fc953830 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -347,9 +347,9 @@ class EmailSenderProfile extends CommonObject
*/
public function info($id)
{
- $sql = 'SELECT rowid, date_creation as datec, tms as datem';
- $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
- $sql .= ' WHERE t.rowid = '.((int) $id);
+ $sql = "SELECT rowid, date_creation as datec, tms as datem";
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
+ $sql .= " WHERE t.rowid = ".((int) $id);
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows($result)) {
diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php
index c8799ebbd5e..104f1567d44 100644
--- a/htdocs/core/class/events.class.php
+++ b/htdocs/core/class/events.class.php
@@ -152,7 +152,7 @@ class Events // extends CommonObject
}
// Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
+ $sql = "INSERT INTO ".$this->db->prefix()."events(";
$sql .= "type,";
$sql .= "entity,";
$sql .= "ip,";
@@ -175,7 +175,7 @@ class Events // extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."events");
return $this->id;
} else {
$this->error = "Error ".$this->db->lasterror();
@@ -202,7 +202,7 @@ class Events // extends CommonObject
// Put here code to add control on parameters values
// Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."events SET";
+ $sql = "UPDATE ".$this->db->prefix()."events SET";
$sql .= " type='".$this->db->escape($this->type)."',";
$sql .= " dateevent='".$this->db->idate($this->dateevent)."',";
$sql .= " description='".$this->db->escape($this->description)."'";
@@ -237,7 +237,7 @@ class Events // extends CommonObject
$sql .= " t.ip,";
$sql .= " t.user_agent,";
$sql .= " t.prefix_session";
- $sql .= " FROM ".MAIN_DB_PREFIX."events as t";
+ $sql .= " FROM ".$this->db->prefix()."events as t";
$sql .= " WHERE t.rowid = ".((int) $id);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@@ -274,7 +274,7 @@ class Events // extends CommonObject
*/
public function delete($user)
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
+ $sql = "DELETE FROM ".$this->db->prefix()."events";
$sql .= " WHERE rowid=".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 4c0ec1ff5a5..abd2c7dd502 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -265,10 +265,10 @@ class ExtraFields
'default' => $default_value
);
- $result = $this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
+ $result = $this->db->DDLAddField($this->db->prefix().$table, $attrname, $field_desc);
if ($result > 0) {
if ($unique) {
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")";
+ $sql = "ALTER TABLE ".$this->db->prefix().$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")";
$resql = $this->db->query($sql, 1, 'dml');
}
return 1;
@@ -353,7 +353,7 @@ class ExtraFields
$params = '';
}
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(";
+ $sql = "INSERT INTO ".$this->db->prefix()."extrafields(";
$sql .= " name,";
$sql .= " label,";
$sql .= " type,";
@@ -447,7 +447,7 @@ class ExtraFields
if (!$error) {
$sql = "SELECT COUNT(rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql .= " FROM ".$this->db->prefix()."extrafields";
$sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'";
$sql .= " AND name = '".$this->db->escape($attrname)."'";
//$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table
@@ -455,7 +455,7 @@ class ExtraFields
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj->nb <= 0) {
- $result = $this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key
+ $result = $this->db->DDLDropField($this->db->prefix().$table, $attrname); // This also drop the unique key
if ($result < 0) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
@@ -492,7 +492,7 @@ class ExtraFields
}
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql = "DELETE FROM ".$this->db->prefix()."extrafields";
$sql .= " WHERE name = '".$this->db->escape($attrname)."'";
$sql .= " AND entity IN (0,".$conf->entity.')';
$sql .= " AND elementtype = '".$this->db->escape($elementtype)."'";
@@ -597,7 +597,7 @@ class ExtraFields
}
if ($type != 'separate') { // No table update when separate type
- $result = $this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
+ $result = $this->db->DDLUpdateField($this->db->prefix().$table, $attrname, $field_desc);
}
if ($result > 0 || $type == 'separate') {
if ($label) {
@@ -606,9 +606,9 @@ class ExtraFields
if ($result > 0) {
$sql = '';
if ($unique) {
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")";
+ $sql = "ALTER TABLE ".$this->db->prefix().$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")";
} else {
- $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname;
+ $sql = "ALTER TABLE ".$this->db->prefix().$table." DROP INDEX uk_".$table."_".$attrname;
}
dol_syslog(get_class($this).'::update', LOG_DEBUG);
$resql = $this->db->query($sql, 1, 'dml');
@@ -699,20 +699,20 @@ class ExtraFields
if ($entity === '' || $entity != '0') {
// We dont want on all entities, we delete all and current
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql_del = "DELETE FROM ".$this->db->prefix()."extrafields";
$sql_del .= " WHERE name = '".$this->db->escape($attrname)."'";
$sql_del .= " AND entity IN (0, ".($entity === '' ? $conf->entity : $entity).")";
$sql_del .= " AND elementtype = '".$this->db->escape($elementtype)."'";
} else {
// We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity)
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql_del = "DELETE FROM ".$this->db->prefix()."extrafields";
$sql_del .= " WHERE name = '".$this->db->escape($attrname)."'";
$sql_del .= " AND entity = 0";
$sql_del .= " AND elementtype = '".$this->db->escape($elementtype)."'";
}
$resql1 = $this->db->query($sql_del);
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(";
+ $sql = "INSERT INTO ".$this->db->prefix()."extrafields(";
$sql .= " name,"; // This is code
$sql .= " entity,";
$sql .= " label,";
@@ -804,15 +804,12 @@ class ExtraFields
if ($elementtype == 'order_supplier') {
$elementtype = 'commande_fournisseur';
}
- if ($elementtype == 'stock_mouvement') {
- $elementtype = 'movement';
- }
$array_name_label = array();
// We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode
$sql = "SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help";
- $sql .= " FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql .= " FROM ".$this->db->prefix()."extrafields";
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
if ($elementtype) {
$sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'"; // Filed with object->table_element
@@ -1139,7 +1136,7 @@ class ExtraFields
$sqlwhere = '';
$sql = "SELECT ".$keyList;
- $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
// can use curent entity filter
if (strpos($InfoFieldList[4], '$ENTITY$') !== false) {
@@ -1158,7 +1155,7 @@ class ExtraFields
}
//We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) {
- $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
+ $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra';
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
} else {
$sqlwhere .= " WHERE ".$InfoFieldList[4];
@@ -1307,7 +1304,7 @@ class ExtraFields
$sqlwhere = '';
$sql = "SELECT ".$keyList;
- $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4])) {
// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
@@ -1370,7 +1367,7 @@ class ExtraFields
// We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra.') !== false) {
- $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
+ $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra';
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
} else {
$sqlwhere .= " WHERE ".$InfoFieldList[4];
@@ -1595,7 +1592,7 @@ class ExtraFields
}
$sql = "SELECT ".$keyList;
- $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main';
}
@@ -1699,7 +1696,7 @@ class ExtraFields
}
$sql = "SELECT ".$keyList;
- $sql .= " FROM ".MAIN_DB_PREFIX.$InfoFieldList[0];
+ $sql .= " FROM ".$this->db->prefix().$InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main';
}
diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php
index 0edae298f46..772c67ff282 100644
--- a/htdocs/core/class/fiscalyear.class.php
+++ b/htdocs/core/class/fiscalyear.class.php
@@ -134,7 +134,7 @@ class Fiscalyear extends CommonObject
$this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_fiscalyear (";
+ $sql = "INSERT INTO ".$this->db->prefix()."accounting_fiscalyear (";
$sql .= "label";
$sql .= ", date_start";
$sql .= ", date_end";
@@ -155,7 +155,7 @@ class Fiscalyear extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_fiscalyear");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."accounting_fiscalyear");
$result = $this->update($user);
if ($result > 0) {
@@ -191,7 +191,7 @@ class Fiscalyear extends CommonObject
$this->db->begin();
- $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_fiscalyear";
+ $sql = "UPDATE ".$this->db->prefix()."accounting_fiscalyear";
$sql .= " SET label = '".$this->db->escape($this->label)."'";
$sql .= ", date_start = '".$this->db->idate($this->date_start)."'";
$sql .= ", date_end = ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null");
@@ -221,7 +221,7 @@ class Fiscalyear extends CommonObject
public function fetch($id)
{
$sql = "SELECT rowid, label, date_start, date_end, statut";
- $sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
+ $sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear";
$sql .= " WHERE rowid = ".((int) $id);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@@ -253,7 +253,7 @@ class Fiscalyear extends CommonObject
{
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE rowid = ".((int) $id);
+ $sql = "DELETE FROM ".$this->db->prefix()."accounting_fiscalyear WHERE rowid = ".((int) $id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -414,10 +414,10 @@ class Fiscalyear extends CommonObject
*/
public function info($id)
{
- $sql = 'SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,';
- $sql .= ' fy.tms';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_fiscalyear as fy';
- $sql .= ' WHERE fy.rowid = '.((int) $id);
+ $sql = "SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,";
+ $sql .= " fy.tms";
+ $sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear as fy";
+ $sql .= " WHERE fy.rowid = ".((int) $id);
dol_syslog(get_class($this)."::fetch info", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -464,7 +464,7 @@ class Fiscalyear extends CommonObject
}
$sql = "SELECT count(DISTINCT piece_num) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
+ $sql .= " FROM ".$this->db->prefix()."accounting_bookkeeping";
$sql .= " WHERE entity IN (".getEntity('bookkeeping', 0).")";
$sql .= " AND doc_date >= '".$this->db->idate($datestart)."' and doc_date <= '".$this->db->idate($dateend)."'";
@@ -498,7 +498,7 @@ class Fiscalyear extends CommonObject
}
$sql = "SELECT count(rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping ";
+ $sql .= " FROM ".$this->db->prefix()."accounting_bookkeeping ";
$sql .= " WHERE entity IN (".getEntity('bookkeeping', 0).")";
$sql .= " AND doc_date >= '".$this->db->idate($datestart)."' and doc_date <= '".$this->db->idate($dateend)."'";
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index ff5f5d0d0a5..3375e9f7cc4 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -204,7 +204,7 @@ class Form
*/
public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id')
{
- global $conf, $langs, $db;
+ global $conf, $langs;
$ret = '';
@@ -886,7 +886,7 @@ class Form
$atleastonefavorite = 0;
$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_country";
+ $sql .= " FROM ".$this->db->prefix()."c_country";
$sql .= " WHERE active > 0";
//$sql.= " ORDER BY code ASC";
@@ -1009,7 +1009,7 @@ class Form
$incotermArray = array();
$sql = "SELECT rowid, code";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_incoterms";
+ $sql .= " FROM ".$this->db->prefix()."c_incoterms";
$sql .= " WHERE active > 0";
$sql .= " ORDER BY code ASC";
@@ -1088,7 +1088,7 @@ class Form
public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0)
{
// phpcs:enable
- global $db, $langs, $user, $conf;
+ global $langs, $conf;
// If product & services are enabled or both disabled.
if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled))
@@ -1155,7 +1155,7 @@ class Form
$langs->load("trips");
$sql = "SELECT c.code, c.label";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c";
+ $sql .= " FROM ".$this->db->prefix()."c_type_fees as c";
$sql .= " WHERE active > 0";
$resql = $this->db->query($sql);
@@ -1344,12 +1344,12 @@ class Form
$sql .= ", s.address, s.zip, s.town";
$sql .= ", dictp.code as country_code";
}
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+ $sql .= " FROM ".$this->db->prefix()."societe as s";
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."c_country as dictp ON dictp.rowid = s.fk_pays";
}
if (empty($user->rights->societe->client->voir) && !$user->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
if (!empty($user->socid)) {
@@ -1523,7 +1523,7 @@ class Form
// On recherche les remises
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql .= " re.description, re.fk_facture_source";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re";
+ $sql .= " FROM ".$this->db->prefix()."societe_remise_except as re";
$sql .= " WHERE re.fk_soc = ".(int) $socid;
$sql .= " AND re.entity = ".$conf->entity;
if ($filter) {
@@ -1668,9 +1668,9 @@ class Form
if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
$sql .= ", s.nom as company, s.town AS company_town";
}
- $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
+ $sql .= " FROM ".$this->db->prefix()."socpeople as sp";
if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
- $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc";
+ $sql .= " LEFT OUTER JOIN ".$this->db->prefix()."societe as s ON s.rowid=sp.fk_soc";
}
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
if ($socid > 0 || $socid == -1) {
@@ -1922,9 +1922,9 @@ class Form
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
$sql .= ", e.label";
}
- $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
+ $sql .= " FROM ".$this->db->prefix()."user as u";
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid = u.entity";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."entity as e ON e.rowid = u.entity";
if ($force_entity) {
$sql .= " WHERE u.entity IN (0, ".$this->db->sanitize($force_entity).")";
} else {
@@ -1932,7 +1932,7 @@ class Form
}
} else {
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= " LEFT JOIN ".$this->db->prefix()."usergroup_user as ug";
$sql .= " ON ug.fk_user = u.rowid";
$sql .= " WHERE ug.entity = ".$conf->entity;
} else {
@@ -2367,6 +2367,69 @@ class Form
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
+ /**
+ * Return list of BOM for customer in Ajax if Ajax activated or go to select_produits_list
+ *
+ * @param int $selected Preselected BOM id
+ * @param string $htmlname Name of HTML select field (must be unique in page).
+ * @param int $limit Limit on number of returned lines
+ * @param int $status Sell status -1=Return all bom, 0=Draft BOM, 1=Validated BOM
+ * @param int $type type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM)
+ * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
+ * @param string $morecss Add more css on select
+ * @param string $nooutput No print, return the output into a string
+ * @param int $forcecombo Force to use combo box
+ * @return void|string
+ */
+ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 1, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0)
+ {
+ // phpcs:enable
+ global $conf, $user, $langs, $db;
+
+ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+
+ $error = 0;
+ $out = '';
+
+ if (!$forcecombo) {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+ $out .= ajax_combobox($htmlname, $events, getDolGlobalInt("PRODUIT_USE_SEARCH_TO_SELECT"));
+ }
+
+ $out .= ' | | ";
print '';
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index ea10b4d7137..057b32e89ca 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -725,6 +725,9 @@ class SupplierProposal extends CommonObject
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
+ $pu_ht = $tabprice[3];
+ $pu_tva = $tabprice[4];
+ $pu_ttc = $tabprice[5];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];
@@ -732,6 +735,11 @@ class SupplierProposal extends CommonObject
$multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
+ $pu = $pu_ht;
+ if ($price_base_type == 'TTC') {
+ $pu = $pu_ttc;
+ }
+
//Fetch current line from the database and then clone the object and set it in $oldline property
$line = new SupplierProposalLine($this->db);
$line->fetch($rowid);
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 02d25d30797..f1d4f62587f 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -290,7 +290,7 @@ if ($action == 'valid' && $user->rights->facture->creer) {
$payment->datepaye = $now;
$payment->fk_account = $bankaccount;
$payment->amounts[$invoice->id] = $amountofpayment;
- if ($pay == 'cash') {
+ if ($pay == 'LIQ') {
$payment->pos_change = price2num(GETPOST('excess', 'alpha'));
}
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index a26fe1aa2fa..fde749b7520 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -59,7 +59,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) {
print "@media (prefers-color-scheme: dark) {";
}
print ":root {
- --colorbackhmenu1: #1d1e20;
+ --colorbackhmenu1: #3d3e40;
--colorbackvmenu1: #2b2c2e;
--colorbacktitle1: #2b2d2f;
--colorbacktabcard1: #1d1e20; /* Must be same than colorbackbody */
@@ -154,8 +154,9 @@ table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td.
max-width: 100px;
text-overflow: ellipsis;
}
-.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
+/*.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
.liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month],
+.liste_titre select[name=year],
.liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create],
.liste_titre input[name=search_month_lim], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], .liste_titre input[name=search_month_create],
.liste_titre input[name=search_month_update], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end],
@@ -166,6 +167,7 @@ table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td.
.liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end],
.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when],
.liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth],
+*/
select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth,
input, input.flat, form.flat select, select, select.flat, .dataTables_length label select {
border: none;
@@ -255,6 +257,12 @@ input:invalid, select:invalid, input.--error , select.--error {
border-color: #ea1212;
}
+section.setupsection {
+ padding: 20px;
+ background-color: var(--colorbacktitle1);
+ border-radius: 5px;
+}
+
.field-error-icon { color: #ea1212; !important; }
/* Focus definitions must be after standard definition */
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 8029ce93681..fb9178e1ed0 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -85,8 +85,8 @@ if (empty($dolibarr_nocache)) {
header('Cache-Control: no-cache');
}
-if (GETPOST('theme', 'alpha')) {
- $conf->theme = GETPOST('theme', 'alpha'); // If theme was forced on URL
+if (GETPOST('theme', 'aZ09')) {
+ $conf->theme = GETPOST('theme', 'aZ09'); // If theme was forced on URL
}
if (GETPOST('lang', 'aZ09')) {
$langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL
diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php
index 3ab9550e42d..6d14830b657 100644
--- a/htdocs/theme/md/btn.inc.php
+++ b/htdocs/theme/md/btn.inc.php
@@ -233,7 +233,7 @@ span.butActionNewRefused>span.fa, span.butActionNewRefused>span.fa:hover
background: var(--butactiondeletebg);
/* border: 1px solid #633; */
color: #633;
- vertical-align: middle;
+ /* vertical-align: middle; */
}
.butActionDelete:hover {
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 7394cbe697f..2249e1e3ce5 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -86,8 +86,8 @@ if (empty($dolibarr_nocache)) {
header('Cache-Control: no-cache');
}
-if (GETPOST('theme', 'alpha')) {
- $conf->theme = GETPOST('theme', 'alpha'); // If theme was forced on URL
+if (GETPOST('theme', 'aZ09')) {
+ $conf->theme = GETPOST('theme', 'aZ09'); // If theme was forced on URL
}
if (GETPOST('lang', 'aZ09')) {
$langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL
@@ -474,6 +474,18 @@ input.short {
width: 40px;
}
+input:invalid, select:invalid, input.--error , select.--error {
+ border-color: #ea1212;
+}
+
+section.setupsection {
+ padding: 20px;
+ background-color: var(--colorbacktitle1);
+ border-radius: 5px;
+}
+
+.field-error-icon { color: #ea1212; !important; }
+
textarea {
border-radius: 0;
border-top:solid 1px var(--inputbordercolor);
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index 690bcb5cad2..f1d33f4eeb0 100755
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -1479,31 +1479,6 @@ if ($action == 'create' || $action == 'presend') {
$morehtmlright = '';
$help = "";
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
- if ($object->fk_soc > 0) {
- $substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
- }
- $substitutionarray['__USER_SIGNATURE__'] = $user->signature;
- $substitutionarray['__TICKET_TRACKID__'] = $object->track_id;
- $substitutionarray['__TICKET_REF__'] = $object->ref;
- $substitutionarray['__TICKET_SUBJECT__'] = $object->subject;
- $substitutionarray['__TICKET_TYPE__'] = $object->type_code;
- $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code;
- $substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility
- $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code;
- $substitutionarray['__TICKET_MESSAGE__'] = $object->message;
- $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress;
- if ($object->fk_user_assign > 0) {
- $userstat->fetch($object->fk_user_assign);
- $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
- }
-
- if ($object->fk_user_create > 0) {
- $userstat->fetch($object->fk_user_create);
- $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
- }
- foreach ($substitutionarray as $key => $val) {
- $help .= $key.' -> '.$langs->trans($val).' ';
- }
$morehtmlright .= $form->textwithpicto(''.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution');
print '';
diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php
index 68aa2b650f7..b2f8085de5a 100644
--- a/htdocs/user/class/api_users.class.php
+++ b/htdocs/user/class/api_users.class.php
@@ -82,9 +82,9 @@ class Users extends DolibarrApi
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
$sql = "SELECT t.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX."user as t";
+ $sql .= " FROM ".$this->db->prefix()."user as t";
if ($category > 0) {
- $sql .= ", ".MAIN_DB_PREFIX."categorie_user as c";
+ $sql .= ", ".$this->db->prefix()."categorie_user as c";
}
$sql .= ' WHERE t.entity IN ('.getEntity('user').')';
if ($user_ids) {
@@ -536,7 +536,7 @@ class Users extends DolibarrApi
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
$sql = "SELECT t.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as t";
+ $sql .= " FROM ".$this->db->prefix()."usergroup as t";
$sql .= ' WHERE t.entity IN ('.getEntity('user').')';
if ($group_ids) {
$sql .= " AND t.rowid IN (".$this->db->sanitize($group_ids).")";
diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php
index d9392ade9d7..42164ce8b2c 100644
--- a/htdocs/user/class/userbankaccount.class.php
+++ b/htdocs/user/class/userbankaccount.class.php
@@ -93,12 +93,12 @@ class UserBankAccount extends Account
{
$now = dol_now();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rib (fk_user, datec)";
+ $sql = "INSERT INTO ".$this->db->prefix()."user_rib (fk_user, datec)";
$sql .= " VALUES (".$this->userid.", '".$this->db->idate($now)."')";
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->affected_rows($resql)) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib");
+ $this->id = $this->db->last_insert_id($this->db->prefix()."user_rib");
return $this->update($user);
}
@@ -123,7 +123,7 @@ class UserBankAccount extends Account
$this->create();
}
- $sql = "UPDATE ".MAIN_DB_PREFIX."user_rib SET";
+ $sql = "UPDATE ".$this->db->prefix()."user_rib SET";
$sql .= " bank = '".$this->db->escape($this->bank)."'";
$sql .= ",code_banque='".$this->db->escape($this->code_banque)."'";
$sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
@@ -167,7 +167,7 @@ class UserBankAccount extends Account
$sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, label, datec, tms as datem";
- $sql .= " FROM ".MAIN_DB_PREFIX."user_rib";
+ $sql .= " FROM ".$this->db->prefix()."user_rib";
if ($id) {
$sql .= " WHERE rowid = ".((int) $id);
}
diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php
index b1b3175aaa9..00e031c33f1 100644
--- a/htdocs/user/class/usergroup.class.php
+++ b/htdocs/user/class/usergroup.class.php
@@ -191,8 +191,8 @@ class UserGroup extends CommonObject
$ret = array();
$sql = "SELECT g.rowid, ug.entity as usergroup_entity";
- $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g,";
- $sql .= " ".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= " FROM ".$this->db->prefix()."usergroup as g,";
+ $sql .= " ".$this->db->prefix()."usergroup_user as ug";
$sql .= " WHERE ug.fk_usergroup = g.rowid";
$sql .= " AND ug.fk_user = ".((int) $userid);
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
@@ -241,9 +241,9 @@ class UserGroup extends CommonObject
if (!empty($this->id)) {
$sql .= ", ug.entity as usergroup_entity";
}
- $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
+ $sql .= " FROM ".$this->db->prefix()."user as u";
if (!empty($this->id)) {
- $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= ", ".$this->db->prefix()."usergroup_user as ug";
}
$sql .= " WHERE 1 = 1";
if (!empty($this->id)) {
@@ -315,7 +315,7 @@ class UserGroup extends CommonObject
// Si on a demande ajout d'un droit en particulier, on recupere
// les caracteristiques (module, perms et subperms) de ce droit.
$sql = "SELECT module, perms, subperms";
- $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
+ $sql .= " FROM ".$this->db->prefix()."rights_def";
$sql .= " WHERE id = ".((int) $rid);
$sql .= " AND entity = ".((int) $entity);
@@ -358,7 +358,7 @@ class UserGroup extends CommonObject
if (!empty($whereforadd)) {
//print "$module-$perms-$subperms";
$sql = "SELECT id";
- $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
+ $sql .= " FROM ".$this->db->prefix()."rights_def";
$sql .= " WHERE entity = ".((int) $entity);
if (!empty($whereforadd) && $whereforadd != 'allmodules') {
$sql .= " AND ".$whereforadd;
@@ -372,11 +372,11 @@ class UserGroup extends CommonObject
$obj = $this->db->fetch_object($result);
$nid = $obj->id;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = ".((int) $this->id)." AND fk_id=".((int) $nid)." AND entity = ".((int) $entity);
+ $sql = "DELETE FROM ".$this->db->prefix()."usergroup_rights WHERE fk_usergroup = ".((int) $this->id)." AND fk_id=".((int) $nid)." AND entity = ".((int) $entity);
if (!$this->db->query($sql)) {
$error++;
}
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".((int) $entity).", ".((int) $this->id).", ".((int) $nid).")";
+ $sql = "INSERT INTO ".$this->db->prefix()."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".((int) $entity).", ".((int) $this->id).", ".((int) $nid).")";
if (!$this->db->query($sql)) {
$error++;
}
@@ -437,7 +437,7 @@ class UserGroup extends CommonObject
// Si on a demande supression d'un droit en particulier, on recupere
// les caracteristiques module, perms et subperms de ce droit.
$sql = "SELECT module, perms, subperms";
- $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
+ $sql .= " FROM ".$this->db->prefix()."rights_def";
$sql .= " WHERE id = ".((int) $rid);
$sql .= " AND entity = ".((int) $entity);
@@ -485,7 +485,7 @@ class UserGroup extends CommonObject
if (!empty($wherefordel)) {
//print "$module-$perms-$subperms";
$sql = "SELECT id";
- $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
+ $sql .= " FROM ".$this->db->prefix()."rights_def";
$sql .= " WHERE entity = ".((int) $entity);
if (!empty($wherefordel) && $wherefordel != 'allmodules') {
$sql .= " AND ".$wherefordel;
@@ -503,7 +503,7 @@ class UserGroup extends CommonObject
$nid = $obj->id;
}
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
+ $sql = "DELETE FROM ".$this->db->prefix()."usergroup_rights";
$sql .= " WHERE fk_usergroup = $this->id AND fk_id=".((int) $nid);
$sql .= " AND entity = ".((int) $entity);
if (!$this->db->query($sql)) {
@@ -564,7 +564,7 @@ class UserGroup extends CommonObject
* Recuperation des droits
*/
$sql = "SELECT r.module, r.perms, r.subperms ";
- $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_rights as u, ".MAIN_DB_PREFIX."rights_def as r";
+ $sql .= " FROM ".$this->db->prefix()."usergroup_rights as u, ".$this->db->prefix()."rights_def as r";
$sql .= " WHERE r.id = u.fk_id";
$sql .= " AND r.entity = ".((int) $conf->entity);
$sql .= " AND u.entity = ".((int) $conf->entity);
diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php
index 57778c44259..0f9085d0b52 100644
--- a/htdocs/user/vcard.php
+++ b/htdocs/user/vcard.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2004-2010 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
+/* Copyright (C) 2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2010 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2020 Tobias Sekan
+ * Copyright (C) 2021-2022 Anthony Berton
*
* 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
@@ -64,27 +65,27 @@ $v->setUid('DOLIBARR-USERID-'.$user2->id);
$v->setName($user2->lastname, $user2->firstname, "", $user2->civility_code, "");
$v->setFormattedName($user2->getFullName($langs, 1));
-$v->setPhoneNumber($user2->phone_pro, "TYPE=WORK;VOICE");
-//$v->setPhoneNumber($user2->phone_perso,"TYPE=HOME;VOICE");
-$v->setPhoneNumber($user2->phone_mobile, "TYPE=CELL;VOICE");
-$v->setPhoneNumber($user2->fax, "TYPE=WORK;FAX");
+$v->setPhoneNumber($user2->office_phone, "TYPE=WORK;VOICE");
+$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE");
+$v->setPhoneNumber($user2->user_mobile, "TYPE=CELL;VOICE");
+$v->setPhoneNumber($user2->office_fax, "TYPE=WORK;FAX");
$country = $user2->country_code ? $user2->country : '';
$v->setAddress("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK;POSTAL");
$v->setLabel("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK");
-$v->setEmail($user2->email);
+$v->setEmail($user2->email, "TYPE=WORK");
$v->setNote($user2->note);
$v->setTitle($user2->poste);
// Data from linked company
if ($company->id) {
$v->setURL($company->url, "TYPE=WORK");
- if (!$user2->phone_pro) {
+ if (!$user2->office_phone) {
$v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
}
- if (!$user2->fax) {
+ if (!$user2->office_fax) {
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
}
if (!$user2->zip) {
@@ -96,16 +97,16 @@ if ($company->id) {
// was set before, don't set twice
} elseif (empty(trim($user2->email))) {
// when user e-mail is empty, use only company e-mail
- $v->setEmail($company->email);
+ $v->setEmail($company->email, "TYPE=WORK");
} elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email)))) {
// when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second)
- $v->setEmail($user2->email);
+ $v->setEmail($user2->email, "TYPE=WORK");
// support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($company->email, 'INTERNET');
} else {
// when e-mail of user and company complete different use company e-mail at first (and user e-mail at second)
- $v->setEmail($company->email);
+ $v->setEmail($company->email, "TYPE=WORK");
// support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($user2->email, 'INTERNET');
@@ -118,7 +119,7 @@ if ($company->id) {
}
// Personal informations
-$v->setPhoneNumber($user2->phone_perso, "TYPE=HOME;VOICE");
+$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE");
if ($user2->birth) {
$v->setBirthday($user2->birth);
}
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index af2f3a96ae1..33f3c89f32e 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -274,27 +274,27 @@ $manifestjsoncontentdefault .= '{
"background_color": "#fff",
"description": "A simple Web app.",
"icons": [{
- "src": "images/'.$website->ref.'/homescreen48.png",
+ "src": "images/'.urlencode($website->ref).'/homescreen48.png",
"sizes": "48x48",
"type": "image/png"
}, {
- "src": "image/'.$website->ref.'/homescreen72.png",
+ "src": "image/'.urlencode($website->ref).'/homescreen72.png",
"sizes": "72x72",
"type": "image/png"
}, {
- "src": "image/'.$website->ref.'/homescreen96.png",
+ "src": "image/'.urlencode($website->ref).'/homescreen96.png",
"sizes": "96x96",
"type": "image/png"
}, {
- "src": "image/'.$website->ref.'/homescreen144.png",
+ "src": "image/'.urlencode($website->ref).'/homescreen144.png",
"sizes": "144x144",
"type": "image/png"
}, {
- "src": "image/'.$website->ref.'/homescreen168.png",
+ "src": "image/'.urlencode($website->ref).'/homescreen168.png",
"sizes": "168x168",
"type": "image/png"
}, {
- "src": "image/'.$website->ref.'/homescreen192.png",
+ "src": "image/'.urlencode($website->ref).'/homescreen192.png",
"sizes": "192x192",
"type": "image/png"
}],
@@ -2477,7 +2477,7 @@ $formother = new FormOther($db);
// Confirm generation of website sitemaps
if ($action == 'confirmgeneratesitemaps') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.urlencode($website->ref), $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1);
$action = 'preview';
}
$helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
@@ -2692,12 +2692,12 @@ if (!GETPOST('hide_websitemenu')) {
print '';
// Regenerate all pages
- print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'">';
+ print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'">';
// Generate site map
- print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">';
+ print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">';
- print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">';
+ print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">';
}
print '';
@@ -2705,11 +2705,11 @@ if (!GETPOST('hide_websitemenu')) {
if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) {
print '';
//print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("MediaFiles")).'">';
- print dolButtonToOpenUrlInDialogPopup('file_manager', $langs->transnoentitiesnoconv("MediaFiles"), '', '/website/index.php?action=file_manager&website='.$website->ref, $disabled);
+ print dolButtonToOpenUrlInDialogPopup('file_manager', $langs->transnoentitiesnoconv("MediaFiles"), '', '/website/index.php?action=file_manager&website='.urlencode($website->ref).'§ion_dir='.urlencode('image/'.$website->ref.'/'), $disabled);
if (!empty($conf->categorie->enabled)) {
//print '';
- print dolButtonToOpenUrlInDialogPopup('categories', $langs->transnoentitiesnoconv("Categories"), '', '/categories/index.php?leftmenu=website&nosearch=1&type=website_page&website='.$website->ref, $disabled);
+ print dolButtonToOpenUrlInDialogPopup('categories', $langs->transnoentitiesnoconv("Categories"), '', '/categories/index.php?leftmenu=website&nosearch=1&type=website_page&website='.urlencode($website->ref), $disabled);
}
print '';
@@ -2787,7 +2787,7 @@ if (!GETPOST('hide_websitemenu')) {
print '';
}
if ($action != 'preview') {
- print '';
+ print '';
}
}
@@ -2808,7 +2808,7 @@ if (!GETPOST('hide_websitemenu')) {
print '';
print '';
- print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("AddPage")).'">';
+ print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("AddPage")).'">';
print '';
//print '';
@@ -2823,7 +2823,7 @@ if (!GETPOST('hide_websitemenu')) {
$out .= $s;
$out .= '';
- $urltocreatenewpage = $_SERVER["PHP_SELF"].'?action=createcontainer&website='.$website->ref;
+ $urltocreatenewpage = $_SERVER["PHP_SELF"].'?action=createcontainer&website='.urlencode($website->ref);
if (!empty($conf->use_javascript_ajax)) {
$out .= ' |