';
@@ -112,31 +111,31 @@ if ($resql)
/*
* Liste des propal brouillons
*/
-if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
-{
+if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
$sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE p.fk_statut = 0";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('propal').")";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$total = 0;
$num = $db->num_rows($resql);
$i = 0;
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '';
print ''.$langs->trans("ProposalsDraft").' ';
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '';
@@ -164,41 +163,45 @@ print '';
/*
* Actions commerciales a faire
*/
-if (!empty($conf->agenda->enabled)) show_array_actions_to_do(10);
+if (!empty($conf->agenda->enabled)) {
+ show_array_actions_to_do(10);
+}
/*
* Dernieres propales ouvertes
*/
-if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
-{
+if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
$sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,";
- $sql .= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
+ $sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."c_propalst as c";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE p.fk_soc = s.rowid";
$sql .= " AND p.fk_statut = c.id";
$sql .= " AND p.fk_statut = 1";
$sql .= " AND p.entity IN (".getEntity('propal').")";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND s.rowid = ".$socid;
+ if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
+ if ($socid) {
+ $sql .= " AND s.rowid = ".$socid;
+ }
$sql .= " ORDER BY p.rowid DESC";
$sql .= $db->plimit(5, 0);
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$total = 0;
$num = $db->num_rows($resql);
$i = 0;
- if ($num > 0)
- {
+ if ($num > 0) {
print '
';
print ''.$langs->trans("ProposalsOpened").' ';
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '';
@@ -218,8 +221,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
$i++;
$total += $obj->price;
}
- if ($total > 0)
- {
+ if ($total > 0) {
print ' '.$langs->trans("Total")." ".price($total)." ";
}
print "
";
@@ -235,25 +237,26 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
*/
$sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
$sql .= " WHERE s.fk_stcomm = 1";
$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
$sql .= " ORDER BY s.tms ASC";
$sql .= $db->plimit(15, 0);
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num > 0)
- {
+ if ($num > 0) {
print '
';
print ''.$langs->trans("ProspectToContact").' ';
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '';
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 6b75d57d082..cb16e419ee8 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -313,7 +313,7 @@ class Commande extends CommonOrder
'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>110),
'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
//'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
- 'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
+ 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1),
@@ -1791,7 +1791,7 @@ class Commande extends CommonOrder
if (empty($id) && empty($ref) && empty($ref_ext)) return -1;
$sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
- $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
+ $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.fk_account';
$sql .= ', c.date_commande, c.date_valid, c.tms';
$sql .= ', c.date_livraison as delivery_date';
@@ -3297,7 +3297,7 @@ class Commande extends CommonOrder
$sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").",";
$sql .= " date_commande=".(strval($this->date_commande) != '' ? "'".$this->db->idate($this->date_commande)."'" : 'null').",";
$sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').",";
- $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").",";
+ $sql .= " total_tva=".(isset($this->total_tva) ? $this->total_tva : "null").",";
$sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").",";
$sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").",";
$sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").",";
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 8b4a79f4dda..a5f548d6e6a 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -286,7 +286,7 @@ if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DI
$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
-$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
+$sql .= ' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
@@ -369,7 +369,7 @@ if ($search_company_alias) $sql .= natural_search('s.name_alia
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1);
-if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1);
+if ($search_total_vat != '') $sql .= natural_search('c.total_tva', $search_total_vat, 1);
if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
@@ -941,7 +941,7 @@ if ($resql)
if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right ');
+ if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['c.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 7b60dd639f6..249df885435 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1376,7 +1376,7 @@ if ($resql)
// Alias
if (!empty($arrayfields['s.name_alias']['checked']))
{
- print ' ';
+ print ' ';
print $obj->name_alias;
print ' ';
if (!$i) $totalarray['nbfield']++;
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index dc397d286cc..8a50619f17c 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -831,7 +831,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
$sql .= ", s.nom as name, s.email";
$sql .= ", s.rowid as socid";
$sql .= ", s.code_client, s.code_compta";
- $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.tva as total_tva, c.total_ttc,";
+ $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.total_tva, c.total_ttc,";
$sql .= " cc.rowid as country_id, cc.code as country_code";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -849,7 +849,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
$reshook = $hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters);
$sql .= $hookmanager->resPrint;
- $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code";
+ $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_tva, c.total_ttc, cc.rowid, cc.code";
$resql = $db->query($sql);
if ($resql)
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 943c704b17f..3866405bee8 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -821,7 +821,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ''.$langs->trans("ContactByDefaultFor").' ';
print '';
$contactType = $object->listeTypeContacts('external', '', 1);
- print $form->multiselectarray('roles', $contactType);
+ print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500');
print ' ';
}
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index cd1db0bbc9a..d625298b14c 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -9,7 +9,7 @@
* Copyright (C) 2014-2020 Ferran Marcet
* Copyright (C) 2014-2016 Marcos García
* Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018-2021 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -768,8 +768,7 @@ if (empty($reshook))
}
// Close all lines
- elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
- {
+ elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) {
$result = $object->closeAll($user);
if ($result < 0)
{
@@ -778,15 +777,13 @@ if (empty($reshook))
}
// Close all lines
- elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer)
- {
+ elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) {
$result = $object->activateAll($user);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
- {
+ } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) {
$result = $object->delete($user);
if ($result >= 0)
{
@@ -795,13 +792,12 @@ if (empty($reshook))
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer)
- {
+ } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) {
if (GETPOST('newcid') > 0)
{
$contractline = new ContratLigne($db);
- $result = $contractline->fetch(GETPOST('lineid'));
- $contractline->fk_contrat = GETPOST('newcid');
+ $result = $contractline->fetch(GETPOSTINT('lineid'));
+ $contractline->fk_contrat = GETPOSTINT('newcid');
$result = $contractline->update($user, 1);
if ($result >= 0)
{
@@ -871,8 +867,7 @@ if (empty($reshook))
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
- } elseif ($action == 'setref')
- {
+ } elseif ($action == 'setref') {
$cancelbutton = GETPOST('cancel', 'alpha');
if (!$cancelbutton) {
@@ -909,8 +904,7 @@ if (empty($reshook))
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
- } elseif ($action == 'setdate_contrat')
- {
+ } elseif ($action == 'setdate_contrat') {
$cancelbutton = GETPOST('cancel', 'alpha');
if (!$cancelbutton) {
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 4fa506a23f4..892cb8ae4e0 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -3,7 +3,7 @@
* Copyright (C) 2018 Nicolas ZABOURI
* Copyright (C) 2018 Juanjo Menent
* Copyright (C) 2019 Ferran Marcet
- * Copyright (C) 2019 Frédéric France
+ * Copyright (C) 2019-2021 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1126,18 +1126,47 @@ if (!$error && $massaction == 'validate' && $permissiontoadd)
if ($result > 0)
{
$result = $objecttmp->validate($user);
- if ($result == 0)
- {
+ if ($result == 0) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
$error++;
break;
- } elseif ($result < 0)
- {
+ } elseif ($result < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
- } else $nbok++;
+ } else {
+ // validate() rename pdf but do not regenerate
+ // Define output language
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $objecttmp->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ $outputlangs->load('products');
+ }
+ $model = $objecttmp->model_pdf;
+ $ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records
+ // To be sure vars is defined
+ $hidedetails = !empty($hidedetails) ? $hidedetails : 0;
+ $hidedesc = !empty($hidedesc) ? $hidedesc : 0;
+ $hideref = !empty($hideref) ? $hideref : 0;
+ $moreparams = !empty($moreparams) ? $moreparams : null;
+
+ $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ if ($result < 0) {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ }
+ }
+ $nbok++;
+ }
} else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php
index 1585241b843..b0dc89f5817 100644
--- a/htdocs/core/boxes/box_activity.php
+++ b/htdocs/core/boxes/box_activity.php
@@ -1,7 +1,7 @@
* Copyright (C) 2005-2015 Laurent Destailleur
- * Copyright (C) 2014-2019 Frederic France
+ * Copyright (C) 2014-2021 Frederic France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -100,8 +100,7 @@ class box_activity extends ModeleBoxes
// list the summary of the propals
- if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
- {
+ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic = new Propal($this->db);
@@ -109,24 +108,28 @@ class box_activity extends ModeleBoxes
$filename = '/boxactivity-propal'.$fileid;
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array();
- if ($refresh)
- {
- $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
+ if ($refresh) {
+ $sql = "SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$user->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= ")";
$sql .= " WHERE p.entity IN (".getEntity('propal').")";
$sql .= " AND p.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
+ if (!$user->rights->societe->client->voir && !$user->socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
+ if ($user->socid) {
+ $sql .= " AND s.rowid = ".$user->socid;
+ }
$sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'";
$sql .= " AND p.date_cloture IS NULL"; // just unclosed
$sql .= " GROUP BY p.fk_statut";
$sql .= " ORDER BY p.fk_statut DESC";
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
$j = 0;
@@ -145,11 +148,9 @@ class box_activity extends ModeleBoxes
$data = dol_readcachefile($cachedir, $filename);
}
- if (!empty($data))
- {
+ if (!empty($data)) {
$j = 0;
- while ($j < count($data))
- {
+ while ($j < count($data)) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="left" width="16"',
'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut,
diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php
index 9b020a05711..f13f7ffa1f9 100644
--- a/htdocs/core/boxes/box_commandes.php
+++ b/htdocs/core/boxes/box_commandes.php
@@ -98,7 +98,7 @@ class box_commandes extends ModeleBoxes
$sql .= ", c.fk_user_valid";
$sql .= ", c.facture";
$sql .= ", c.total_ht";
- $sql .= ", c.tva as total_tva";
+ $sql .= ", c.total_tva";
$sql .= ", c.total_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande as c";
diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php
index 6efd56c01db..a6a023952d4 100644
--- a/htdocs/core/boxes/box_propales.php
+++ b/htdocs/core/boxes/box_propales.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville
* Copyright (C) 2004-2007 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2015-2019 Frederic France
+ * Copyright (C) 2015-2021 Frederic France
* Copyright (C) 2020 Pierre Ardoin
*
* This program is free software; you can redistribute it and/or modify
@@ -83,26 +83,33 @@ class box_propales extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."Propals", $max));
- if ($user->rights->propale->lire)
- {
+ if ($user->rights->propale->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
- $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms";
+ $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$user->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('propal').")";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
- if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY p.datep DESC, p.ref DESC ";
- else $sql .= " ORDER BY p.tms DESC, p.ref DESC ";
+ if (!$user->rights->societe->client->voir && !$user->socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
+ if ($user->socid) {
+ $sql .= " AND s.rowid = ".$user->socid;
+ }
+ if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
+ $sql .= " ORDER BY p.datep DESC, p.ref DESC ";
+ } else {
+ $sql .= " ORDER BY p.tms DESC, p.ref DESC ";
+ }
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
$now = dol_now();
@@ -168,11 +175,12 @@ class box_propales extends ModeleBoxes
$line++;
}
- if ($num == 0)
+ if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedProposals"),
);
+ }
$this->db->free($result);
} else {
diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php
index 5074d403231..c91068b1ff3 100644
--- a/htdocs/core/boxes/box_supplier_orders.php
+++ b/htdocs/core/boxes/box_supplier_orders.php
@@ -88,7 +88,7 @@ class box_supplier_orders extends ModeleBoxes
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", c.rowid, c.ref, c.tms, c.date_commande";
$sql .= ", c.total_ht";
- $sql .= ", c.tva as total_tva";
+ $sql .= ", c.total_tva";
$sql .= ", c.total_ttc";
$sql .= ", c.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php
index 22f669966f3..2c1dc49161e 100644
--- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php
+++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php
@@ -88,7 +88,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison as delivery_date";
$sql .= ", c.total_ht";
- $sql .= ", c.tva as total_tva";
+ $sql .= ", c.total_tva";
$sql .= ", c.total_ttc";
$sql .= ", c.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index cf22db4670d..09e8ec4a00b 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1412,6 +1412,8 @@ abstract class CommonObject
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num > 0) {
+ $langs->loadLangs(array("propal", "orders", "bills", "suppliers", "contracts", "supplier_proposal"));
+
while ($obj = $this->db->fetch_object($resql)) {
$modulename = $obj->element;
if (strpos($obj->element, 'project') !== false) {
@@ -1427,11 +1429,15 @@ abstract class CommonObject
}
if (!empty($conf->{$modulename}->enabled)) {
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
- $transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code;
+ $tmpelement = $obj->element;
+ $transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code;
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
- if (empty($option))
+ if (empty($option)) {
$tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
- else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
+ }
+ else {
+ $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
+ }
}
}
}
@@ -3230,12 +3236,11 @@ abstract class CommonObject
// Specific code for backward compatibility with old field names
if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total';
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva';
- if ($this->element == 'propal') {
- $fieldttc = 'total';
- $fieldtva = 'total_tva';
- }
+ if ($this->element == 'propal') $fieldtva = 'total_tva';
if ($this->element == 'expensereport') $fieldtva = 'total_tva';
- if ($this->element == 'supplier_proposal') $fieldttc = 'total';
+ if ($this->element == 'supplier_proposal') $fieldtva = 'total_tva';
+ if ($this->element == 'commande') $fieldtva = 'total_tva';
+ if ($this->element == 'order_supplier') $fieldtva = 'total_tva';
if (empty($nodatabaseupdate))
{
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 8cff096e56a..1ed2af9aa2d 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -824,7 +824,7 @@ class FormCompany extends Form
}
if (count($newselected) > 0) $selected = $newselected;
}
- return $this->multiselectarray($htmlname, $contactType, $selected);
+ return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, 'minwidth500');
}
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 4d56fd9697a..310f34a86fb 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -52,10 +52,10 @@ function societe_prepare_head(Societe $object)
if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
-
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$nbContact = 0;
+ // Enable caching of thirdrparty count Contacts
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_contacts_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
@@ -71,7 +71,7 @@ function societe_prepare_head(Societe $object)
$nbContact = $obj->nb;
}
- dol_setcache($cachekey, $nbContact); // If setting cache fails, this is not a problem, so we do not test result.
+ dol_setcache($cachekey, $nbContact, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
@@ -129,22 +129,32 @@ function societe_prepare_head(Societe $object)
}
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
- $nbNote = 0;
- $sql = "SELECT COUNT(n.rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
- $sql .= " WHERE fk_soc = ".$object->id;
- $sql .= " AND entity IN (".getEntity('project').")";
- $resql = $db->query($sql);
- if ($resql) {
- $obj = $db->fetch_object($resql);
- $nbNote = $obj->nb;
+ $nbProject = 0;
+ // Enable caching of thirdrparty count projects
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
+ $cachekey = 'count_projects_thirdparty_'.$object->id;
+ $dataretrieved = dol_getcache($cachekey);
+
+ if (!is_null($dataretrieved)) {
+ $nbProject = $dataretrieved;
} else {
- dol_print_error($db);
+ $sql = "SELECT COUNT(n.rowid) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
+ $sql .= " WHERE fk_soc = ".$object->id;
+ $sql .= " AND entity IN (".getEntity('project').")";
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ $nbProject = $obj->nb;
+ } else {
+ dol_print_error($db);
+ }
+ dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Projects");
- if ($nbNote > 0) {
- $head[$h][1] .= ''.$nbNote.' ';
+ if ($nbProject > 0) {
+ $head[$h][1] .= ''.$nbProject.' ';
}
$head[$h][2] = 'project';
$h++;
@@ -271,10 +281,9 @@ function societe_prepare_head(Societe $object)
if ($user->socid == 0) {
// Notifications
if (!empty($conf->notification->enabled)) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
-
$nbNotif = 0;
// Enable caching of thirdrparty count notifications
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_notifications_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
@@ -290,7 +299,7 @@ function societe_prepare_head(Societe $object)
} else {
dol_print_error($db);
}
- dol_setcache($cachekey, $nbNotif); // If setting cache fails, this is not a problem, so we do not test result.
+ dol_setcache($cachekey, $nbNotif, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id;
@@ -318,17 +327,28 @@ function societe_prepare_head(Societe $object)
$head[$h][2] = 'note';
$h++;
- // Attached files
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
- $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
- $nbLinks = Link::count($db, $object->element, $object->id);
+ // Attached files and Links
+ $totalAttached = 0;
+ // Enable caching of thirdrparty count attached files and links
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
+ $cachekey = 'count_attached_thirdparty_'.$object->id;
+ $dataretrieved = dol_getcache($cachekey);
+ if (!is_null($dataretrieved)) {
+ $totalAttached = $dataretrieved;
+ } else {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+ $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
+ $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+ $nbLinks = Link::count($db, $object->element, $object->id);
+ $totalAttached = $nbFiles + $nbLinks;
+ dol_setcache($cachekey, $totalAttached, 120); // If setting cache fails, this is not a problem, so we do not test result.
+ }
$head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Documents");
- if (($nbFiles + $nbLinks) > 0) {
- $head[$h][1] .= ''.($nbFiles + $nbLinks).' ';
+ if (($totalAttached) > 0) {
+ $head[$h][1] .= ''.($totalAttached).' ';
}
$head[$h][2] = 'document';
$h++;
@@ -337,10 +357,9 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
-
$nbEvent = 0;
// Enable caching of thirdrparty count actioncomm
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
@@ -356,7 +375,7 @@ function societe_prepare_head(Societe $object)
} else {
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
}
- dol_setcache($cachekey, $nbEvent); // If setting cache fails, this is not a problem, so we do not test result.
+ dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][1] .= '/';
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 7d994616e5c..5457a6859e3 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2450,21 +2450,32 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64,
function getArrayOfSocialNetworks()
{
global $conf, $db;
- $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
- $sql .= " WHERE entity=".$conf->entity;
+
$socialnetworks = array();
- $resql = $db->query($sql);
- if ($resql) {
- while ($obj = $db->fetch_object($resql)) {
- $socialnetworks[$obj->code] = array(
- 'rowid' => $obj->rowid,
- 'label' => $obj->label,
- 'url' => $obj->url,
- 'icon' => $obj->icon,
- 'active' => $obj->active,
- );
+ // Enable caching of array
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
+ $cachekey = 'socialnetworks_' . $conf->entity;
+ $dataretrieved = dol_getcache($cachekey);
+ if (!is_null($dataretrieved)) {
+ $socialnetworks = $dataretrieved;
+ } else {
+ $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
+ $sql .= " WHERE entity=".$conf->entity;
+ $resql = $db->query($sql);
+ if ($resql) {
+ while ($obj = $db->fetch_object($resql)) {
+ $socialnetworks[$obj->code] = array(
+ 'rowid' => $obj->rowid,
+ 'label' => $obj->label,
+ 'url' => $obj->url,
+ 'icon' => $obj->icon,
+ 'active' => $obj->active,
+ );
+ }
}
+ dol_setcache($cachekey, $socialnetworks); // If setting cache fails, this is not a problem, so we do not test result.
}
+
return $socialnetworks;
}
@@ -3173,15 +3184,15 @@ function dol_substr($string, $start, $length, $stringencoding = '', $trunconbyte
/**
- * Truncate a string to a particular length adding '...' if string larger than length.
- * If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
+ * Truncate a string to a particular length adding '…' if string larger than length.
+ * If length = max length+1, we do no truncate to avoid having just 1 char replaced with '…'.
* MAIN_DISABLE_TRUNC=1 can disable all truncings
*
* @param string $string String to truncate
- * @param int $size Max string size visible (excluding ...). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added ..., or if size was max+1 or max+2 or max+3 so it does not worse to replace with ...)
+ * @param int $size Max string size visible (excluding …). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added …, or if size was max+1 so it does not worse to replace with ...)
* @param string $trunc Where to trunc: 'right', 'left', 'middle' (size must be a 2 power), 'wrap'
* @param string $stringencoding Tell what is source string encoding
- * @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation.
+ * @param int $nodot Truncation do not add … after truncation. So it's an exact truncation.
* @param int $display Trunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
* @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise.
*/
@@ -3189,42 +3200,53 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
{
global $conf;
- if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
+ if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
+ return $string;
+ }
- if (empty($stringencoding)) $stringencoding = 'UTF-8';
+ if (empty($stringencoding)) {
+ $stringencoding = 'UTF-8';
+ }
// reduce for small screen
if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3);
// We go always here
- if ($trunc == 'right')
- {
- $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
- if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
- return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...');
- else //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
- return $string;
- } elseif ($trunc == 'middle')
- {
- $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
- if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1))
- {
+ if ($trunc == 'right') {
+ $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
+ if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
+ // If nodot is 0 and size is 1 chars more, we don't trunc and don't add …
+ return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '…');
+ } else {
+ //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
+ return $string;
+ }
+ } elseif ($trunc == 'middle') {
+ $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
+ if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
$size1 = round($size / 2);
$size2 = round($size / 2);
- return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
- } else return $string;
- } elseif ($trunc == 'left')
- {
- $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
- if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
- return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
- else return $string;
- } elseif ($trunc == 'wrap')
- {
- $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
- if (dol_strlen($newstring, $stringencoding) > ($size + 1))
- return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
- else return $string;
- } else return 'BadParam3CallingDolTrunc';
+ return dol_substr($newstring, 0, $size1, $stringencoding).'…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
+ } else {
+ return $string;
+ }
+ } elseif ($trunc == 'left') {
+ $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
+ if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
+ // If nodot is 0 and size is 1 chars more, we don't trunc and don't add …
+ return '…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
+ } else {
+ return $string;
+ }
+ } elseif ($trunc == 'wrap') {
+ $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
+ if (dol_strlen($newstring, $stringencoding) > ($size + 1)) {
+ return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
+ } else {
+ return $string;
+ }
+ } else {
+ return 'BadParam3CallingDolTrunc';
+ }
}
/**
@@ -6386,8 +6408,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
$substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null);
$substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null);
-
$substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : '');
+ $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%d") : '');
+ $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%A") : '');
+ $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%m") : '');
+ $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%b") : '');
+ $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%Y") : '');
+ $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%H") : '');
+ $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : '');
+ $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : '');
// For backward compatibility
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php
index 232b5a9d94a..484b3933e42 100644
--- a/htdocs/core/lib/memory.lib.php
+++ b/htdocs/core/lib/memory.lib.php
@@ -61,10 +61,11 @@ $shmoffset = 1000; // Max number of entries found into a language file. If too l
*
* @param string $memoryid Memory id of shared area
* @param mixed $data Data to save. It must not be a null value.
+ * @param int $expire ttl in seconds, 0 never expire
* @return int <0 if KO, 0 if nothing is done, Nb of bytes written if OK
* @see dol_getcache()
*/
-function dol_setcache($memoryid, $data)
+function dol_setcache($memoryid, $data, $expire = 0)
{
global $conf;
$result = 0;
@@ -85,7 +86,7 @@ function dol_setcache($memoryid, $data)
$memoryid = session_name() . '_' . $memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
- $dolmemcache->add($memoryid, $data); // This fails if key already exists
+ $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists
$rescode = $dolmemcache->getResultCode();
if ($rescode == 0) {
return count($data);
@@ -104,7 +105,7 @@ function dol_setcache($memoryid, $data)
$memoryid = session_name() . '_' . $memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
- $result = $dolmemcache->add($memoryid, $data); // This fails if key already exists
+ $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists
if ($result) {
return count($data);
} else {
@@ -112,7 +113,7 @@ function dol_setcache($memoryid, $data)
}
} elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // This is a really not reliable cache ! Use Memcached instead.
// Using shmop
- $result = dol_setshmop($memoryid, $data);
+ $result = dol_setshmop($memoryid, $data, $expire);
}
return $result;
@@ -226,9 +227,10 @@ function dol_listshmop()
*
* @param int $memoryid Memory id of shared area ('main', 'agenda', ...)
* @param string $data Data to save. Must be a not null value.
+ * @param int $expire ttl in seconds, 0 never expire
* @return int <0 if KO, 0=Caching not available, Nb of bytes written if OK
*/
-function dol_setshmop($memoryid, $data)
+function dol_setshmop($memoryid, $data, $expire)
{
global $shmkeys, $shmoffset;
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 75a20ac6852..bc232f2cf15 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -205,7 +205,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
/**
* Render a string of an HTML content and output it.
- * Used to ouput the page when viewed from server (Dolibarr or Apache).
+ * Used to ouput the page when viewed from a server (Dolibarr or Apache).
*
* @param string $content Content string
* @param string $contenttype Content type
@@ -296,7 +296,7 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
if (empty($includehtmlcontentopened)) {
$content = str_replace('!~!~!~', '', $content);
}
- } else // REPLACEMENT OF LINKS When page called from virtual host
+ } else // REPLACEMENT OF LINKS When page called from virtual host web server
{
$symlinktomediaexists = 1;
if ($website->virtualhost) {
@@ -355,7 +355,9 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
}
}
- $content = str_replace(' contenteditable="true"', ' contenteditable="false"', $content);
+ if (!defined('USEDOLIBARREDITOR')) {
+ $content = str_replace(' contenteditable="true"', ' contenteditable="false"', $content);
+ }
if (!empty($conf->global->WEBSITE_ADD_CSS_TO_BODY)) {
$content = str_replace(''CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"OrderId", 'f.ref'=>"Ref", 'f.ref_supplier'=>"RefSupplier", 'f.date_creation'=>"DateCreation", 'f.date_commande'=>"OrderDate", 'f.date_livraison'=>"DateDeliveryPlanned",
- 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',
+ 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',
'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC",
'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',
@@ -544,7 +544,7 @@ class modFournisseur extends DolibarrModules
$this->export_TypeFields_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text",
- 'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric",
+ 'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric",
'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",
'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_tva'=>"Numeric",
'fd.product_type'=>'Numeric', 'fd.ref'=>'Text', 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
@@ -852,7 +852,7 @@ class modFournisseur extends DolibarrModules
'c.fk_statut' => 'Status*',
'c.billed' => 'Billed(0/1)',
'c.remise_percent' => 'GlobalDiscount',
- 'c.tva' => 'TotalTVA',
+ 'c.total_tva' => 'TotalTVA',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
'c.note_private' => 'NotePrivate',
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index bb4ba6c1744..af249e3b65c 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -191,7 +191,7 @@ class modPropale extends DolibarrModules
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer",
'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount",
- 'c.total_ht'=>"TotalHT", 'c.total'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
+ 'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC",
@@ -208,14 +208,14 @@ class modPropale extends DolibarrModules
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text',
// 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",
- // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
+ // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
// 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",
// 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
//);
$this->export_TypeFields_array[$r] = array(
's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text',
's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date",
- 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',
+ 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',
'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric",
'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text'
);
@@ -223,7 +223,7 @@ class modPropale extends DolibarrModules
's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"propal", 'c.ref'=>"propal", 'c.ref_client'=>"propal",
'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal",
- 'c.total'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line',
+ 'c.total_ttc'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line',
'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",
'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'
);
@@ -276,7 +276,7 @@ class modPropale extends DolibarrModules
'c.fin_validite' => 'DateEndPropal',
'c.remise_percent' => 'GlobalDiscount',
'c.total_ht' => 'TotalHT',
- 'c.total' => 'TotalTTC',
+ 'c.total_ttc' => 'TotalTTC',
'c.fk_statut' => 'Status*',
'c.note_public' => 'Note',
'c.date_livraison' => 'DeliveryDate',
@@ -313,7 +313,7 @@ class modPropale extends DolibarrModules
'c.fin_validite' => '2020-01-01',
'c.remise_percent' => '',
'c.total_ht' => '0',
- 'c.total' => '0',
+ 'c.total_ttc' => '0',
'c.fk_statut' => '1',
'c.note_public' => '',
'c.date_livraison' => '2020-01-01',
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 5d3381b2719..0a7ed20981e 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -275,6 +275,9 @@ if ($action == 'presend')
foreach ($contactarr as $contact) {
$contactstatic->fetch($contact['id']);
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
+ $substitutionarray['__CONTACT_LASTNAME_'.$contact['code'].'__'] = $contactstatic->lastname;
+ $substitutionarray['__CONTACT_FIRSTNAME_'.$contact['code'].'__'] = $contactstatic->firstname;
+ $substitutionarray['__CONTACT_TITLE_'.$contact['code'].'__'] = $contactstatic->getCivilityLabel();
}
}
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 9d18f3cfd1a..9794ea3cc11 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -550,7 +550,7 @@ if ($object->id > 0)
{
$langs->loadLangs(array("supplier_proposal"));
- $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc";
+ $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p ";
$sql .= " WHERE p.fk_soc =".$object->id;
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 1e6e0234cdc..52121d8c83d 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -204,7 +204,7 @@ class CommandeFournisseur extends CommonOrder
'amount_ht' =>array('type'=>'double(24,8)', 'label'=>'Amount ht', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
- 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
+ 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1),
@@ -305,7 +305,7 @@ class CommandeFournisseur extends CommonOrder
// Check parameters
if (empty($id) && empty($ref)) return -1;
- $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,";
+ $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.total_tva,";
$sql .= " c.localtax1, c.localtax2, ";
$sql .= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,";
$sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,";
@@ -356,7 +356,7 @@ class CommandeFournisseur extends CommonOrder
$this->user_approve_id = $obj->fk_user_approve;
$this->user_approve_id2 = $obj->fk_user_approve2;
$this->total_ht = $obj->total_ht;
- $this->total_tva = $obj->total_vat;
+ $this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc;
@@ -451,7 +451,7 @@ class CommandeFournisseur extends CommonOrder
$sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc';
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
$sql .= ", pfp.rowid as fk_pfp, pfp.packaging";
- $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
+ $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn";
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index aa5f7c3ddc5..0918b316fb3 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -78,12 +78,12 @@ $optioncss = GETPOST('optioncss', 'alpha');
$socid = GETPOST('socid', 'int');
$search_sale = GETPOST('search_sale', 'int');
$search_total_ht = GETPOST('search_total_ht', 'alpha');
-$search_total_vat = GETPOST('search_total_vat', 'alpha');
+$search_total_tva = GETPOST('search_total_tva', 'alpha');
$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
-$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
+$search_multicurrency_montant_tva = GETPOST('search_multicurrency_montant_tva', 'alpha');
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$search_billed = GETPOST('search_billed', 'int');
@@ -155,12 +155,12 @@ $arrayfields = array(
'cf.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1),
'cf.date_livraison'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)),
'cf.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
- 'cf.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
+ 'cf.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0),
'cf.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'cf.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'cf.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'cf.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
- 'cf.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
+ 'cf.multicurrency_total_tva'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'cf.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'cf.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'cf.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
@@ -210,12 +210,12 @@ if (empty($reshook))
$search_type_thirdparty = '';
$search_request_author = '';
$search_total_ht = '';
- $search_total_vat = '';
+ $search_total_tva = '';
$search_total_ttc = '';
$search_multicurrency_code = '';
$search_multicurrency_tx = '';
$search_multicurrency_montant_ht = '';
- $search_multicurrency_montant_vat = '';
+ $search_multicurrency_montant_tva = '';
$search_multicurrency_montant_ttc = '';
$search_project_ref = '';
$search_status = -1;
@@ -477,7 +477,7 @@ if (empty($reshook))
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
- if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat);
+ if ($search_total_tva != '') $param .= '&search_total_tva='.urlencode($search_total_tva);
if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc);
if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref);
if ($show_files) $param .= '&show_files='.urlencode($show_files);
@@ -539,8 +539,8 @@ if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DI
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
-$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,";
-$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva as multicurrency_total_vat, cf.multicurrency_total_ttc,';
+$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,";
+$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,';
$sql .= ' cf.date_creation as date_creation, cf.tms as date_update,';
$sql .= ' cf.note_public, cf.note_private,';
$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
@@ -600,12 +600,12 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user);
if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
-if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1);
+if ($search_total_tva != '') $sql .= natural_search('cf.total_tva', $search_total_tva, 1);
if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
if ($search_multicurrency_code != '') $sql .= ' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
if ($search_multicurrency_tx != '') $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
-if ($search_multicurrency_montant_vat != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
+if ($search_multicurrency_montant_tva != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1);
if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref);
// Add where from extra fields
@@ -672,7 +672,7 @@ if ($resql)
if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
- if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
+ if ($search_multicurrency_montant_tva != '') $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva);
if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
if ($search_refsupp) $param .= "&search_refsupp=".urlencode($search_refsupp);
if ($search_status != '' && $search_status != '-1') $param .= "&search_status=".urlencode($search_status);
@@ -905,11 +905,11 @@ if ($resql)
print ' ';
print '';
}
- if (!empty($arrayfields['cf.total_vat']['checked']))
+ if (!empty($arrayfields['cf.total_tva']['checked']))
{
// Amount
print '';
- print ' ';
+ print ' ';
print ' ';
}
if (!empty($arrayfields['cf.total_ttc']['checked']))
@@ -940,11 +940,11 @@ if ($resql)
print ' ';
print '';
}
- if (!empty($arrayfields['cf.multicurrency_total_vat']['checked']))
+ if (!empty($arrayfields['cf.multicurrency_total_tva']['checked']))
{
// Amount
print '';
- print ' ';
+ print ' ';
print ' ';
}
if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked']))
@@ -1011,12 +1011,12 @@ if ($resql)
if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cf.date_livraison']['checked'])) print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right ');
+ if (!empty($arrayfields['cf.total_tva']['checked'])) print_liste_field_titre($arrayfields['cf.total_tva']['label'], $_SERVER["PHP_SELF"], "cf.total_tva", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['cf.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
- if (!empty($arrayfields['cf.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
+ if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@@ -1199,12 +1199,12 @@ if ($resql)
$totalarray['val']['cf.total_ht'] += $obj->total_ht;
}
// Amount VAT
- if (!empty($arrayfields['cf.total_vat']['checked']))
+ if (!empty($arrayfields['cf.total_tva']['checked']))
{
print ''.price($obj->total_tva)." \n";
if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_vat';
- $totalarray['val']['cf.total_vat'] += $obj->total_tva;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva';
+ $totalarray['val']['cf.total_tva'] += $obj->total_tva;
}
// Amount TTC
if (!empty($arrayfields['cf.total_ttc']['checked']))
@@ -1237,9 +1237,9 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Amount VAT
- if (!empty($arrayfields['cf.multicurrency_total_vat']['checked']))
+ if (!empty($arrayfields['cf.multicurrency_total_tva']['checked']))
{
- print ''.price($obj->multicurrency_total_vat)." \n";
+ print ''.price($obj->multicurrency_total_tva)." \n";
if (!$i) $totalarray['nbfield']++;
}
// Amount TTC
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 0a3e49c9600..7594ead39a4 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -43,7 +43,9 @@ $langs->load("install");
// Now we load forced/pre-set values from install.forced.php file.
$useforcedwizard = false;
$forcedfile = "./install.forced.php";
-if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php";
+if ($conffile == "/etc/dolibarr/conf.php") {
+ $forcedfile = "/etc/dolibarr/install.forced.php";
+}
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
@@ -66,36 +68,36 @@ print ' '.$langs->trans("WarningBrowserTooOld")." \n";
+ if ($browsername == 'ie' && $browserversion < 7) {
+ print ' '.$langs->trans("WarningBrowserTooOld")." \n";
+ }
}
// Check PHP version
$arrayphpminversionerror = array(5, 5, 0);
$arrayphpminversionwarning = array(5, 6, 0);
-if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) // Minimum to use (error if lower)
-{
+if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) { // Minimum to use (error if lower)
print ' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
$checksok = 0; // 0=error, 1=warning
-} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) // Minimum supported (warning if lower)
-{
+} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) { // Minimum supported (warning if lower)
print ' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
$checksok = 0; // 0=error, 1=warning
} else {
print ' '.$langs->trans("PHPVersion")." ".versiontostring(versionphparray());
}
-if (empty($force_install_nophpinfo)) print ' ('.$langs->trans("MoreInformation").' )';
+if (empty($force_install_nophpinfo)) {
+ print ' ('.$langs->trans("MoreInformation").' )';
+}
print " \n";
// Check PHP support for $_GET and $_POST
-if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) // We must keep $_GET and $_POST here
-{
+if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) { // We must keep $_GET and $_POST here
print ' '.$langs->trans("PHPSupportPOSTGETKo");
print ' ('.$langs->trans("Recheck").' )';
print " \n";
@@ -106,8 +108,7 @@ if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) // We must keep $_GE
// Check if session_id is enabled
-if (!function_exists("session_id"))
-{
+if (!function_exists("session_id")) {
print ' '.$langs->trans("ErrorPHPDoesNotSupportSessions")." \n";
$checksok = 0;
} else {
@@ -116,8 +117,7 @@ if (!function_exists("session_id"))
// Check if GD is supported (we need GD for image conversion)
-if (!function_exists("imagecreate"))
-{
+if (!function_exists("imagecreate")) {
$langs->load("errors");
print ' '.$langs->trans("ErrorPHPDoesNotSupportGD")." \n";
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
@@ -127,8 +127,7 @@ if (!function_exists("imagecreate"))
// Check if Curl is supported
-if (!function_exists("curl_init"))
-{
+if (!function_exists("curl_init")) {
$langs->load("errors");
print ' '.$langs->trans("ErrorPHPDoesNotSupportCurl")." \n";
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
@@ -137,8 +136,7 @@ if (!function_exists("curl_init"))
}
// Check if PHP calendar extension is available
-if (!function_exists("easter_date"))
-{
+if (!function_exists("easter_date")) {
print ' '.$langs->trans("ErrorPHPDoesNotSupportCalendar")." \n";
} else {
print ' '.$langs->trans("PHPSupport", "Calendar")." \n";
@@ -146,8 +144,7 @@ if (!function_exists("easter_date"))
// Check if UTF8 is supported
-if (!function_exists("utf8_encode"))
-{
+if (!function_exists("utf8_encode")) {
$langs->load("errors");
print ' '.$langs->trans("ErrorPHPDoesNotSupportUTF8")." \n";
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
@@ -157,10 +154,8 @@ if (!function_exists("utf8_encode"))
// Check if intl methods are supported
-if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost')
-{
- if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region"))
- {
+if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
+ if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) {
$langs->load("errors");
print ' '.$langs->trans("ErrorPHPDoesNotSupportIntl")." \n";
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
@@ -169,8 +164,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc
}
}
-if (!class_exists('ZipArchive'))
-{
+if (!class_exists('ZipArchive')) {
$langs->load("errors");
print ' '.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")." \n";
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
@@ -183,17 +177,20 @@ $memrequiredorig = '64M';
$memrequired = 64 * 1024 * 1024;
$memmaxorig = @ini_get("memory_limit");
$memmax = @ini_get("memory_limit");
-if ($memmaxorig != '')
-{
+if ($memmaxorig != '') {
preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
- if ($reg[2])
- {
- if (strtoupper($reg[2]) == 'G') $memmax = $reg[1] * 1024 * 1024 * 1024;
- if (strtoupper($reg[2]) == 'M') $memmax = $reg[1] * 1024 * 1024;
- if (strtoupper($reg[2]) == 'K') $memmax = $reg[1] * 1024;
+ if ($reg[2]) {
+ if (strtoupper($reg[2]) == 'G') {
+ $memmax = $reg[1] * 1024 * 1024 * 1024;
+ }
+ if (strtoupper($reg[2]) == 'M') {
+ $memmax = $reg[1] * 1024 * 1024;
+ }
+ if (strtoupper($reg[2]) == 'K') {
+ $memmax = $reg[1] * 1024;
+ }
}
- if ($memmax >= $memrequired || $memmax == -1)
- {
+ if ($memmax >= $memrequired || $memmax == -1) {
print ' '.$langs->trans("PHPMemoryOK", $memmaxorig, $memrequiredorig)." \n";
} else {
print ' '.$langs->trans("PHPMemoryTooLow", $memmaxorig, $memrequiredorig)." \n";
@@ -203,15 +200,13 @@ if ($memmaxorig != '')
// If that config file is present and filled
clearstatcache();
-if (is_readable($conffile) && filesize($conffile) > 8)
-{
+if (is_readable($conffile) && filesize($conffile) > 8) {
dolibarr_install_syslog("check: conf file '".$conffile."' already defined");
$confexists = 1;
include_once $conffile;
$databaseok = 1;
- if ($databaseok)
- {
+ if ($databaseok) {
// Already installed for all parts (config and database). We can propose upgrade.
$allowupgrade = true;
} else {
@@ -223,8 +218,7 @@ if (is_readable($conffile) && filesize($conffile) > 8)
$confexists = 0;
// First we try by copying example
- if (@copy($conffile.".example", $conffile))
- {
+ if (@copy($conffile.".example", $conffile)) {
// Success
dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile);
} else {
@@ -232,12 +226,13 @@ if (is_readable($conffile) && filesize($conffile) > 8)
dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING);
$fp = @fopen($conffile, "w");
- if ($fp)
- {
+ if ($fp) {
@fwrite($fp, ' 8)
// File is missing and cannot be created
-if (!file_exists($conffile))
-{
+if (!file_exists($conffile)) {
print ' '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
print " ";
print $langs->trans("YouMustCreateWithPermission", $conffiletoshow);
@@ -257,17 +251,13 @@ if (!file_exists($conffile))
print $langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok');
$err++;
} else {
- if (dol_is_dir($conffile))
- {
+ if (dol_is_dir($conffile)) {
print ' '.$langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow);
$allowinstall = 0;
- }
- // File exists but cannot be modified
- elseif (!is_writable($conffile))
- {
- if ($confexists)
- {
+ } elseif (!is_writable($conffile)) {
+ // File exists but cannot be modified
+ if ($confexists) {
print ' '.$langs->trans("ConfFileExists", $conffiletoshow);
} else {
print ' '.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
@@ -277,11 +267,9 @@ if (!file_exists($conffile))
print " \n";
$allowinstall = 0;
- }
- // File exists and can be modified
- else {
- if ($confexists)
- {
+ } else {
+ // File exists and can be modified
+ if ($confexists) {
print ' '.$langs->trans("ConfFileExists", $conffiletoshow);
} else {
print ' '.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
@@ -295,32 +283,28 @@ if (!file_exists($conffile))
print " \n";
// Requirements met/all ok: display the next step button
- if ($checksok)
- {
+ if ($checksok) {
$ok = 0;
// Try to create db connection
- if (file_exists($conffile))
- {
+ if (file_exists($conffile)) {
include_once $conffile;
- if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root))
- {
- if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php"))
- {
+ if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
+ if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) {
print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file. '."\n";
dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING);
} else {
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
// If password is encoded, we decode it
- if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
- {
+ if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
- if (preg_match('/crypted:/i', $dolibarr_main_db_pass))
- {
+ if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
$dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
- } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ } else {
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
}
// $conf already created in inc.php
@@ -331,8 +315,7 @@ if (!file_exists($conffile))
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
- if ($db->connected && $db->database_selected)
- {
+ if ($db->connected && $db->database_selected) {
$ok = true;
}
}
@@ -340,16 +323,21 @@ if (!file_exists($conffile))
}
// If database access is available, we set more variables
- if ($ok)
- {
- if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
+ if ($ok) {
+ if (empty($dolibarr_main_db_encryption)) {
+ $dolibarr_main_db_encryption = 0;
+ }
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
- if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = '';
+ if (empty($dolibarr_main_db_cryptkey)) {
+ $dolibarr_main_db_cryptkey = '';
+ }
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
$conf->setValues($db);
// Reset forced setup after the setValues
- if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
+ if (defined('SYSLOG_FILE')) {
+ $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
+ }
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
@@ -359,14 +347,15 @@ if (!file_exists($conffile))
}
// Show title
- if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL))
- {
+ if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) {
print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).' - ';
print $langs->trans("VersionProgram").': '.DOL_VERSION.' ';
//print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
print ' ';
print ' ';
- } else print " \n";
+ } else {
+ print " \n";
+ }
//print $langs->trans("InstallEasy")." ";
print ''.$langs->trans("ChooseYourSetupMode").' ';
@@ -376,8 +365,7 @@ if (!file_exists($conffile))
$available_choices = array();
$notavailable_choices = array();
- if (empty($dolibarr_main_db_host)) // This means install process was not run
- {
+ if (empty($dolibarr_main_db_host)) { // This means install process was not run
$foundrecommandedchoice = 1; // To show only once
}
@@ -387,8 +375,7 @@ if (!file_exists($conffile))
$choice .= '';
$choice .= '';
$choice .= $langs->trans("FreshInstallDesc");
- if (empty($dolibarr_main_db_host)) // This means install process was not run
- {
+ if (empty($dolibarr_main_db_host)) { // This means install process was not run
$choice .= ' ';
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= ''.$langs->trans("InstallChoiceSuggested").'
';
@@ -397,8 +384,7 @@ if (!file_exists($conffile))
$choice .= ' ';
$choice .= '';
- if ($allowinstall)
- {
+ if ($allowinstall) {
$choice .= ''.$langs->trans("Start").' ';
} else {
$choice .= ($foundrecommandedchoice ? '' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? ' ' : '');
@@ -415,12 +401,15 @@ if (!file_exists($conffile))
// Show upgrade lines
$allowupgrade = true;
- if (empty($dolibarr_main_db_host)) // This means install process was not run
- {
+ if (empty($dolibarr_main_db_host)) { // This means install process was not run
$allowupgrade = false;
}
- if (defined("MAIN_NOT_INSTALLED")) $allowupgrade = false;
- if (GETPOST('allowupgrade')) $allowupgrade = true;
+ if (defined("MAIN_NOT_INSTALLED")) {
+ $allowupgrade = false;
+ }
+ if (GETPOST('allowupgrade')) {
+ $allowupgrade = true;
+ }
$migrationscript = array(array('from'=>'3.0.0', 'to'=>'3.1.0'),
array('from'=>'3.1.0', 'to'=>'3.2.0'),
array('from'=>'3.2.0', 'to'=>'3.3.0'),
@@ -444,8 +433,7 @@ if (!file_exists($conffile))
);
$count = 0;
- foreach ($migrationscript as $migarray)
- {
+ foreach ($migrationscript as $migarray) {
$choice = '';
$count++;
@@ -460,20 +448,16 @@ if (!file_exists($conffile))
$newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
$newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
$newversionfrombis = '';
- if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1
- {
+ if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) { // From x.y.z -> x.y.z+1
$newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
}
- if ($ok)
- {
- if (count($dolibarrlastupgradeversionarray) >= 2) // If database access is available and last upgrade version is known
- {
+ if ($ok) {
+ if (count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known
// Now we check if this is the first qualified choice
if ($allowupgrade && empty($foundrecommandedchoice) &&
(versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
- )
- {
+ ) {
$foundrecommandedchoice = 1; // To show only once
$recommended_choice = true;
}
@@ -489,14 +473,12 @@ if (!file_exists($conffile))
$choice .= ' ';
$choice .= $langs->trans("UpgradeDesc");
- if ($recommended_choice)
- {
+ if ($recommended_choice) {
$choice .= ' ';
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= '';
$choice .= '
'.$langs->trans("InstallChoiceSuggested").'
';
- if ($count < count($migarray)) // There are other choices after
- {
+ if ($count < count($migarray)) { // There are other choices after
print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
}
$choice .= '
';
@@ -504,19 +486,15 @@ if (!file_exists($conffile))
$choice .= ' ';
$choice .= '';
- if ($allowupgrade)
- {
+ if ($allowupgrade) {
$disabled = false;
- if ($foundrecommandedchoice == 2)
- {
+ if ($foundrecommandedchoice == 2) {
$disabled = true;
}
- if ($foundrecommandedchoice == 1)
- {
+ if ($foundrecommandedchoice == 1) {
$foundrecommandedchoice = 2;
}
- if ($disabled)
- {
+ if ($disabled) {
$choice .= ''.$langs->trans("NotYetAvailable").' ';
} else {
$choice .= ''.$langs->trans("Start").' ';
@@ -535,8 +513,7 @@ if (!file_exists($conffile))
}
// If there is no choice at all, we show all of them.
- if (empty($available_choices))
- {
+ if (empty($available_choices)) {
$available_choices = $notavailable_choices;
$notavailable_choices = array();
}
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index 12bab777edb..3f7cb019521 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -5,7 +5,8 @@
* Copyright (C) 2007-2012 Laurent Destailleur
* Copyright (C) 2012 Marcos García
* Copyright (C) 2016 Raphaël Doursenaud
- *
+ * Copyright (C) 2021 Charlene Benke
+*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -27,40 +28,40 @@
*/
// Just to define version DOL_VERSION
-if (!defined('DOL_INC_FOR_VERSION_ERROR')) define('DOL_INC_FOR_VERSION_ERROR', '1');
+if (!defined('DOL_INC_FOR_VERSION_ERROR')) {
+ define('DOL_INC_FOR_VERSION_ERROR', '1');
+}
require_once '../filefunc.inc.php';
// Define DOL_DOCUMENT_ROOT and ADODB_PATH used for install/upgrade process
-if (!defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
-if (!defined('ADODB_PATH'))
-{
+if (!defined('DOL_DOCUMENT_ROOT')) {
+ define('DOL_DOCUMENT_ROOT', '..');
+}
+if (!defined('ADODB_PATH')) {
$foundpath = DOL_DOCUMENT_ROOT.'/includes/adodbtime/';
- if (!is_dir($foundpath)) $foundpath = '/usr/share/php/adodb/';
+ if (!is_dir($foundpath)) {
+ $foundpath = '/usr/share/php/adodb/';
+ }
define('ADODB_PATH', $foundpath);
}
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once ADODB_PATH.'adodb-time.inc.php';
-// Avoid warnings with strict mode E_STRICT
-$conf = new stdClass(); // instantiate $conf explicitely
-$conf->global = new stdClass();
-$conf->file = new stdClass();
-$conf->db = new stdClass();
-$conf->syslog = new stdClass();
+$conf = new Conf();
// Force $_REQUEST["logtohtml"]
$_REQUEST["logtohtml"] = 1;
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu.
-if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
-{
+if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) {
$_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"];
}
@@ -79,19 +80,21 @@ $conffiletoshow = "htdocs/conf/conf.php";
// Load conf file if it is already defined
-if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just 8) { // Test on filesize is to ensure that conf file is more that an empty template with just
$dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) : '';
// Remove last / or \ on directories or url value
- if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root);
- if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root);
- if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root);
- if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt);
- if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt);
+ if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) {
+ $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root);
+ }
+ if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) {
+ $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root);
+ }
+ if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) {
+ $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root);
+ }
+ if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) {
+ $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt);
+ }
+ if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) {
+ $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt);
+ }
// Create conf object
- if (!empty($dolibarr_main_document_root))
- {
+ if (!empty($dolibarr_main_document_root)) {
$result = conf($dolibarr_main_document_root);
}
// Load database driver
- if ($result)
- {
- if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type))
- {
+ if ($result) {
+ if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) {
$result = include_once $dolibarr_main_document_root."/core/db/".$dolibarr_main_db_type.'.class.php';
- if (!$result)
- {
+ if (!$result) {
$includeconferror = 'ErrorBadValueForDolibarrMainDBType';
}
}
@@ -133,7 +142,9 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
// Define prefix
-if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) $dolibarr_main_db_prefix = 'llx_';
+if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) {
+ $dolibarr_main_db_prefix = 'llx_';
+}
define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : ''));
define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir
@@ -141,42 +152,51 @@ define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_r
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain
-if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
+if ($suburi == '/') {
+ $suburi = ''; // If $suburi is /, it is now ''
+}
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
-if (empty($conf->file->character_set_client)) $conf->file->character_set_client = "utf-8";
-if (empty($conf->db->character_set)) $conf->db->character_set = 'utf8';
-if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci';
-if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_encryption = 0;
-if (empty($conf->db->dolibarr_main_db_cryptkey)) $conf->db->dolibarr_main_db_cryptkey = '';
-if (empty($conf->db->user)) $conf->db->user = '';
+if (empty($conf->file->character_set_client)) {
+ $conf->file->character_set_client = "utf-8";
+}
+if (empty($conf->db->character_set)) {
+ $conf->db->character_set = 'utf8';
+}
+if (empty($conf->db->dolibarr_main_db_collation)) {
+ $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci';
+}
+if (empty($conf->db->dolibarr_main_db_encryption)) {
+ $conf->db->dolibarr_main_db_encryption = 0;
+}
+if (empty($conf->db->dolibarr_main_db_cryptkey)) {
+ $conf->db->dolibarr_main_db_cryptkey = '';
+}
+if (empty($conf->db->user)) {
+ $conf->db->user = '';
+}
// Define array of document root directories
$conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT);
-if (!empty($dolibarr_main_document_root_alt))
-{
+if (!empty($dolibarr_main_document_root_alt)) {
// dolibarr_main_document_root_alt contains several directories
$values = preg_split('/[;,]/', $dolibarr_main_document_root_alt);
- foreach ($values as $value)
- {
+ foreach ($values as $value) {
$conf->file->dol_document_root[] = $value;
}
}
// Security check (old method, when directory is renamed /install.lock)
-if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"]))
-{
- if (!is_object($langs))
- {
+if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"])) {
+ if (!is_object($langs)) {
$langs = new Translate('..', $conf);
$langs->setDefaultLang('auto');
}
$langs->load("install");
print $langs->trans("YouTryInstallDisabledByDirLock");
- if (!empty($dolibarr_main_url_root))
- {
+ if (!empty($dolibarr_main_url_root)) {
print 'Click on following link, ';
print $langs->trans("ClickHereToGoToApp");
print ' ';
@@ -190,17 +210,14 @@ if (constant('DOL_DATA_ROOT') === null) {
// Try to detect any lockfile in the default documents path
$lockfile = '../../documents/install.lock';
}
-if (@file_exists($lockfile))
-{
- if (!isset($langs) || !is_object($langs))
- {
+if (@file_exists($lockfile)) {
+ if (!isset($langs) || !is_object($langs)) {
$langs = new Translate('..', $conf);
$langs->setDefaultLang('auto');
}
$langs->load("install");
print $langs->trans("YouTryInstallDisabledByFileLock");
- if (!empty($dolibarr_main_url_root))
- {
+ if (!empty($dolibarr_main_url_root)) {
print $langs->trans("ClickOnLinkOrRemoveManualy").' ';
print '';
print $langs->trans("ClickHereToGoToApp");
@@ -215,42 +232,55 @@ if (@file_exists($lockfile))
// Force usage of log file for install and upgrades
$conf->syslog->enabled = 1;
$conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
-if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
-if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
-{
- if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
- elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
- elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
- elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
- elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
+if (!defined('SYSLOG_HANDLERS')) {
+ define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
+}
+if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined
+ if (@is_writable('/tmp')) {
+ define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
+ } elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) {
+ define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
+ } elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) {
+ define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
+ } elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) {
+ define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
+ } elseif (@is_writable('../../')) {
+ define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
+ }
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
-if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
-if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1);
+if (defined('SYSLOG_FILE')) {
+ $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
+}
+if (!defined('SYSLOG_FILE_NO_ERROR')) {
+ define('SYSLOG_FILE_NO_ERROR', 1);
+}
// We init log handler for install
$handlers = array('mod_syslog_file');
-foreach ($handlers as $handler)
-{
+foreach ($handlers as $handler) {
$file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php';
- if (!file_exists($file))
- {
+ if (!file_exists($file)) {
throw new Exception('Missing log handler file '.$handler.'.php');
}
require_once $file;
$loghandlerinstance = new $handler();
- if (!$loghandlerinstance instanceof LogHandlerInterface)
- {
+ if (!$loghandlerinstance instanceof LogHandlerInterface) {
throw new Exception('Log handler does not extend LogHandlerInterface');
}
- if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance;
+ if (empty($conf->loghandlers[$handler])) {
+ $conf->loghandlers[$handler] = $loghandlerinstance;
+ }
}
// Define object $langs
$langs = new Translate('..', $conf);
-if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
-else $langs->setDefaultLang('auto');
+if (GETPOST('lang', 'aZ09')) {
+ $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
+} else {
+ $langs->setDefaultLang('auto');
+}
/**
@@ -271,7 +301,9 @@ function conf($dolibarr_main_document_root)
global $character_set_client;
$return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
- if (!$return) return -1;
+ if (!$return) {
+ return -1;
+ }
$conf = new Conf();
$conf->db->type = trim($dolibarr_main_db_type);
@@ -282,51 +314,73 @@ function conf($dolibarr_main_document_root)
$conf->db->pass = trim($dolibarr_main_db_pass);
// Mysql driver support has been removed in favor of mysqli
- if ($conf->db->type == 'mysql') $conf->db->type = 'mysqli';
- if (empty($character_set_client)) $character_set_client = "UTF-8";
+ if ($conf->db->type == 'mysql') {
+ $conf->db->type = 'mysqli';
+ }
+ if (empty($character_set_client)) {
+ $character_set_client = "UTF-8";
+ }
$conf->file->character_set_client = strtoupper($character_set_client);
- if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : '');
+ if (empty($dolibarr_main_db_character_set)) {
+ $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : '');
+ }
$conf->db->character_set = $dolibarr_main_db_character_set;
- if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : '');
+ if (empty($dolibarr_main_db_collation)) {
+ $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : '');
+ }
$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
- if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
+ if (empty($dolibarr_main_db_encryption)) {
+ $dolibarr_main_db_encryption = 0;
+ }
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
- if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = '';
+ if (empty($dolibarr_main_db_cryptkey)) {
+ $dolibarr_main_db_cryptkey = '';
+ }
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
// Force usage of log file for install and upgrades
$conf->syslog->enabled = 1;
$conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
- if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
- if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
- {
- if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
- elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
- elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
- elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
- elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
+ if (!defined('SYSLOG_HANDLERS')) {
+ define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
+ }
+ if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined
+ if (@is_writable('/tmp')) {
+ define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
+ } elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) {
+ define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
+ } elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) {
+ define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
+ } elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) {
+ define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
+ } elseif (@is_writable('../../')) {
+ define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
+ }
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
- if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
- if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1);
+ if (defined('SYSLOG_FILE')) {
+ $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
+ }
+ if (!defined('SYSLOG_FILE_NO_ERROR')) {
+ define('SYSLOG_FILE_NO_ERROR', 1);
+ }
// We init log handler for install
$handlers = array('mod_syslog_file');
- foreach ($handlers as $handler)
- {
+ foreach ($handlers as $handler) {
$file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php';
- if (!file_exists($file))
- {
+ if (!file_exists($file)) {
throw new Exception('Missing log handler file '.$handler.'.php');
}
require_once $file;
$loghandlerinstance = new $handler();
- if (!$loghandlerinstance instanceof LogHandlerInterface)
- {
+ if (!$loghandlerinstance instanceof LogHandlerInterface) {
throw new Exception('Log handler does not extend LogHandlerInterface');
}
- if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance;
+ if (empty($conf->loghandlers[$handler])) {
+ $conf->loghandlers[$handler] = $loghandlerinstance;
+ }
}
return 1;
@@ -354,8 +408,7 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
$jquerytheme = 'base';
- if ($forcejqueryurl)
- {
+ if ($forcejqueryurl) {
$jQueryCustomPath = $forcejqueryurl;
$jQueryUiCustomPath = $forcejqueryurl;
} else {
@@ -376,14 +429,23 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
print ' '."\n";
print ''."\n";
- if ($jQueryUiCustomPath) print ' '."\n"; // JQuery
- else print ' '."\n"; // JQuery
+ if ($jQueryUiCustomPath) {
+ print ' '."\n"; // JQuery
+ } else {
+ print ' '."\n"; // JQuery
+ }
print ''."\n";
- if ($jQueryCustomPath) print ''."\n";
- else print ''."\n";
- if ($jQueryUiCustomPath) print ''."\n";
- else print ''."\n";
+ if ($jQueryCustomPath) {
+ print ''."\n";
+ } else {
+ print ''."\n";
+ }
+ if ($jQueryUiCustomPath) {
+ print ''."\n";
+ } else {
+ print ''."\n";
+ }
print ''.$langs->trans("DolibarrSetup").' '."\n";
print ''."\n";
@@ -402,7 +464,9 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
print ''."\n";
print '
'."\n";
print '
'."\n";
- if (!$nonext || ($nonext == '2'))
- {
+ if (!$nonext || ($nonext == '2')) {
print '';
- if ($nonext == '2')
- {
+ if ($nonext == '2') {
print '';
print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '');
print ' ';
@@ -442,25 +504,26 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
}
print ' trans("NextStep").' ->"';
- if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"';
+ if ($jscheckfunction) {
+ print ' onClick="return '.$jscheckfunction.'();"';
+ }
print '>
';
- if ($withpleasewait) print ''.$langs->trans("NextStepMightLastALongTime").'
'.$langs->trans("PleaseBePatient").'
';
+ if ($withpleasewait) {
+ print ''.$langs->trans("NextStepMightLastALongTime").'
'.$langs->trans("PleaseBePatient").'
';
+ }
}
- if ($setuplang)
- {
+ if ($setuplang) {
print ' ';
}
print ''."\n";
// If there is some logs in buffer to show
- if (isset($conf->logbuffer) && count($conf->logbuffer))
- {
+ if (isset($conf->logbuffer) && count($conf->logbuffer)) {
print "\n";
print "\n";
$resql = $db->query($buffer, 0, 'dml');
- if ($resql)
- {
+ if ($resql) {
$ok = 1;
$db->free($resql);
} else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
- || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
- {
+ || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') {
//print "Insert line : ".$buffer." \n";
} else {
$ok = 0;
@@ -463,8 +437,7 @@ if ($action == "set")
}
print "