';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
@@ -211,13 +198,11 @@ if ($action == 'edit')
print '';
print ' ';
} else {
- if (!empty($arrayofparameters))
- {
+ if (!empty($arrayofparameters)) {
print '";
print '';
}
@@ -966,8 +1015,7 @@ if ($object->id > 0)
/*
* Latest contracts
*/
- if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
- {
+ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql .= " WHERE c.fk_soc = s.rowid ";
@@ -976,13 +1024,11 @@ if ($object->id > 0)
$sql .= " ORDER BY c.datec DESC";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$contrat = new Contrat($db);
$num = $db->num_rows($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '
';
@@ -995,8 +1041,7 @@ if ($object->id > 0)
}
$i = 0;
- while ($i < $num && $i < $MAXLIST)
- {
+ while ($i < $num && $i < $MAXLIST) {
$objp = $db->fetch_object($resql);
$contrat->id = $objp->id;
@@ -1009,12 +1054,14 @@ if ($object->id > 0)
$late = '';
foreach ($contrat->lines as $line) {
if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
- if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
+ if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) {
+ $late = img_warning($langs->trans("Late"));
+ }
}
}
print '';
- print '';
+ print ' ';
print $contrat->getNomUrl(1, 12);
print $late;
print " \n";
@@ -1030,8 +1077,7 @@ if ($object->id > 0)
}
$db->free($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print "
";
print '
';
}
@@ -1043,8 +1089,7 @@ if ($object->id > 0)
/*
* Latest interventions
*/
- if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
- {
+ if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) {
$sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid";
@@ -1053,13 +1098,11 @@ if ($object->id > 0)
$sql .= " ORDER BY f.tms DESC";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$fichinter_static = new Fichinter($db);
$num = $db->num_rows($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '
';
@@ -1071,15 +1114,17 @@ if ($object->id > 0)
}
$i = 0;
- while ($i < $num && $i < $MAXLIST)
- {
+ while ($i < $num && $i < $MAXLIST) {
$objp = $db->fetch_object($resql);
$fichinter_static->id = $objp->id;
+ $fichinter_static->ref = $objp->ref;
$fichinter_static->statut = $objp->fk_statut;
print '';
- print ''.img_object($langs->trans("ShowPropal"), "propal").' '.$objp->ref.' '."\n";
+ print '';
+ print $fichinter_static->getNomUrl(1);
+ print ' '."\n";
//print ''.dol_print_date($db->jdate($objp->startdate)).' '."\n";
print ''.convertSecondToTime($objp->duration).' '."\n";
print ''.$fichinter_static->getLibStatut(5).' '."\n";
@@ -1089,8 +1134,7 @@ if ($object->id > 0)
}
$db->free($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print "
";
print '
';
}
@@ -1102,8 +1146,7 @@ if ($object->id > 0)
/*
* Latest invoices templates
*/
- if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
- {
+ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
$sql = 'SELECT f.rowid as id, f.titre as ref';
$sql .= ', f.total as total_ht';
$sql .= ', f.tva as total_tva';
@@ -1124,13 +1167,11 @@ if ($object->id > 0)
$sql .= " ORDER BY f.date_last_gen, f.datec DESC";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$invoicetemplate = new FactureRec($db);
$num = $db->num_rows($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '
';
@@ -1141,8 +1182,7 @@ if ($object->id > 0)
}
$i = 0;
- while ($i < $num && $i < $MAXLIST)
- {
+ while ($i < $num && $i < $MAXLIST) {
$objp = $db->fetch_object($resql);
$invoicetemplate->id = $objp->id;
@@ -1160,12 +1200,10 @@ if ($object->id > 0)
print '';
print $invoicetemplate->getNomUrl(1);
print ' ';
- if ($objp->frequency && $objp->date_last_gen > 0)
- {
+ if ($objp->frequency && $objp->date_last_gen > 0) {
print ''.dol_print_date($db->jdate($objp->date_last_gen), 'day').' ';
} else {
- if ($objp->dc > 0)
- {
+ if ($objp->dc > 0) {
print ''.dol_print_date($db->jdate($objp->dc), 'day').' ';
} else {
print '!!! ';
@@ -1175,8 +1213,7 @@ if ($object->id > 0)
print price($objp->total_ht);
print '';
- if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES))
- {
+ if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
print '';
print price($objp->total_ttc);
print ' ';
@@ -1191,8 +1228,7 @@ if ($object->id > 0)
}
$db->free($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print "
";
print '
';
}
@@ -1204,13 +1240,12 @@ if ($object->id > 0)
/*
* Latest invoices
*/
- if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
- {
+ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
$sql = 'SELECT f.rowid as facid, f.ref, f.type';
$sql .= ', f.total as total_ht';
$sql .= ', f.tva as total_tva';
$sql .= ', f.total_ttc';
- $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut';
+ $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status';
$sql .= ', s.nom, s.rowid as socid';
$sql .= ', SUM(pf.amount) as am';
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
@@ -1223,13 +1258,11 @@ if ($object->id > 0)
$sql .= " ORDER BY f.datef DESC, f.datec DESC";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$facturestatic = new Facture($db);
$num = $db->num_rows($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '
';
@@ -1241,8 +1274,7 @@ if ($object->id > 0)
}
$i = 0;
- while ($i < $num && $i < $MAXLIST)
- {
+ while ($i < $num && $i < $MAXLIST) {
$objp = $db->fetch_object($resql);
$facturestatic->id = $objp->facid;
@@ -1251,13 +1283,13 @@ if ($object->id > 0)
$facturestatic->total_ht = $objp->total_ht;
$facturestatic->total_tva = $objp->total_tva;
$facturestatic->total_ttc = $objp->total_ttc;
+ $facturestatic->statut = $objp->status;
print '';
- print '';
+ print ' ';
print $facturestatic->getNomUrl(1);
print ' ';
- if ($objp->df > 0)
- {
+ if ($objp->df > 0) {
print ''.dol_print_date($db->jdate($objp->df), 'day').' ';
} else {
print '!!! ';
@@ -1266,21 +1298,19 @@ if ($object->id > 0)
print price($objp->total_ht);
print '';
- if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES))
- {
+ if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
print '';
print price($objp->total_ttc);
print ' ';
}
- print ''.($facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am)).' ';
+ print ''.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).' ';
print " \n";
$i++;
}
$db->free($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print "
";
print '
';
}
@@ -1292,8 +1322,11 @@ if ($object->id > 0)
// Allow external modules to add their own shortlist of recent objects
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- else print $hookmanager->resPrint;
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ } else {
+ print $hookmanager->resPrint;
+ }
print '';
print '
';
@@ -1310,73 +1343,68 @@ if ($object->id > 0)
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
- if (empty($reshook))
- {
- if ($object->status != 1)
- {
+ if (empty($reshook)) {
+ if ($object->status != 1) {
print '';
}
- if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1)
- {
+ if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) {
$langs->load("propal");
print '';
}
- if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1)
- {
+ if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) {
$langs->load("orders");
print '';
}
- if ($user->rights->contrat->creer && $object->status == 1)
- {
+ if ($user->rights->contrat->creer && $object->status == 1) {
$langs->load("contracts");
print '';
}
- if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1)
- {
+ if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) {
$langs->load("fichinter");
print '';
}
// Add invoice
- if ($user->socid == 0)
- {
- if (!empty($conf->deplacement->enabled) && $object->status == 1)
- {
+ if ($user->socid == 0) {
+ if (!empty($conf->deplacement->enabled) && $object->status == 1) {
$langs->load("trips");
print '';
}
- if (!empty($conf->facture->enabled) && $object->status == 1)
- {
- if (empty($user->rights->facture->creer))
- {
+ if (!empty($conf->facture->enabled) && $object->status == 1) {
+ if (empty($user->rights->facture->creer)) {
print '';
} else {
$langs->loadLangs(array("orders", "bills"));
- if (!empty($conf->commande->enabled))
- {
+ if (!empty($conf->commande->enabled)) {
if ($object->client != 0 && $object->client != 2) {
- if (!empty($orders2invoice) && $orders2invoice > 0) print '';
- else print '';
- } else print '';
+ if (!empty($orders2invoice) && $orders2invoice > 0) {
+ print '';
+ } else {
+ print '';
+ }
+ } else {
+ print '';
+ }
}
- if ($object->client != 0 && $object->client != 2) print '';
- else print '';
+ if ($object->client != 0 && $object->client != 2) {
+ print '';
+ } else {
+ print '';
+ }
}
}
}
// Add action
- if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1)
- {
- if ($user->rights->agenda->myactions->create)
- {
+ if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
+ if ($user->rights->agenda->myactions->create) {
print '';
} else {
print '';
@@ -1386,14 +1414,12 @@ if ($object->id > 0)
print '';
- if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD))
- {
+ if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) {
// List of contacts
show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
}
- if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB))
- {
+ if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
// List of todo actions
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index 46636f93812..899c9275d31 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -29,7 +29,9 @@
require '../main.inc.php';
-if (!$user->rights->societe->lire) accessforbidden();
+if (!$user->rights->societe->lire) {
+ accessforbidden();
+}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
@@ -73,10 +75,18 @@ $now = dol_now();
$form = new Form($db);
$formfile = new FormFile($db);
$companystatic = new Societe($db);
-if (!empty($conf->propal->enabled)) $propalstatic = new Propal($db);
-if (!empty($conf->supplier_proposal->enabled)) $supplierproposalstatic = new SupplierProposal($db);
-if (!empty($conf->commande->enabled)) $orderstatic = new Commande($db);
-if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) $supplierorderstatic = new CommandeFournisseur($db);
+if (!empty($conf->propal->enabled)) {
+ $propalstatic = new Propal($db);
+}
+if (!empty($conf->supplier_proposal->enabled)) {
+ $supplierproposalstatic = new SupplierProposal($db);
+}
+if (!empty($conf->commande->enabled)) {
+ $orderstatic = new Commande($db);
+}
+if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) {
+ $supplierorderstatic = new CommandeFournisseur($db);
+}
llxHeader("", $langs->trans("CommercialArea"));
@@ -118,10 +128,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) {
print '';
$i = 0;
foreach ($listofsearchfields as $key => $value) {
- if ($i == 0) print ''.$langs->trans("Search").' ';
+ if ($i == 0) {
+ print ''.$langs->trans("Search").' ';
+ }
print '';
print ''.$langs->trans($value["text"]).' ';
- if ($i == 0) print ' ';
+ if ($i == 0) {
+ print ' ';
+ }
print ' ';
$i++;
}
@@ -137,7 +151,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) {
* Draft customer proposals
*/
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
- $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status";
+ $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -145,12 +159,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$sql .= ", s.canvas";
$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.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT;
- 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;
+ }
$resql = $db->query($sql);
if ($resql) {
@@ -228,7 +248,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
* Draft supplier proposals
*/
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
- $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status";
+ $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -236,12 +256,18 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal 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.entity IN (".getEntity($supplierproposalstatic->element).")";
$sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
$sql .= " AND p.fk_soc = s.rowid";
- 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;
+ }
$resql = $db->query($sql);
if ($resql) {
@@ -318,7 +344,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
* Draft customer orders
*/
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
- $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, c.fk_statut as status";
+ $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -326,12 +352,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
$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 c.entity IN (".getEntity($orderstatic->element).")";
$sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT;
$sql .= " AND c.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND c.fk_soc = ".$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 c.fk_soc = ".$socid;
+ }
$resql = $db->query($sql);
if ($resql) {
@@ -417,12 +449,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
$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 cf.entity IN (".getEntity($supplierorderstatic->element).")";
$sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
$sql .= " AND cf.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND cf.fk_soc = ".$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 cf.fk_soc = ".$socid;
+ }
$resql = $db->query($sql);
if ($resql) {
@@ -509,11 +547,17 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
$sql .= ", s.canvas";
$sql .= ", s.datec, s.tms";
$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.entity IN (".getEntity($companystatic->element).")";
$sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
- 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 s.tms DESC";
$sql .= $db->plimit($max, 0);
@@ -521,11 +565,9 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
if ($resql) {
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$header = "BoxTitleLastCustomersOrProspects";
- }
- elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+ } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$header = "BoxTitleLastModifiedProspects";
- }
- else {
+ } else {
$header = "BoxTitleLastModifiedCustomers";
}
@@ -559,12 +601,10 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
$obj = $companystatic;
$s = '';
- if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
- {
+ if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).' ';
}
- if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
- {
+ if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$s .= ''.dol_substr($langs->trans("Customer"), 0, 1).' ';
}
/*
@@ -603,11 +643,17 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$sql .= ", s.canvas";
$sql .= ", s.datec as dc, s.tms as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- 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 s.entity IN (".getEntity($companystatic->element).")";
$sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
- if (!$user->rights->societe->client->voir && !$user->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 && !$user->socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
+ if ($socid) {
+ $sql .= " AND s.rowid = ".$socid;
+ }
$sql .= " ORDER BY s.datec DESC";
$sql .= $db->plimit($max, 0);
@@ -649,8 +695,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
{
$s .= ''.dol_substr($langs->trans("Customer"), 0, 1).' ';
}*/
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) {
$s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).' ';
}
print $s;
@@ -704,12 +749,18 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."product as p";
- 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 c.entity IN (".getEntity($staticcontrat->element).")";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.fk_product = p.rowid";
- 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 c.tms DESC";
$sql .= $db->plimit($max + 1, 0);
@@ -765,7 +816,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T
* Opened (validated) proposals
*/
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
- $sql = "SELECT p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
+ $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -773,12 +824,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$sql .= ", s.canvas";
$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.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
- 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";
$resql = $db->query($sql);
@@ -875,7 +932,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
* Opened (validated) order
*/
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
- $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
+ $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -883,12 +940,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
$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 c.entity IN (".getEntity($orderstatic->element).")";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
- 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 c.rowid DESC";
$resql = $db->query($sql);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index a115d8bca5e..061d06092c3 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -13,7 +13,7 @@
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2015 Marcos García
* Copyright (C) 2018 Nicolas ZABOURI
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018-2021 Frédéric France
* Copyright (C) 2018 Ferran Marcet
*
* This program is free software; you can redistribute it and/or modify
@@ -285,10 +285,10 @@ class Propal extends CommonObject
'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),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
- 'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
+ 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', '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' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1),
+ 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1),
'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Currency', 'enabled'=>1, 'visible'=>-1, 'position'=>155),
'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>160),
@@ -1038,8 +1038,8 @@ class Propal extends CommonObject
$sql .= ", remise";
$sql .= ", remise_percent";
$sql .= ", remise_absolue";
- $sql .= ", tva";
- $sql .= ", total";
+ $sql .= ", total_tva";
+ $sql .= ", total_ttc";
$sql .= ", datep";
$sql .= ", datec";
$sql .= ", ref";
@@ -1425,7 +1425,7 @@ class Propal extends CommonObject
public function fetch($rowid, $ref = '', $ref_ext = '')
{
$sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc";
- $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht";
+ $sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht";
$sql .= ", p.datec";
$sql .= ", p.date_valid as datev";
$sql .= ", p.datep as dp";
@@ -1463,14 +1463,14 @@ class Propal extends CommonObject
if ($ref) {
$sql .= " WHERE p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid
$sql .= " AND p.ref='".$this->db->escape($ref)."'";
- } else $sql .= " WHERE p.rowid=".$rowid;
+ } else {
+ $sql .= " WHERE p.rowid=".$rowid;
+ }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -1481,12 +1481,12 @@ class Propal extends CommonObject
$this->remise = $obj->remise;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
- $this->total = $obj->total; // TODO deprecated
+ $this->total = $obj->total_ttc; // TODO deprecated
+ $this->total_ttc = $obj->total_ttc;
$this->total_ht = $obj->total_ht;
- $this->total_tva = $obj->tva;
+ $this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
- $this->total_ttc = $obj->total;
$this->socid = $obj->fk_soc;
$this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty
@@ -1537,8 +1537,8 @@ class Propal extends CommonObject
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->user_author_id = $obj->fk_user_author;
- $this->user_valid_id = $obj->fk_user_valid;
- $this->user_close_id = $obj->fk_user_cloture;
+ $this->user_valid_id = $obj->fk_user_valid;
+ $this->user_close_id = $obj->fk_user_cloture;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
@@ -1550,11 +1550,10 @@ class Propal extends CommonObject
$this->multicurrency_code = $obj->multicurrency_code;
$this->multicurrency_tx = $obj->multicurrency_tx;
$this->multicurrency_total_ht = $obj->multicurrency_total_ht;
- $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
- $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
+ $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
+ $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
- if ($obj->fk_statut == self::STATUS_DRAFT)
- {
+ if ($obj->fk_statut == self::STATUS_DRAFT) {
$this->brouillon = 1;
}
@@ -1568,8 +1567,7 @@ class Propal extends CommonObject
// Lines
$result = $this->fetch_lines();
- if ($result < 0)
- {
+ if ($result < 0) {
return -3;
}
@@ -1618,11 +1616,11 @@ class Propal extends CommonObject
$sql .= " datep=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').",";
if (!empty($this->fin_validite)) $sql .= " fin_validite=".(strval($this->fin_validite) != '' ? "'".$this->db->idate($this->fin_validite)."'" : '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").",";
- $sql .= " total=".(isset($this->total_ttc) ? $this->total_ttc : "null").",";
+ $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").",";
$sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").",";
$sql .= " fk_user_author=".(isset($this->user_author_id) ? $this->user_author_id : "null").",";
$sql .= " fk_user_valid=".(isset($this->user_valid) ? $this->user_valid : "null").",";
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index fbe7fdbec5c..530f7392f54 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -80,7 +80,7 @@ if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
- include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
}
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index b51f138b0e5..b02ac911bad 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -29,8 +29,7 @@ require '../../main.inc.php';
// Security check
$socid = GETPOST('socid', 'int');
-if (isset($user->socid) && $user->socid > 0)
-{
+if (isset($user->socid) && $user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@@ -66,8 +65,7 @@ print '';
print '
';
// This is useless due to the global search combo
-if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))
-{
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) {
print '
';
print '';
print '
';
@@ -97,16 +95,21 @@ $listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::ST
$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
-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.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND p.fk_soc = s.rowid";
-if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid;
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+if ($user->socid) {
+ $sql .= ' AND p.fk_soc = '.$user->socid;
+}
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
$sql .= " AND p.fk_statut IN (".implode(" ,", $listofstatus).")";
$sql .= " GROUP BY p.fk_statut";
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
@@ -115,11 +118,9 @@ if ($resql)
$colorseries = array();
$vals = array();
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
- if ($obj)
- {
+ if ($obj) {
$vals[$obj->status] = $obj->nb;
$totalinprocess += $obj->nb;
@@ -140,11 +141,21 @@ if ($resql)
foreach ($listofstatus as $status) {
$dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
- if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
- if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
- if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4;
- if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9;
- if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6;
+ if ($status == Propal::STATUS_DRAFT) {
+ $colorseries[$status] = '-'.$badgeStatus0;
+ }
+ if ($status == Propal::STATUS_VALIDATED) {
+ $colorseries[$status] = $badgeStatus1;
+ }
+ if ($status == Propal::STATUS_SIGNED) {
+ $colorseries[$status] = $badgeStatus4;
+ }
+ if ($status == Propal::STATUS_NOTSIGNED) {
+ $colorseries[$status] = $badgeStatus9;
+ }
+ if ($status == Propal::STATUS_BILLED) {
+ $colorseries[$status] = $badgeStatus6;
+ }
if (empty($conf->use_javascript_ajax)) {
print '
';
@@ -198,16 +209,22 @@ if ($resql)
* Draft proposals
*/
if (!empty($conf->propal->enabled)) {
- $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc";
+ $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc";
$sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta";
$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.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.fk_statut =".Propal::STATUS_DRAFT;
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- if ($socid) $sql .= " AND p.fk_soc = ".$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 p.fk_soc = ".$socid;
+ }
$resql = $db->query($sql);
if ($resql) {
@@ -271,12 +288,18 @@ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, date_cloture as datec";
$sql .= ", s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
$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 c.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND c.fk_soc = s.rowid";
//$sql.= " AND c.fk_statut > 2";
-if ($socid) $sql .= " AND c.fk_soc = ".$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 c.fk_soc = ".$socid;
+}
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
$sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0);
@@ -336,15 +359,21 @@ if ($resql) {
*/
if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client";
- $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
+ $sql .= ", p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
- 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.entity IN (".getEntity($propalstatic->element).")";
$sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
- 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";
$resql = $db->query($sql);
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index cc296e4472a..ef78cd32c9d 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -116,6 +116,11 @@ $pagenext = $page + 1;
if (!$sortfield) $sortfield = 'p.ref';
if (!$sortorder) $sortorder = 'DESC';
+$permissiontoread = $user->rights->propal->lire;
+$permissiontoadd = $user->rights->propal->write;
+$permissiontodelete = $user->rights->propal->supprimer;
+$permissiontoclose = $user->rights->propal->cloturer;
+
// Security check
$module = 'propal';
$dbtable = '';
@@ -176,14 +181,14 @@ $arrayfields = array(
'p.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0),
'p.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0),
'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
- 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
+ 'p.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0),
'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
- 'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
+ 'p.multicurrency_total_tva'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
@@ -260,13 +265,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
}
if ($object_statut != '') $search_status = $object_statut;
+
if (empty($reshook))
{
$objectclass = 'Propal';
$objectlabel = 'Proposals';
- $permissiontoread = $user->rights->propal->lire;
- $permissiontodelete = $user->rights->propal->supprimer;
- $permissiontoclose = $user->rights->propal->cloturer;
$uploaddir = $conf->propal->multidir_output[$conf->entity];
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -388,8 +391,8 @@ $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.tow
$sql .= " typent.code as typent_code,";
$sql .= " ava.rowid as availability,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
-$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
-$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva as multicurrency_total_vat, p.multicurrency_total_ttc,';
+$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
+$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,';
$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql .= ' p.note_public, p.note_private,';
$sql .= ' p.fk_cond_reglement,p.fk_mode_reglement,p.fk_shipping_method,';
@@ -446,8 +449,8 @@ if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_societe_alias);
if ($search_login) $sql .= natural_search("u.login", $search_login);
if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
-if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1);
-if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1);
+if ($search_montant_vat != '') $sql .= natural_search("p.total_tva", $search_montant_vat, 1);
+if ($search_montant_ttc != '') $sql .= natural_search("p.total_ttc", $search_montant_ttc, 1);
if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
@@ -831,7 +834,7 @@ if ($resql)
print ' ';
print '';
}
- if (!empty($arrayfields['p.total_vat']['checked']))
+ if (!empty($arrayfields['p.total_tva']['checked']))
{
// Amount
print '';
@@ -878,7 +881,7 @@ if ($resql)
print ' ';
print ' ';
}
- if (!empty($arrayfields['p.multicurrency_total_vat']['checked']))
+ if (!empty($arrayfields['p.multicurrency_total_tva']['checked']))
{
// Amount
print '';
@@ -989,14 +992,14 @@ if ($resql)
if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
- if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder);
+ if (!empty($arrayfields['p.total_tva']['checked'])) print_liste_field_titre($arrayfields['p.total_tva']['label'], $_SERVER["PHP_SELF"], 'p.total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
- if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
+ if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
@@ -1264,12 +1267,12 @@ if ($resql)
$totalarray['val']['p.total_ht'] += $obj->total_ht;
}
// Amount VAT
- if (!empty($arrayfields['p.total_vat']['checked']))
+ if (!empty($arrayfields['p.total_tva']['checked']))
{
- print ' '.price($obj->total_vat)." \n";
+ print ''.price($obj->total_tva)." \n";
if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_vat';
- $totalarray['val']['p.total_vat'] += $obj->total_vat;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva';
+ $totalarray['val']['p.total_tva'] += $obj->total_tva;
}
// Amount TTC
if (!empty($arrayfields['p.total_ttc']['checked']))
@@ -1317,9 +1320,9 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Amount VAT
- if (!empty($arrayfields['p.multicurrency_total_vat']['checked']))
+ if (!empty($arrayfields['p.multicurrency_total_tva']['checked']))
{
- print ''.price($obj->multicurrency_total_vat)." \n";
+ print ''.price($obj->multicurrency_total_tva)." \n";
if (!$i) $totalarray['nbfield']++;
}
// Amount TTC
@@ -1492,7 +1495,7 @@ if ($resql)
print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
} else {
- dol_print_error($db);
+ dol_print_error($db);
}
// End of page
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 06be1179fb1..8937e562227 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -61,7 +61,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
* View
*/
-llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
+$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
+
+llxHeader('', $langs->trans('Proposal'), $help_url);
$form = new Form($db);
diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php
index 7ae61362f09..a9681f199da 100644
--- a/htdocs/comm/prospect/index.php
+++ b/htdocs/comm/prospect/index.php
@@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
$langs->load("propal");
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$socid = $user->socid;
}
@@ -53,8 +52,7 @@ print load_fiche_titre($langs->trans("ProspectionArea"));
print '';
-if (!empty($conf->propal->enabled))
-{
+if (!empty($conf->propal->enabled)) {
$var = false;
print '
';
print ' ';
@@ -75,26 +73,27 @@ if (!empty($conf->propal->enabled))
$sql = "SELECT count(*) as cc, st.libelle, st.picto, st.id";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
-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 = st.id";
$sql .= " AND s.client IN (2, 3)";
$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 .= " GROUP BY st.id";
$sql .= " ORDER BY st.id";
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '';
print ''.$langs->trans("ProspectsByStatus").' ';
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '';
@@ -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/card.php b/htdocs/commande/card.php
index f7cc3e7af47..f0c05ec7986 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -238,7 +238,7 @@ if (empty($reshook))
elseif ($action == 'add' && $usercancreate)
{
$datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
- $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
+ $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
$selectedLines = GETPOST('toselect', 'array');
if ($datecommande == '') {
@@ -271,8 +271,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int');
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
- $object->date_livraison = $datelivraison; // deprecated
- $object->delivery_date = $datelivraison;
+ $object->date_livraison = $date_delivery; // deprecated
+ $object->delivery_date = $date_delivery;
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address');
@@ -1628,7 +1628,7 @@ if ($action == 'create' && $usercancreate)
print ' '.$langs->trans("DateDeliveryPlanned").' ';
print '';
$date_delivery = ($date_delivery ? $date_delivery : $object->date_delivery);
- print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1);
+ print $form->selectDate($date_delivery ? $date_delivery : -1, 'liv_', 1, 1, 1);
print " \n";
print ' ';
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 4c2f643df1c..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';
@@ -3283,6 +3283,7 @@ class Commande extends CommonOrder
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
if (isset($this->import_key)) $this->import_key = trim($this->import_key);
+ $delivery_date = empty($this->delivery_date) ? $this->date_livraison : $this->delivery_date;
// Check parameters
// Put here code to add control on parameters values
@@ -3296,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").",";
@@ -3307,6 +3308,8 @@ class Commande extends CommonOrder
$sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").",";
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").",";
$sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").",";
+ $sql .= " date_livraison=".(strval($this->delivery_date) != '' ? "'".$this->db->idate($this->delivery_date)."'" : 'null').",";
+ $sql .= " fk_shipping_method=".(isset($this->shipping_method_id) ? $this->shipping_method_id : "null").",";
$sql .= " fk_account=".($this->fk_account > 0 ? $this->fk_account : "null").",";
$sql .= " fk_input_reason=".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null").",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 7df7dbea130..add4244d7dc 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -3,6 +3,7 @@
* Copyright (C) 2005-2011 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011-2015 Philippe Grand
+ * Copyright (C) 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
@@ -128,23 +129,17 @@ $userstatic = new User($db);
/* */
/* *************************************************************************** */
-if ($id > 0 || !empty($ref))
-{
- $langs->trans("OrderCard");
-
- if ($object->fetch($id, $ref) > 0)
- {
+if ($id > 0 || !empty($ref)) {
+ if ($object->fetch($id, $ref) > 0) {
$object->fetch_thirdparty();
$head = commande_prepare_head($object);
print dol_get_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order');
-
// Order card
$linkback = ''.$langs->trans("BackToList").' ';
-
$morehtmlref = '';
// Ref customer
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index f95f61b6025..f51d8635787 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -80,7 +80,7 @@ if ($object->fetch($id))
$upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
}
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
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/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php
index fd7c6b1d292..b1c5c937f76 100644
--- a/htdocs/compta/bank/account_statement_document.php
+++ b/htdocs/compta/bank/account_statement_document.php
@@ -133,7 +133,7 @@ if (!empty($numref))
$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref);
}
$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$numref;
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 37c125668ec..3f29ab4d022 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -91,7 +91,7 @@ $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), G
$search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int'));
$search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int'));
$search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int'));
-$search_thirdparty = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha');
+$search_thirdparty_user = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha');
$search_req_nb = GETPOST("req_nb", 'alpha');
$search_num_releve = GETPOST("search_num_releve", 'alpha');
$search_conciliated = GETPOST("search_conciliated", 'int');
@@ -142,16 +142,16 @@ $extrafields->fetch_name_optionals_label('banktransaction');
$search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_');
$arrayfields = array(
- 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
- 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
- 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1),
- 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1),
- 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
- 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1),
- 'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500),
- 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000),
- 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
- 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
+ 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
+ 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
+ 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1),
+ 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1),
+ 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
+ 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1),
+ 'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>500),
+ 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000),
+ 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
+ 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000),
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001),
'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010),
@@ -191,7 +191,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = "";
$search_req_nb = '';
$search_description = '';
- $search_thirdparty = '';
+ $search_thirdparty_user = '';
$search_num_releve = '';
$search_conciliated = '';
$thirdparty = '';
@@ -255,7 +255,7 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', '
$param .= '&search_conciliated='.urlencode($search_conciliated);
if ($page) $param .= '&page='.urlencode($page);
if ($offset) $param .= '&offset='.urlencode($offset);
- if ($search_thirdparty) $param .= '&search_thirdparty='.urlencode($search_thirdparty);
+ if ($search_thirdparty_user) $param .= '&search_thirdparty='.urlencode($search_thirdparty_user);
if ($search_num_releve) $param .= '&search_num_releve='.urlencode($search_num_releve);
if ($search_description) $param .= '&search_description='.urlencode($search_description);
if ($search_start_dt) $param .= '&search_start_dt='.urlencode($search_start_dt);
@@ -359,6 +359,7 @@ $formaccounting = new FormAccounting($db);
$companystatic = new Societe($db);
$bankaccountstatic = new Account($db);
+$userstatic= new User($db);
$banktransferstatic = new BonPrelevement($db);
$societestatic = new Societe($db);
@@ -390,7 +391,7 @@ if (!empty($ref)) $param .= '&ref='.urlencode($ref);
if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref);
if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description);
if (!empty($search_type)) $param .= '&type='.urlencode($search_type);
-if (!empty($search_thirdparty)) $param .= '&search_thirdparty='.urlencode($search_thirdparty);
+if (!empty($search_thirdparty_user)) $param .= '&search_thirdparty='.urlencode($search_thirdparty_user);
if (!empty($search_debit)) $param .= '&search_debit='.urlencode($search_debit);
if (!empty($search_credit)) $param .= '&search_credit='.urlencode($search_credit);
if (!empty($search_account)) $param .= '&search_account='.urlencode($search_account);
@@ -481,9 +482,7 @@ if ($id > 0 || !empty($ref))
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
$sql .= " b.fk_account, b.fk_type,";
-$sql .= " ba.rowid as bankid, ba.ref as bankref,";
-$sql .= " bu.url_id,";
-$sql .= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
+$sql .= " ba.rowid as bankid, ba.ref as bankref";
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
@@ -497,8 +496,6 @@ if ($search_bid > 0) $sql .= MAIN_DB_PREFIX."bank_class as l,";
$sql .= " ".MAIN_DB_PREFIX."bank_account as ba,";
$sql .= " ".MAIN_DB_PREFIX."bank as b";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)";
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'";
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
if ($search_account > 0) $sql .= " AND b.fk_account = ".$search_account;
@@ -512,7 +509,20 @@ if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1);
if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb);
if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve);
if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".urlencode($search_conciliated);
-if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty);
+if ($search_thirdparty_user) {
+ $sql.= " AND (b.rowid IN ";
+ $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
+ $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
+ $sql.= " JOIN ".MAIN_DB_PREFIX."user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)";
+ $sql.= " WHERE ". natural_search(array("subUser.firstname", "subUser.lastname"), $search_thirdparty_user, '', 1)."))";
+
+ $sql.= " OR b.rowid IN ";
+ $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
+ $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank";
+ $sql.= " JOIN ".MAIN_DB_PREFIX."societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)";
+ $sql.= " WHERE ". natural_search(array("subSoc.nom"), $search_thirdparty_user, '', 1);
+ $sql.= ")";
+}
if ($search_description)
{
$search_description_to_use = $search_description;
@@ -587,7 +597,7 @@ if (!empty($search_description)) $mode_balance_ok = false;
if (!empty($search_type)) $mode_balance_ok = false;
if (!empty($search_debit)) $mode_balance_ok = false;
if (!empty($search_credit)) $mode_balance_ok = false;
-if (!empty($search_thirdparty)) $mode_balance_ok = false;
+if (!empty($search_thirdparty_user)) $mode_balance_ok = false;
if ($search_conciliated != '' && $search_conciliated != '-1') $mode_balance_ok = false;
if (!empty($search_num_releve)) $mode_balance_ok = false;
@@ -1012,6 +1022,8 @@ if ($resql)
while ($i < min($num, $limit))
{
$objp = $db->fetch_object($resql);
+ $links = $bankaccountstatic->get_url($objp->rowid);
+
// If we are in a situation where we need/can show balance, we calculate the start of balance
if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0'))
{
@@ -1202,7 +1214,6 @@ if ($resql)
//print " ";
// Add links after description
- $links = $bankaccountstatic->get_url($objp->rowid);
$cachebankaccount = array();
foreach ($links as $key=>$val)
{
@@ -1369,27 +1380,42 @@ if ($resql)
}
// Third party
- if (!empty($arrayfields['bu.label']['checked']))
- {
+ if (!empty($arrayfields['bu.label']['checked']))
+ {
print '
';
- if ($objp->url_id)
- {
- $companystatic->id = $objp->url_id;
- $companystatic->name = $objp->nom;
- $companystatic->name_alias = $objp->name_alias;
- $companystatic->client = $objp->client;
- $companystatic->email = $objp->email;
- $companystatic->fournisseur = $objp->fournisseur;
- $companystatic->code_client = $objp->code_client;
- $companystatic->code_fournisseur = $objp->code_fournisseur;
- $companystatic->code_compta = $objp->code_compta;
- $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
+
+ $companylinked_id = 0;
+ $userlinked_id = 0;
+
+ //payment line type to define user display and user or company linked
+ foreach ($links as $key=>$value){
+ if ($links[$key]['type'] == 'payment_sc') $type_link = 'payment_sc';
+ if ($links[$key]['type'] == 'payment_salary') $type_link = 'payment_salary';
+
+ if ($links[$key]['type'] == 'company') {
+ $companylinked_id = $links[$key]['url_id'];
+ }
+ if ($links[$key]['type'] == 'user') {
+ $userlinked_id = $links[$key]['url_id'];
+ }
+ }
+
+ if ($companylinked_id) {
+ // TODO Add a cache of loaded companies here
+ $companystatic->fetch($companylinked_id);
print $companystatic->getNomUrl(1);
+ } elseif ($userlinked_id &&
+ (($type_link == 'payment_salary' && !empty($user->rights->salaries->read))
+ || ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))){
+ // TODO Add a cache of loaded users here
+ $userstatic->fetch($userlinked_id);
+ print $userstatic->getNomUrl(1);
} else {
print ' ';
}
+
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) $totalarray['nbfield']++;
}
// Bank account
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index c67c0496727..cb2e4915323 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -77,7 +77,7 @@ if ($object->id > 0)
$upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref);
}
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index 1184da6d7ac..45d8c535f2d 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -585,7 +585,7 @@ foreach ($accounts as $key=>$type)
if (!empty($arrayfields['balance']['checked']))
{
print '
';
- print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).' ';
+ print ''.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).' ';
print ' ';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance';
diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php
index 14187bf51e3..1cd8d285eeb 100644
--- a/htdocs/compta/bank/various_payment/document.php
+++ b/htdocs/compta/bank/various_payment/document.php
@@ -66,7 +66,7 @@ $modulepart = 'banque';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index 0d91eb38e7d..3990c968806 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -58,6 +58,10 @@ $search_accountancy_account = GETPOST("search_accountancy_account");
if ($search_accountancy_account == - 1) $search_accountancy_account = '';
$search_accountancy_subledger = GETPOST("search_accountancy_subledger");
if ($search_accountancy_subledger == - 1) $search_accountancy_subledger = '';
+if (empty($search_datep_start)) $search_datep_start = GETPOST("search_datep_start", 'int');
+if (empty($search_datep_end)) $search_datep_end = GETPOST("search_datep_end", 'int');
+if (empty($search_datev_start)) $search_datev_start = GETPOST("search_datev_start", 'int');
+if (empty($search_datev_end)) $search_datev_end = GETPOST("search_datev_end", 'int');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
@@ -247,7 +251,7 @@ if ($result)
if ($typeid > 0) $param .= '&typeid='.urlencode($typeid);
if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb);
if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred);
- if ($search_bank_account > 0) $param .= '&search_amount='.urlencode($search_bank_account);
+ if ($search_bank_account > 0) $param .= '&search_account='.urlencode($search_bank_account);
if ($search_accountancy_account > 0) $param .= '&search_accountancy_account='.urlencode($search_accountancy_account);
if ($search_accountancy_subledger > 0) $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger);
diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php
index 04cdea52f7f..32a7e9bede5 100644
--- a/htdocs/compta/cashcontrol/report.php
+++ b/htdocs/compta/cashcontrol/report.php
@@ -73,9 +73,10 @@ $terminalid = $cashcontrol->posnumber;
* View
*/
+$title = $langs->trans("CashControl");
$param = '';
-llxHeader('', $langs->trans("CashControl"), '', '', 0, 0, array(), array(), $param);
+llxHeader('', $title, '', '', 0, 0, array(), array(), $param);
/*$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
$sql.= " b.fk_account, b.fk_type,";
@@ -110,7 +111,7 @@ $sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id =
$sql .= " AND f.module_source = '".$db->escape($posmodule)."'";
$sql .= " AND f.pos_source = '".$db->escape($terminalid)."'";
$sql .= " AND f.paye = 1";
-$sql .= " AND p.entity IN (".getEntity('facture').")";
+$sql .= " AND p.entity = ".$conf->entity; // Never share entities for features related to accountancy
/*if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'";
elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'";
elseif ($key == 'card') $sql.=" AND cp.code = 'CB'";
diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php
index 86d0dd383f1..c1e432f4b1a 100644
--- a/htdocs/compta/deplacement/document.php
+++ b/htdocs/compta/deplacement/document.php
@@ -71,7 +71,7 @@ $modulepart = 'trip';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index a1471f48482..b17cb5b6049 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -289,11 +289,11 @@ if (empty($reshook))
elseif ($action == 'setref' && $user->rights->facture->creer)
{
//var_dump(GETPOST('ref', 'alpha'));exit;
- $result = $object->setValueFrom('title', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY');
+ $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY');
if ($result > 0)
{
- $object->titre = GETPOST('ref', 'alpha'); // deprecated
- $object->title = GETPOST('ref', 'alpha');
+ $object->titre = $ref; // deprecated
+ $object->title = $ref;
$object->ref = $object->title;
} else {
$error++;
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index cdb729991da..4571bf423e7 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -50,8 +50,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-if (!empty($conf->commande->enabled))
+if (!empty($conf->commande->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+}
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
@@ -154,12 +155,9 @@ $parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-if (empty($reshook))
-{
- if ($cancel)
- {
- if (!empty($backtopage))
- {
+if (empty($reshook)) {
+ if ($cancel) {
+ if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@@ -173,8 +171,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object
- if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
- {
+ if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) {
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid.
$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
@@ -230,8 +227,7 @@ if (empty($reshook))
}
}
} // Delete line
- elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
- {
+ elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) {
$object->fetch($id);
$object->fetch_thirdparty();
@@ -262,14 +258,12 @@ if (empty($reshook))
$action = '';
}
} // Delete link of credit note to invoice
- elseif ($action == 'unlinkdiscount' && $usercancreate)
- {
+ elseif ($action == 'unlinkdiscount' && $usercancreate) {
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(GETPOST("discountid"));
$discount->unlink_invoice();
} // Validation
- elseif ($action == 'valid' && $usercancreate)
- {
+ elseif ($action == 'valid' && $usercancreate) {
$object->fetch($id);
// On verifie signe facture
@@ -306,13 +300,11 @@ if (empty($reshook))
}
//var_dump($array_of_total_ht_per_vat_rate);exit;
- foreach ($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue)
- {
+ foreach ($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue) {
$tmp_total_ht = $array_of_total_ht_per_vat_rate[$vatrate];
$tmp_total_ht_devise = $array_of_total_ht_devise_per_vat_rate[$vatrate];
- if (($tmp_total_ht < 0 || $tmp_total_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
- {
+ if (($tmp_total_ht < 0 || $tmp_total_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
if ($object->type == $object::TYPE_DEPOSIT) {
$langs->load("errors");
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
@@ -335,18 +327,15 @@ if (empty($reshook))
}
}
- elseif ($action == 'classin' && $usercancreate)
- {
+ elseif ($action == 'classin' && $usercancreate) {
$object->fetch($id);
$object->setProject($_POST['projectid']);
- } elseif ($action == 'setmode' && $usercancreate)
- {
+ } elseif ($action == 'setmode' && $usercancreate) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
dol_print_error($db, $object->error);
- } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer)
- {
+ } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) {
$object->fetch($id);
$object->retained_warranty_fk_cond_reglement = 0; // To clean property
$result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int'));
@@ -368,11 +357,9 @@ if (empty($reshook))
$result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float'));
if ($result < 0)
dol_print_error($db, $object->error);
- } // Multicurrency Code
- elseif ($action == 'setmulticurrencycode' && $usercancreate) {
+ } elseif ($action == 'setmulticurrencycode' && $usercancreate) { // Multicurrency Code
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
- } // Multicurrency rate
- elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
+ } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { // Multicurrency rate
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} elseif ($action == 'setinvoicedate' && $usercancreate) {
$object->fetch($id);
@@ -400,8 +387,7 @@ if (empty($reshook))
if ($result < 0) {
dol_print_error($db, $object->error);
}
- } elseif ($action == 'setconditions' && $usercancreate)
- {
+ } elseif ($action == 'setconditions' && $usercancreate) {
$object->fetch($id);
$object->cond_reglement_code = 0; // To clean property
$object->cond_reglement_id = 0; // To clean property
@@ -435,8 +421,7 @@ if (empty($reshook))
} else {
$db->commit();
}
- } elseif ($action == 'setpaymentterm' && $usercancreate)
- {
+ } elseif ($action == 'setpaymentterm' && $usercancreate) {
$object->fetch($id);
$object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']);
if ($object->date_lim_reglement < $object->date) {
@@ -447,8 +432,7 @@ if (empty($reshook))
if ($result < 0) {
dol_print_error($db, $object->error);
}
- } elseif ($action == 'setrevenuestamp' && $usercancreate)
- {
+ } elseif ($action == 'setrevenuestamp' && $usercancreate) {
$object->fetch($id);
$object->revenuestamp = GETPOST('revenuestamp');
$result = $object->update($user);
@@ -475,11 +459,9 @@ if (empty($reshook))
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
}
- } // Set incoterm
- elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) {
+ } elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { // Set incoterm
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
- } // bank account
- elseif ($action == 'setbankaccount' && $usercancreate) {
+ } elseif ($action == 'setbankaccount' && $usercancreate) { // bank account
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
} elseif ($action == 'setremisepercent' && $usercancreate) {
$object->fetch($id);
@@ -500,8 +482,7 @@ if (empty($reshook))
}
}
// We use the credit to reduce remain to pay
- if (GETPOST("remise_id_for_payment", 'int') > 0)
- {
+ if (GETPOST("remise_id_for_payment", 'int') > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($db);
$discount->fetch(GETPOST("remise_id_for_payment", 'int'));
@@ -515,8 +496,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors');
}
- if (!$error)
- {
+ if (!$error) {
$result = $discount->link_to_invoice(0, $id);
if ($result < 0) {
setEventMessages($discount->error, $discount->errors, 'errors');
@@ -524,8 +504,7 @@ if (empty($reshook))
}
}
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
+ 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');
@@ -539,12 +518,10 @@ if (empty($reshook))
$result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'setref' && $usercancreate)
- {
+ } elseif ($action == 'setref' && $usercancreate) {
$object->fetch($id);
$object->setValueFrom('ref', GETPOST('ref'), '', null, '', '', $user, 'BILL_MODIFY');
- } elseif ($action == 'setref_client' && $usercancreate)
- {
+ } elseif ($action == 'setref_client' && $usercancreate) {
$object->fetch($id);
$object->set_ref_client(GETPOST('ref_client'));
} // Classify to validated
@@ -559,16 +536,13 @@ if (empty($reshook))
// Check for mandatory fields in thirdparty (defined into setup)
$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL');
- foreach ($array_to_check as $key)
- {
+ foreach ($array_to_check as $key) {
$keymin = strtolower($key);
$i = (int) preg_replace('/[^0-9]/', '', $key);
$vallabel = $object->thirdparty->$keymin;
- if ($i > 0)
- {
- if ($object->thirdparty->isACompany())
- {
+ if ($i > 0) {
+ if ($object->thirdparty->isACompany()) {
// Check for mandatory prof id (but only if country is other than ours)
if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id)
{
@@ -583,11 +557,9 @@ if (empty($reshook))
}
} else {
//var_dump($conf->global->SOCIETE_EMAIL_MANDATORY);
- if ($key == 'EMAIL')
- {
+ if ($key == 'EMAIL') {
// Check for mandatory
- if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email))
- {
+ if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) {
$langs->load("errors");
$error++;
setEventMessages($langs->trans("ErrorBadEMail", $object->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors');
@@ -598,15 +570,13 @@ if (empty($reshook))
// Check for mandatory fields in invoice
$array_to_check = array('REF_CUSTOMER'=>'RefCustomer');
- foreach ($array_to_check as $key => $val)
- {
+ foreach ($array_to_check as $key => $val) {
$keymin = strtolower($key);
$vallabel = $object->$keymin;
// Check for mandatory
$keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION';
- if (!$vallabel && !empty($conf->global->$keymandatory))
- {
+ if (!$vallabel && !empty($conf->global->$keymandatory)) {
$langs->load("errors");
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
@@ -614,8 +584,7 @@ if (empty($reshook))
}
// Check for warehouse
- if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL))
- {
+ if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$qualified_for_stock_change = $object->hasProductsOrServices(2);
@@ -623,8 +592,7 @@ if (empty($reshook))
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}
- if ($qualified_for_stock_change)
- {
+ if ($qualified_for_stock_change) {
if (!$idwarehouse || $idwarehouse == - 1) {
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
@@ -633,11 +601,9 @@ if (empty($reshook))
}
}
- if (!$error)
- {
+ if (!$error) {
$result = $object->validate($user, '', $idwarehouse);
- if ($result >= 0)
- {
+ if ($result >= 0) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
@@ -663,16 +629,14 @@ if (empty($reshook))
}
}
} // Go back to draft status (unvalidate)
- elseif ($action == 'confirm_modif' && $usercanunvalidate)
- {
+ elseif ($action == 'confirm_modif' && $usercanunvalidate) {
$idwarehouse = GETPOST('idwarehouse', 'int');
$object->fetch($id);
$object->fetch_thirdparty();
// Check parameters
- if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL))
- {
+ if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$qualified_for_stock_change = $object->hasProductsOrServices(2);
@@ -680,8 +644,7 @@ if (empty($reshook))
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}
- if ($qualified_for_stock_change)
- {
+ if ($qualified_for_stock_change) {
if (!$idwarehouse || $idwarehouse == - 1) {
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
@@ -716,16 +679,13 @@ if (empty($reshook))
$ventilExportCompta = $object->getVentilExportCompta();
// On verifie si aucun paiement n'a ete effectue
- if ($ventilExportCompta == 0)
- {
- if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye)))
- {
+ if ($ventilExportCompta == 0) {
+ if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) {
$result = $object->setDraft($user, $idwarehouse);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
// Define output language
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
+ 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');
@@ -744,14 +704,12 @@ if (empty($reshook))
}
}
} // Classify "paid"
- elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment)
- {
+ elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment) {
$object->fetch($id);
$result = $object->setPaid($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} // Classif "paid partialy"
- elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment)
- {
+ elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment) {
$object->fetch($id);
$close_code = GETPOST("close_code", 'restricthtml');
$close_note = GETPOST("close_note", 'restricthtml');
@@ -773,8 +731,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors');
}
} // Convertir en reduc
- elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate)
- {
+ elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) {
$object->fetch($id);
$object->fetch_thirdparty();
//$object->fetch_lines(); // Already done into fetch
@@ -786,8 +743,8 @@ if (empty($reshook))
$canconvert = 0;
if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc)
if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
- if ($canconvert)
- {
+
+ if ($canconvert) {
$db->begin();
$amount_ht = $amount_tva = $amount_ttc = array();
@@ -795,10 +752,8 @@ if (empty($reshook))
// Loop on each vat rate
$i = 0;
- foreach ($object->lines as $line)
- {
- if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null
- {
+ foreach ($object->lines as $line) {
+ if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null
$keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : '');
$amount_ht[$keyforvatrate] += $line->total_ht;
@@ -830,13 +785,13 @@ if (empty($reshook))
// Insert one discount by VAT rate category
$discount = new DiscountAbsolute($db);
- if ($object->type == Facture::TYPE_CREDIT_NOTE)
+ if ($object->type == Facture::TYPE_CREDIT_NOTE) {
$discount->description = '(CREDIT_NOTE)';
- elseif ($object->type == Facture::TYPE_DEPOSIT)
+ } elseif ($object->type == Facture::TYPE_DEPOSIT) {
$discount->description = '(DEPOSIT)';
- elseif ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION)
+ } elseif ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) {
$discount->description = '(EXCESS RECEIVED)';
- else {
+ } else {
setEventMessages($langs->trans('CantConvertToReducAnInvoiceOfThisType'), null, 'errors');
}
$discount->fk_soc = $object->socid;
@@ -844,8 +799,7 @@ if (empty($reshook))
$error = 0;
- if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION)
- {
+ if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) {
// If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT
// Total payments
@@ -872,7 +826,9 @@ if (empty($reshook))
while ($obj = $db->fetch_object($resql)) {
$total_creditnote_and_deposit += $obj->amount_ttc;
}
- } else dol_print_error($db);
+ } else {
+ dol_print_error($db);
+ }
$discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc;
$discount->amount_tva = 0;
@@ -880,15 +836,12 @@ if (empty($reshook))
$discount->vat_src_code = '';
$result = $discount->create($user);
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
- {
- foreach ($amount_ht as $tva_tx => $xxx)
- {
+ if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
+ foreach ($amount_ht as $tva_tx => $xxx) {
$discount->amount_ht = abs($amount_ht[$tva_tx]);
$discount->amount_tva = abs($amount_tva[$tva_tx]);
$discount->amount_ttc = abs($amount_ttc[$tva_tx]);
@@ -909,21 +862,18 @@ if (empty($reshook))
$discount->vat_src_code = $vat_src_code;
$result = $discount->create($user);
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
break;
}
}
}
- if (empty($error))
- {
+ if (empty($error)) {
if ($object->type != Facture::TYPE_DEPOSIT) {
// Classe facture
$result = $object->setPaid($user);
- if ($result >= 0)
- {
+ if ($result >= 0) {
$db->commit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
@@ -938,11 +888,9 @@ if (empty($reshook))
}
}
} // Delete payment
- elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate)
- {
+ elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) {
$object->fetch($id);
- if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0)
- {
+ if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) {
$paiement = new Paiement($db);
$result = $paiement->fetch(GETPOST('paiement_id'));
if ($result > 0) {
@@ -956,9 +904,10 @@ if (empty($reshook))
} /*
* Insert new invoice in database
*/
- elseif ($action == 'add' && $usercancreate)
- {
- if ($socid > 0) $object->socid = GETPOST('socid', 'int');
+ elseif ($action == 'add' && $usercancreate) {
+ if ($socid > 0) {
+ $object->socid = GETPOST('socid', 'int');
+ }
$selectedLines = GETPOST('toselect', 'array');
$db->begin();
@@ -970,8 +919,7 @@ if (empty($reshook))
if ($ret < 0) $error++;
// Replacement invoice
- if (GETPOST('type') == Facture::TYPE_REPLACEMENT)
- {
+ if (GETPOST('type') == Facture::TYPE_REPLACEMENT) {
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) {
$error++;
@@ -983,7 +931,7 @@ if (empty($reshook))
$action = 'create';
}
- if (!($_POST['fac_replacement'] > 0)) {
+ if (!(GETPOST('fac_replacement', 'int') > 0)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors');
$action = 'create';
@@ -1014,7 +962,7 @@ if (empty($reshook))
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
// Proprietes particulieres a facture de remplacement
- $object->fk_facture_source = $_POST['fac_replacement'];
+ $object->fk_facture_source = GETPOST('fac_replacement', 'int');
$object->type = Facture::TYPE_REPLACEMENT;
$id = $object->createFromCurrent($user);
@@ -1025,11 +973,9 @@ if (empty($reshook))
}
// Credit note invoice
- if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE)
- {
+ if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
$sourceinvoice = GETPOST('fac_avoir', 'int');
- if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
- {
+ if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors');
$action = 'create';
@@ -1077,10 +1023,8 @@ if (empty($reshook))
$object->type = Facture::TYPE_CREDIT_NOTE;
$facture_source = new Facture($db); // fetch origin object
- if ($facture_source->fetch($object->fk_facture_source) > 0)
- {
- if ($facture_source->type == Facture::TYPE_SITUATION)
- {
+ if ($facture_source->fetch($object->fk_facture_source) > 0) {
+ if ($facture_source->type == Facture::TYPE_SITUATION) {
$object->situation_counter = $facture_source->situation_counter;
$object->situation_cycle_ref = $facture_source->situation_cycle_ref;
$facture_source->fetchPreviousNextSituationInvoice();
@@ -1113,22 +1057,18 @@ if (empty($reshook))
}
- if ($facture_source->type == Facture::TYPE_SITUATION)
- {
+ if ($facture_source->type == Facture::TYPE_SITUATION) {
$source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
$line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
- if (!empty($facture_source->tab_previous_situation_invoice))
- {
+ if (!empty($facture_source->tab_previous_situation_invoice)) {
// search the last standard invoice in cycle and the possible credit note between this last and facture_source
// TODO Move this out of loop of $facture_source->lines
$tab_jumped_credit_notes = array();
$lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
$searchPreviousInvoice = true;
- while ($searchPreviousInvoice)
- {
- if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1)
- {
+ while ($searchPreviousInvoice) {
+ if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) {
$searchPreviousInvoice = false; // find, exit;
break;
} else {
@@ -1140,10 +1080,8 @@ if (empty($reshook))
}
$maxPrevSituationPercent = 0;
- foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
- {
- if ($prevLine->id == $source_fk_prev_id)
- {
+ foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
+ if ($prevLine->id == $source_fk_prev_id) {
$maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
//$line->subprice = $line->subprice - $prevLine->subprice;
@@ -1168,10 +1106,8 @@ if (empty($reshook))
// If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
$maxPrevSituationPercent = 0;
foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
- foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine)
- {
- if ($prevLine->fk_prev_id == $source_fk_prev_id)
- {
+ foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) {
+ if ($prevLine->fk_prev_id == $source_fk_prev_id) {
$maxPrevSituationPercent = $prevLine->situation_percent;
$line->total_ht -= $prevLine->total_ht;
@@ -1225,10 +1161,8 @@ if (empty($reshook))
}
}
- if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0)
- {
- if ($facture_source->fetch($object->fk_facture_source) > 0)
- {
+ if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) {
+ if ($facture_source->fetch($object->fk_facture_source) > 0) {
$totalpaye = $facture_source->getSommePaiement();
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
$totaldeposits = $facture_source->getSumDepositsUsed();
@@ -1253,8 +1187,7 @@ if (empty($reshook))
}
// Standard invoice or Deposit invoice, created from a Predefined template invoice
- if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0)
- {
+ if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) {
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) {
$error++;
@@ -1268,8 +1201,7 @@ if (empty($reshook))
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
- if (!$error)
- {
+ if (!$error) {
$object->socid = GETPOST('socid', 'int');
$object->type = GETPOST('type');
$object->ref = GETPOST('ref');
@@ -1298,17 +1230,20 @@ if (empty($reshook))
}
}
- // Standard or deposit or proforma invoice, not from a Predefined template invoice
- if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT || GETPOST('type') == Facture::TYPE_PROFORMA || (GETPOST('type') == Facture::TYPE_SITUATION && !GETPOST('situations'))) && GETPOST('fac_rec') <= 0)
- {
- if (GETPOST('socid', 'int') < 1)
- {
+ // Standard or deposit invoice, not from a Predefined template invoice
+ if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT || GETPOST('type') == Facture::TYPE_PROFORMA || (GETPOST('type') == Facture::TYPE_SITUATION && !GETPOST('situations'))) && GETPOST('fac_rec') <= 0) {
+ $typeamount = GETPOST('typedeposit', 'aZ09');
+ $valuestandardinvoice = price2num(str_replace('%', '', GETPOST('valuestandardinvoice', 'alpha')), 'MU');
+ $valuedeposit = price2num(str_replace('%', '', GETPOST('valuedeposit', 'alpha')), 'MU');
+ $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+ $date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
+
+ if (GETPOST('socid', 'int') < 1) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors');
$action = 'create';
}
- $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
@@ -1319,10 +1254,34 @@ if (empty($reshook))
$action = 'create';
}
- $date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
- if (!$error)
- {
+ if (GETPOST('type') == Facture::TYPE_STANDARD) {
+ if ($valuestandardinvoice < 0 || $valuestandardinvoice > 100) {
+ setEventMessages($langs->trans("ErrorAPercentIsRequired"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+ } elseif (GETPOST('type') == Facture::TYPE_DEPOSIT) {
+ if ($typeamount && !empty($origin) && !empty($originid)) {
+ if ($typeamount == 'amount' && $valuedeposit <= 0) {
+ setEventMessages($langs->trans("ErrorAnAmountWithoutTaxIsRequired"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+ if ($typeamount == 'variable' && $valuedeposit <= 0) {
+ setEventMessages($langs->trans("ErrorAPercentIsRequired"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+ if ($typeamount == 'variablealllines' && $valuedeposit <= 0) {
+ setEventMessages($langs->trans("ErrorAPercentIsRequired"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+ }
+ }
+
+ if (!$error) {
// Si facture standard
$object->socid = GETPOST('socid', 'int');
$object->type = GETPOST('type');
@@ -1345,8 +1304,7 @@ if (empty($reshook))
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
- if (GETPOST('type') == Facture::TYPE_SITUATION)
- {
+ if (GETPOST('type') == Facture::TYPE_SITUATION) {
$object->situation_counter = 1;
$object->situation_final = 0;
$object->situation_cycle_ref = $object->newCycle();
@@ -1361,21 +1319,21 @@ if (empty($reshook))
}
$retained_warranty_date_limit = GETPOST('retained_warranty_date_limit');
- if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) {
- $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit);
+ if (!empty($retained_warranty_date_limit) && dol_stringtotime($retained_warranty_date_limit)) {
+ $object->retained_warranty_date_limit = dol_stringtotime($retained_warranty_date_limit);
}
$object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement);
$object->fetch_thirdparty();
// If creation from another object of another module (Example: origin=propal, originid=1)
- if (!empty($origin) && !empty($originid))
- {
+ if (!empty($origin) && !empty($originid)) {
+ $regs = array();
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
- $element = $regs [1];
- $subelement = $regs [2];
+ $element = $regs[1];
+ $subelement = $regs[2];
}
// For compatibility
@@ -1415,15 +1373,13 @@ if (empty($reshook))
}
}
- if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects']))
- {
+ if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) {
$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
}
$id = $object->create($user); // This include class to add_object_linked() and add add_contact()
- if ($id > 0)
- {
+ if ($id > 0) {
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
@@ -1432,48 +1388,46 @@ if (empty($reshook))
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines or deposit lines");
$result = $srcobject->fetch($object->origin_id);
- $typeamount = GETPOST('typedeposit', 'aZ09');
- $valuedeposit = price2num(GETPOST('valuedeposit', 'alpha'), 'MU');
-
- // If deposit invoice
- if ($_POST['type'] == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable')))
- {
+ // If deposit invoice - down payment with 1 line (fixed amount or percent)
+ if (GETPOST('type') == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable'))) {
+ // Define the array $amountdeposit
$amountdeposit = array();
- if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA))
- {
- if ($typeamount == 'amount') $amount = $valuedeposit;
- else $amount = $srcobject->total_ttc * ($valuedeposit / 100);
+ if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) {
+ if ($typeamount == 'amount') {
+ $amount = $valuedeposit;
+ } else {
+ $amount = $srcobject->total_ttc * ($valuedeposit / 100);
+ }
$TTotalByTva = array();
- foreach ($srcobject->lines as &$line)
- {
+ foreach ($srcobject->lines as &$line) {
if (!empty($line->special_code)) continue;
$TTotalByTva[$line->tva_tx] += $line->total_ttc;
}
- foreach ($TTotalByTva as $tva => &$total)
- {
+ foreach ($TTotalByTva as $tva => &$total) {
$coef = $total / $srcobject->total_ttc; // Calc coef
$am = $amount * $coef;
$amount_ttc_diff += $am;
$amountdeposit[$tva] += $am / (1 + $tva / 100); // Convert into HT for the addline
}
} else {
- if ($typeamount == 'amount')
- {
+ if ($typeamount == 'amount') {
$amountdeposit[0] = $valuedeposit;
- } elseif ($typeamount == 'variable')
- {
- if ($result > 0)
- {
+ } elseif ($typeamount == 'variable') {
+ if ($result > 0) {
$totalamount = 0;
$lines = $srcobject->lines;
$numlines = count($lines);
for ($i = 0; $i < $numlines; $i++)
{
$qualified = 1;
- if (empty($lines[$i]->qty)) $qualified = 0; // We discard qty=0, it is an option
- if (!empty($lines[$i]->special_code)) $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...)
+ if (empty($lines[$i]->qty)) {
+ $qualified = 0; // We discard qty=0, it is an option
+ }
+ if (!empty($lines[$i]->special_code)) {
+ $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...)
+ }
if ($qualified) {
$totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
$tva_tx = $lines[$i]->tva_tx;
@@ -1495,7 +1449,9 @@ if (empty($reshook))
foreach ($amountdeposit as $tva => $amount)
{
- if (empty($amount)) continue;
+ if (empty($amount)) {
+ continue;
+ }
$arraylist = array(
'amount' => 'FixAmount',
@@ -1540,27 +1496,34 @@ if (empty($reshook))
$diff = $object->total_ttc - $amount_ttc_diff;
- if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0)
- {
+ if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) {
$object->fetch_lines();
$subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100);
$object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100);
}
}
- if ($_POST['type'] != Facture::TYPE_DEPOSIT || ($_POST['type'] == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines'))
+ // standard invoice, credit note, or down payment from a percent of all lines
+ if (GETPOST('type') != Facture::TYPE_DEPOSIT || (GETPOST('type') == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines'))
{
- if ($result > 0)
- {
+ if ($result > 0) {
$lines = $srcobject->lines;
- if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
- {
+ if (empty($lines) && method_exists($srcobject, 'fetch_lines')) {
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
- // If we create a deposit with all lines and a percent, we change amount
- if ($_POST['type'] == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines') {
+ // If we create a standard invoice with a percent, we change amount by changing the qty
+ if (GETPOST('type') == Facture::TYPE_STANDARD && $valuestandardinvoice > 0 && $valuestandardinvoice < 100) {
+ if (is_array($lines)) {
+ foreach ($lines as $line) {
+ // We keep ->subprice and ->pa_ht, but we change the qty
+ $line->qty = price2num($line->qty * $valuestandardinvoice / 100, 'MS');
+ }
+ }
+ }
+ // If we create a down payment with a percent on all lines, we change amount by changing the qty
+ if (GETPOST('type') == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines') {
if (is_array($lines)) {
foreach ($lines as $line) {
// We keep ->subprice and ->pa_ht, but we change the qty
@@ -1572,15 +1535,22 @@ if (empty($reshook))
$fk_parent_line = 0;
$num = count($lines);
- for ($i = 0; $i < $num; $i++)
- {
- if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines
+ for ($i = 0; $i < $num; $i++) {
+ if (!in_array($lines[$i]->id, $selectedLines)) {
+ continue; // Skip unselected lines
+ }
// Don't add lines with qty 0 when coming from a shipment including all order lines
- if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue;
+ if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) {
+ continue;
+ }
// Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines)
- if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5';
- if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue;
+ if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) {
+ $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5';
+ }
+ if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) {
+ continue;
+ }
$label = (!empty($lines[$i]->label) ? $lines[$i]->label : '');
$desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle);
@@ -1611,23 +1581,29 @@ if (empty($reshook))
// Date start
$date_start = false;
- if ($lines[$i]->date_debut_prevue)
+ if ($lines[$i]->date_debut_prevue) {
$date_start = $lines[$i]->date_debut_prevue;
- if ($lines[$i]->date_debut_reel)
+ }
+ if ($lines[$i]->date_debut_reel) {
$date_start = $lines[$i]->date_debut_reel;
- if ($lines[$i]->date_start)
+ }
+ if ($lines[$i]->date_start) {
$date_start = $lines[$i]->date_start;
+ }
- // Date end
+ // Date end
$date_end = false;
- if ($lines[$i]->date_fin_prevue)
+ if ($lines[$i]->date_fin_prevue) {
$date_end = $lines[$i]->date_fin_prevue;
- if ($lines[$i]->date_fin_reel)
+ }
+ if ($lines[$i]->date_fin_reel) {
$date_end = $lines[$i]->date_fin_reel;
- if ($lines[$i]->date_end)
+ }
+ if ($lines[$i]->date_end) {
$date_end = $lines[$i]->date_end;
+ }
- // Reset fk_parent_line for no child products and special product
+ // Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
@@ -1730,8 +1706,7 @@ if (empty($reshook))
}
// Situation invoices
- if (GETPOST('type') == Facture::TYPE_SITUATION && GETPOST('situations'))
- {
+ if (GETPOST('type') == Facture::TYPE_SITUATION && GETPOST('situations')) {
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) {
$error++;
@@ -2670,8 +2645,9 @@ if (empty($reshook))
}
}
- if ($error)
+ if ($error) {
$action = 'edit_extras';
+ }
}
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) {
@@ -2715,8 +2691,9 @@ if (empty($reshook))
}
}
- if ($error)
+ if ($error) {
$action = 'edit_extras';
+ }
}
}
@@ -2738,6 +2715,7 @@ $now = dol_now();
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Card');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
+
llxHeader('', $title, $helpurl);
// Mode creation
@@ -2749,15 +2727,15 @@ if ($action == 'create')
print load_fiche_titre($langs->trans('NewBill'), '', 'bill');
- if ($socid > 0)
+ if ($socid > 0) {
$res = $soc->fetch($socid);
+ }
$currency_code = $conf->currency;
// Load objectsrc
$remise_absolue = 0;
- if (!empty($origin) && !empty($originid))
- {
+ if (!empty($origin) && !empty($originid)) {
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
$regs = array();
@@ -2809,11 +2787,11 @@ if ($action == 'create')
$projectid = (!empty($projectid) ? $projectid : $objectsrc->fk_project);
$ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : ''));
- $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : '');
// only if socid not filled else it's allready done upper
- if (empty($socid))
+ if (empty($socid)) {
$soc = $objectsrc->thirdparty;
+ }
$dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice);
@@ -2887,8 +2865,7 @@ if ($action == 'create')
print ajax_combobox('situations');
}
- if ($origin == 'contrat')
- {
+ if ($origin == 'contrat') {
$langs->load("admin");
$text = $langs->trans("ToCreateARecurringInvoice");
$text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates"));
@@ -2918,18 +2895,16 @@ if ($action == 'create')
print '
';
// Ref
- print ''.$langs->trans('Ref').' '.$langs->trans('Draft').' ';
+ //print ''.$langs->trans('Ref').' '.$langs->trans('Draft').' ';
$exampletemplateinvoice = new FactureRec($db);
$invoice_predefined = new FactureRec($db);
- if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0)
- {
+ if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) {
$invoice_predefined->fetch(GETPOST('fac_rec', 'int'));
}
// Thirdparty
- if ($soc->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency)))
- {
+ if ($soc->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) {
// If thirdparty known and not a predefined invoiced without a recurring rule
print ''.$langs->trans('Customer').' ';
print '';
@@ -2938,14 +2913,13 @@ if ($action == 'create')
// Outstanding Bill
$arrayoutstandingbills = $soc->getOutstandingBills();
$outstandingBills = $arrayoutstandingbills['opened'];
- print ' ('.$langs->trans('CurrentOutstandingBill').': ';
+ print ' - '.$langs->trans('CurrentOutstandingBill').': ';
print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
if ($soc->outstanding_limit != '')
{
if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
}
- print ')';
print ' ';
print ' '."\n";
} else {
@@ -2953,8 +2927,7 @@ if ($action == 'create')
print '';
print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// Option to reload page to retrieve customer informations.
- if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
- {
+ if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
print '';
$tmp = $tmp.''.$langs->trans("InvoiceDeposit").' ';
$desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3);
- print '';
+ print '';
+ print '';
print $desc;
print ' ';
- if (($origin == 'propal') || ($origin == 'commande'))
- {
- print '';
+ if (($origin == 'propal') || ($origin == 'commande')) {
+ print ' ';
$arraylist = array(
'amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')),
'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')),
@@ -3090,18 +3093,18 @@ if ($action == 'create')
);
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1);
print ' ';
- print ''.$langs->trans('Value').': ';
+ print ' ';
+ print ''.$langs->trans("AmountOrPercent").' ';
+ print ' ';
}
- print '
';
+ print '
';
print '';
}
}
- if ($socid > 0)
- {
- if (!empty($conf->global->INVOICE_USE_SITUATION))
- {
+ if ($socid > 0) {
+ if (!empty($conf->global->INVOICE_USE_SITUATION)) {
// First situation invoice
print '';
$tmp = '
';
@@ -3115,8 +3118,9 @@ if ($action == 'create')
print '
';
$tmp = '
'.$langs->trans('NoSituations').'') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande'))
+ if ($opt == ('
'.$langs->trans('NoSituations').' ') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) {
$tmp .= ' disabled';
+ }
$tmp .= '> ';
$text = '
'.$tmp.$langs->trans("InvoiceSituationAsk").' ';
$text .= '
global->INVOICE_DISABLE_REPLACEMENT))
- {
+ if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) {
// Type de facture
$facids = $facturestatic->list_replacable_invoices($soc->id);
if ($facids < 0) {
@@ -3141,8 +3144,7 @@ if ($action == 'create')
}
$options = "";
if (is_array($facids)) {
- foreach ($facids as $facparam)
- {
+ foreach ($facids as $facparam) {
$options .= '';
print '';
}
} else {
- if (!empty($conf->global->INVOICE_USE_SITUATION))
- {
+ if (!empty($conf->global->INVOICE_USE_SITUATION)) {
print '';
$tmp = '
';
$text = '
'.$tmp.$langs->trans("InvoiceFirstSituationAsk").' ';
@@ -3210,24 +3214,19 @@ if ($action == 'create')
}
- if (empty($origin))
- {
- if ($socid > 0)
- {
+ if (empty($origin)) {
+ if ($socid > 0) {
// Credit note
- if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
- {
+ if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) {
// Show link for credit note
$facids = $facturestatic->list_qualified_avoir_invoices($soc->id);
- if ($facids < 0)
- {
+ if ($facids < 0) {
dol_print_error($db, $facturestatic);
exit;
}
$optionsav = "";
$newinvoice_static = new Facture($db);
- foreach ($facids as $key => $valarray)
- {
+ foreach ($facids as $key => $valarray) {
$newinvoice_static->id = $key;
$newinvoice_static->ref = $valarray ['ref'];
$newinvoice_static->statut = $valarray ['status'];
@@ -3245,7 +3244,9 @@ if ($action == 'create')
print '
';
$tmp = ' global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp .= ' disabled';
+ if ((!$optionsav && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) {
+ $tmp .= ' disabled';
+ }
$tmp .= '> ';
// Show credit note options only if we checked credit note
print ''."\n";
}
@@ -475,7 +472,7 @@ if ($action == 'create')
// Auto create payment
print '
'.$langs->trans('AutomaticCreationPayment').' ';
- print ' '."\n";
+ print ' '."\n";
// Number
print ''.$langs->trans('Numero');
diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php
index e310e61fcb8..addaf50d990 100644
--- a/htdocs/compta/tva/document.php
+++ b/htdocs/compta/tva/document.php
@@ -78,7 +78,7 @@ $modulepart = 'tax-vat';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
if ($action == 'setlib' && $user->rights->tax->charges->creer)
{
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 8d78b410329..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) {
@@ -889,8 +884,8 @@ if (empty($reshook))
$action = 'editref';
} else {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref);
- $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref);
+ $old_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($old_ref);
+ $new_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$files = dol_dir_list($old_filedir);
if (!empty($files))
@@ -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) {
@@ -935,7 +929,7 @@ if (empty($reshook))
// Actions to build doc
- $upload_dir = $conf->contrat->dir_output;
+ $upload_dir = $conf->contrat->multidir_output[$object->entity];
$permissiontoadd = $user->rights->contrat->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
@@ -2137,19 +2131,25 @@ if ($action == 'create')
* Documents generes
*/
$filename = dol_sanitizeFileName($object->ref);
- $filedir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref);
+ $filedir = $conf->contrat->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->contrat->lire;
$delallowed = $user->rights->contrat->creer;
- print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
+ print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, ($object->model_pdf ? $object->model_pdf : $conf->global->CONTRACT_ADDON_PDF), 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+ // Show direct download link
+ if ($object->statut != Contrat::STATUS_DRAFT && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD))
+ {
+ print ' '."\n";
+ print showDirectDownloadLink($object).' ';
+ }
print ' ';
@@ -2168,7 +2168,7 @@ if ($action == 'create')
// Presend form
$modelmail = 'contract';
$defaulttopic = 'SendContractRef';
- $diroutput = $conf->contrat->dir_output;
+ $diroutput = $conf->contrat->multidir_output[$object->entity];
$trackid = 'con'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 36edee80669..7c99a9483b9 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -1296,7 +1296,7 @@ class Contrat extends CommonObject
$ref = dol_sanitizeFileName($this->ref);
if ($conf->contrat->dir_output)
{
- $dir = $conf->contrat->dir_output."/".$ref;
+ $dir = $conf->contrat->multidir_output[$this->entity]."/".$ref;
if (file_exists($dir))
{
$res = @dol_delete_dir_recursive($dir);
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index b68da3170ed..dfdb0fe6d31 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -74,7 +74,7 @@ if ($object->id > 0)
$object->fetch_thirdparty();
}
-$upload_dir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref);
+$upload_dir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$modulepart = 'contract';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -85,7 +85,7 @@ $hookmanager->initHooks(array('contractcard', 'globalcard'));
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 1226d578f2f..a890b1f3ce2 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -204,7 +204,7 @@ $formcompany = new FormCompany($db);
$contracttmp = new Contrat($db);
$sql = 'SELECT';
-$sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
+$sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,";
$sql .= ' s.rowid as socid, s.nom as name, s.name_alias, s.email, s.town, s.zip, s.fk_pays as country_id, s.client, s.code_client, s.status as company_status, s.logo as company_logo,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
@@ -260,7 +260,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
-$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
+$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,";
$sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.status, s.logo,';
$sql .= " typent.code,";
$sql .= " state.code_departement, state.nom";
@@ -644,7 +644,7 @@ while ($i < min($num, $limit))
}
$filename = dol_sanitizeFileName($obj->ref);
- $filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($obj->ref);
+ $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
print '
';
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 95c5037c5fb..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
@@ -1097,6 +1097,7 @@ if ($action == 'remove_file')
$action = '';
}
+
// Validate records
if (!$error && $massaction == 'validate' && $permissiontoadd)
{
@@ -1125,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_comptes.php b/htdocs/core/boxes/box_comptes.php
index 53be2725680..f09a80f0227 100644
--- a/htdocs/core/boxes/box_comptes.php
+++ b/htdocs/core/boxes/box_comptes.php
@@ -135,7 +135,7 @@ class box_comptes extends ModeleBoxes
$this->info_box_contents[$line][] = array(
'td' => 'class="right nowraponall"',
- 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code)
+ 'text' => price($solde, 0, $langs, 1, -1, -1, $objp->currency_code)
);
$line++;
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 12e82b4df6d..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,9 +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';
+ 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))
{
@@ -4884,6 +4892,9 @@ abstract class CommonObject
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey = true;
}
+ if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) {
+ $setsharekey = true;
+ }
if ($setsharekey) {
if (empty($ecmfile->share)) // Because object not found or share not set yet
@@ -6886,7 +6897,7 @@ abstract class CommonObject
/**
* Function to show lines of extrafields with output datas.
- * This function is responsible to output the and according to correct number of columns received into $params['colspan']
+ * This function is responsible to output the and according to correct number of columns received into $params['colspan'] or according to $display_type
*
* @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output ('view') or input ('create' or 'edit') for extrafield
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 1eb3b9911ba..d8fbceeecf8 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -98,7 +98,7 @@ class Conf
public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url
public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone
public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
- public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url
+ public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url. 0=default, 1=to say we use app from a webview app, 2=to say we use app from a webview app and keep ajax
public $liste_limit;
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 9f901ed3452..af336c38745 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -222,6 +222,7 @@ class DiscountAbsolute
if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0;
if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0;
if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0;
+ if (empty($this->tva_tx)) $this->tva_tx = 0;
// Check parameters
if (empty($this->description))
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index 4dfca1186c0..8091d5debbe 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -825,7 +825,7 @@ class dolReceiptPrinter extends Printer
if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector")
{
$data = $this->printer->connector->getData();
- if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo base64_encode($data);
+ if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
dol_syslog($data);
}
// Close and print
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 045ab92f08e..db436574086 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -839,7 +839,7 @@ class ExtraFields
$array_name_label = array();
// We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode
- $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,printable,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
+ $sql = "SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help";
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields";
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
if ($elementtype) $sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'"; // Filed with object->table_element
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 9ecd6a659a1..f1577496f8b 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -248,7 +248,7 @@ class HookManager
$actionclassinstance->error = 0;
$actionclassinstance->errors = array();
- dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", action=".$action." context=".$context, LOG_DEBUG);
+ dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".get_class($actionclassinstance).'->'.$method.", context=".$context.", module=".$module.", action=".$action.((is_object($object) && property_exists($object, 'id')) ? ', objectid='.$object->id : ''), LOG_DEBUG);
// Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return;
$parameters['currentcontext'] = $context;
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index a4a905d256d..1abb7eb26e0 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -253,9 +253,9 @@ class Form
if (empty($notabletag)) $ret .= '
';
//else $ret.='
';
- $ret .= ' ';
+ $ret .= ' ';
if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) $ret .= ' '."\n";
- $ret .= ' ';
+ $ret .= ' ';
if (empty($notabletag)) $ret .= ' ';
if (empty($notabletag)) $ret .= '
'."\n";
@@ -672,7 +672,7 @@ class Form
// Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button
$ret .= '
'; // Hidden button BEFORE so it is the one used when we submit with ENTER.
- $ret .= '
';
+ $ret .= '
use_javascript_ajax) ? '' : ' style="display: none"').' class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
$ret .= '
';
if (!empty($conf->use_javascript_ajax))
@@ -984,6 +984,7 @@ class Form
print '>'.$langs->trans("Service");
print '';
+ print ajax_combobox('select_'.$htmlname);
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
if ((empty($forceall) && empty($conf->product->enabled) && !empty($conf->service->enabled)) || $forceall == 3)
@@ -2753,9 +2754,10 @@ class Form
* @param int $hidelabel Hide label (0=no, 1=yes)
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
* @param string $morecss More CSS
+ * @param string $placeholder Placeholder
* @return void
*/
- public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '')
+ public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '', $placeholder = '')
{
// phpcs:enable
global $langs, $conf;
@@ -2776,9 +2778,9 @@ class Form
// mode=2 means suppliers products
$urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
- print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').' ';
+ print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').' ';
} else {
- print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', -1, 0, 0, $alsoproductwithnosupplierprice, $morecss);
+ print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', -1, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
}
}
@@ -2798,9 +2800,10 @@ class Form
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
* @param string $morecss Add more CSS
* @param int $showstockinlist Show stock information (slower).
+ * @param string $placeholder Placeholder
* @return array Array of keys for json
*/
- public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0)
+ public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0, $placeholder = '')
{
// phpcs:enable
global $langs, $conf, $db, $user;
@@ -2884,9 +2887,9 @@ class Form
$num = $this->db->num_rows($result);
//$out.=''; // remove select to have id same with combo and ajax
- $out .= '';
- if (!$selected) $out .= ' ';
- else $out .= ' ';
+ $out .= '';
+ if (!$selected) $out .= ''.($placeholder ? $placeholder : ' ').' ';
+ else $out .= ''.($placeholder ? $placeholder : ' ').' ';
$i = 0;
while ($i < $num)
@@ -3101,7 +3104,7 @@ class Form
// Add new entry
- // "key" value of json key array is used by jQuery automatically as selected value
+ // "key" value of json key array is used by jQuery automatically as selected value. Example: 'type' = product or service, 'price_ht' = unit price without tax
// "label" value of json key array is used by jQuery automatically as text for combo box
$out .= $opt;
array_push($outarray,
@@ -3109,12 +3112,12 @@ class Form
'value'=>$outref,
'label'=>$outval,
'qty'=>$outqty,
- 'up'=>$objp->unitprice,
+ 'price_ht'=>price2num($objp->unitprice, 'MT'),
'discount'=>$outdiscount,
'type'=>$outtype,
'duration_value'=>$outdurationvalue,
'duration_unit'=>$outdurationunit,
- 'disabled'=>(empty($objp->idprodfournprice) ?true:false),
+ 'disabled'=>(empty($objp->idprodfournprice) ? true : false),
'description'=>$objp->description
)
);
@@ -4164,6 +4167,7 @@ class Form
print '';
print ' ';
print ' ';
+ print img_picto('', 'bank_account', 'class="pictofixedwidth"');
$nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty);
if ($nbaccountfound > 0) print ' ';
print ' ';
@@ -4362,14 +4366,11 @@ class Form
$moreattr = (!empty($input['moreattr']) ? ' '.$input['moreattr'] : '');
$morecss = (!empty($input['morecss']) ? ' '.$input['morecss'] : '');
- if ($input['type'] == 'text')
- {
+ if ($input['type'] == 'text') {
$more .= ''."\n";
- } elseif ($input['type'] == 'password')
- {
+ } elseif ($input['type'] == 'password') {
$more .= ''."\n";
- } elseif ($input['type'] == 'select')
- {
+ } elseif ($input['type'] == 'select') {
if (empty($morecss)) {
$morecss = 'minwidth100';
}
@@ -4377,8 +4378,7 @@ class Form
if (!empty($input['label'])) $more .= $input['label'].'';
$more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
$more .= '
'."\n";
- } elseif ($input['type'] == 'checkbox')
- {
+ } elseif ($input['type'] == 'checkbox') {
$more .= '';
$more .= '
'.$input['label'].'
';
$more .= ' $selval)
{
@@ -4403,8 +4402,7 @@ class Form
$more .= '
'."\n";
$i++;
}
- } elseif ($input['type'] == 'date')
- {
+ } elseif ($input['type'] == 'date') {
$more .= ''.$input['label'].'
';
$more .= '
';
$more .= $this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0);
@@ -4414,17 +4412,17 @@ class Form
$formquestion[] = array('name'=>$input['name'].'year');
$formquestion[] = array('name'=>$input['name'].'hour');
$formquestion[] = array('name'=>$input['name'].'min');
- } elseif ($input['type'] == 'other')
- {
+ } elseif ($input['type'] == 'other') {
$more .= '
';
if (!empty($input['label'])) $more .= $input['label'].'
';
$more .= $input['value'];
$more .= '
'."\n";
- } elseif ($input['type'] == 'onecolumn')
- {
+ } elseif ($input['type'] == 'onecolumn') {
$moreonecolumn .= '
';
$moreonecolumn .= $input['value'];
$moreonecolumn .= '
'."\n";
+ } elseif ($input['type'] == 'hidden') {
+ // Do nothing more, already added by a previous loop
} else {
$more .= 'Error type '.$input['type'].' for the confirm box is not a supported type';
}
@@ -5702,6 +5700,9 @@ class Form
if ($h == 3) $shour = '';
if ($m == 3) $smin = '';
+ $nowgmt = dol_now('gmt');
+ //var_dump(dol_print_date($nowgmt, 'dayhourinputnoreduce', 'tzuserrel'));
+
// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
$usecalendar = 'combo';
if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) {
@@ -5724,13 +5725,13 @@ class Form
// Calendrier popup version eldy
if ($usecalendar == "eldy")
{
- // Zone de saisie manuelle de la date
+ // Input area to enter date manually
$retstring .= '
trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= '>';
- // Icone calendar
+ // Icon calendar
$retstringbuttom = '';
if (!$disabled) {
$retstringbuttom = '
use_javascript_ajax && $adddateof)
{
$tmparray = dol_getdate($adddateof);
if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice");
- $retstring .= ' - '.$labeladddateof.'';
+ $retstring .= ' - '.$labeladddateof.'';
}
return $retstring;
@@ -6303,7 +6301,7 @@ class Form
*/
public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0)
{
- global $conf, $langs, $user;
+ global $conf, $langs, $user, $hookmanager;
//print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled";
@@ -6349,27 +6347,34 @@ class Form
}
if ($objecttmp->ismultientitymanaged == 'fk_soc@societe')
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= " WHERE 1=1";
- if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
- if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
- $sql .= ' AND parenttable.entity = t.'.$tmparray[0];
- }
- if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
- if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid;
- else $sql .= " AND t.fk_soc = ".$user->socid;
- }
- if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
- if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- }
- if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
- /*if (! DolibarrApi::_checkFilters($objecttmp->filter))
- {
- throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter);
- }*/
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
- $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")";
- }
+
+ // Add where from hooks
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook
+ if (!empty($hookmanager->resPrint)) $sql .= $hookmanager->resPrint;
+ else {
+ $sql .= " WHERE 1=1";
+ if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
+ if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
+ $sql .= ' AND parenttable.entity = t.'.$tmparray[0];
+ }
+ if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
+ if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid;
+ else $sql .= " AND t.fk_soc = ".$user->socid;
+ }
+ if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
+ if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
+ if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
+ /*if (! DolibarrApi::_checkFilters($objecttmp->filter))
+ {
+ throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter);
+ }*/
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")";
+ }
+ }
$sql .= $this->db->order($fieldstoshow, "ASC");
//$sql.=$this->db->plimit($limit, 0);
//print $sql;
@@ -6475,6 +6480,11 @@ class Form
$out = '';
+ if ($addjscombo < 0) {
+ if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1;
+ else $addjscombo = 0;
+ }
+
// Add code for jquery to use multiselect
if ($addjscombo && $jsbeautify) {
// Enhance with select2
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index bfd5a6f64f7..92c697ceae7 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -20,7 +20,7 @@
/**
* \file htdocs/core/class/html.formactions.class.php
* \ingroup core
- * \brief Fichier de la classe des fonctions predefinie de composants html actions
+ * \brief File of class with predefined functions and HTML components
*/
@@ -355,7 +355,7 @@ class FormActions
if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
$out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0);
} else {
- $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'.($morecss ? ' '.$morecss : ''), 1);
+ $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth300'.($morecss ? ' '.$morecss : ''), 1);
}
if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0)
diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php
index 3e8eb04c430..36af8bfa875 100644
--- a/htdocs/core/class/html.formadmin.class.php
+++ b/htdocs/core/class/html.formadmin.class.php
@@ -77,7 +77,7 @@ class FormAdmin
if ($showempty && !$multiselect)
{
$out .= 'trans("AutoDetectLang").' ';
}
@@ -115,7 +115,7 @@ class FormAdmin
}
$valuetoshow .= ' '.picto_from_langcode($key, 'class="saturatemedium"');
- if ($selected == $keytouse) {
+ if ((string) $selected == (string) $keytouse) {
$out .= ''.$valuetoshow.' ';
} else {
$out .= ''.$valuetoshow.' ';
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index e84a6716134..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
@@ -1029,11 +1029,10 @@ class FormCompany extends Form
public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0)
{
// phpcs:enable
- global $langs;
+ global $conf, $langs;
$out = '';
- if ($htmlname != "none")
- {
+ if ($htmlname != "none") {
$out .= '';
$out .= ' ';
$out .= ' ';
@@ -1042,8 +1041,7 @@ class FormCompany extends Form
$out .= ' ';
$out .= ' ';
} else {
- if ($selected)
- {
+ if ($selected) {
$arr = $this->typent_array(0);
$typent = $arr[$selected];
$out .= $typent;
@@ -1052,7 +1050,10 @@ class FormCompany extends Form
}
}
- if ($nooutput) return $out;
- else print $out;
+ if ($nooutput) {
+ return $out;
+ } else {
+ print $out;
+ }
}
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index c9c895148bf..c53bc1a0750 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -450,7 +450,7 @@ class FormFile
if ($modulepart == 'company')
{
- $showempty = 1;
+ $showempty = 1; // can have no template active
if (is_array($genallowed)) $modellist = $genallowed;
else {
include_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php';
@@ -514,6 +514,7 @@ class FormFile
}
} elseif ($modulepart == 'contract')
{
+ $showempty = 1; // can have no template active
if (is_array($genallowed)) $modellist = $genallowed;
else {
include_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
@@ -577,6 +578,7 @@ class FormFile
}
} elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice')
{
+ $showempty = 1; // can have no template active
if (is_array($genallowed)) $modellist = $genallowed;
else {
include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index d81d1ef2156..e8b291ebfca 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -1257,7 +1257,7 @@ class FormMail extends Form
$sql .= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')";
}
if ($id > 0) {
- $sql .= " AND rowid=".$id;
+ $sql .= " AND rowid=".(int) $id;
}
if ($id == -1) {
$sql .= " AND position=0";
@@ -1331,6 +1331,8 @@ class FormMail extends Form
return $ret;
} else {
dol_print_error($db);
+ $this->error=$db->lasterror;
+ $this->errors[]=$db->lasterror;
return -1;
}
}
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index d7cf03c41e0..c1837af4c56 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -247,6 +247,18 @@ class FormTicket
$doleditor->Create();
print '';
+ if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
+ print ''.$langs->trans("SecurityCode").' ';
+ print '';
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print ''.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').' ';
+ print ' ';
+ print ' ';
+ }
// Attached files
if (!empty($this->withfile)) {
@@ -368,7 +380,9 @@ class FormTicket
if (response.num) {
var selecthtml_str = response.value;
var selecthtml_dom=$.parseHTML(selecthtml_str);
- $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
+ $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ }
} else {
$("#inputautocomplete"+htmlname).val("");
}
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index ac9285363d7..c2850990ff5 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -113,7 +113,12 @@ class Translate
} else $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
} else { // If it's for a codetouse that is a short code xx
// Array to convert short lang code into long code.
- $longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'ja'=>'ja_JP', 'nb'=>'nb_NO', 'no'=>'nb_NO');
+ $longforshort = array(
+ 'am'=>'am_ET', 'ar'=>'ar_SA', 'bn'=>'bn_DB', 'el'=>'el_GR', 'ca'=>'ca_ES', 'cs'=>'cs_CZ', 'en'=>'en_US', 'fa'=>'fa_IR',
+ 'gl'=>'gl_ES', 'he'=>'he_IL', 'hi'=>'hi_IN', 'ja'=>'ja_JP',
+ 'ka'=>'ka_GE', 'km'=>'km_KH', 'kn'=>'kn_IN', 'ko'=>'ko_KR', 'lo'=>'lo_LA', 'nb'=>'nb_NO', 'no'=>'nb_NO', 'ne'=>'ne_NP',
+ 'sl'=>'sl_SI', 'sq'=>'sq_AL', 'sr'=>'sr_RS', 'sv'=>'sv_SE', 'uk'=>'uk_UA', 'vi'=>'vi_VN', 'zh'=>'zh_CN'
+ );
if (isset($longforshort[strtolower($langpart[0])])) $srclang = $longforshort[strtolower($langpart[0])];
elseif (!empty($langpart[0])) $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang = 'en_US';
@@ -455,7 +460,7 @@ class Translate
$tmparray = dol_getcache($usecachekey);
if (is_array($tmparray) && count($tmparray))
{
- $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
+ $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
//print $newdomain."\n";
//var_dump($this->tab_translate);
$fileread = 1;
diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php
index e35fefdad6f..9cf8439483a 100644
--- a/htdocs/core/class/utils.class.php
+++ b/htdocs/core/class/utils.class.php
@@ -62,13 +62,16 @@ class Utils
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- if (empty($choices)) $choices = 'tempfilesold,logfiles';
+ if (empty($choices)) {
+ $choices = 'tempfilesold+logfiles';
+ }
dol_syslog("Utils::purgeFiles choice=".$choices, LOG_DEBUG);
$count = 0;
$countdeleted = 0;
$counterror = 0;
+ $filelog = '';
$choicesarray = preg_split('/[\+,]/', $choices);
foreach ($choicesarray as $choice) {
@@ -109,7 +112,6 @@ class Utils
$filesarray = dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*(\.gz)?$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1);
}
- $filelog = '';
if (!empty($conf->syslog->enabled))
{
$filelog = $conf->global->SYSLOG_FILE;
@@ -143,8 +145,7 @@ class Utils
if ($filesarray[$key]['fullname'] != $filelog || $choice == 'logfile' || $choice == 'logfiles')
{
$result = dol_delete_file($filesarray[$key]['fullname'], 1, 1);
- if ($result)
- {
+ if ($result) {
$count++;
$countdeleted++;
} else {
@@ -166,7 +167,9 @@ class Utils
if ($count > 0) {
$this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
- if ($count > $countdeleted) $this->output .= ' '.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
+ if ($count > $countdeleted) {
+ $this->output .= ' '.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
+ }
} else {
$this->output = $langs->trans("PurgeNothingToDelete").(in_array('tempfilesold', $choicesarray) ? ' (older than 24h for temp files)' : '');
}
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index 382f12840d7..ee95a13208f 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -183,17 +183,18 @@ function getObjectFromID(id){
}
// Called after selection of a date to save details into detailed fields
-function dpChangeDay(dateFieldID,format)
+function dpChangeDay(dateFieldID, format)
{
//showDP.datefieldID=dateFieldID;
- console.log("Call dpChangeDay, we save date into detailed fields.");
+ console.log("Call dpChangeDay, we save date into detailed fields from format = "+format);
var thefield=getObjectFromID(dateFieldID);
var thefieldday=getObjectFromID(dateFieldID+"day");
var thefieldmonth=getObjectFromID(dateFieldID+"month");
var thefieldyear=getObjectFromID(dateFieldID+"year");
- var date=getDateFromFormat(thefield.value,format);
+ var date=getDateFromFormat(thefield.value, format);
+ //console.log(date);
if (date)
{
thefieldday.value=date.getDate();
@@ -573,11 +574,12 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
$.each(data, function(key, value) {
$("#set_" + key).hide();
$("#del_" + key).show();
- $.get( url, {
+ $.post( url, {
action: "set",
name: key,
value: value,
- entity: entity
+ entity: entity,
+ token: token
});
});
}
@@ -643,10 +645,11 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
$.each(data, function(key, value) {
$("#del_" + value).hide();
$("#set_" + value).show();
- $.get( url, {
+ $.post( url, {
action: "del",
name: value,
- entity: entity
+ entity: entity,
+ token: token
});
});
}
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index f8dd34ce0ac..8e71f8255e8 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -137,9 +137,10 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
update: update, textarea: textarea,
pbq: item.pbq,
type: item.type, qty: item.qty, discount: item.discount,
- pricebasetype: item.pricebasetype, price_ht: item.price_ht,
+ pricebasetype: item.pricebasetype,
+ price_ht: item.price_ht,
price_ttc: item.price_ttc,
- up: item.up, description : item.description,
+ description : item.description,
ref_customer: item.ref_customer }
}));
}
@@ -152,32 +153,24 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
console.log("We will trigger change on input '.$htmlname.' because of the select definition of autocomplete code for input#search_'.$htmlname.'");
console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective");
- console.log("Propagate before some properties");
+ console.log("Propagate before some properties retrieved by ajax into data-xxx properties");
- //console.log(ui.item);
- //For supplier price
- $("#'.$htmlname.'").attr("data-up", ui.item.up);
- $("#'.$htmlname.'").attr("data-discount", ui.item.discount);
+ // For supplier price and customer when price by quantity is off
+ $("#'.$htmlname.'").attr("data-up", ui.item.price_ht);
+ $("#'.$htmlname.'").attr("data-base", ui.item.pricebasetype);
$("#'.$htmlname.'").attr("data-qty", ui.item.qty);
+ $("#'.$htmlname.'").attr("data-discount", ui.item.discount);
$("#'.$htmlname.'").attr("data-description", ui.item.description);
$("#'.$htmlname.'").attr("data-ref-customer", ui.item.ref_customer);
-
- //For customer price
- ';
+ ';
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
$script .= '
- $("#' . $htmlname . '").attr("data-pbq", ui.item.pbq);
- $("#' . $htmlname . '").attr("data-pbqup", ui.item.price_ht);
- $("#' . $htmlname . '").attr("data-pbqbase", ui.item.pricebasetype);
- $("#' . $htmlname . '").attr("data-pbqqty", ui.item.qty);
- $("#' . $htmlname . '").attr("data-pbqpercent", ui.item.discount);
- ';
- } else {
- $script .= '
- $("#' . $htmlname . '").attr("data-up", ui.item.price_ht);
- $("#' . $htmlname . '").attr("data-base", ui.item.pricebasetype);
- $("#' . $htmlname . '").attr("data-qty", ui.item.qty);
- $("#' . $htmlname . '").attr("data-discount", ui.item.discount);
+ // For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on
+ $("#'.$htmlname.'").attr("data-pbq", ui.item.pbq);
+ $("#'.$htmlname.'").attr("data-pbqup", ui.item.price_ht);
+ $("#'.$htmlname.'").attr("data-pbqbase", ui.item.pricebasetype);
+ $("#'.$htmlname.'").attr("data-pbqqty", ui.item.qty);
+ $("#'.$htmlname.'").attr("data-pbqpercent", ui.item.discount);
';
}
$script .= '
@@ -217,6 +210,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
console.log("Make action update on each ui.item.update")
// loop on each "update" fields
$.each(ui.item.update, function(key, value) {
+ console.log("Set value "+value+" into #"+key);
$("#" + key).val(value).trigger("change");
});
}
@@ -500,7 +494,9 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
if (response.num) {
var selecthtml_str = response.value;
var selecthtml_dom=$.parseHTML(selecthtml_str);
- $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
+ $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ }
} else {
$("#inputautocomplete"+htmlname).val("");
}
diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php
index 5fddf4f1c46..96355704c96 100644
--- a/htdocs/core/lib/asset.lib.php
+++ b/htdocs/core/lib/asset.lib.php
@@ -80,7 +80,7 @@ function asset_prepare_head(Asset $object)
$h = 0;
$head = array();
- $head[$h][0] = DOL_URL_ROOT.'/asset/card.php';
+ $head[$h][0] = DOL_URL_ROOT.'/asset/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index a424657e206..310f34a86fb 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -7,7 +7,7 @@
* Copyright (C) 2013-2014 Juanjo Menent
* Copyright (C) 2013 Christophe Battarel
* Copyright (C) 2013-2018 Alexandre Spangaro
- * Copyright (C) 2015-2019 Frédéric France
+ * Copyright (C) 2015-2021 Frédéric France
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2017 Rui Strecht
* Copyright (C) 2018 Ferran Marcet
@@ -53,20 +53,32 @@ 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) {
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
- $nbContact = 0; // TODO
+ $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);
- $sql = "SELECT COUNT(p.rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
- $sql .= " WHERE p.fk_soc = ".$object->id;
- $resql = $db->query($sql);
- if ($resql) {
- $obj = $db->fetch_object($resql);
- if ($obj) $nbContact = $obj->nb;
+ if (!is_null($dataretrieved)) {
+ $nbContact = $dataretrieved;
+ } else {
+ $sql = "SELECT COUNT(p.rowid) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
+ $sql .= " WHERE p.fk_soc = ".$object->id;
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ $nbContact = $obj->nb;
+ }
+
+ 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;
$head[$h][1] = $langs->trans('ContactsAddresses');
- if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.' ';
+ if ($nbContact > 0) {
+ $head[$h][1] .= ''.$nbContact.' ';
+ }
$head[$h][2] = 'contact';
$h++;
}
@@ -74,7 +86,9 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
$head[$h][1] = $langs->trans("ContactsAddresses");
- if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.' ';
+ if ($nbContact > 0) {
+ $head[$h][1] .= ''.$nbContact.' ';
+ }
$head[$h][2] = 'contact';
$h++;
}
@@ -82,9 +96,15 @@ function societe_prepare_head(Societe $object)
if ($object->client == 1 || $object->client == 2 || $object->client == 3) {
$head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id;
$head[$h][1] = '';
- if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect");
- if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) $head[$h][1] .= ' | ';
- if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) $head[$h][1] .= $langs->trans("Customer");
+ if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) {
+ $head[$h][1] .= $langs->trans("Prospect");
+ }
+ if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) {
+ $head[$h][1] .= ' | ';
+ }
+ if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) {
+ $head[$h][1] .= $langs->trans("Customer");
+ }
$head[$h][2] = 'customer';
$h++;
@@ -98,7 +118,9 @@ function societe_prepare_head(Societe $object)
}
}
$supplier_module_enabled = 0;
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1;
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ $supplier_module_enabled = 1;
+ }
if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
$head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Supplier");
@@ -107,26 +129,33 @@ function societe_prepare_head(Societe $object)
}
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
+ $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 {
+ $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");
- $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) {
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $obj = $db->fetch_object($resql);
- $nbNote = $obj->nb;
- $i++;
- }
- } else {
- dol_print_error($db);
+ if ($nbProject > 0) {
+ $head[$h][1] .= ''.$nbProject.' ';
}
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.' ';
$head[$h][2] = 'project';
$h++;
}
@@ -180,12 +209,16 @@ function societe_prepare_head(Societe $object)
//$title = $langs->trans("BankAccountsAndGateways");
$servicestatus = 0;
- if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) $servicestatus = 1;
+ if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
+ $servicestatus = 1;
+ }
include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
$societeaccount = new SocieteAccount($db);
$stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_...
- if ($stripecu) $foundonexternalonlinesystem++;
+ if ($stripecu) {
+ $foundonexternalonlinesystem++;
+ }
}
$sql = "SELECT COUNT(n.rowid) as nb";
@@ -199,13 +232,8 @@ function societe_prepare_head(Societe $object)
$resql = $db->query($sql);
if ($resql) {
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $obj = $db->fetch_object($resql);
- $nbBankAccount = $obj->nb;
- $i++;
- }
+ $obj = $db->fetch_object($resql);
+ $nbBankAccount = $obj->nb;
} else {
dol_print_error($db);
}
@@ -214,8 +242,11 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
$head[$h][1] = $title;
- if ($foundonexternalonlinesystem) $head[$h][1] .= '... ';
- elseif ($nbBankAccount > 0) $head[$h][1] .= ''.$nbBankAccount.' ';
+ if ($foundonexternalonlinesystem) {
+ $head[$h][1] .= '... ';
+ } elseif ($nbBankAccount > 0) {
+ $head[$h][1] .= ''.$nbBankAccount.' ';
+ }
$head[$h][2] = 'rib';
$h++;
}
@@ -229,17 +260,14 @@ function societe_prepare_head(Societe $object)
$sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0';
$resql = $db->query($sql);
if ($resql) {
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $obj = $db->fetch_object($resql);
- $nbNote = $obj->nb;
- $i++;
- }
+ $obj = $db->fetch_object($resql);
+ $nbNote = $obj->nb;
} else {
dol_print_error($db);
}
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.' ';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.' ';
+ }
$head[$h][2] = 'website';
$h++;
}
@@ -253,50 +281,75 @@ function societe_prepare_head(Societe $object)
if ($user->socid == 0) {
// Notifications
if (!empty($conf->notification->enabled)) {
- $nbNote = 0;
- $sql = "SELECT COUNT(n.rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
- $sql .= " WHERE fk_soc = ".$object->id;
- $resql = $db->query($sql);
- if ($resql) {
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $obj = $db->fetch_object($resql);
- $nbNote = $obj->nb;
- $i++;
- }
+ $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)) {
+ $nbNotif = $dataretrieved;
} else {
- dol_print_error($db);
+ $sql = "SELECT COUNT(n.rowid) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
+ $sql .= " WHERE fk_soc = ".$object->id;
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ $nbNotif = $obj->nb;
+ } else {
+ dol_print_error($db);
+ }
+ 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;
$head[$h][1] = $langs->trans("Notifications");
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.' ';
+ if ($nbNotif > 0) {
+ $head[$h][1] .= ''.$nbNotif.' ';
+ }
$head[$h][2] = 'notify';
$h++;
}
// Notes
$nbNote = 0;
- if (!empty($object->note_private)) $nbNote++;
- if (!empty($object->note_public)) $nbNote++;
+ if (!empty($object->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_public)) {
+ $nbNote++;
+ }
$head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Notes");
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.' ';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.' ';
+ }
$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++;
}
@@ -304,17 +357,41 @@ 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))) {
+ $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)) {
+ $nbEvent = $dataretrieved;
+ } else {
+ $sql = "SELECT COUNT(id) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
+ $sql .= " WHERE fk_soc = ".$object->id;
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ $nbEvent = $obj->nb;
+ } else {
+ dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
+ }
+ dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
+ }
+
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
+ if ($nbEvent > 0) {
+ $head[$h][1] .= ''.$nbEvent.' ';
+ }
}
$head[$h][2] = 'agenda';
$h++;
// Log
/*$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id;
- $head[$h][1] = $langs->trans("Info");
- $head[$h][2] = 'info';
- $h++;*/
+ $head[$h][1] = $langs->trans("Info");
+ $head[$h][2] = 'info';
+ $h++;*/
complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'remove');
@@ -412,16 +489,27 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '',
// Check parameters
if (empty($searchkey) && empty($searchlabel)) {
- if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>'');
- else return '';
+ if ($withcode === 'all') {
+ return array('id'=>'', 'code'=>'', 'label'=>'');
+ } else {
+ return '';
+ }
+ }
+ if (!is_object($dbtouse)) {
+ $dbtouse = $db;
+ }
+ if (!is_object($outputlangs)) {
+ $outputlangs = $langs;
}
- if (!is_object($dbtouse)) $dbtouse = $db;
- if (!is_object($outputlangs)) $outputlangs = $langs;
$sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country";
- if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey;
- elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'";
- else $sql .= " WHERE label='".$db->escape($searchlabel)."'";
+ if (is_numeric($searchkey)) {
+ $sql .= " WHERE rowid=".$searchkey;
+ } elseif (!empty($searchkey)) {
+ $sql .= " WHERE code='".$db->escape($searchkey)."'";
+ } else {
+ $sql .= " WHERE label='".$db->escape($searchlabel)."'";
+ }
$resql = $dbtouse->query($sql);
if ($resql) {
@@ -433,17 +521,25 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '',
if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label;
else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label;
}
- if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code";
- elseif ($withcode == 2) $result = $obj->code;
- elseif ($withcode == 3) $result = $obj->rowid;
- elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label);
- else $result = $label;
+ if ($withcode == 1) {
+ $result = $label ? "$obj->code - $label" : "$obj->code";
+ } elseif ($withcode == 2) {
+ $result = $obj->code;
+ } elseif ($withcode == 3) {
+ $result = $obj->rowid;
+ } elseif ($withcode === 'all') {
+ $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label);
+ } else {
+ $result = $label;
+ }
} else {
$result = 'NotDefined';
}
$dbtouse->free($resql);
return $result;
- } else dol_print_error($dbtouse, '');
+ } else {
+ dol_print_error($dbtouse, '');
+ }
return 'Error';
}
@@ -466,7 +562,9 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan
{
global $db, $langs;
- if (!is_object($dbtouse)) $dbtouse = $db;
+ if (!is_object($dbtouse)) {
+ $dbtouse = $db;
+ }
$sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM";
$sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c";
@@ -529,7 +627,9 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null)
{
global $langs, $db;
- if (empty($outputlangs)) $outputlangs = $langs;
+ if (empty($outputlangs)) {
+ $outputlangs = $langs;
+ }
$outputlangs->load("dict");
@@ -549,8 +649,11 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null)
if ($num) {
$obj = $db->fetch_object($resql);
$label = ($obj->label != '-' ? $obj->label : '');
- if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label";
- else return $label;
+ if ($withcode) {
+ return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label";
+ } else {
+ return $label;
+ }
} else {
return $code_iso;
}
@@ -895,8 +998,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_status = '';
- $search_name = '';
- $search_roles = array();
+ $search_name = '';
+ $search_roles = array();
$search_address = '';
$search_poste = '';
$search = array();
@@ -989,7 +1092,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
} elseif (in_array($key, array('role'))) {
print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles);
} else {
- print ' ';
+ print ' ';
}
print '';
}
@@ -1260,14 +1363,27 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql .= " a.fk_contact,";
$sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
$sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
- if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= ", sp.lastname, sp.firstname";
- elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname";
- elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref";
- elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref";
- elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref";
- elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref";
- elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref";
- elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", o.ref";
+ if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) {
+ $sql .= ", sp.lastname, sp.firstname";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
+ /* Nothing */
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') {
+ /* Nothing */
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
+ $sql .= ", m.lastname, m.firstname";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
+ $sql .= ", o.ref";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
+ $sql .= ", o.ref";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
+ $sql .= ", o.ref";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
+ $sql .= ", o.ref";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
+ $sql .= ", o.ref";
+ } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) {
+ $sql .= ", o.ref";
+ }
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
@@ -1286,7 +1402,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql .= " ON er.resource_type = 'dolresource'";
$sql .= " AND er.element_id = a.id";
$sql .= " AND er.resource_id = ".$filterobj->id;
- } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m";
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') {
+ /* Nothing */
+ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m";
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o";
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o";
diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php
index c72c46c8916..10f8d37a3c8 100644
--- a/htdocs/core/lib/contract.lib.php
+++ b/htdocs/core/lib/contract.lib.php
@@ -70,7 +70,7 @@ function contract_prepare_head(Contrat $object)
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- $upload_dir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->contrat->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id;
diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php
index fda122be7bf..9702c8ab1dc 100644
--- a/htdocs/core/lib/cron.lib.php
+++ b/htdocs/core/lib/cron.lib.php
@@ -99,10 +99,10 @@ function dol_print_cron_urls()
// Cron launch
print '';
print $langs->trans("URLToLaunchCronJobs").':
';
- $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
+ $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
print img_picto('', 'globe').'
'.$url." \n";
print ' '.$langs->trans("OrToLaunchASpecificJob").'
';
- $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
+ $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
print img_picto('', 'globe').'
'.$url." \n";
print '
';
print ' ';
diff --git a/htdocs/core/lib/eventorganization.lib.php b/htdocs/core/lib/eventorganization.lib.php
new file mode 100644
index 00000000000..80dc72b50e5
--- /dev/null
+++ b/htdocs/core/lib/eventorganization.lib.php
@@ -0,0 +1,62 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file eventorganization/lib/eventorganization.lib.php
+ * \ingroup eventorganization
+ * \brief Library files with common functions for EventOrganization
+ */
+
+/**
+ * Prepare admin pages header
+ *
+ * @return array
+ */
+function eventorganizationAdminPrepareHead()
+{
+ global $langs, $conf;
+
+ $langs->load("eventorganization");
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/admin/eventorganization.php';
+ $head[$h][1] = $langs->trans("Settings");
+ $head[$h][2] = 'settings';
+ $h++;
+
+
+ $head[$h][0] = DOL_URL_ROOT.'/admin/eventorganization_confbooth_extrafields.php';
+ $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("EventOrganizationConfOrBooth").")";
+ $head[$h][2] = 'eventorganization_extrafields';
+ $h++;
+
+ // Show more tabs from modules
+ // Entries must be declared in modules descriptor with line
+ //$this->tabs = array(
+ // 'entity:+tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
+ //); // to add new tab
+ //$this->tabs = array(
+ // 'entity:-tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
+ //); // to remove a tab
+ complete_head_from_modules($conf, $langs, null, $head, $h, 'eventorganization');
+
+ complete_head_from_modules($conf, $langs, null, $head, $h, 'eventorganization', 'remove');
+
+ return $head;
+}
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 1bdaeef13ef..14701d57256 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -1192,6 +1192,16 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
{
if ($nophperrors) $ok = @unlink($filename);
else $ok = unlink($filename);
+
+ // If it fails and it is because of the missing write permission on parent dir
+ if (!$ok && file_exists(dirname($filename)) && !(fileperms(dirname($filename)) & 0200)) {
+ dol_syslog("Error in deletion, but parent directory exists with no permission to write, we try to change permission on parent directory and retry...", LOG_DEBUG);
+ @chmod(dirname($filename), fileperms(dirname($filename)) | 0200);
+ // Now we retry deletion
+ if ($nophperrors) $ok = @unlink($filename);
+ else $ok = unlink($filename);
+ }
+
if ($ok)
{
dol_syslog("Removed file ".$filename, LOG_DEBUG);
@@ -2316,10 +2326,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if ($fuser->rights->ficheinter->{$lire}) $accessallowed = 1;
$original_file = $conf->ficheinter->dir_output.'/'.$original_file;
} // Wrapping pour les apercu conat
- elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output))
+ elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->multidir_output[$entity]))
{
if ($fuser->rights->contrat->{$lire}) $accessallowed = 1;
- $original_file = $conf->contrat->dir_output.'/'.$original_file;
+ $original_file = $conf->contrat->multidir_output[$entity].'/'.$original_file;
} // Wrapping pour les apercu supplier proposal
elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output))
{
@@ -2709,13 +2719,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
if (!empty($conf->stock->enabled)) $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file;
} // Wrapping pour les contrats
- elseif ($modulepart == 'contract' && !empty($conf->contrat->dir_output))
+ elseif ($modulepart == 'contract' && !empty($conf->contrat->multidir_output[$entity]))
{
if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file))
{
$accessallowed = 1;
}
- $original_file = $conf->contrat->dir_output.'/'.$original_file;
+ $original_file = $conf->contrat->multidir_output[$entity].'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")";
} // Wrapping pour les dons
elseif ($modulepart == 'donation' && !empty($conf->don->dir_output))
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c71ba0bfc96..5457a6859e3 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -13,7 +13,7 @@
* Copyright (C) 2014 Cédric GROSS
* Copyright (C) 2014-2015 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
* Copyright (C) 2019 Thibault Foucart
* Copyright (C) 2020 Open-Dsi
* Copyright (C) 2021 Gauthier VERDOL
@@ -1970,7 +1970,7 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
* "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S",
* "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day
- * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...reduceformat"
+ * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...inputnoreduce", "...reduceformat"
* @param string $tzoutput true or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage
* 'tzuser' => output string is for user TZ (current browser TZ with current dst) => In a future, we should have same behaviour than 'tzuserrel'
@@ -2014,13 +2014,17 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
}
if (!is_object($outputlangs)) $outputlangs = $langs;
if (!$format) $format = 'daytextshort';
- $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
+
+ // Do we have to reduce the length of date (year on 2 chars) to save space.
+ // Note: dayinputnoreduce is same than day but no reduction of year length will be done
+ $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; // Test on original $format param.
+ $format = preg_replace('/inputnoreduce/', '', $format); // so format 'dayinputnoreduce' is processed like day
$formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day
// Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
// TODO Add format daysmallyear and dayhoursmallyear
- if ($format == 'day') $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short);
+ if ($format == 'day') $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short);
elseif ($format == 'hour') $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short);
elseif ($format == 'hourduration') $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration);
elseif ($format == 'daytext') $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text);
@@ -2446,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;
}
@@ -2480,12 +2495,14 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
$htmllink = $value;
- if (empty($value)) return ' ';
+ if (empty($value)) {
+ return ' ';
+ }
if (!empty($type)) {
$htmllink = '';
- // TODO use dictionary definition for picto $dictsocialnetworks[$type]['icon']
- $htmllink .= img_picto($langs->trans(dol_ucfirst($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0);
+ // Use dictionary definition for picto $dictsocialnetworks[$type]['icon']
+ $htmllink .= '
';
if ($type == 'skype') {
$htmllink .= $value;
$htmllink .= ' ';
@@ -2501,7 +2518,9 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
$addlink = 'AC_SKYPE';
$link = '';
- if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = '
'.img_object($langs->trans("AddAction"), "calendar").' ';
+ if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
+ $link = '
'.img_object($langs->trans("AddAction"), "calendar").' ';
+ }
$htmllink .= ($link ? ' '.$link : '');
}
} else {
@@ -3165,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.
*/
@@ -3181,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';
+ }
}
/**
@@ -3228,7 +3258,7 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
* Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img
* Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img
* Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)
- * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"')
+ * @param string $moreatt Add more attribute on img tag (For example 'class="pictofixedwidth"')
* @param boolean|int $pictoisfullpath If true or 1, image path is a full path
* @param int $srconly Return only content of the src attribute of img.
* @param int $notitle 1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip.
@@ -3241,7 +3271,6 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0, $alt = '', $morecss = '', $marginleftonlyshort = 2)
{
global $conf, $langs;
-
// We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_URL_ROOT/theme/$conf->theme/img/$picto
$url = DOL_URL_ROOT;
$theme = isset($conf->theme) ? $conf->theme : null;
@@ -3262,7 +3291,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
if (empty($srconly) && in_array($pictowithouttext, array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
- 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building',
+ 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building',
'cash-register', 'category', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes',
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt',
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group',
@@ -3270,11 +3299,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot',
'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next',
'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom',
- 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder',
+ 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert',
+ 'object_folder', 'object_folder-open','object_generic',
'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser',
'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_donation', 'object_dynamicprice',
'object_globe', 'object_holiday', 'object_hrm', 'object_invoice', 'object_intervention', 'object_label',
- 'object_margin', 'object_money-bill-alt', 'object_multicurrency', 'object_order', 'object_payment',
+ 'object_margin', 'object_members', 'object_money-bill-alt', 'object_multicurrency', 'object_order', 'object_payment',
'object_lot', 'object_mrp', 'object_other',
'object_payment', 'object_pdf', 'object_product', 'object_propal',
'object_paragraph', 'object_poll', 'object_printer', 'object_project', 'object_projectpub', 'object_propal', 'object_resource', 'object_rss', 'object_projecttask',
@@ -3288,11 +3318,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies',
'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
- 'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'supplier_invoice', 'ticket',
+ 'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'shipment', 'supplier_invoice', 'technic', 'ticket',
'error', 'warning',
'recruitmentcandidature', 'recruitmentjobposition', 'resource',
'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'user-cog',
- 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda'
+ 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda',
+ 'eventorganization', 'object_eventorganization'
)
)) {
$pictowithouttext = str_replace('object_', '', $pictowithouttext);
@@ -3314,11 +3345,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd',
'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins',
'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly',
- 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'users', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode',
+ 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode',
'email'=>'at',
'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle',
'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group', 'loan'=>'money-bill-alt',
- 'member'=>'users', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
+ 'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'group'=>'users', 'movement'=>'people-carry',
'sign-out'=>'sign-out-alt',
'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star',
@@ -3337,7 +3368,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'title_agenda'=>'calendar-alt',
'uparrow'=>'mail-forward', 'vcard'=>'address-card',
'jabber'=>'comment-o',
- 'website'=>'globe-americas'
+ 'website'=>'globe-americas',
+ 'eventorganization'=>'id-badge'
);
if ($pictowithouttext == 'off') {
$fakey = 'fa-square';
@@ -3365,11 +3397,14 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$fakey = 'fa-'.$pictowithouttext;
}
- if (in_array($pictowithouttext, array('member', 'contract'))) {
- $fasize = '0.92em';
+ if (in_array($pictowithouttext, array('holiday', 'dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) {
+ $morecss = 'em092';
}
- if (in_array($pictowithouttext, array('intervention', 'payment', 'loan'))) {
- $fasize = '0.80em';
+ if (in_array($pictowithouttext, array('holiday'))) {
+ $morecss = 'em088';
+ }
+ if (in_array($pictowithouttext, array('intervention', 'payment', 'loan', 'stock', 'technic'))) {
+ $morecss = 'em080';
}
// Define $marginleftonlyshort
@@ -3418,7 +3453,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944',
'other'=>'#ddd',
'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba',
- 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa',
+ 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa',
'website'=>'#304'
);
if (isset($arrayconvpictotocolor[$pictowithouttext])) {
@@ -6242,17 +6277,19 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
)
);
- $substitutionarray = array_merge($substitutionarray, array(
- '__USER_ID__' => (string) $user->id,
- '__USER_LOGIN__' => (string) $user->login,
- '__USER_EMAIL__' => (string) $user->email,
- '__USER_LASTNAME__' => (string) $user->lastname,
- '__USER_FIRSTNAME__' => (string) $user->firstname,
- '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
- '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'),
- '__USER_REMOTE_IP__' => (string) getUserRemoteIP()
- )
+ if (is_object($user)) {
+ $substitutionarray = array_merge($substitutionarray, array(
+ '__USER_ID__' => (string) $user->id,
+ '__USER_LOGIN__' => (string) $user->login,
+ '__USER_EMAIL__' => (string) $user->email,
+ '__USER_LASTNAME__' => (string) $user->lastname,
+ '__USER_FIRSTNAME__' => (string) $user->firstname,
+ '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
+ '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'),
+ '__USER_REMOTE_IP__' => (string) getUserRemoteIP()
+ )
);
+ }
}
if ((empty($exclude) || !in_array('mycompany', $exclude)) && is_object($mysoc))
{
@@ -6266,7 +6303,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
'__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
'__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
'__MYCOMPANY_CAPITAL__' => $mysoc->capital,
- '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1, ', '),
+ '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc, 'getFullAddress') ? $mysoc->getFullAddress(1, ', ') : ''), // $mysoc may be stdClass
'__MYCOMPANY_ADDRESS__' => $mysoc->address,
'__MYCOMPANY_ZIP__' => $mysoc->zip,
'__MYCOMPANY_TOWN__' => $mysoc->town,
@@ -6371,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));
@@ -6547,6 +6591,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'commande') $typeforonlinepayment = 'order';
if (is_object($object) && $object->element == 'facture') $typeforonlinepayment = 'invoice';
if (is_object($object) && $object->element == 'member') $typeforonlinepayment = 'member';
+ if (is_object($object) && $object->element == 'contrat') $typeforonlinepayment = 'contract';
$url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']);
$paymenturl = $url;
}
@@ -6568,10 +6613,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
{
$substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
} else $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
+ if (!empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'contrat')
+ {
+ $substitutionarray['__DIRECTDOWNLOAD_URL_CONTRACT__'] = $object->getLastMainDocLink($object->element);
+ } else $substitutionarray['__DIRECTDOWNLOAD_URL_CONTRACT__'] = '';
if (is_object($object) && $object->element == 'propal') $substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id;
if (is_object($object) && $object->element == 'commande') $substitutionarray['__URL_ORDER__'] = DOL_MAIN_URL_ROOT."/commande/card.php?id=".$object->id;
if (is_object($object) && $object->element == 'facture') $substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id;
+ if (is_object($object) && $object->element == 'contrat') $substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'action')
@@ -7868,7 +7918,10 @@ function printCommonFooter($zone = 'private')
// Add property 'required' on input
print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
- print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr
+ print '// required on a select works only if key is "", so we add the required attributes but also we reset the key -1 or 0 to an empty string'."\n";
+ print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
+ print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'-1\']").prop(\'value\', \'\');'."\n";
+ print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'0\']").prop(\'value\', \'\');'."\n";
}
}
}
@@ -8197,7 +8250,7 @@ function showDirectDownloadLink($object)
if ($url)
{
- $out .= img_picto('', 'globe').' '.$langs->trans("DirectDownloadLink").'
';
+ $out .= img_picto($langs->trans("PublicDownloadLinkdesc"), 'globe').' '.$langs->trans("DirectDownloadLink").'
';
$out .= '
';
$out .= ajax_autoselect("directdownloadlink", 0);
}
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 453bc34be8a..eda1a901986 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -189,7 +189,7 @@ function invoice_rec_prepare_head($object)
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/card-rec.php?id='.$object->id;
- $head[$h][1] = $langs->trans("CardBill");
+ $head[$h][1] = $langs->trans("RepeatableInvoice");
$head[$h][2] = 'card';
$h++;
diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php
index 7b863391b24..484b3933e42 100644
--- a/htdocs/core/lib/memory.lib.php
+++ b/htdocs/core/lib/memory.lib.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 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
@@ -23,11 +24,34 @@
global $shmkeys, $shmoffset;
-$shmkeys = array('main'=>1, 'admin'=>2, 'dict'=>3, 'companies'=>4, 'suppliers'=>5, 'products'=>6,
- 'commercial'=>7, 'compta'=>8, 'projects'=>9, 'cashdesk'=>10, 'agenda'=>11, 'bills'=>12,
- 'propal'=>13, 'boxes'=>14, 'banks'=>15, 'other'=>16, 'errors'=>17, 'members'=>18, 'ecm'=>19,
- 'orders'=>20, 'users'=>21, 'help'=>22, 'stocks'=>23, 'interventions'=>24,
- 'donations'=>25, 'contracts'=>26);
+$shmkeys = array(
+ 'main' => 1,
+ 'admin' => 2,
+ 'dict' => 3,
+ 'companies' => 4,
+ 'suppliers' => 5,
+ 'products' => 6,
+ 'commercial' => 7,
+ 'compta' => 8,
+ 'projects' => 9,
+ 'cashdesk' => 10,
+ 'agenda' => 11,
+ 'bills' => 12,
+ 'propal' => 13,
+ 'boxes' => 14,
+ 'banks' => 15,
+ 'other' => 16,
+ 'errors' => 17,
+ 'members' => 18,
+ 'ecm' => 19,
+ 'orders' => 20,
+ 'users' => 21,
+ 'help' => 22,
+ 'stocks' => 23,
+ 'interventions' => 24,
+ 'donations' => 25,
+ 'contracts' => 26,
+);
$shmoffset = 1000; // Max number of entries found into a language file. If too low, some entries will be overwritten.
@@ -36,60 +60,60 @@ $shmoffset = 1000; // Max number of entries found into a language file. If too l
* Save data into a memory area shared by all users, all sessions on server
*
* @param string $memoryid Memory id of shared area
- * @param string $data Data to save
- * @return int <0 if KO, Nb of bytes written if OK
+ * @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;
- // Using a memcached server
- if (!empty($conf->memcached->enabled) && class_exists('Memcached'))
- {
- global $dolmemcache;
- if (empty($dolmemcache) || !is_object($dolmemcache))
- {
- $dolmemcache = new Memcached();
- $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
- $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
- }
+ if (strpos($memoryid, 'count_') === 0) { // The memoryid key start with 'count_...'
+ if (empty($conf->global->MAIN_CACHE_COUNT)) return 0;
+ }
- $memoryid = session_name().'_'.$memoryid;
+ if (!empty($conf->memcached->enabled) && class_exists('Memcached')) {
+ // Using a memcached server
+ global $dolmemcache;
+ if (empty($dolmemcache) || !is_object($dolmemcache)) {
+ $dolmemcache = new Memcached();
+ $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
+ $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
+ if (!$result) return -1;
+ }
+
+ $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)
- {
+ if ($rescode == 0) {
return count($data);
} else {
return -$rescode;
}
- } elseif (!empty($conf->memcached->enabled) && class_exists('Memcache'))
- {
+ } elseif (!empty($conf->memcached->enabled) && class_exists('Memcache')) { // This is a really not reliable cache ! Use Memcached instead.
+ // Using a memcache server
global $dolmemcache;
- if (empty($dolmemcache) || !is_object($dolmemcache))
- {
- $dolmemcache = new Memcache();
- $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
- $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
- }
+ if (empty($dolmemcache) || !is_object($dolmemcache)) {
+ $dolmemcache = new Memcache();
+ $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
+ $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
+ if (!$result) return -1;
+ }
- $memoryid = session_name().'_'.$memoryid;
+ $memoryid = session_name() . '_' . $memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
- $result = $dolmemcache->add($memoryid, $data); // This fails if key already exists
- if ($result)
- {
+ $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists
+ if ($result) {
return count($data);
} else {
return -1;
}
- } // Using shmop
- elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
- {
- $result = dol_setshmop($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, $expire);
}
return $result;
@@ -99,67 +123,67 @@ function dol_setcache($memoryid, $data)
* Read a memory area shared by all users, all sessions on server
*
* @param string $memoryid Memory id of shared area
- * @return int <0 if KO, data if OK
+ * @return int|mixed <0 if KO, data if OK, null if not found into cache or no caching feature enabled
+ * @see dol_setcache()
*/
function dol_getcache($memoryid)
{
global $conf;
- // Using a memcached server
- if (!empty($conf->memcached->enabled) && class_exists('Memcached'))
- {
- global $m;
- if (empty($m) || !is_object($m))
- {
- $m = new Memcached();
- $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
- $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
- }
+ if (strpos($memoryid, 'count_') === 0) { // The memoryid key start with 'count_...'
+ if (empty($conf->global->MAIN_CACHE_COUNT)) return null;
+ }
- $memoryid = session_name().'_'.$memoryid;
+ // Using a memcached server
+ if (!empty($conf->memcached->enabled) && class_exists('Memcached')) {
+ global $m;
+ if (empty($m) || !is_object($m)) {
+ $m = new Memcached();
+ $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
+ $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
+ if (!$result) return -1;
+ }
+
+ $memoryid = session_name() . '_' . $memoryid;
//$m->setOption(Memcached::OPT_COMPRESSION, false);
//print "Get memoryid=".$memoryid;
$data = $m->get($memoryid);
$rescode = $m->getResultCode();
- //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n ";
+ //print "memoryid=".$memoryid." - rescode=".$rescode." - count(response)=".count($data)."\n ";
//var_dump($data);
- if ($rescode == 0)
- {
+ if ($rescode == 0) {
return $data;
+ } elseif ($rescode == 16) { // = Memcached::MEMCACHED_NOTFOUND but this constant doe snot exists.
+ return null;
} else {
return -$rescode;
}
- } elseif (!empty($conf->memcached->enabled) && class_exists('Memcache'))
- {
+ } elseif (!empty($conf->memcached->enabled) && class_exists('Memcache')) { // This is a really not reliable cache ! Use Memcached instead.
global $m;
- if (empty($m) || !is_object($m))
- {
- $m = new Memcache();
- $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
- $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
- }
+ if (empty($m) || !is_object($m)) {
+ $m = new Memcache();
+ $tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
+ $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
+ if (!$result) return -1;
+ }
- $memoryid = session_name().'_'.$memoryid;
+ $memoryid = session_name() . '_' . $memoryid;
//$m->setOption(Memcached::OPT_COMPRESSION, false);
$data = $m->get($memoryid);
//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n ";
//var_dump($data);
- if ($data)
- {
+ if ($data) {
return $data;
} else {
- return -1;
+ return null; // There is no way to make a difference between NOTFOUND and error when using Memcache. So do not use it, use Memcached instead.
}
- } // Using shmop
- elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
- {
+ } 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
$data = dol_getshmop($memoryid);
return $data;
}
- return 0;
+ return null;
}
@@ -173,7 +197,9 @@ function dol_getcache($memoryid)
function dol_getshmopaddress($memoryid)
{
global $shmkeys, $shmoffset;
- if (empty($shmkeys[$memoryid])) return 0;
+ if (empty($shmkeys[$memoryid])) { // No room reserved for thid memoryid, no way to use cache
+ return 0;
+ }
return $shmkeys[$memoryid] + $shmoffset;
}
@@ -187,10 +213,11 @@ function dol_listshmop()
global $shmkeys, $shmoffset;
$resarray = array();
- foreach ($shmkeys as $key => $val)
- {
+ foreach ($shmkeys as $key => $val) {
$result = dol_getshmop($key);
- if (!is_numeric($result) || $result > 0) $resarray[$key] = $result;
+ if (!is_numeric($result) || $result > 0) {
+ $resarray[$key] = $result;
+ }
}
return $resarray;
}
@@ -199,32 +226,33 @@ function dol_listshmop()
* Save data into a memory area shared by all users, all sessions on server
*
* @param int $memoryid Memory id of shared area ('main', 'agenda', ...)
- * @param string $data Data to save
- * @return int <0 if KO, Nb of bytes written if OK
+ * @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;
//print 'dol_setshmop memoryid='.$memoryid." \n";
if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0;
$shmkey = dol_getshmopaddress($memoryid);
+ if (empty($shmkey)) return 0; // No key reserved for this memoryid, we can't cache this memoryid
+
$newdata = serialize($data);
$size = strlen($newdata);
//print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes \n";
$handle = shmop_open($shmkey, 'c', 0644, 6 + $size);
- if ($handle)
- {
+ if ($handle) {
$shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0);
$shm_bytes_written2 = shmop_write($handle, $newdata, 6);
- if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata)))
- {
- print "Couldn't write the entire length of data\n";
+ if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata))) {
+ print "Couldn't write the entire length of data\n";
}
shmop_close($handle);
return ($shm_bytes_written1 + $shm_bytes_written2);
} else {
- print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size;
+ print 'Error in shmop_open for memoryid=' . $memoryid . ' shmkey=' . $shmkey . ' 6+size=6+' . $size;
return -1;
}
}
@@ -233,24 +261,29 @@ function dol_setshmop($memoryid, $data)
* Read a memory area shared by all users, all sessions on server
*
* @param string $memoryid Memory id of shared area ('main', 'agenda', ...)
- * @return int <0 if KO, data if OK
+ * @return int <0 if KO, data if OK, Null if no cache enabled or not found
*/
function dol_getshmop($memoryid)
{
global $shmkeys, $shmoffset;
- if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) return 0;
+ $data = null;
+
+ if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) {
+ return null;
+ }
$shmkey = dol_getshmopaddress($memoryid);
+ if (empty($shmkey)) return null; // No key reserved for this memoryid, we can't cache this memoryid
+
//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey." \n";
$handle = @shmop_open($shmkey, 'a', 0, 0);
- if ($handle)
- {
+ if ($handle) {
$size = trim(shmop_read($handle, 0, 6));
if ($size) $data = unserialize(shmop_read($handle, 6, $size));
else return -1;
shmop_close($handle);
} else {
- return -2;
+ return null; // Can't open existing block, so we suppose it was not created, so nothing were cached yet for the memoryid
}
return $data;
}
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 9bbfe1322e9..f3a123ba386 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -121,6 +121,17 @@ function project_prepare_head(Project $project)
$h++;
}
+ if ($conf->eventorganization->enabled) {
+ $langs->load('eventorganization');
+ //TODO : Count
+ $nbConfOrBooth = 1;
+ $head[$h][0] = DOL_URL_ROOT . '/projet/event.php?id=' . $project->id;
+ $head[$h][1] = $langs->trans("ConferenceOrBoothTab");
+ if ($nbContact > 0) $head[$h][1] .= '' . $nbConfOrBooth . ' ';
+ $head[$h][2] = 'eventorganisation';
+ $h++;
+ }
+
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
@@ -356,6 +367,15 @@ function project_admin_prepare_head()
$head[$h][2] = 'attributes_task';
$h++;
+ if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ $langs->load("members");
+
+ $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
+ $head[$h][1] = $langs->trans("BlankSubscriptionForm");
+ $head[$h][2] = 'website';
+ $h++;
+ }
+
complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
return $head;
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 2f1e3d5596b..9d18dd1dd85 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -165,6 +165,7 @@ function dol_verifyHash($chain, $hash, $type = '0')
/**
* Check permissions of a user to show a page and an object. Check read permission.
* If GETPOST('action','aZ09') defined, we also check write and delete permission.
+ * This method check permission on module then call checkUserAccessToObject() for permission on object (according to entity and socid of user).
*
* @param User $user User to check
* @param string $features Features to check (it must be module $object->element. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...)
@@ -175,20 +176,22 @@ function dol_verifyHash($chain, $hash, $type = '0')
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
* @param int $isdraft 1=The object with id=$objectid is a draft
* @return int Always 1, die process if not allowed
- * @see dol_check_secure_access_document()
+ * @see dol_check_secure_access_document(), checkUserAccessToObject()
*/
function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid', $isdraft = 0)
{
global $db, $conf;
global $hookmanager;
- //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename,$feature2,$dbt_socfield,$dbt_select");
+ //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft");
//print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid;
//print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select;
//print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)." ";
$parentfortableentity = '';
+ // Fix syntax of $features param
+ $originalfeatures = $features;
if ($features == 'facturerec') $features = 'facture';
if ($features == 'mo') $features = 'mrp';
if ($features == 'member') $features = 'adherent';
@@ -198,7 +201,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
if ($features == 'product') $features = 'produit';
// Get more permissions checks from hooks
- $parameters = array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select);
+ $parameters = array('features'=>$features, 'originalfeatures'=>$originalfeatures, 'objectid'=>$objectid, 'dbt_select'=>$dbt_select, 'idtype'=>$dbt_select, 'isdraft'=>$isdraft);
$reshook = $hookmanager->executeHooks('restrictedArea', $parameters);
if (isset($hookmanager->resArray['result'])) {
@@ -218,11 +221,6 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
// More subfeatures to check
if (!empty($feature2)) $feature2 = explode("|", $feature2);
- // More parameters
- $params = explode('&', $tableandshare);
- $dbtablename = (!empty($params[0]) ? $params[0] : '');
- $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
-
$listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
// Check read permission from module
@@ -247,6 +245,10 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
if (!$user->rights->banque->cheque) { $readok = 0; $nbko++; }
} elseif ($feature == 'projet') {
if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { $readok = 0; $nbko++; }
+ } elseif ($feature == 'payment') {
+ if (!$user->rights->facture->lire) { $readok = 0; $nbko++; }
+ } elseif ($feature == 'payment_supplier') {
+ if (!$user->rights->fournisseur->facture->lire) { $readok = 0; $nbko++; }
} elseif (!empty($feature2)) { // This is for permissions on 2 levels
$tmpreadok = 1;
foreach ($feature2 as $subfeature) {
@@ -426,6 +428,10 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
{
global $db, $conf;
+ //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft");
+ //print "user_id=".$user->id.", features=".join(',', $featuresarray).", feature2=".$feature2.", objectid=".$objectid;
+ //print ", tableandshare=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select." ";
+
// More parameters
$params = explode('&', $tableandshare);
$dbtablename = (!empty($params[0]) ? $params[0] : '');
@@ -440,13 +446,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
if ($feature == 'project') $feature = 'projet';
if ($feature == 'task') $feature = 'projet_task';
- $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'website'); // Test on entity only (Objects with no link to company)
+ $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'website'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for societe object
- $checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
+ $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet', 'project'); // Test for project object
$checktask = array('projet_task'); // Test for task object
$nocheck = array('barcode', 'stock'); // No test
- //$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
+ //$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...).
// If dbtablename not defined, we use same name for table than module name
if (empty($dbtablename))
@@ -455,17 +461,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too.
}
- // Check permission for object with entity
+ // Check permission for object on entity only
if (in_array($feature, $check))
{
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
- if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled))
- {
- if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
- {
- if ($conf->entity == 1 && $user->admin && !$user->entity)
- {
+ if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) { // Special for multicompany
+ if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if ($conf->entity == 1 && $user->admin && !$user->entity) {
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
$sql .= " AND dbt.entity IS NOT NULL";
} else {
@@ -490,15 +493,12 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}
- } elseif (in_array($feature, $checksoc)) // We check feature = checksoc
- {
- // If external user: Check permission for external users
- if ($user->socid > 0)
- {
+ } elseif (in_array($feature, $checksoc)) { // We check feature = checksoc
+ if ($user->socid > 0) {
+ // If external user: Check permission for external users
if ($user->socid <> $objectid) return false;
- } // If internal user: Check permission for internal users that are restricted on their objects
- elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
- {
+ } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
+ // If internal user: Check permission for internal users that are restricted on their objects
$sql = "SELECT COUNT(sc.fk_soc) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ", ".MAIN_DB_PREFIX."societe as s)";
@@ -506,15 +506,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sql .= " AND sc.fk_user = ".$user->id;
$sql .= " AND sc.fk_soc = s.rowid";
$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
- } // If multicompany and internal users with all permissions, check user is in correct entity
- elseif (!empty($conf->multicompany->enabled))
- {
+ } elseif (!empty($conf->multicompany->enabled)) {
+ // If multicompany and internal users with all permissions, check user is in correct entity
$sql = "SELECT COUNT(s.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.rowid IN (".$objectid.")";
$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
}
- } elseif (in_array($feature, $checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
+ } elseif (in_array($feature, $checkother)) // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...).
{
// If external user: Check permission for external users
if ($user->socid > 0)
@@ -590,9 +589,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql .= " WHERE dbt.rowid IN (".$objectid.")";
$sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid;
- } elseif (!empty($conf->societe->enabled)) {
+ } elseif (!empty($conf->societe->enabled) && !$user->rights->societe->client->voir) {
// If internal user: Check permission for internal users that are restricted on their objects
- if ($feature != 'ticket' && !$user->rights->societe->client->voir) {
+ if ($feature != 'ticket') {
if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
$sql = "SELECT COUNT(sc.fk_soc) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
@@ -601,9 +600,8 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
$sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield;
$sql .= " AND sc.fk_user = ".$user->id;
- }
- // On ticket, the thirdparty is not mandatory, so we need a special test to accept record with no thirdparties.
- if ($feature == 'ticket' && !$user->rights->societe->client->voir) {
+ } else {
+ // On ticket, the thirdparty is not mandatory, so we need a special test to accept record with no thirdparties.
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield." AND sc.fk_user = ".$user->id;
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('trans("MenuListAssets"), 1, $user->rights->asset->read);
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) {
- $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->setup_advance));
+ $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->setup_advance);
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
}
}
@@ -1534,7 +1536,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if ($mainmenu == 'products') {
// Products
if (!empty($conf->product->enabled)) {
- $newmenu->add("/product/index.php?leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product');
+ $newmenu->add("/product/index.php?leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product', 0, '', '', '', img_picto('', 'product', 'class="pictofixedwidth"'));
$newmenu->add("/product/card.php?leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer);
$newmenu->add("/product/list.php?leftmenu=product&type=0", $langs->trans("List"), 1, $user->rights->produit->lire);
if (!empty($conf->stock->enabled)) {
@@ -1562,7 +1564,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Services
if (!empty($conf->service->enabled)) {
- $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
+ $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service', 0, '', '', '', img_picto('', 'service', 'class="pictofixedwidth"'));
$newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer);
$newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire);
if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) {
@@ -1579,7 +1581,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Warehouse
if (!empty($conf->stock->enabled)) {
$langs->load("stocks");
- $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
+ $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'stock', 'class="pictofixedwidth"'));
$newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer);
$newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->rights->stock->lire);
$newmenu->add("/product/stock/movement_list.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
@@ -1601,7 +1603,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (!empty($conf->stock->enabled)) {
$langs->load("stocks");
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
- $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("Inventories"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
+ $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("Inventories"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock', 0, '', '', '', img_picto('', 'inventory', 'class="pictofixedwidth"'));
if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") {
$newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->rights->stock->creer);
$newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("List"), 1, $user->rights->stock->lire);
@@ -1619,7 +1621,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Shipments
if (!empty($conf->expedition->enabled)) {
$langs->load("sendings");
- $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings');
+ $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings', 0, '', '', '', img_picto('', 'shipment', 'class="pictofixedwidth"'));
$newmenu->add("/expedition/card.php?action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer);
$newmenu->add("/expedition/list.php?leftmenu=sendings", $langs->trans("List"), 1, $user->rights->expedition->lire);
if ($usemenuhider || empty($leftmenu) || $leftmenu == "sendings") {
@@ -1633,7 +1635,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Receptions
if (!empty($conf->reception->enabled)) {
$langs->load("receptions");
- $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions');
+ $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions', 0, '', '', '', img_picto('', 'dollyrevert', 'class="pictofixedwidth"'));
$newmenu->add("/reception/card.php?action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->rights->reception->creer);
$newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->rights->reception->lire);
if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
@@ -1699,7 +1701,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
}
// Project assigned to user
- $newmenu->add("/projet/index.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects');
+ $newmenu->add("/projet/index.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects', 0, '', '', '', img_picto('', 'project', 'class="pictofixedwidth"'));
$newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->rights->projet->creer);
if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) {
@@ -1722,7 +1724,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
// Project affected to user
- $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks');
+ $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'task', 'class="pictofixedwidth"'));
$newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
$newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
@@ -1740,7 +1742,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (!empty($conf->hrm->enabled)) {
$langs->load("hrm");
- $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm');
+ $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"'));
$newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->rights->hrm->employee->write);
$newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->rights->hrm->employee->read);
}
@@ -1750,7 +1752,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Load translation files required by the page
$langs->loadLangs(array("holiday", "trips"));
- $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
+ $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'holiday', 'class="pictofixedwidth"'));
$newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write);
$newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu == "hrm") {
@@ -1820,14 +1822,14 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (!empty($conf->export->enabled)) {
$langs->load("exports");
- $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export');
+ $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->rights->export->creer);
//$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->rights->export->lire);
}
if (!empty($conf->import->enabled)) {
$langs->load("exports");
- $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import');
+ $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->rights->import->run);
}
}
@@ -1861,7 +1863,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/categories/index.php?leftmenu=cat&type=3", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
}
- $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->rights->adherent->cotisation->lire);
+ $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->rights->adherent->cotisation->lire, '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/adherents/list.php?leftmenu=members&statut=-1,1&mainmenu=members", $langs->trans("NewSubscription"), 1, $user->rights->adherent->cotisation->creer);
$newmenu->add("/adherents/subscription/list.php?leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->cotisation->lire);
$newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire);
@@ -1870,7 +1872,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
//if (! empty($conf->export->enabled) && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("Datas"),1,$user->rights->adherent->export);
// Type
- $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->rights->adherent->configurer, '', $mainmenu, 'setup');
+ $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->rights->adherent->configurer, '', $mainmenu, 'setup', 0, '', '', '', img_picto('', 'members', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->rights->adherent->configurer);
$newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->rights->adherent->configurer);
}
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 485b079d1cd..f3078516080 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -357,8 +357,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*
* @param array $array_sql SQL requests to be executed when enabling module
* @param string $options String with options when disabling module:
- * - 'noboxes' = Do not insert boxes
- * - 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
+ * - 'noboxes' = Do all actions but do not insert boxes
+ * - 'newboxdefonly' = Do all actions but for boxes, insert def of boxes only and not boxes activation
* @return int 1 if OK, 0 if KO
*/
protected function _init($array_sql, $options = '')
@@ -389,7 +389,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$err += $this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade
}
- // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes)
+ // Insert boxes def (into llx_boxes_def) and boxes setup (into llx_boxes)
if (!$err && !preg_match('/noboxes/', $options)) {
$err += $this->insert_boxes($options);
}
@@ -1815,7 +1815,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// phpcs:enable
global $user;
- if (!is_array($this->menu) || empty($this->menu)) { return 0;
+ if (!is_array($this->menu) || empty($this->menu)) {
+ return 0;
}
include_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
@@ -2172,9 +2173,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
* The init function adds tabs, constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
- * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
- * 'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes,
- * insert def of boxes only and not boxes activation
+ * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes', 'menuonly')
+ * 'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
* @return int 1 if OK, 0 if KO
*/
public function init($options = '')
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index f02f04728cd..8d17f9759fb 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -712,7 +712,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index 3daa5288d7e..c7d83ebbaf7 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -930,7 +930,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
index edad675857f..bc6274482c4 100644
--- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
+++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
@@ -219,7 +219,7 @@ class doc_generic_contract_odt extends ModelePDFContract
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
- if ($conf->contrat->dir_output)
+ if ($conf->contrat->multidir_output[$object->entity])
{
// If $object is id instead of object
if (!is_object($object))
@@ -236,7 +236,7 @@ class doc_generic_contract_odt extends ModelePDFContract
$object->fetch_thirdparty();
- $dir = $conf->contrat->dir_output;
+ $dir = $conf->contrat->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
$file = $dir."/".$objectref.".odt";
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index 619dcdf84d3..877bf19f3a9 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -201,7 +201,7 @@ class pdf_strato extends ModelePDFContract
$file = $dir."/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->contrat->dir_output."/".$objectref;
+ $dir = $conf->contrat->multidir_output[$object->entity]."/".$objectref;
$file = $dir."/".$objectref.".pdf";
}
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index ce44aac0319..9e336863467 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1004,7 +1004,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 0edcdec536b..aafbb192bce 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -1108,7 +1108,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index 6c0bcc0f4b1..5b2e339a588 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -173,7 +173,7 @@ class ImportXlsx extends ModeleImports
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
- $col = 0;
+ $col = 1;
foreach ($headerlinefields as $field) {
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field));
// set autowidth
@@ -195,7 +195,7 @@ class ImportXlsx extends ModeleImports
public function write_record_example($outputlangs, $contentlinevalues)
{
// phpcs:enable
- $col = 0;
+ $col = 1;
$row = 2;
foreach ($contentlinevalues as $cell) {
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell);
@@ -289,7 +289,7 @@ class ImportXlsx extends ModeleImports
$xlsx = new Xlsx();
$info = $xlsx->listWorksheetinfo($this->file);
$countcolumns = $info[0]['totalColumns'];
- for ($col = 0; $col < $countcolumns; $col++) {
+ for ($col = 1; $col <= $countcolumns; $col++) {
$this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue();
}
return 0;
@@ -314,7 +314,7 @@ class ImportXlsx extends ModeleImports
$xlsx = new Xlsx();
$info = $xlsx->listWorksheetinfo($this->file);
$countcolumns = $info[0]['totalColumns'];
- for ($col = 0; $col < $countcolumns; $col++) {
+ for ($col = 1; $col <= $countcolumns; $col++) {
$val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue();
$array[$col]['val'] = $val;
$array[$col]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we consider it null
@@ -372,7 +372,7 @@ class ImportXlsx extends ModeleImports
//var_dump($sort_array_match_file_to_database);
- if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) {
+ if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[1]['val']))) {
//print 'W';
$this->warnings[$warning]['lib'] = $langs->trans('EmptyLine');
$this->warnings[$warning]['type'] = 'EMPTY';
@@ -420,7 +420,7 @@ class ImportXlsx extends ModeleImports
if ($key <= $maxfields) {
// Set $newval with value to insert and set $listvalues with sql request part for insert
$newval = '';
- if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value
+ if ($arrayrecord[($key)]['type'] > 0) $newval = $arrayrecord[($key)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value
// Make some tests on $newval
@@ -572,21 +572,21 @@ class ImportXlsx extends ModeleImports
$newval = $this->thirpartyobject->code_client;
//print 'code_client='.$newval;
}
- if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
+ if (empty($newval)) $arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') {
if (strtolower($newval) == 'auto') {
$newval = $this->thirpartyobject->get_codefournisseur(0, 1);
$newval = $this->thirpartyobject->code_fournisseur;
//print 'code_fournisseur='.$newval;
}
- if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
+ if (empty($newval)) $arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') {
if (strtolower($newval) == 'auto') {
$this->thirpartyobject->get_codecompta('customer');
$newval = $this->thirpartyobject->code_compta;
//print 'code_compta='.$newval;
}
- if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
+ if (empty($newval)) $arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') {
if (strtolower($newval) == 'auto') {
$this->thirpartyobject->get_codecompta('supplier');
@@ -594,7 +594,7 @@ class ImportXlsx extends ModeleImports
if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
//print 'code_compta_fournisseur='.$newval;
}
- if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
+ if (empty($newval)) $arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') {
$defaultref = '';
// TODO provide the $modTask (module of generation of ref) as parameter of import_insert function
@@ -624,7 +624,7 @@ class ImportXlsx extends ModeleImports
$errorforthistable++;
$error++;
} else {
- $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed.
+ $newval = $arrayrecord[($key)]['val']; //We get new value computed.
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
$newval = price2num($newval);
@@ -695,8 +695,8 @@ class ImportXlsx extends ModeleImports
$listfields[] = $fieldname;
// Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert
- if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) $listvalues[] = ($newval == '0' ? $newval : "null");
- elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) $listvalues[] = "''";
+ if (empty($newval) && $arrayrecord[($key)]['type'] < 0) $listvalues[] = ($newval == '0' ? $newval : "null");
+ elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) $listvalues[] = "''";
else $listvalues[] = "'" . $this->db->escape($newval) . "'";
}
$i++;
diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php
index 505ed444f55..6ee48388234 100644
--- a/htdocs/core/modules/modAsset.class.php
+++ b/htdocs/core/modules/modAsset.class.php
@@ -79,7 +79,7 @@ class modAsset extends DolibarrModules
// Data directories to create when module is enabled.
// Example: this->dirs = array("/asset/temp","/asset/subdir");
- $this->dirs = array();
+ $this->dirs = array("/asset/temp");
// Config pages. Put here list of php page, stored into asset/admin directory, to use to setup module.
$this->config_page_url = array("setup.php@asset");
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index f257c6e3132..8cc0dedec6c 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -288,7 +288,7 @@ class modCommande extends DolibarrModules
'c.fk_user_valid' => 'ValidatedById',
'c.fk_statut' => 'Status*',
'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/modECM.class.php b/htdocs/core/modules/modECM.class.php
index 847200adc4f..b97dce7157b 100644
--- a/htdocs/core/modules/modECM.class.php
+++ b/htdocs/core/modules/modECM.class.php
@@ -58,7 +58,7 @@ class modECM extends DolibarrModules
// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of png file (without png) used for this module
- $this->picto = 'folder';
+ $this->picto = 'folder-open';
// Data directories to create when module is enabled
$this->dirs = array("/ecm/temp");
diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php
new file mode 100644
index 00000000000..b0527ad30b5
--- /dev/null
+++ b/htdocs/core/modules/modEventOrganization.class.php
@@ -0,0 +1,475 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \defgroup eventorganization Module EventOrganization
+ * \brief EventOrganization module descriptor.
+ *
+ * \file htdocs/eventorganization/core/modules/modEventOrganization.class.php
+ * \ingroup eventorganization
+ * \brief Description and activation file for module EventOrganization
+ */
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
+
+/**
+ * Description and activation class for module EventOrganization
+ * This module is base on this specification :
+ * https://wiki.dolibarr.org/index.php/Draft:Module_Event_Organization
+ */
+class modEventOrganization extends DolibarrModules
+{
+ /**
+ * Constructor. Define names, constants, directories, boxes, permissions
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $langs, $conf;
+ $this->db = $db;
+
+ $this->numero = 2450;
+
+ $this->rights_class = 'eventorganization';
+
+ $this->family = "projects";
+
+ $this->module_position = '20';
+
+ $this->name = preg_replace('/^mod/i', '', get_class($this));
+
+ $this->description = "EventOrganizationDescription";
+ $this->descriptionlong = "EventOrganizationDescriptionLong";
+
+ $this->version = 'development';
+
+
+ // Key used in llx_const table to save module status enabled/disabled (where EVENTORGANIZATION is value of property name of module in uppercase)
+ $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
+
+ $this->picto = 'action';
+
+ // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
+ $this->module_parts = array(
+ // Set this to 1 if module has its own trigger directory (core/triggers)
+ 'triggers' => 0,
+ // Set this to 1 if module has its own login method file (core/login)
+ 'login' => 0,
+ // Set this to 1 if module has its own substitution function file (core/substitutions)
+ 'substitutions' => 0,
+ // Set this to 1 if module has its own menus handler directory (core/menus)
+ 'menus' => 0,
+ // Set this to 1 if module overwrite template dir (core/tpl)
+ 'tpl' => 0,
+ // Set this to 1 if module has its own barcode directory (core/modules/barcode)
+ 'barcode' => 0,
+ // Set this to 1 if module has its own models directory (core/modules/xxx)
+ 'models' => 1,
+ // Set this to 1 if module has its own printing directory (core/modules/printing)
+ 'printing' => 0,
+ // Set this to 1 if module has its own theme directory (theme)
+ 'theme' => 0,
+ // Set this to relative path of css file if module has its own css file
+ 'css' => array(
+ // '/eventorganization/css/eventorganization.css.php',
+ ),
+ // Set this to relative path of js file if module must load a js on all pages
+ 'js' => array(
+ // '/eventorganization/js/eventorganization.js.php',
+ ),
+ // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
+ 'hooks' => array(
+ // 'data' => array(
+ // 'hookcontext1',
+ // 'hookcontext2',
+ // ),
+ // 'entity' => '0',
+ ),
+ // Set this to 1 if features of module are opened to external users
+ 'moduleforexternal' => 0,
+ );
+
+ // Data directories to create when module is enabled.
+ // Example: this->dirs = array("/eventorganization/temp","/eventorganization/subdir");
+ $this->dirs = array("/eventorganization/temp");
+
+ // Config pages. Put here list of php page, stored into eventorganization/admin directory, to use to setup module.
+ $this->config_page_url = array("eventorganization.php");
+
+ // Dependencies
+ // A condition to hide module
+ $this->hidden = false;
+ // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
+ $this->depends = array('modProjet','modCategorie');
+ $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
+
+ // The language file dedicated to your module
+ $this->langfiles = array("eventorganization");
+
+ // Prerequisites
+ $this->phpmin = array(5, 6); // Minimum version of PHP required by module
+ $this->need_dolibarr_version = array(13, -3); // Minimum version of Dolibarr required by module
+
+ // Messages at activation
+ $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ //$this->automatic_activation = array('FR'=>'EventOrganizationWasAutomaticallyActivatedBecauseOfYourCountryChoice');
+ //$this->always_enabled = true; // If true, can't be disabled
+
+ // Constants
+ // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
+ // Example: $this->const=array(1 => array('EVENTORGANIZATION_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
+ // 2 => array('EVENTORGANIZATION_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
+ // );
+ $this->const = array(1 => array('EVENTORGANIZATION_TASK_LABEL', 'chaine', '', '', 0));
+
+
+
+ // Some keys to add into the overwriting translation tables
+ /*$this->overwrite_translation = array(
+ 'en_US:ParentCompany'=>'Parent company or reseller',
+ 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
+ )*/
+
+ if (!isset($conf->eventorganization) || !isset($conf->eventorganization->enabled)) {
+ $conf->eventorganization = new stdClass();
+ $conf->eventorganization->enabled = 0;
+ }
+
+ // Array to add new pages in new tabs
+ $this->tabs = array();
+ // Example:
+ // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@eventorganization:$user->rights->eventorganization->read:/eventorganization/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
+ // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@eventorganization:$user->rights->othermodule->read:/eventorganization/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
+ // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
+ //
+ // Where objecttype can be
+ // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
+ // 'contact' to add a tab in contact view
+ // 'contract' to add a tab in contract view
+ // 'group' to add a tab in group view
+ // 'intervention' to add a tab in intervention view
+ // 'invoice' to add a tab in customer invoice view
+ // 'invoice_supplier' to add a tab in supplier invoice view
+ // 'member' to add a tab in fundation member view
+ // 'opensurveypoll' to add a tab in opensurvey poll view
+ // 'order' to add a tab in customer order view
+ // 'order_supplier' to add a tab in supplier order view
+ // 'payment' to add a tab in payment view
+ // 'payment_supplier' to add a tab in supplier payment view
+ // 'product' to add a tab in product view
+ // 'propal' to add a tab in propal view
+ // 'project' to add a tab in project view
+ // 'stock' to add a tab in stock view
+ // 'thirdparty' to add a tab in third party view
+ // 'user' to add a tab in user view
+
+ // Dictionaries
+ $this->dictionaries = array();
+ /* Example:
+ $this->dictionaries=array(
+ 'langs'=>'eventorganization@eventorganization',
+ // List of tables we want to see into dictonnary editor
+ 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"),
+ // Label of tables
+ 'tablib'=>array("Table1", "Table2", "Table3"),
+ // Request to select fields
+ 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),
+ // Sort order
+ 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
+ // List of fields (result of select to show dictionary)
+ 'tabfield'=>array("code,label", "code,label", "code,label"),
+ // List of fields (list of fields to edit a record)
+ 'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
+ // List of fields (list of fields for insert)
+ 'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
+ // Name of columns with primary key (try to always name it 'rowid')
+ 'tabrowid'=>array("rowid", "rowid", "rowid"),
+ // Condition to show each dictionary
+ 'tabcond'=>array($conf->eventorganization->enabled, $conf->eventorganization->enabled, $conf->eventorganization->enabled)
+ );
+ */
+
+ // Boxes/Widgets
+ // Add here list of php file(s) stored in eventorganization/core/boxes that contains a class to show a widget.
+ $this->boxes = array(
+ // 0 => array(
+ // 'file' => 'eventorganizationwidget1.php@eventorganization',
+ // 'note' => 'Widget provided by EventOrganization',
+ // 'enabledbydefaulton' => 'Home',
+ // ),
+ // ...
+ );
+
+ // Cronjobs (List of cron jobs entries to add when module is enabled)
+ // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
+ $this->cronjobs = array(
+ // 0 => array(
+ // 'label' => 'MyJob label',
+ // 'jobtype' => 'method',
+ // 'class' => '/eventorganization/class/conferenceorbooth.class.php',
+ // 'objectname' => 'ConferenceOrBooth',
+ // 'method' => 'doScheduledJob',
+ // 'parameters' => '',
+ // 'comment' => 'Comment',
+ // 'frequency' => 2,
+ // 'unitfrequency' => 3600,
+ // 'status' => 0,
+ // 'test' => '$conf->eventorganization->enabled',
+ // 'priority' => 50,
+ // ),
+ );
+ // Example: $this->cronjobs=array(
+ // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->eventorganization->enabled', 'priority'=>50),
+ // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->eventorganization->enabled', 'priority'=>50)
+ // );
+
+ // Permissions provided by this module
+ $this->rights = array();
+ $r = 0;
+ // Add here entries to declare new permissions
+ /* BEGIN MODULEBUILDER PERMISSIONS */
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Read objects of EventOrganization'; // Permission label
+ $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $r++;
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Create/Update objects of EventOrganization'; // Permission label
+ $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $r++;
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Delete objects of EventOrganization'; // Permission label
+ $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $r++;
+ /*$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Read objects of EventOrganization - Conference Or Booth'; // Permission label
+ $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $r++;
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Create/Update objects of EventOrganization - Conference Or Booth'; // Permission label
+ $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $r++;
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Delete objects of EventOrganization - Conference Or Booth'; // Permission label
+ $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
+ $r++;*/
+ /* END MODULEBUILDER PERMISSIONS */
+
+ // Main menu entries to add
+ $this->menu = array();
+ $r = 0;
+ // Add here entries to declare new menus
+ /* BEGIN MODULEBUILDER TOPMENU */
+ /*$this->menu[$r++] = array(
+ 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'top', // This is a Top menu entry
+ 'titre'=>'ModuleEventOrganizationName',
+ 'mainmenu'=>'eventorganization',
+ 'leftmenu'=>'',
+ 'url'=>'/eventorganization/eventorganizationindex.php',
+ 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000 + $r,
+ 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'1', // Use 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );*/
+ /* END MODULEBUILDER TOPMENU */
+ /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Top menu entry
+ 'titre'=>'ConferenceOrBooth',
+ 'mainmenu'=>'eventorganization',
+ 'leftmenu'=>'conferenceorbooth',
+ 'url'=>'/eventorganization/eventorganizationindex.php',
+ 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000+$r,
+ 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=eventorganization,fk_leftmenu=conferenceorbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>'List_ConferenceOrBooth',
+ 'mainmenu'=>'eventorganization',
+ 'leftmenu'=>'eventorganization_conferenceorbooth_list',
+ 'url'=>'/eventorganization/conferenceorbooth_list.php',
+ 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000+$r,
+ 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=eventorganization,fk_leftmenu=conferenceorbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>'New_ConferenceOrBooth',
+ 'mainmenu'=>'eventorganization',
+ 'leftmenu'=>'eventorganization_conferenceorbooth_new',
+ 'url'=>'/eventorganization/conferenceorbooth_card.php?action=create',
+ 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000+$r,
+ 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'$user->rights->eventorganization->conferenceorbooth->write', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ */
+
+ /* END MODULEBUILDER LEFTMENU CONFERENCEORBOOTH */
+ // Exports profiles provided by this module
+ $r = 1;
+ /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */
+ /*
+ $langs->load("eventorganization@eventorganization");
+ $this->export_code[$r]=$this->rights_class.'_'.$r;
+ $this->export_label[$r]='ConferenceOrBoothLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->export_icon[$r]='conferenceorbooth@eventorganization';
+ // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
+ $keyforclass = 'ConferenceOrBooth'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorbooth@eventorganization';
+ include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+ //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
+ //unset($this->export_fields_array[$r]['t.fieldtoremove']);
+ //$keyforclass = 'ConferenceOrBoothLine'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorboothline@eventorganization'; $keyforalias='tl';
+ //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+ $keyforselect='conferenceorbooth'; $keyforaliasextra='extra'; $keyforelement='conferenceorbooth@eventorganization';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+ //$keyforselect='conferenceorboothline'; $keyforaliasextra='extraline'; $keyforelement='conferenceorboothline@eventorganization';
+ //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+ //$this->export_dependencies_array[$r] = array('conferenceorboothline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
+ //$this->export_special_array[$r] = array('t.field'=>'...');
+ //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
+ //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
+ $this->export_sql_start[$r]='SELECT DISTINCT ';
+ $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'conferenceorbooth as t';
+ //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'conferenceorbooth_line as tl ON tl.fk_conferenceorbooth = t.rowid';
+ $this->export_sql_end[$r] .=' WHERE 1 = 1';
+ $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('conferenceorbooth').')';
+ $r++; */
+ /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */
+
+ // Imports profiles provided by this module
+ $r = 1;
+ /* BEGIN MODULEBUILDER IMPORT CONFERENCEORBOOTH */
+ /*
+ $langs->load("eventorganization@eventorganization");
+ $this->export_code[$r]=$this->rights_class.'_'.$r;
+ $this->export_label[$r]='ConferenceOrBoothLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->export_icon[$r]='conferenceorbooth@eventorganization';
+ $keyforclass = 'ConferenceOrBooth'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorbooth@eventorganization';
+ include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+ $keyforselect='conferenceorbooth'; $keyforaliasextra='extra'; $keyforelement='conferenceorbooth@eventorganization';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+ //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
+ $this->export_sql_start[$r]='SELECT DISTINCT ';
+ $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'conferenceorbooth as t';
+ $this->export_sql_end[$r] .=' WHERE 1 = 1';
+ $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('conferenceorbooth').')';
+ $r++; */
+ /* END MODULEBUILDER IMPORT CONFERENCEORBOOTH */
+ }
+
+ /**
+ * Function called when module is enabled.
+ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
+ * It also creates data directories
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function init($options = '')
+ {
+ global $conf, $langs;
+
+ $result = $this->_load_tables('/eventorganization/sql/');
+ if ($result < 0) {
+ return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
+ }
+
+ // Create extrafields during init
+ //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+ //$extrafields = new ExtraFields($this->db);
+ //$result1=$extrafields->addExtraField('eventorganization_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled');
+ //$result2=$extrafields->addExtraField('eventorganization_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled');
+ //$result3=$extrafields->addExtraField('eventorganization_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled');
+ //$result4=$extrafields->addExtraField('eventorganization_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled');
+ //$result5=$extrafields->addExtraField('eventorganization_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled');
+
+ // Permissions
+ $this->remove($options);
+
+ $sql = array();
+
+ // Document templates
+ $moduledir = 'eventorganization';
+ $myTmpObjects = array();
+ $myTmpObjects['ConferenceOrBooth'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
+
+ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
+ if ($myTmpObjectKey == 'ConferenceOrBooth') {
+ continue;
+ }
+ if ($myTmpObjectArray['includerefgeneration']) {
+ $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/eventorganization/template_conferenceorbooths.odt';
+ $dirodt = DOL_DATA_ROOT.'/doctemplates/eventorganization';
+ $dest = $dirodt.'/template_conferenceorbooths.odt';
+
+ if (file_exists($src) && !file_exists($dest)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ dol_mkdir($dirodt);
+ $result = dol_copy($src, $dest, 0, 0);
+ if ($result < 0) {
+ $langs->load("errors");
+ $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
+ return 0;
+ }
+ }
+
+ $sql = array_merge($sql, array(
+ "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
+ "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")",
+ "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
+ "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")"
+ ));
+ }
+ }
+
+ return $this->_init($sql, $options);
+ }
+
+ /**
+ * Function called when module is disabled.
+ * Remove from database constants, boxes and permissions from Dolibarr database.
+ * Data directories are not deleted
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function remove($options = '')
+ {
+ $sql = array();
+ return $this->_remove($sql, $options);
+ }
+}
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index d39d67775f5..eb9b89f3087 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -522,7 +522,7 @@ class modFournisseur extends DolibarrModules
's.rowid'=>"IdCompany", 's.nom'=>'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/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 27d44160949..b4c1dd13e7d 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -192,6 +192,7 @@ class modProduct extends DolibarrModules
'p.duration'=>"Duration",
'p.finished' => 'Nature',
'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC",
+ 'p.price_min'=>"MinPriceHT",'p.price_min_ttc'=>"MinPriceTTC",
'p.tva_tx'=>'VATRate',
'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'
);
@@ -216,7 +217,9 @@ class modProduct extends DolibarrModules
'p.customcode'=>'Text',
'p.duration'=>"Text",
'p.finished' => 'Numeric',
- 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric',
+ 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric",
+ 'p.price_min'=>"Numeric", 'p.price_min_ttc'=>"Numeric",
+ 'p.tva_tx'=>'Numeric',
'p.datec'=>'Date', 'p.tms'=>'Date'
);
if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('e.ref'=>'Text', 'p.tobatch'=>'Numeric', 'p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
@@ -547,7 +550,7 @@ class modProduct extends DolibarrModules
// field order as per structure of table llx_product
$import_sample = array(
- 'p.ref' => "PREF123456",
+ 'p.ref' => "ref:PREF123456",
'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
'p.label' => "Product name in default language",
'p.description' => "Product description in default language",
@@ -687,7 +690,7 @@ class modProduct extends DolibarrModules
);
$this->import_examplevalues_array[$r] = array(
- 'sp.fk_product' => "PRODUCT_REF or id:123456",
+ 'sp.fk_product' => "ref:PRODUCT_REF or id:123456",
'sp.fk_soc' => "My Supplier",
'sp.ref_fourn' => "XYZ-F123456",
'sp.quantity' => "5",
@@ -749,13 +752,13 @@ class modProduct extends DolibarrModules
$this->import_convertvalue_array[$r] = array(
'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
);
- $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456",
+ $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:PRODUCT_REF or id:123456",
'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1",
'pr.price'=>"100", 'pr.price_ttc'=>"110",
'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
'pr.tva_tx'=>'20',
'pr.recuperableonly'=>'0',
- 'pr.date_price'=>'2013-04-10');
+ 'pr.date_price'=>'2020-12-31');
}
if (!empty($conf->global->MAIN_MULTILANGS))
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/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php
index 7a72d3967e0..5887fac8577 100644
--- a/htdocs/core/modules/modResource.class.php
+++ b/htdocs/core/modules/modResource.class.php
@@ -188,7 +188,7 @@ class modResource extends DolibarrModules
'fk_menu'=>'fk_mainmenu=tools',
'type'=>'left',
'titre'=> 'MenuResourceIndex',
- 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
+ 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'),
'mainmenu'=>'tools',
'leftmenu'=> 'resource',
'url'=> '/resource/list.php',
diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php
index 2d7a6c7c4e6..2c3679c0374 100644
--- a/htdocs/core/modules/modTicket.class.php
+++ b/htdocs/core/modules/modTicket.class.php
@@ -208,7 +208,7 @@ class modTicket extends DolibarrModules
$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket',
'type' => 'left',
'titre' => 'Ticket',
- 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
+ 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em092"'),
'mainmenu' => 'ticket',
'leftmenu' => 'ticket',
'url' => '/ticket/index.php',
diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php
index ec1c458ce00..f7655db824a 100644
--- a/htdocs/core/modules/modWorkflow.class.php
+++ b/htdocs/core/modules/modWorkflow.class.php
@@ -51,7 +51,7 @@ class modWorkflow extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
- $this->description = "Workflow management";
+ $this->description = "Inter-modules workflow management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index be3f53847bf..be0d044ac25 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -908,7 +908,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
index bc71116081e..4e1b448d9db 100644
--- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
@@ -1048,7 +1048,7 @@ class pdf_cyan extends ModelePDFPropales
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
index 275b4672109..74abd0fc715 100644
--- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
@@ -865,7 +865,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
index 2094eab8c3a..99e76b20337 100644
--- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
@@ -747,7 +747,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_id);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
index 3d3990c06b4..36f589531e6 100644
--- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
+++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
@@ -807,7 +807,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index f1b5a109230..67c524d67f6 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -451,8 +451,10 @@ if ($action == 'confirm_crop')
*/
$title= $langs->trans("ImageEditor");
+$morejs = array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js', '/core/js/lib_photosresize.js');
+$morecss = array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css');
-llxHeader($head, $title, '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js', '/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css'));
+llxHeader($head, $title, '', '', 0, 0, $morejs, $morecss);
print load_fiche_titre($title);
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
index 9e893bf93e3..5239a93fdf7 100644
--- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
@@ -169,6 +169,7 @@ $totalizable = $extrafields->attributes[$elementtype]['totalizable'][$attrname];
$help = $extrafields->attributes[$elementtype]['help'][$attrname];
$entitycurrentorall = $extrafields->attributes[$elementtype]['entityid'][$attrname];
$printable = $extrafields->attributes[$elementtype]['printable'][$attrname];
+$enabled = $extrafields->attributes[$elementtype]['enabled'][$attrname];
if ((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
{
@@ -302,6 +303,14 @@ if (in_array($type, array_keys($typewecanchangeinto)))
trans("AllEntities"); ?> >
+
+
+
+ trans("EnabledCondition"); ?>
+
+
+
+
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php
index fb542f9037e..c62a95ec12b 100644
--- a/htdocs/core/tpl/admin_extrafields_view.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php
@@ -76,6 +76,11 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel
{
foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value)
{
+ /*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1)) {
+ // TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
+ // continue;
+ }*/
+
// Load language if required
if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
$langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php
index 25d5f6f3526..1a797b936c3 100644
--- a/htdocs/core/tpl/ajaxrow.tpl.php
+++ b/htdocs/core/tpl/ajaxrow.tpl.php
@@ -28,7 +28,7 @@
// Protection to avoid direct call of template
if (empty($object) || !is_object($object))
{
- print "Error, template page can't be called as URL";
+ print "Error, template page ".basename(__FILE__)." can't be called with no object defined.";
exit;
}
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/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
index d2d77cf3b5c..bbc5ba3370b 100644
--- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
@@ -1,6 +1,6 @@
'."\n";
+// This tpl file is included into the init part of pages, so before action.
+// So no output must be done.
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf))
diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php
index 85afea4ab16..c2c89e28ce0 100644
--- a/htdocs/core/tpl/object_discounts.tpl.php
+++ b/htdocs/core/tpl/object_discounts.tpl.php
@@ -88,7 +88,7 @@ if ($absolute_creditnote > 0) {
}
if ($absolute_discount <= 0 || $isNewObject) {
- $text .= '('.$addabsolutediscount.')';
+ $text .= ' ('.$addabsolutediscount.')';
}
if ($isNewObject) {
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index cc74b02a29b..b4950f00e39 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -32,6 +32,7 @@
* $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders)
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
*/
+
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL";
@@ -174,7 +175,7 @@ if ($nolinesbefore) {
echo ((GETPOST('prod_entry_mode', 'alpha') == 'free' || !empty($conf->global->MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT)) ? ' checked' : '');
echo '> ';
// Show type selector
- echo $langs->trans("FreeLineOfType");
+ echo '';
echo '';
echo ' ';
} else {
@@ -193,20 +194,25 @@ if ($nolinesbefore) {
// Predefined product/service
if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
{
- if ($forceall >= 0 && $freelines) echo '
';
- echo '
';
+ if ($forceall >= 0 && $freelines) echo '';
+ else echo '';
echo '';
echo ' ';
- if (empty($senderissupplier))
- {
- if (!empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
- elseif ((empty($conf->product->enabled) && !empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
- else echo $langs->trans('PredefinedProductsAndServicesToSell');
+ $labelforradio = '';
+ if (empty($conf->dol_optimize_smallscreen)) {
+ if (empty($senderissupplier)) {
+ if (!empty($conf->product->enabled) && empty($conf->service->enabled)) $labelforradio = $langs->trans('PredefinedProductsToSell');
+ elseif ((empty($conf->product->enabled) && !empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) $labelforradio = $langs->trans('PredefinedServicesToSell');
+ else $labelforradio = $langs->trans('PredefinedProductsAndServicesToSell');
+ } else {
+ if (!empty($conf->product->enabled) && empty($conf->service->enabled)) $labelforradio = $langs->trans('PredefinedProductsToPurchase');
+ elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) $labelforradio = $langs->trans('PredefinedServicesToPurchase');
+ else $labelforradio = $langs->trans('PredefinedProductsAndServicesToPurchase');
+ }
} else {
- if (!empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
- elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
- else echo $langs->trans('PredefinedProductsAndServicesToPurchase');
+ $labelforradio = $langs->trans('PredefinedItem');
}
+ print '';
echo ' ';
echo ' ';
$filtertype = '';
@@ -239,22 +245,22 @@ if ($nolinesbefore) {
array('qty'=>'qty', 'remise_percent' => 'discount', 'idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key
- 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
- 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
+ 'update' => array('qty'=>'qty', 'remise_percent' => 'discount', 'idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key
+ 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
+ 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
);
$alsoproductwithnosupplierprice = 0;
} else {
$ajaxoptions = array(
- 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key
+ 'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
);
$alsoproductwithnosupplierprice = 1;
}
- $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth500');
+ $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'minwidth300imp maxwidth500');
if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
{
?>
@@ -331,7 +337,7 @@ if ($nolinesbefore) {
{
$coldisplay++;
?>
- ">
+
">
';
$coldisplay++;
@@ -535,47 +541,47 @@ if (!empty($usemargins) && $user->rights->margins->creer)
/* TODO This does not work for number with thousand separator that is , */
function checkFreeLine(e, npRate)
{
- var buying_price = $("input[name='buying_price']:first");
- var remise = $("input[name='remise_percent']:first");
+ var buying_price = $("input[name='buying_price']:first");
+ var remise = $("input[name='remise_percent']:first");
+
+ var rate = $("input[name='"+npRate+"']:first");
+ if (rate.val() == '')
+ return true;
+
+ if (! $.isNumeric(rate.val().replace(',','.')))
+ {
+ alert('trans("rateMustBeNumeric")); ?>');
+ e.stopPropagation();
+ setTimeout(function () { rate.focus() }, 50);
+ return false;
+ }
+ if (npRate == "np_markRate" && rate.val() >= 100)
+ {
+ alert('trans("markRateShouldBeLesserThan100")); ?>');
+ e.stopPropagation();
+ setTimeout(function () { rate.focus() }, 50);
+ return false;
+ }
+
+ var price = 0;
+ remisejs=price2numjs(remise.val());
+
+ if (remisejs != 100) // If a discount not 100 or no discount
+ {
+ if (remisejs == '') remisejs=0;
+
+ bpjs=price2numjs(buying_price.val());
+ ratejs=price2numjs(rate.val());
+
+ if (npRate == "np_marginRate")
+ price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
+ else if (npRate == "np_markRate")
+ price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
+ }
+
+ $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
- var rate = $("input[name='"+npRate+"']:first");
- if (rate.val() == '')
return true;
-
- if (! $.isNumeric(rate.val().replace(',','.')))
- {
- alert('trans("rateMustBeNumeric")); ?>');
- e.stopPropagation();
- setTimeout(function () { rate.focus() }, 50);
- return false;
- }
- if (npRate == "np_markRate" && rate.val() >= 100)
- {
- alert('trans("markRateShouldBeLesserThan100")); ?>');
- e.stopPropagation();
- setTimeout(function () { rate.focus() }, 50);
- return false;
- }
-
- var price = 0;
- remisejs=price2numjs(remise.val());
-
- if (remisejs != 100) // If a discount not 100 or no discount
- {
- if (remisejs == '') remisejs=0;
-
- bpjs=price2numjs(buying_price.val());
- ratejs=price2numjs(rate.val());
-
- if (npRate == "np_marginRate")
- price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
- else if (npRate == "np_markRate")
- price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
- }
-
- $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
-
- return true;
}
rights->margins->creer)
$("#select_type").change(function()
{
setforfree();
- if (jQuery('#select_type').val() >= 0)
- {
- /* focus work on a standard textarea but not if field was replaced with CKEDITOR */
- jQuery('#dp_desc').focus();
- /* focus if CKEDITOR */
- if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
+ if (jQuery('#select_type').val() >= 0)
{
- var editor = CKEDITOR.instances['dp_desc'];
- if (editor) { editor.focus(); }
+ /* focus work on a standard textarea but not if field was replaced with CKEDITOR */
+ jQuery('#dp_desc').focus();
+ /* focus if CKEDITOR */
+ if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
+ {
+ var editor = CKEDITOR.instances['dp_desc'];
+ if (editor) { editor.focus(); }
+ }
+ }
+ console.log("Hide/show date according to product type");
+ if (jQuery('#select_type').val() == '0')
+ {
+ jQuery('#trlinefordates').hide();
+ jQuery('.divlinefordates').hide();
+ }
+ else
+ {
+ jQuery('#trlinefordates').show();
+ jQuery('.divlinefordates').show();
}
- }
- console.log("Hide/show date according to product type");
- if (jQuery('#select_type').val() == '0')
- {
- jQuery('#trlinefordates').hide();
- jQuery('.divlinefordates').hide();
- }
- else
- {
- jQuery('#trlinefordates').show();
- jQuery('.divlinefordates').show();
- }
});
$("#prod_entry_mode_predef").on( "click", function() {
@@ -652,7 +658,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
/* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function()
{
- console.log("Call method change() after change on #idprod or #idprodfournprice. this.val = "+$(this).val());
+ console.log("Call method change() after change on #idprod or #idprodfournprice (senderissupplier=). this.val = "+$(this).val());
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php
index 8a7c38f8ada..697c46c6fcd 100644
--- a/htdocs/core/tpl/objectline_title.tpl.php
+++ b/htdocs/core/tpl/objectline_title.tpl.php
@@ -53,9 +53,10 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print '
'.$langs->trans('Description').' ';
+// Supplier ref
if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' || $this->element == 'invoice_supplier')
{
- print '
'.$langs->trans("SupplierRef").' ';
+ print '
'.$langs->trans("SupplierRef").' ';
}
// VAT
@@ -90,6 +91,7 @@ if ($inputalsopricewithtax) print '
'.$lang
// Qty
print ' '.$langs->trans('Qty').' ';
+// Unit
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
print '
'.$langs->trans('Unit').' ';
@@ -104,6 +106,7 @@ if ($this->situation_cycle_ref) {
print '
'.$form->textwithpicto($langs->trans('TotalHT100Short'), $langs->trans('UnitPriceXQtyLessDiscount')).' ';
}
+// Purchase price
if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid))
{
if (!empty($user->rights->margins->creer))
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 3d4c4ed63b7..4034198fff0 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -654,7 +654,10 @@ class InterfaceActionsAuto extends DolibarrTriggers
if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
$object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
- $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
+ //$object->actionmsg .= "\n".$langs->transnoentities("Task").': ???';
+ if (!empty($object->usage_opportunity) && is_object($object->oldcopy) && $object->opp_status != $object->oldcopy->opp_status) {
+ $object->actionmsg .= "\n".$langs->transnoentitiesnoconv("OpportunityStatus").': '.$object->oldcopy->opp_status.' -> '.$object->opp_status;
+ }
$object->sendtoid = 0;
}
diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
index ee576992865..a903ab53b23 100644
--- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
+++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
@@ -47,7 +47,7 @@ class InterfaceContactRoles extends DolibarrTriggers
$this->description = "Triggers of this module auto link contact to company.";
// 'development', 'experimental', 'dolibarr' or version
$this->version = self::VERSION_DOLIBARR;
- $this->picto = 'action';
+ $this->picto = 'company';
}
/**
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 9d084ec4f24..d41d055b996 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -50,8 +50,19 @@ class Cronjob extends CommonObject
*/
public $entity;
+ /**
+ * @var string Job type
+ */
public $jobtype;
+
+ /**
+ * @var string|int Date for last cron object update
+ */
public $tms = '';
+
+ /**
+ * @var string|int Date for cron job create
+ */
public $datec = '';
/**
@@ -59,6 +70,9 @@ class Cronjob extends CommonObject
*/
public $label;
+ /**
+ * @var string Job command
+ */
public $command;
public $classesname;
public $objectname;
@@ -67,20 +81,50 @@ class Cronjob extends CommonObject
public $md5params;
public $module_name;
public $priority;
+
/**
* @var string|int Date for last job execution
*/
public $datelastrun = '';
+
/**
* @var string|int Date for next job execution
*/
public $datenextrun = '';
+
+ /**
+ * @var string|int Date for end job execution
+ */
public $dateend = '';
+
+ /**
+ * @var string|int Date for first start job execution
+ */
public $datestart = '';
+
+ /**
+ * @var string|int Date for last result job execution
+ */
public $datelastresult = '';
+
+ /**
+ * @var string Last result from end job execution
+ */
public $lastresult;
+
+ /**
+ * @var string Last output from end job execution
+ */
public $lastoutput;
+
+ /**
+ * @var string Unit frequency of job execution
+ */
public $unitfrequency;
+
+ /**
+ * @var int Frequency of job execution
+ */
public $frequency;
/**
@@ -88,6 +132,9 @@ class Cronjob extends CommonObject
*/
public $status;
+ /**
+ * @var int Is job processing
+ */
public $processing;
/**
@@ -100,9 +147,25 @@ class Cronjob extends CommonObject
*/
public $fk_user_mod;
+ /**
+ * @var int Number of run job execution
+ */
public $nbrun;
+
+ /**
+ * @var int Maximum run job execution
+ */
+ public $maxrun;
+
+ /**
+ * @var string Libname
+ */
public $libname;
- public $test; // A test condition to know if job is visible/qualified
+
+ /**
+ * @var string A test condition to know if job is visible/qualified
+ */
+ public $test;
const STATUS_DISABLED = 0;
const STATUS_ENABLED = 1;
@@ -152,7 +215,12 @@ class Cronjob extends CommonObject
if (isset($this->frequency)) $this->frequency = trim($this->frequency);
if (isset($this->status)) $this->status = trim($this->status);
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
- if (isset($this->nbrun)) $this->nbrun = trim($this->nbrun);
+ if (isset($this->nbrun)) {
+ $this->nbrun = (int) $this->nbrun;
+ }
+ if (isset($this->maxrun)) {
+ $this->maxrun = (int) $this->maxrun;
+ }
if (isset($this->libname)) $this->libname = trim($this->libname);
if (isset($this->test)) $this->test = trim($this->test);
@@ -262,7 +330,10 @@ class Cronjob extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
+ if (!$resql) {
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
+ }
if (!$error)
{
@@ -1253,8 +1324,7 @@ class Cronjob extends CommonObject
}
$result = $this->update($user);
- if ($result < 0)
- {
+ if ($result < 0) {
dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR);
return -1;
}
@@ -1289,14 +1359,16 @@ class Cronjob extends CommonObject
$this->labelStatus = array(); // Force reset o array because label depends on other fields
$this->labelStatusShort = array();
- if (empty($this->labelStatus) || empty($this->labelStatusShort))
- {
+ if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
$langs->load('users');
$moretext = '';
- if ($processing) $moretext = ' ('.$langs->trans("Running").')';
- elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')';
+ if ($processing) {
+ $moretext = ' ('.$langs->trans("Running").')';
+ } elseif ($lastresult) {
+ $moretext .= ' ('.$langs->trans("Error").')';
+ }
$this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled').$moretext;
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Scheduled').$moretext;
diff --git a/htdocs/don/document.php b/htdocs/don/document.php
index 9ff1fa98ea2..a211f076253 100644
--- a/htdocs/don/document.php
+++ b/htdocs/don/document.php
@@ -78,7 +78,7 @@ $modulepart = 'don';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
if ($action == 'classin' && $user->rights->don->creer)
{
diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php
index 4c4a3fc3412..802e3681bd7 100644
--- a/htdocs/ecm/class/ecmdirectory.class.php
+++ b/htdocs/ecm/class/ecmdirectory.class.php
@@ -40,7 +40,7 @@ class EcmDirectory extends CommonObject
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
- public $picto = 'dir';
+ public $picto = 'folder-open';
/**
* @var int ID
diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index 6392d6f162e..bd550dbf751 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -47,7 +47,7 @@ class EcmFiles extends CommonObject
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
- public $picto = 'generic';
+ public $picto = 'folder-open';
/**
* @var string Ref hash of file path
diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php
index b1c7eb0ec28..93885c2843a 100644
--- a/htdocs/ecm/file_card.php
+++ b/htdocs/ecm/file_card.php
@@ -290,7 +290,7 @@ print '
';
print '
';
print '
';
-print ''.$langs->trans("ECMCreationDate").' ';
+print ' '.$langs->trans("ECMCreationDate").' ';
print dol_print_date(dol_filemtime($fullpath), 'dayhour');
print ' ';
/*print ''.$langs->trans("ECMDirectoryForFiles").' ';
@@ -321,7 +321,9 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Link for internal download
-print ' '.$langs->trans("DirectDownloadInternalLink").' ';
+print ' ';
+print $form->textwithpicto($langs->trans("DirectDownloadInternalLink"), $langs->trans("PrivateDownloadLinkDesc"));
+print ' ';
$modulepart = 'ecm';
$forcedownload = 1;
$rellink = '/document.php?modulepart='.$modulepart;
@@ -347,9 +349,9 @@ print ' ';
// Link for direct external download
print '';
if ($action != 'edit') {
- print $langs->trans("DirectDownloadLink");
+ print $form->textwithpicto($langs->trans("DirectDownloadLink"), $langs->trans("PublicDownloadLinkDesc"));
} else {
- print $langs->trans("FileSharedViaALink");
+ print $form->textwithpicto($langs->trans("FileSharedViaALink"), $langs->trans("PublicDownloadLinkDesc"));
}
print ' ';
if (!empty($object->share)) {
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index a5050889e09..8feff24e4c3 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -327,7 +327,7 @@ $moreheadjs .= ''."\n";
llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
$head = ecm_prepare_dasboard_head('');
-print dol_get_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, '');
+print dol_get_fiche_head($head, 'index', '', -1, '');
// Add filemanager component
diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php
index ae7aa840ab9..9d8e1527b9b 100644
--- a/htdocs/ecm/index_auto.php
+++ b/htdocs/ecm/index_auto.php
@@ -341,7 +341,7 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED))
}
$head = ecm_prepare_dasboard_head('');
-print dol_get_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, '');
+print dol_get_fiche_head($head, 'index_auto', '', -1, '');
diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php
new file mode 100644
index 00000000000..d87ad431b7c
--- /dev/null
+++ b/htdocs/eventorganization/class/conferenceorbooth.class.php
@@ -0,0 +1,1058 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file class/conferenceorbooth.class.php
+ * \ingroup eventorganization
+ * \brief This file is a CRUD class file for ConferenceOrBooth (Create/Read/Update/Delete)
+ */
+
+// Put here all includes required by your class file
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
+//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
+
+/**
+ * Class for ConferenceOrBooth
+ */
+class ConferenceOrBooth extends CommonObject
+{
+ /**
+ * @var string ID of module.
+ */
+ public $module = 'eventorganization';
+
+ /**
+ * @var string ID to identify managed object.
+ */
+ public $element = 'conferenceorbooth';
+
+ /**
+ * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
+ */
+ public $table_element = 'actioncomm';
+
+ /**
+ * @var int Does this object support multicompany module ?
+ * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
+ */
+ public $ismultientitymanaged = 1;
+
+ /**
+ * @var int Does object support extrafields ? 0=No, 1=Yes
+ */
+ public $isextrafieldmanaged = 1;
+
+ /**
+ * @var string String with name of icon for conferenceorbooth. Must be the part after the 'object_' into object_conferenceorbooth.png
+ */
+ public $picto = 'conferenceorbooth@eventorganization';
+
+
+ const STATUS_DRAFT = 0;
+ const STATUS_VALIDATED = 1;
+ const STATUS_CANCELED = 9;
+
+
+ /**
+ * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
+ * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'picto' is code of a picto to show before value in forms
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
+ * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200'
+ * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
+ * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
+ */
+
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields=array(
+ 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
+ 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
+ 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',),
+ //'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"Help text for amount",),
+ //'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'css'=>'maxwidth75imp', 'help'=>"Help text for quantity",),
+ 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",),
+ 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,),
+ 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3,),
+ 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
+ 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
+ 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
+ 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
+ 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
+ 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
+ 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
+ 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
+ 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'),),
+ );
+ public $rowid;
+ public $ref;
+ public $label;
+ public $amount;
+ public $qty;
+ public $fk_soc;
+ public $fk_project;
+ public $description;
+ public $note_public;
+ public $note_private;
+ public $date_creation;
+ public $tms;
+ public $fk_user_creat;
+ public $fk_user_modif;
+ public $last_main_doc;
+ public $import_key;
+ public $model_pdf;
+ public $status;
+ // END MODULEBUILDER PROPERTIES
+
+
+ // If this object has a subtable with lines
+
+ // /**
+ // * @var string Name of subtable line
+ // */
+ // public $table_element_line = 'eventorganization_conferenceorboothline';
+
+ // /**
+ // * @var string Field with ID of parent key if this object has a parent
+ // */
+ // public $fk_element = 'fk_conferenceorbooth';
+
+ // /**
+ // * @var string Name of subtable class that manage subtable lines
+ // */
+ // public $class_element_line = 'ConferenceOrBoothline';
+
+ // /**
+ // * @var array List of child tables. To test if we can delete object.
+ // */
+ // protected $childtables = array();
+
+ // /**
+ // * @var array List of child tables. To know object to delete on cascade.
+ // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
+ // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
+ // */
+ // protected $childtablesoncascade = array('eventorganization_conferenceorboothdet');
+
+ // /**
+ // * @var ConferenceOrBoothLine[] Array of subtable lines
+ // */
+ // public $lines = array();
+
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ public function __construct(DoliDB $db)
+ {
+ global $conf, $langs;
+
+ $this->db = $db;
+
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
+ if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
+
+ // Example to show how to set values of fields definition dynamically
+ /*if ($user->rights->eventorganization->conferenceorbooth->read) {
+ $this->fields['myfield']['visible'] = 1;
+ $this->fields['myfield']['noteditable'] = 0;
+ }*/
+
+ // Unset fields that are disabled
+ foreach ($this->fields as $key => $val)
+ {
+ if (isset($val['enabled']) && empty($val['enabled']))
+ {
+ unset($this->fields[$key]);
+ }
+ }
+
+ // Translate some data of arrayofkeyval
+ if (is_object($langs))
+ {
+ foreach ($this->fields as $key => $val)
+ {
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
+ {
+ foreach ($val['arrayofkeyval'] as $key2 => $val2)
+ {
+ $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ public function create(User $user, $notrigger = false)
+ {
+ return $this->createCommon($user, $notrigger);
+ }
+
+ /**
+ * Clone an object into another one
+ *
+ * @param User $user User that creates
+ * @param int $fromid Id of object to clone
+ * @return mixed New object created, <0 if KO
+ */
+ public function createFromClone(User $user, $fromid)
+ {
+ global $langs, $extrafields;
+ $error = 0;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $object = new self($this->db);
+
+ $this->db->begin();
+
+ // Load source object
+ $result = $object->fetchCommon($fromid);
+ if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
+
+ // get lines so they will be clone
+ //foreach($this->lines as $line)
+ // $line->fetch_optionals();
+
+ // Reset some properties
+ unset($object->id);
+ unset($object->fk_user_creat);
+ unset($object->import_key);
+
+ // Clear fields
+ if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
+ if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
+ if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; }
+ if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); }
+ if (property_exists($object, 'date_modification')) { $object->date_modification = null; }
+ // ...
+ // Clear extrafields that are unique
+ if (is_array($object->array_options) && count($object->array_options) > 0)
+ {
+ $extrafields->fetch_name_optionals_label($this->table_element);
+ foreach ($object->array_options as $key => $option)
+ {
+ $shortkey = preg_replace('/options_/', '', $key);
+ if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey]))
+ {
+ //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
+ unset($object->array_options[$key]);
+ }
+ }
+ }
+
+ // Create clone
+ $object->context['createfromclone'] = 'createfromclone';
+ $result = $object->createCommon($user);
+ if ($result < 0) {
+ $error++;
+ $this->error = $object->error;
+ $this->errors = $object->errors;
+ }
+
+ if (!$error)
+ {
+ // copy internal contacts
+ if ($this->copy_linked_contact($object, 'internal') < 0)
+ {
+ $error++;
+ }
+ }
+
+ if (!$error)
+ {
+ // copy external contacts if same company
+ if (property_exists($this, 'socid') && $this->socid == $object->socid)
+ {
+ if ($this->copy_linked_contact($object, 'external') < 0)
+ $error++;
+ }
+ }
+
+ unset($object->context['createfromclone']);
+
+ // End
+ if (!$error) {
+ $this->db->commit();
+ return $object;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @param string $ref Ref
+ * @return int <0 if KO, 0 if not found, >0 if OK
+ */
+ public function fetch($id, $ref = null)
+ {
+ $result = $this->fetchCommon($id, $ref);
+ if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
+ return $result;
+ }
+
+ /**
+ * Load object lines in memory from the database
+ *
+ * @return int <0 if KO, 0 if not found, >0 if OK
+ */
+ public function fetchLines()
+ {
+ $this->lines = array();
+
+ $result = $this->fetchLinesCommon();
+ return $result;
+ }
+
+
+ /**
+ * Load list of objects in memory from the database.
+ *
+ * @param string $sortorder Sort Order
+ * @param string $sortfield Sort field
+ * @param int $limit limit
+ * @param int $offset Offset
+ * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
+ * @param string $filtermode Filter mode (AND or OR)
+ * @return array|int int <0 if KO, array of pages if OK
+ */
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
+ global $conf;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $records = array();
+
+ $sql = 'SELECT ';
+ $sql .= $this->getFieldList();
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
+ else $sql .= ' WHERE 1 = 1';
+ // Manage filter
+ $sqlwhere = array();
+ if (count($filter) > 0) {
+ foreach ($filter as $key => $value) {
+ if ($key == 't.rowid') {
+ $sqlwhere[] = $key.'='.$value;
+ } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
+ $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
+ } elseif ($key == 'customsql') {
+ $sqlwhere[] = $value;
+ } elseif (strpos($value, '%') === false) {
+ $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')';
+ } else {
+ $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
+ }
+ }
+ }
+ if (count($sqlwhere) > 0) {
+ $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
+ }
+
+ if (!empty($sortfield)) {
+ $sql .= $this->db->order($sortfield, $sortorder);
+ }
+ if (!empty($limit)) {
+ $sql .= ' '.$this->db->plimit($limit, $offset);
+ }
+
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < ($limit ? min($limit, $num) : $num))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $record = new self($this->db);
+ $record->setVarsFromFetchObj($obj);
+
+ $records[$record->id] = $record;
+
+ $i++;
+ }
+ $this->db->free($resql);
+
+ return $records;
+ } else {
+ $this->errors[] = 'Error '.$this->db->lasterror();
+ dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
+
+ return -1;
+ }
+ }
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update(User $user, $notrigger = false)
+ {
+ return $this->updateCommon($user, $notrigger);
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function delete(User $user, $notrigger = false)
+ {
+ return $this->deleteCommon($user, $notrigger);
+ //return $this->deleteCommon($user, $notrigger, 1);
+ }
+
+ /**
+ * Delete a line of object in database
+ *
+ * @param User $user User that delete
+ * @param int $idline Id of line to delete
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int >0 if OK, <0 if KO
+ */
+ public function deleteLine(User $user, $idline, $notrigger = false)
+ {
+ if ($this->status < 0)
+ {
+ $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
+ return -2;
+ }
+
+ return $this->deleteLineCommon($user, $idline, $notrigger);
+ }
+
+
+ /**
+ * Validate object
+ *
+ * @param User $user User making status change
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <=0 if OK, 0=Nothing done, >0 if KO
+ */
+ public function validate($user, $notrigger = 0)
+ {
+ global $conf, $langs;
+
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ $error = 0;
+
+ // Protection
+ if ($this->status == self::STATUS_VALIDATED)
+ {
+ dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorbooth->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorbooth->conferenceorbooth_advance->validate))))
+ {
+ $this->error='NotEnoughPermissions';
+ dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
+ return -1;
+ }*/
+
+ $now = dol_now();
+
+ $this->db->begin();
+
+ // Define new ref
+ if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
+ {
+ $num = $this->getNextNumRef();
+ } else {
+ $num = $this->ref;
+ }
+ $this->newref = $num;
+
+ if (!empty($num)) {
+ // Validate
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET ref = '".$this->db->escape($num)."',";
+ $sql .= " status = ".self::STATUS_VALIDATED;
+ if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'";
+ if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id;
+ $sql .= " WHERE rowid = ".$this->id;
+
+ dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (!$resql)
+ {
+ dol_print_error($this->db);
+ $this->error = $this->db->lasterror();
+ $error++;
+ }
+
+ if (!$error && !$notrigger)
+ {
+ // Call trigger
+ $result = $this->call_trigger('CONFERENCEORBOOTH_VALIDATE', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+ }
+
+ if (!$error)
+ {
+ $this->oldref = $this->ref;
+
+ // Rename directory if dir was a temporary ref
+ if (preg_match('/^[\(]?PROV/i', $this->ref))
+ {
+ // Now we rename also files into index
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorbooth/".$this->db->escape($this->newref)."'";
+ $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorbooth/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
+
+ // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
+ $oldref = dol_sanitizeFileName($this->ref);
+ $newref = dol_sanitizeFileName($num);
+ $dirsource = $conf->eventorganization->dir_output.'/conferenceorbooth/'.$oldref;
+ $dirdest = $conf->eventorganization->dir_output.'/conferenceorbooth/'.$newref;
+ if (!$error && file_exists($dirsource))
+ {
+ dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
+
+ if (@rename($dirsource, $dirdest))
+ {
+ dol_syslog("Rename ok");
+ // Rename docs starting with $oldref with $newref
+ $listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorbooth/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
+ foreach ($listoffiles as $fileentry)
+ {
+ $dirsource = $fileentry['name'];
+ $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
+ $dirsource = $fileentry['path'].'/'.$dirsource;
+ $dirdest = $fileentry['path'].'/'.$dirdest;
+ @rename($dirsource, $dirdest);
+ }
+ }
+ }
+ }
+ }
+
+ // Set new ref and current status
+ if (!$error)
+ {
+ $this->ref = $num;
+ $this->status = self::STATUS_VALIDATED;
+ }
+
+ if (!$error)
+ {
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+
+ /**
+ * Set draft status
+ *
+ * @param User $user Object user that modify
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setDraft($user, $notrigger = 0)
+ {
+ // Protection
+ if ($this->status <= self::STATUS_DRAFT)
+ {
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }*/
+
+ return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTH_UNVALIDATE');
+ }
+
+ /**
+ * Set cancel status
+ *
+ * @param User $user Object user that modify
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, 0=Nothing done, >0 if OK
+ */
+ public function cancel($user, $notrigger = 0)
+ {
+ // Protection
+ if ($this->status != self::STATUS_VALIDATED)
+ {
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }*/
+
+ return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTH_CANCEL');
+ }
+
+ /**
+ * Set back to validated status
+ *
+ * @param User $user Object user that modify
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, 0=Nothing done, >0 if OK
+ */
+ public function reopen($user, $notrigger = 0)
+ {
+ // Protection
+ if ($this->status != self::STATUS_CANCELED)
+ {
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }*/
+
+ return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTH_REOPEN');
+ }
+
+ /**
+ * Return a link to the object card (with optionaly the picto)
+ *
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to ('nolink', ...)
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
+ {
+ global $conf, $langs, $hookmanager;
+
+ if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+
+ $result = '';
+
+ $label = img_picto('', $this->picto).' '.$langs->trans("ConferenceOrBooth").' ';
+ if (isset($this->status)) {
+ $label .= ' '.$this->getLibStatut(5);
+ }
+ $label .= ' ';
+ $label .= ''.$langs->trans('Ref').': '.$this->ref;
+
+ $url = dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.$this->id;
+
+ if ($option != 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+ if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ }
+
+ $linkclose = '';
+ if (empty($notooltip))
+ {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label = $langs->trans("ShowConferenceOrBooth");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+
+ $linkstart = '';
+ $linkend = ' ';
+
+ $result .= $linkstart;
+
+ if (empty($this->showphoto_on_popup)) {
+ if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ } else {
+ if ($withpicto) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ list($class, $module) = explode('@', $this->picto);
+ $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
+ $filearray = dol_dir_list($upload_dir, "files");
+ $filename = $filearray[0]['name'];
+ if (!empty($filename)) {
+ $pospoint = strpos($filearray[0]['name'], '.');
+
+ $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
+ if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
+ $result .= '';
+ } else {
+ $result .= '';
+ }
+
+ $result .= '';
+ } else {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ }
+ }
+
+ if ($withpicto != 2) $result .= $this->ref;
+
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+
+ global $action, $hookmanager;
+ $hookmanager->initHooks(array('conferenceorboothdao'));
+ $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
+ $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) $result = $hookmanager->resPrint;
+ else $result .= $hookmanager->resPrint;
+
+ return $result;
+ }
+
+ /**
+ * Return the label of the status
+ *
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ public function getLibStatut($mode = 0)
+ {
+ return $this->LibStatut($this->status, $mode);
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return the status
+ *
+ * @param int $status Id status
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ public function LibStatut($status, $mode = 0)
+ {
+ // phpcs:enable
+ if (empty($this->labelStatus) || empty($this->labelStatusShort))
+ {
+ global $langs;
+ //$langs->load("eventorganization@eventorganization");
+ $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
+ $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
+ $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
+ $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
+ $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
+ $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
+ }
+
+ $statusType = 'status'.$status;
+ //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
+ if ($status == self::STATUS_CANCELED) $statusType = 'status6';
+
+ return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
+ }
+
+ /**
+ * Load the info information in the object
+ *
+ * @param int $id Id of object
+ * @return void
+ */
+ public function info($id)
+ {
+ $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
+ $sql .= ' fk_user_creat, fk_user_modif';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= ' WHERE t.rowid = '.$id;
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ if ($this->db->num_rows($result))
+ {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author)
+ {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
+
+ if ($obj->fk_user_valid)
+ {
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
+ $this->user_validation = $vuser;
+ }
+
+ if ($obj->fk_user_cloture)
+ {
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
+ $this->user_cloture = $cluser;
+ }
+
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_modification = $this->db->jdate($obj->datem);
+ $this->date_validation = $this->db->jdate($obj->datev);
+ }
+
+ $this->db->free($result);
+ } else {
+ dol_print_error($this->db);
+ }
+ }
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ public function initAsSpecimen()
+ {
+ $this->initAsSpecimenCommon();
+ }
+
+ /**
+ * Create an array of lines
+ *
+ * @return array|int array of lines if OK, <0 if KO
+ */
+ public function getLinesArray()
+ {
+ $this->lines = array();
+
+ $objectline = new ConferenceOrBoothLine($this->db);
+ $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorbooth = '.$this->id));
+
+ if (is_numeric($result))
+ {
+ $this->error = $this->error;
+ $this->errors = $this->errors;
+ return $result;
+ } else {
+ $this->lines = $result;
+ return $this->lines;
+ }
+ }
+
+ /**
+ * Returns the reference to the following non used object depending on the active numbering module.
+ *
+ * @return string Object free reference
+ */
+ public function getNextNumRef()
+ {
+ global $langs, $conf;
+ $langs->load("eventorganization@eventorganization");
+
+ if (empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON)) {
+ $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON = 'mod_conferenceorbooth_standard';
+ }
+
+ if (!empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON))
+ {
+ $mybool = false;
+
+ $file = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON.".php";
+ $classname = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTH_ADDON;
+
+ // Include file with class
+ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+ foreach ($dirmodels as $reldir)
+ {
+ $dir = dol_buildpath($reldir."core/modules/eventorganization/");
+
+ // Load file with numbering class (if found)
+ $mybool |= @include_once $dir.$file;
+ }
+
+ if ($mybool === false)
+ {
+ dol_print_error('', "Failed to include file ".$file);
+ return '';
+ }
+
+ if (class_exists($classname)) {
+ $obj = new $classname();
+ $numref = $obj->getNextValue($this);
+
+ if ($numref != '' && $numref != '-1')
+ {
+ return $numref;
+ } else {
+ $this->error = $obj->error;
+ //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
+ return "";
+ }
+ } else {
+ print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
+ return "";
+ }
+ } else {
+ print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
+ return "";
+ }
+ }
+
+ /**
+ * Create a document onto disk according to template module.
+ *
+ * @param string $modele Force template to use ('' to not force)
+ * @param Translate $outputlangs objet lang a utiliser pour traduction
+ * @param int $hidedetails Hide details of lines
+ * @param int $hidedesc Hide description
+ * @param int $hideref Hide ref
+ * @param null|array $moreparams Array to provide more information
+ * @return int 0 if KO, 1 if OK
+ */
+ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
+ {
+ global $conf, $langs;
+
+ $result = 0;
+ $includedocgeneration = 0;
+
+ $langs->load("eventorganization@eventorganization");
+
+ if (!dol_strlen($modele)) {
+ $modele = 'standard_conferenceorbooth';
+
+ if (!empty($this->model_pdf)) {
+ $modele = $this->model_pdf;
+ } elseif (!empty($conf->global->CONFERENCEORBOOTH_ADDON_PDF)) {
+ $modele = $conf->global->CONFERENCEORBOOTH_ADDON_PDF;
+ }
+ }
+
+ $modelpath = "core/modules/eventorganization/doc/";
+
+ if ($includedocgeneration && !empty($modele)) {
+ $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Action executed by scheduler
+ * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
+ * Use public function doScheduledJob($param1, $param2, ...) to get parameters
+ *
+ * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
+ */
+ public function doScheduledJob()
+ {
+ global $conf, $langs;
+
+ //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
+
+ $error = 0;
+ $this->output = '';
+ $this->error = '';
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $now = dol_now();
+
+ $this->db->begin();
+
+ // ...
+
+ $this->db->commit();
+
+ return $error;
+ }
+}
+
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
+
+/**
+ * Class ConferenceOrBoothLine. You can also remove this and generate a CRUD class for lines objects.
+ */
+class ConferenceOrBoothLine extends CommonObjectLine
+{
+ // To complete with content of an object ConferenceOrBoothLine
+ // We should have a field rowid, fk_conferenceorbooth and position
+
+ /**
+ * @var int Does object support extrafields ? 0=No, 1=Yes
+ */
+ public $isextrafieldmanaged = 0;
+
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ public function __construct(DoliDB $db)
+ {
+ $this->db = $db;
+ }
+}
diff --git a/htdocs/eventorganization/conferenceorbooth_agenda.php b/htdocs/eventorganization/conferenceorbooth_agenda.php
new file mode 100644
index 00000000000..1583c0acbd2
--- /dev/null
+++ b/htdocs/eventorganization/conferenceorbooth_agenda.php
@@ -0,0 +1,287 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file conferenceorbooth_agenda.php
+ * \ingroup eventorganization
+ * \brief Tab of events on ConferenceOrBooth
+ */
+
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
+//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
+//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+dol_include_once('/eventorganization/class/conferenceorbooth.class.php');
+dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php');
+
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization@eventorganization", "other"));
+
+// Get parameters
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
+if (GETPOST('actioncode', 'array')) {
+ $actioncode = GETPOST('actioncode', 'array', 3);
+ if (!count($actioncode)) {
+ $actioncode = '0';
+ }
+} else {
+ $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+}
+$search_agenda_label = GETPOST('search_agenda_label');
+
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (!$sortfield) {
+ $sortfield = 'a.datep,a.id';
+}
+if (!$sortorder) {
+ $sortorder = 'DESC,DESC';
+}
+
+// Initialize technical objects
+$object = new ConferenceOrBooth($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('conferenceorboothagenda', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) {
+ $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id;
+}
+
+// Security check - Protection if external user
+//if ($user->socid > 0) accessforbidden();
+//if ($user->socid > 0) $socid = $user->socid;
+//$result = restrictedArea($user, 'eventorganization', $object->id);
+
+$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php
+
+
+/*
+ * Actions
+ */
+
+$parameters = array('id'=>$id);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+if (empty($reshook)) {
+ // Cancel
+ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
+ header("Location: ".$backtopage);
+ exit;
+ }
+
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
+ $actioncode = '';
+ $search_agenda_label = '';
+ }
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+if ($object->id > 0) {
+ $title = $langs->trans("Agenda");
+ //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
+ $help_url = '';
+ llxHeader('', $title, $help_url);
+
+ if (!empty($conf->notification->enabled)) {
+ $langs->load("mails");
+ }
+ $head = conferenceorboothPrepareHead($object);
+
+
+ print dol_get_fiche_head($head, 'agenda', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $morehtmlref = '';
+ /*
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
+ // Project
+ if (! empty($conf->projet->enabled)) {
+ $langs->load("projects");
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($permissiontoadd) {
+ if ($action != 'classify') {
+ //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ }
+ $morehtmlref.=' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='
';
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ': '.$proj->getNomUrl();
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }*/
+ $morehtmlref .= '
';
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+ print '';
+ print '
';
+
+ $object->info($object->id);
+ dol_print_object_info($object, 1);
+
+ print '
';
+
+ print dol_get_fiche_end();
+
+
+
+ // Actions buttons
+
+ $objthirdparty = $object;
+ $objcon = new stdClass();
+
+ $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id);
+ $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
+ $out .= '&backtopage='.urlencode($urlbacktopage);
+ $permok = $user->rights->agenda->myactions->create;
+ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
+ //$out.='trans("AddAnAction"),'filenew');
+ //$out.=" ";
+ }
+
+
+ print '';
+
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
+ $param = '&id='.$object->id.'&socid='.$socid;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+ }
+ if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+ }
+
+
+ //print load_fiche_titre($langs->trans("ActionsOnConferenceOrBooth"), '', '');
+
+ // List of all actions
+ $filters = array();
+ $filters['search_agenda_label'] = $search_agenda_label;
+
+ // TODO Replace this with same code than into list.php
+ show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
+ }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php
new file mode 100644
index 00000000000..59b59b78436
--- /dev/null
+++ b/htdocs/eventorganization/conferenceorbooth_card.php
@@ -0,0 +1,550 @@
+
+ * Copyright (C) 2021 Florian Henry
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file event.php
+ * \ingroup eventorganization
+ * \brief Page to create/edit/view conferenceorbooth
+ */
+
+require '../main.inc.php';
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization", "projects"));
+
+// Get parameters
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$confirm = GETPOST('confirm', 'alpha');
+$cancel = GETPOST('cancel', 'aZ09');
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothcard'; // To manage different context of search
+$backtopage = GETPOST('backtopage', 'alpha');
+$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
+//$lineid = GETPOST('lineid', 'int');
+
+// Initialize technical objects
+$object = new ConferenceOrBooth($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('conferenceorboothcard', 'globalcard')); // Note that conf->hooks_modules contains array
+
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
+
+// Initialize array of search criterias
+$search_all = GETPOST("search_all", 'alpha');
+$search = array();
+foreach ($object->fields as $key => $val) {
+ if (GETPOST('search_'.$key, 'alpha')) {
+ $search[$key] = GETPOST('search_'.$key, 'alpha');
+ }
+}
+
+if (empty($action) && empty($id) && empty($ref)) {
+ $action = 'view';
+}
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
+
+
+/*$permissiontoread = $user->rights->eventorganization->conferenceorbooth->read;
+$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->rights->eventorganization->conferenceorbooth->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_dellink.inc.php*/
+$permissiontoread = $user->rights->eventorganization->read;
+$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php
+$upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1];
+
+// Security check - Protection if external user
+if ($user->socid > 0) accessforbidden();
+if ($user->socid > 0) $socid = $user->socid;
+$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
+$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
+
+if (!$permissiontoread) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+if (empty($reshook)) {
+ $error = 0;
+
+ $backurlforlist = dol_buildpath('/eventorganization/conferenceorbooth_list.php', 1);
+
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
+ }
+ }
+ }
+
+ $triggermodname = 'EVENTORGANIZATION_CONFERENCEORBOOTH_MODIFY'; // Name of trigger action code to execute when we modify record
+
+ // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
+ include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
+
+ // Actions when linking object each other
+ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
+
+ // Actions when printing a doc from card
+ include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
+
+ // Action to move up and down lines of object
+ //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
+
+ // Action to build doc
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+
+ if ($action == 'set_thirdparty' && $permissiontoadd) {
+ $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
+ }
+ if ($action == 'classin' && $permissiontoadd) {
+ $object->setProject(GETPOST('projectid', 'int'));
+ }
+
+ // Actions to send emails
+ $triggersendname = 'EVENTORGANIZATION_CONFERENCEORBOOTH_SENTBYMAIL';
+ $autocopy = 'MAIN_MAIL_AUTOCOPY_CONFERENCEORBOOTH_TO';
+ $trackid = 'conferenceorbooth'.$object->id;
+ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
+}
+
+
+
+
+/*
+ * View
+ *
+ * Put here all code to build page
+ */
+
+$form = new Form($db);
+$formfile = new FormFile($db);
+$formproject = new FormProjets($db);
+
+$title = $langs->trans("ConferenceOrBooth");
+$help_url = '';
+llxHeader('', $title, $help_url);
+
+// Example : Adding jquery code
+/*print '';*/
+
+
+// Part to create
+if ($action == 'create') {
+ print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto);
+
+ print '';
+ print ' ';
+ print ' ';
+ if ($backtopage) {
+ print ' ';
+ }
+ if ($backtopageforcancel) {
+ print ' ';
+ }
+
+ print dol_get_fiche_head(array(), '');
+
+ // Set some default values
+ //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
+
+ print ''."\n";
+
+ // Common attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
+
+ // Other attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
+
+ print '
'."\n";
+
+ print dol_get_fiche_end();
+
+ print '';
+ print ' ';
+ print ' ';
+ print ' '; // Cancel for create does not post form if we don't know the backtopage
+ print '
';
+
+ print ' ';
+
+ //dol_set_focus('input[name="ref"]');
+}
+
+// Part to edit record
+if (($id || $ref) && $action == 'edit') {
+ print load_fiche_titre($langs->trans("ConferenceOrBooth"), '', 'object_'.$object->picto);
+
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ if ($backtopage) {
+ print ' ';
+ }
+ if ($backtopageforcancel) {
+ print ' ';
+ }
+
+ print dol_get_fiche_head();
+
+ print ''."\n";
+
+ // Common attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
+
+ // Other attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
+
+ print '
';
+
+ print dol_get_fiche_end();
+
+ print ' ';
+ print ' ';
+ print '
';
+
+ print ' ';
+}
+
+// Part to show record
+if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
+ $res = $object->fetch_optionals();
+
+ $head = conferenceorboothPrepareHead($object);
+ print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
+
+ $formconfirm = '';
+
+ // Confirmation to delete
+ if ($action == 'delete') {
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
+ }
+ // Confirmation to delete line
+ if ($action == 'deleteline') {
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
+ }
+ // Clone confirmation
+ if ($action == 'clone') {
+ // Create an array for form
+ $formquestion = array();
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
+ }
+
+ // Confirmation of action xxxx
+ if ($action == 'xxx') {
+ $formquestion = array();
+ /*
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
+ );
+ */
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
+ }
+
+ // Call Hook formConfirm
+ $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) {
+ $formconfirm .= $hookmanager->resPrint;
+ } elseif ($reshook > 0) {
+ $formconfirm = $hookmanager->resPrint;
+ }
+
+ // Print form confirm
+ print $formconfirm;
+
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $morehtmlref = '';
+ /*
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
+ // Project
+ if (! empty($conf->projet->enabled)) {
+ $langs->load("projects");
+ $morehtmlref .= '
'.$langs->trans('Project') . ' ';
+ if ($permissiontoadd) {
+ //if ($action != 'classify') $morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' ';
+ $morehtmlref .= ' : ';
+ if ($action == 'classify') {
+ //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '
';
+ $morehtmlref .= ' ';
+ $morehtmlref .= ' ';
+ $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref .= ' ';
+ $morehtmlref .= ' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ': '.$proj->getNomUrl();
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }*/
+ $morehtmlref .= '
';
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+
+ print '';
+ print '
';
+ print '
';
+ print '
'."\n";
+
+ // Common attributes
+ //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
+ //unset($object->fields['fk_project']); // Hide field already shown in banner
+ //unset($object->fields['fk_soc']); // Hide field already shown in banner
+ include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
+
+ // Other attributes. Fields from hook formObjectOptions and Extrafields.
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
+
+ print '
';
+ print '
';
+ print '
';
+
+ print '
';
+
+ print dol_get_fiche_end();
+
+
+ /*
+ * Lines
+ */
+
+ if (!empty($object->table_element_line)) {
+ // Show object lines
+ $result = $object->getLinesArray();
+
+ print ' id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
+
+
+
+
+ ';
+
+ if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
+ include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
+ }
+
+ print '';
+ if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
+ print '
';
+ }
+
+ if (!empty($object->lines)) {
+ $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
+ }
+
+ // Form to add new line
+ if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
+ if ($action != 'editline') {
+ // Add products/services form
+ $object->formAddObjectLine(1, $mysoc, $soc);
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ }
+ }
+
+ if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
+ print '
';
+ }
+ print '
';
+
+ print " \n";
+ }
+
+
+ // Buttons for actions
+
+ if ($action != 'presend' && $action != 'editline') {
+ print ''."\n";
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ if (empty($reshook)) {
+ // Send
+ if (empty($user->socid)) {
+ print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle');
+ }
+
+ // Back to draft
+ if ($object->status == $object::STATUS_VALIDATED) {
+ print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd);
+ }
+
+ print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd);
+
+ // Validate
+ if ($object->status == $object::STATUS_DRAFT) {
+ if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
+ print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd);
+ } else {
+ $langs->load("errors");
+ //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0);
+ print '
'.$langs->trans("Validate").' ';
+ }
+ }
+
+ // Clone
+ print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd);
+
+ /*
+ if ($permissiontoadd) {
+ if ($object->status == $object::STATUS_ENABLED) {
+ print '
id.'&action=disable">'.$langs->trans("Disable").' '."\n";
+ } else {
+ print '
id.'&action=enable">'.$langs->trans("Enable").' '."\n";
+ }
+ }
+ if ($permissiontoadd) {
+ if ($object->status == $object::STATUS_VALIDATED) {
+ print '
id.'&action=close">'.$langs->trans("Cancel").' '."\n";
+ } else {
+ print '
id.'&action=reopen">'.$langs->trans("Re-Open").' '."\n";
+ }
+ }
+ */
+
+ // Delete (need delete permission, or if draft, just need create/modify permission)
+ print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
+ }
+ print '
'."\n";
+ }
+
+
+ // Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
+
+ if ($action != 'presend') {
+ print '';
+ print '
'; // ancre
+
+ $includedocgeneration = 0;
+
+ // Documents
+ if ($includedocgeneration) {
+ $objref = dol_sanitizeFileName($object->ref);
+ $relativepath = $objref.'/'.$objref.'.pdf';
+ $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref;
+ $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
+ $genallowed = $user->rights->eventorganization->conferenceorbooth->read; // If you can read, you can build the PDF to read content
+ $delallowed = $user->rights->eventorganization->conferenceorbooth->write; // If you can create/edit, you can remove a file on card
+ print $formfile->showdocuments('eventorganization:ConferenceOrBooth', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
+ }
+
+ // Show links to link elements
+ $linktoelem = $form->showLinkToObjectBlock($object, null, array('conferenceorbooth'));
+ $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+
+
+ print '
';
+
+ $MAXEVENT = 10;
+
+ $morehtmlright = '
';
+ $morehtmlright .= $langs->trans("SeeAll");
+ $morehtmlright .= ' ';
+
+ // List of actions on element
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+ $formactions = new FormActions($db);
+ $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
+
+ print '
';
+ }
+
+ //Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
+
+ // Presend form
+ $modelmail = 'conferenceorbooth';
+ $defaulttopic = 'InformationMessage';
+ $diroutput = $conf->eventorganization->dir_output;
+ $trackid = 'conferenceorbooth'.$object->id;
+
+ include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php
new file mode 100644
index 00000000000..b2a80de902c
--- /dev/null
+++ b/htdocs/eventorganization/conferenceorbooth_contact.php
@@ -0,0 +1,197 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file conferenceorbooth_contact.php
+ * \ingroup eventorganization
+ * \brief Tab for contacts linked to ConferenceOrBooth
+ */
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+dol_include_once('/eventorganization/class/conferenceorbooth.class.php');
+dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php');
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails"));
+
+$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
+$ref = GETPOST('ref', 'alpha');
+$lineid = GETPOST('lineid', 'int');
+$socid = GETPOST('socid', 'int');
+$action = GETPOST('action', 'aZ09');
+
+// Initialize technical objects
+$object = new ConferenceOrBooth($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('conferenceorboothcontact', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+// Security check - Protection if external user
+//if ($user->socid > 0) accessforbidden();
+//if ($user->socid > 0) $socid = $user->socid;
+//$result = restrictedArea($user, 'eventorganization', $object->id);
+
+$permission = $user->rights->eventorganization->conferenceorbooth->write;
+
+/*
+ * Add a new contact
+ */
+
+if ($action == 'addcontact' && $permission) {
+ $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
+ $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
+ $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
+
+ if ($result >= 0) {
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ } else {
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+} elseif ($action == 'swapstatut' && $permission) {
+ // Toggle the status of a contact
+ $result = $object->swapContactStatus(GETPOST('ligne'));
+} elseif ($action == 'deletecontact' && $permission) {
+ // Deletes a contact
+ $result = $object->delete_contact($lineid);
+
+ if ($result >= 0) {
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ } else {
+ dol_print_error($db);
+ }
+}
+
+
+/*
+ * View
+ */
+
+$title = $langs->trans('ConferenceOrBooth')." - ".$langs->trans('ContactsAddresses');
+$help_url = '';
+//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+llxHeader('', $title, $help_url);
+
+$form = new Form($db);
+$formcompany = new FormCompany($db);
+$contactstatic = new Contact($db);
+$userstatic = new User($db);
+
+
+/* *************************************************************************** */
+/* */
+/* View and edit mode */
+/* */
+/* *************************************************************************** */
+
+if ($object->id) {
+ /*
+ * Show tabs
+ */
+ $head = conferenceorboothPrepareHead($object);
+
+ print dol_get_fiche_head($head, 'contact', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $morehtmlref = '';
+ /*
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($permissiontoadd)
+ {
+ if ($action != 'classify')
+ //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $morehtmlref.=' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='
';
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ': '.$proj->getNomUrl();
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }*/
+ $morehtmlref .= '
';
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
+
+ print dol_get_fiche_end();
+
+ print ' ';
+
+ // Contacts lines (modules that overwrite templates must declare this into descriptor)
+ $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
+ foreach ($dirtpls as $reldir) {
+ $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
+ if ($res) {
+ break;
+ }
+ }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php
new file mode 100644
index 00000000000..7ad8088c127
--- /dev/null
+++ b/htdocs/eventorganization/conferenceorbooth_document.php
@@ -0,0 +1,234 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file conferenceorbooth_document.php
+ * \ingroup eventorganization
+ * \brief Tab for documents linked to ConferenceOrBooth
+ */
+
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
+//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
+//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+dol_include_once('/eventorganization/class/conferenceorbooth.class.php');
+dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php');
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails"));
+
+
+$action = GETPOST('action', 'aZ09');
+$confirm = GETPOST('confirm');
+$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
+$ref = GETPOST('ref', 'alpha');
+
+// Get parameters
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
+$offset = $liste_limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "name";
+}
+//if (! $sortfield) $sortfield="position_name";
+
+// Initialize technical objects
+$object = new ConferenceOrBooth($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+if ($id > 0 || !empty($ref)) {
+ $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object);
+}
+
+// Security check - Protection if external user
+//if ($user->socid > 0) accessforbidden();
+//if ($user->socid > 0) $socid = $user->socid;
+//$result = restrictedArea($user, 'eventorganization', $object->id);
+
+$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php
+
+
+
+/*
+ * Actions
+ */
+
+include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files");
+$help_url = '';
+//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+llxHeader('', $title, $help_url);
+
+if ($object->id) {
+ /*
+ * Show tabs
+ */
+ $head = conferenceorboothPrepareHead($object);
+
+ print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
+
+
+ // Build file list
+ $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
+ $totalsize = 0;
+ foreach ($filearray as $key => $file) {
+ $totalsize += $file['size'];
+ }
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $morehtmlref = '';
+ /*
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($permissiontoadd)
+ {
+ if ($action != 'classify')
+ //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $morehtmlref.=' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='
';
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ': '.$proj->getNomUrl();
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }*/
+ $morehtmlref .= '
';
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+ print '';
+
+ print '
';
+ print '
';
+
+ // Number of files
+ print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
+
+ // Total size
+ print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
+
+ print '
';
+
+ print '
';
+
+ print dol_get_fiche_end();
+
+ $modulepart = 'eventorganization';
+ //$permission = $user->rights->eventorganization->conferenceorbooth->write;
+ $permission = 1;
+ //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write;
+ $permtoedit = 1;
+ $param = '&id='.$object->id;
+
+ //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/';
+ $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/';
+
+ include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
+} else {
+ accessforbidden('', 0, 1);
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php
new file mode 100644
index 00000000000..737e69f67e6
--- /dev/null
+++ b/htdocs/eventorganization/conferenceorbooth_list.php
@@ -0,0 +1,678 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file conferenceorbooth_list.php
+ * \ingroup eventorganization
+ * \brief List page for conferenceorbooth
+ */
+
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
+//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
+//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+
+// load eventorganization libraries
+require_once __DIR__.'/class/conferenceorbooth.class.php';
+
+// for other modules
+//dol_include_once('/othermodule/class/otherobject.class.php');
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization@eventorganization", "other"));
+
+$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
+$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
+$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
+$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
+$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
+$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothlist'; // To manage different context of search
+$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
+$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
+
+$id = GETPOST('id', 'int');
+
+// Load variable for pagination
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST('sortfield', 'aZ09comma');
+$sortorder = GETPOST('sortorder', 'aZ09comma');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
+ $page = 0;
+} // If $page is not defined, or '' or -1 or if we click on clear filters
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+// Initialize technical objects
+$object = new ConferenceOrBooth($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('conferenceorboothlist')); // Note that conf->hooks_modules contains array
+
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+//$extrafields->fetch_name_optionals_label($object->table_element_line);
+
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
+
+// Default sort order (if not yet defined by previous GETPOST)
+if (!$sortfield) {
+ reset($object->fields); // Reset is required to avoid key() to return null.
+ $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
+}
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+
+// Initialize array of search criterias
+$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
+$search = array();
+foreach ($object->fields as $key => $val) {
+ if (GETPOST('search_'.$key, 'alpha') !== '') {
+ $search[$key] = GETPOST('search_'.$key, 'alpha');
+ }
+ if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
+ $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
+ $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
+ }
+}
+
+// List of fields to search into when doing a "search in all"
+$fieldstosearchall = array();
+foreach ($object->fields as $key => $val) {
+ if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
+}
+
+// Definition of array of fields for columns
+$arrayfields = array();
+foreach ($object->fields as $key => $val) {
+ // If $val['visible']==0, then we never show the field
+ if (!empty($val['visible'])) {
+ $visible = (int) dol_eval($val['visible'], 1);
+ $arrayfields['t.'.$key] = array(
+ 'label'=>$val['label'],
+ 'checked'=>(($visible < 0) ? 0 : 1),
+ 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+ 'position'=>$val['position'],
+ 'help'=>$val['help']
+ );
+ }
+}
+// Extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
+
+$object->fields = dol_sort_array($object->fields, 'position');
+$arrayfields = dol_sort_array($arrayfields, 'position');
+
+$permissiontoread = $user->rights->eventorganization->conferenceorbooth->read;
+$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write;
+$permissiontodelete = $user->rights->eventorganization->conferenceorbooth->delete;
+
+// Security check
+if (empty($conf->eventorganization->enabled)) accessforbidden('Module not enabled');
+$socid = 0;
+if ($user->socid > 0) { // Protection if external user
+ //$socid = $user->socid;
+ accessforbidden();
+}
+//$result = restrictedArea($user, 'eventorganization', $id, '');
+//if (!$permissiontoread) accessforbidden();
+
+
+
+/*
+ * Actions
+ */
+
+if (GETPOST('cancel', 'alpha')) {
+ $action = 'list';
+ $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
+ $massaction = '';
+}
+
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+if (empty($reshook)) {
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
+ foreach ($object->fields as $key => $val) {
+ $search[$key] = '';
+ if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
+ $search[$key.'_dtstart'] = '';
+ $search[$key.'_dtend'] = '';
+ }
+ }
+ $toselect = '';
+ $search_array_options = array();
+ }
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
+ || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
+ $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
+ }
+
+ // Mass actions
+ $objectclass = 'ConferenceOrBooth';
+ $objectlabel = 'ConferenceOrBooth';
+ $uploaddir = $conf->eventorganization->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$now = dol_now();
+
+//$help_url="EN:Module_ConferenceOrBooth|FR:Module_ConferenceOrBooth_FR|ES:Módulo_ConferenceOrBooth";
+$help_url = '';
+$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBooths"));
+
+
+// Build and execute select
+// --------------------------------------------------------------------
+$sql = 'SELECT ';
+foreach ($object->fields as $key => $val) {
+ $sql .= 't.'.$key.', ';
+}
+// Add fields from extrafields
+if (!empty($extrafields->attributes[$object->table_element]['label'])) {
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
+ }
+}
+// Add fields from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
+$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+$sql = preg_replace('/,\s*$/', '', $sql);
+$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
+}
+// Add table from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
+else $sql .= " WHERE 1 = 1";
+foreach ($search as $key => $val) {
+ if (in_array($key, $object->fields)) {
+ if ($key == 'status' && $search[$key] == -1) continue;
+ $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
+ if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
+ if ($search[$key] == '-1') $search[$key] = '';
+ $mode_search = 2;
+ }
+ if ($search[$key] != '') {
+ $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
+ }
+ } else {
+ if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
+ $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key);
+ if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
+ if (preg_match('/_dtstart$/', $key)) {
+ $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
+ }
+ if (preg_match('/_dtend$/', $key)) {
+ $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
+ }
+ }
+ }
+ }
+}
+if ($search_all) {
+ $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
+}
+//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
+// Add where from extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
+// Add where from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+
+/* If a group by is required
+$sql.= " GROUP BY ";
+foreach($object->fields as $key => $val) {
+ $sql.='t.'.$key.', ';
+}
+// Add fields from extrafields
+if (! empty($extrafields->attributes[$object->table_element]['label'])) {
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
+}
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+$sql=preg_replace('/,\s*$/','', $sql);
+*/
+
+$sql .= $db->order($sortfield, $sortorder);
+
+// Count total nb of records
+$nbtotalofrecords = '';
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
+ $resql = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($resql);
+ if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
+ $page = 0;
+ $offset = 0;
+ }
+}
+// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
+if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
+ $num = $nbtotalofrecords;
+} else {
+ if ($limit) $sql .= $db->plimit($limit + 1, $offset);
+
+ $resql = $db->query($sql);
+ if (!$resql) {
+ dol_print_error($db);
+ exit;
+ }
+
+ $num = $db->num_rows($resql);
+}
+
+// Direct jump if only one record found
+if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
+ $obj = $db->fetch_object($resql);
+ $id = $obj->rowid;
+ header("Location: ".dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.$id);
+ exit;
+}
+
+
+// Output page
+// --------------------------------------------------------------------
+
+llxHeader('', $title, $help_url);
+
+// Example : Adding jquery code
+print '';
+
+$arrayofselected = is_array($toselect) ? $toselect : array();
+
+$param = '';
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+}
+foreach ($search as $key => $val) {
+ if (is_array($search[$key]) && count($search[$key])) {
+ foreach ($search[$key] as $skey) {
+ $param .= '&search_'.$key.'[]='.urlencode($skey);
+ }
+ } else {
+ $param .= '&search_'.$key.'='.urlencode($search[$key]);
+ }
+}
+if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
+}
+// Add $param from extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
+// Add $param from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
+$param .= $hookmanager->resPrint;
+
+// List of mass actions available
+$arrayofmassactions = array(
+ //'validate'=>$langs->trans("Validate"),
+ //'generate_doc'=>$langs->trans("ReGeneratePDF"),
+ //'builddoc'=>$langs->trans("PDFMerge"),
+ //'presend'=>$langs->trans("SendByMail"),
+);
+if ($permissiontodelete) {
+ $arrayofmassactions['predelete'] = ' '.$langs->trans("Delete");
+}
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
+ $arrayofmassactions = array();
+}
+$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
+
+print ''."\n";
+if ($optioncss != '') {
+ print ' ';
+}
+print ' ';
+print ' ';
+print ' ';
+print ' ';
+print ' ';
+print ' ';
+
+$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
+
+print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
+
+// Add code for pre mass action (confirmation or email presend form)
+$topicmail = "SendConferenceOrBoothRef";
+$modelmail = "conferenceorbooth";
+$objecttmp = new ConferenceOrBooth($db);
+$trackid = 'xxxx'.$object->id;
+include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
+
+if ($search_all) {
+ foreach ($fieldstosearchall as $key => $val) {
+ $fieldstosearchall[$key] = $langs->trans($val);
+ }
+ print ''.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
';
+}
+
+$moreforfilter = '';
+/*$moreforfilter.='';
+$moreforfilter.= $langs->trans('MyFilter') . ': ';
+$moreforfilter.= '
';*/
+
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
+if (empty($reshook)) {
+ $moreforfilter .= $hookmanager->resPrint;
+} else {
+ $moreforfilter = $hookmanager->resPrint;
+}
+
+if (!empty($moreforfilter)) {
+ print '';
+ print $moreforfilter;
+ print '
';
+}
+
+$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
+$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
+$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
+
+print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
+print '
'."\n";
+
+
+// Fields title search
+// --------------------------------------------------------------------
+print '';
+foreach ($object->fields as $key => $val) {
+ $cssforfield = (empty($val['css']) ? '' : $val['css']);
+ if ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
+ print '';
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
+ print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ } elseif (strpos($val['type'], 'integer:') === 0) {
+ print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
+ } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
+ print ' ';
+ } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
+ print '';
+ print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print '';
+ print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ print '
';
+ }
+ print ' ';
+ }
+}
+// Extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
+
+// Fields from hook
+$parameters = array('arrayfields'=>$arrayfields);
+$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
+// Action column
+print '';
+$searchpicto = $form->showFilterButtons();
+print $searchpicto;
+print ' ';
+print ' '."\n";
+
+
+// Fields title label
+// --------------------------------------------------------------------
+print '';
+foreach ($object->fields as $key => $val) {
+ $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
+ if ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
+ print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
+ }
+}
+// Extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
+// Hook fields
+$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
+$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
+// Action column
+print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
+print ' '."\n";
+
+
+// Detect if we need a fetch on each output line
+$needToFetchEachLine = 0;
+if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
+ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
+ if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
+ }
+}
+
+
+// Loop on record
+// --------------------------------------------------------------------
+$i = 0;
+$totalarray = array();
+while ($i < ($limit ? min($num, $limit) : $num)) {
+ $obj = $db->fetch_object($resql);
+ if (empty($obj)) {
+ break; // Should not happen
+ }
+
+ // Store properties in $object
+ $object->setVarsFromFetchObj($obj);
+
+ // Show here line of result
+ print '';
+ foreach ($object->fields as $key => $val) {
+ $cssforfield = (empty($val['css']) ? '' : $val['css']);
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ }
+
+ if (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ } elseif ($key == 'ref') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ }
+
+ if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
+ //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
+
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
+ print '';
+ if ($key == 'status') {
+ print $object->getLibStatut(5);
+ } else {
+ print $object->showOutputField($val, $key, $object->$key, '');
+ }
+ print ' ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!empty($val['isameasure'])) {
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ }
+ $totalarray['val']['t.'.$key] += $object->$key;
+ }
+ }
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Action column
+ print '';
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($object->id, $arrayofselected)) $selected = 1;
+ print ' ';
+ }
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+
+ print ' '."\n";
+
+ $i++;
+}
+
+// Show total line
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
+// If no record found
+if ($num == 0) {
+ $colspan = 1;
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
+ print ''.$langs->trans("NoRecordFound").' ';
+}
+
+
+$db->free($resql);
+
+$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
+
+print '
'."\n";
+print '
'."\n";
+
+print ' '."\n";
+
+if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
+ $hidegeneratedfilelistifempty = 1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
+ $hidegeneratedfilelistifempty = 0;
+ }
+
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+ $formfile = new FormFile($db);
+
+ // Show list of available documents
+ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource .= str_replace('&', '&', $param);
+
+ $filedir = $diroutputmassaction;
+ $genallowed = $permissiontoread;
+ $delallowed = $permissiontoadd;
+
+ print $formfile->showdocuments('massfilesarea_eventorganization', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/conferenceorbooth_note.php b/htdocs/eventorganization/conferenceorbooth_note.php
new file mode 100644
index 00000000000..c34b01df436
--- /dev/null
+++ b/htdocs/eventorganization/conferenceorbooth_note.php
@@ -0,0 +1,184 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file conferenceorbooth_note.php
+ * \ingroup eventorganization
+ * \brief Tab for notes on ConferenceOrBooth
+ */
+
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
+//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
+//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
+//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
+//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
+//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
+//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
+//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
+//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
+//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+dol_include_once('/eventorganization/class/conferenceorbooth.class.php');
+dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php');
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization@eventorganization", "companies"));
+
+// Get parameters
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
+// Initialize technical objects
+$object = new ConferenceOrBooth($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('conferenceorboothnote', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Security check - Protection if external user
+//if ($user->socid > 0) accessforbidden();
+//if ($user->socid > 0) $socid = $user->socid;
+//$result = restrictedArea($user, 'eventorganization', $id);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) {
+ $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id;
+}
+
+$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php
+$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php
+
+
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
+$help_url = '';
+llxHeader('', $langs->trans('ConferenceOrBooth'), $help_url);
+
+if ($id > 0 || !empty($ref)) {
+ $object->fetch_thirdparty();
+
+ $head = conferenceorboothPrepareHead($object);
+
+ print dol_get_fiche_head($head, 'note', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $morehtmlref = '';
+ /*
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($permissiontoadd)
+ {
+ if ($action != 'classify')
+ //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $morehtmlref.=' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='
';
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ': '.$proj->getNomUrl();
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }*/
+ $morehtmlref .= '
';
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+
+ print '';
+ print '
';
+
+
+ $cssclass = "titlefield";
+ include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
+
+ print '
';
+
+ print dol_get_fiche_end();
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/eventorganizationindex.php b/htdocs/eventorganization/eventorganizationindex.php
new file mode 100644
index 00000000000..655da7813e6
--- /dev/null
+++ b/htdocs/eventorganization/eventorganizationindex.php
@@ -0,0 +1,225 @@
+
+ * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2015 Jean-François Ferry
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file eventorganization/eventorganizationindex.php
+ * \ingroup eventorganization
+ * \brief Home page of eventorganization top menu
+ */
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("eventorganization@eventorganization"));
+
+$action = GETPOST('action', 'aZ09');
+
+
+// Security check
+// if (! $user->rights->eventorganization->myobject->read) {
+// accessforbidden();
+// }
+$socid = GETPOST('socid', 'int');
+if (isset($user->socid) && $user->socid > 0) {
+ $action = '';
+ $socid = $user->socid;
+}
+
+$max = 5;
+$now = dol_now();
+
+
+/*
+ * Actions
+ */
+
+// None
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formfile = new FormFile($db);
+
+llxHeader("", $langs->trans("EventOrganizationArea"));
+
+print load_fiche_titre($langs->trans("EventOrganizationArea"), '', 'eventorganization.png@eventorganization');
+
+print '';
+
+
+/* BEGIN MODULEBUILDER DRAFT MYOBJECT
+// Draft MyObject
+if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganization->read)
+{
+ $langs->load("orders");
+
+ $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
+ $sql.= ", s.code_client";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
+ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE c.fk_soc = s.rowid";
+ $sql.= " AND c.fk_statut = 0";
+ $sql.= " AND c.entity IN (".getEntity('commande').")";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socid) $sql.= " AND c.fk_soc = ".$socid;
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $total = 0;
+ $num = $db->num_rows($resql);
+
+ print '
';
+ print '';
+ print ''.$langs->trans("DraftMyObjects").($num?''.$num.' ':'').' ';
+
+ $var = true;
+ if ($num > 0)
+ {
+ $i = 0;
+ while ($i < $num)
+ {
+
+ $obj = $db->fetch_object($resql);
+ print '';
+
+ $myobjectstatic->id=$obj->rowid;
+ $myobjectstatic->ref=$obj->ref;
+ $myobjectstatic->ref_client=$obj->ref_client;
+ $myobjectstatic->total_ht = $obj->total_ht;
+ $myobjectstatic->total_tva = $obj->total_tva;
+ $myobjectstatic->total_ttc = $obj->total_ttc;
+
+ print $myobjectstatic->getNomUrl(1);
+ print ' ';
+ print '';
+ print ' ';
+ print ''.price($obj->total_ttc).' ';
+ $i++;
+ $total += $obj->total_ttc;
+ }
+ if ($total>0)
+ {
+
+ print ''.$langs->trans("Total").' '.price($total)." ";
+ }
+ }
+ else
+ {
+
+ print ''.$langs->trans("NoOrder").' ';
+ }
+ print "
";
+
+ $db->free($resql);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+END MODULEBUILDER DRAFT MYOBJECT */
+
+
+print '
';
+
+
+$NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
+$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
+
+/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
+// Last modified myobject
+if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganization->read)
+{
+ $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
+ $sql.= " FROM ".MAIN_DB_PREFIX."eventorganization_myobject as s";
+ //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
+ //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 s.tms DESC";
+ $sql .= $db->plimit($max, 0);
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ print '
';
+ print '';
+ print '';
+ print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
+ print ' ';
+ print ''.$langs->trans("DateModificationShort").' ';
+ print ' ';
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($resql);
+
+ $myobjectstatic->id=$objp->rowid;
+ $myobjectstatic->ref=$objp->ref;
+ $myobjectstatic->label=$objp->label;
+ $myobjectstatic->status = $objp->status;
+
+ print '';
+ print ''.$myobjectstatic->getNomUrl(1).' ';
+ print '';
+ print " ";
+ print ''.dol_print_date($db->jdate($objp->tms), 'day')." ";
+ print ' ';
+ $i++;
+ }
+
+ $db->free($resql);
+ } else {
+ print ''.$langs->trans("None").' ';
+ }
+ print "
";
+ }
+}
+*/
+
+print '
';
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php
new file mode 100644
index 00000000000..792fa77d087
--- /dev/null
+++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php
@@ -0,0 +1,85 @@
+.
+ */
+
+/**
+ * \file lib/eventorganization_conferenceorbooth.lib.php
+ * \ingroup eventorganization
+ * \brief Library files with common functions for ConferenceOrBooth
+ */
+
+/**
+ * Prepare array of tabs for ConferenceOrBooth
+ *
+ * @param ConferenceOrBooth $object ConferenceOrBooth
+ * @return array Array of tabs
+ */
+function conferenceorboothPrepareHead($object)
+{
+ global $db, $langs, $conf;
+
+ $langs->load("eventorganization@eventorganization");
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("Card");
+ $head[$h][2] = 'card';
+ $h++;
+
+ if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
+ {
+ $nbNote = 0;
+ if (!empty($object->note_private)) $nbNote++;
+ if (!empty($object->note_public)) $nbNote++;
+ $head[$h][0] = dol_buildpath('/eventorganization/conferenceorbooth_note.php', 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.' ' : '');
+ $head[$h][2] = 'note';
+ $h++;
+ }
+
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+ $upload_dir = $conf->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref);
+ $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+ $nbLinks = Link::count($db, $object->element, $object->id);
+ $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans('Documents');
+ if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).' ';
+ $head[$h][2] = 'document';
+ $h++;
+
+ $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_agenda.php", 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("Events");
+ $head[$h][2] = 'agenda';
+ $h++;
+
+ // Show more tabs from modules
+ // Entries must be declared in modules descriptor with line
+ //$this->tabs = array(
+ // 'entity:+tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
+ //); // to add new tab
+ //$this->tabs = array(
+ // 'entity:-tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
+ //); // to remove a tab
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization');
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization', 'remove');
+
+ return $head;
+}
diff --git a/htdocs/eventorganization/modulebuilder.txt b/htdocs/eventorganization/modulebuilder.txt
new file mode 100644
index 00000000000..670a1774929
--- /dev/null
+++ b/htdocs/eventorganization/modulebuilder.txt
@@ -0,0 +1,3 @@
+# DO NOT DELETE THIS FILE MANUALLY
+# File to flag module built using official module template.
+# When this file is present into a module directory, you can edit it with the module builder tool.
\ No newline at end of file
diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php
index a9b19ede7c3..2b710e87dee 100644
--- a/htdocs/expedition/document.php
+++ b/htdocs/expedition/document.php
@@ -76,7 +76,7 @@ if ($object->fetch($id))
$upload_dir = $conf->expedition->dir_output."/sending/".dol_sanitizeFileName($object->ref);
}
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 6ff4c418988..f41f2902e71 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -225,10 +225,12 @@ if (empty($reshook))
if (!($object->fk_user_author > 0)) $object->fk_user_author = $user->id;
// Check that expense report is for a user inside the hierarchy or advanced permission for all is set
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->writeall_advance))) {
+ if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer))
+ || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer) && empty($user->rights->expensereport->writeall_advance))) {
$error++;
setEventMessages($langs->trans("NotEnoughPermission"), null, 'errors');
- } else {
+ }
+ if (!$error) {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)) {
if (!in_array($object->fk_user_author, $childids)) {
$error++;
diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php
index f245084f8db..bee9ac1c9fe 100644
--- a/htdocs/fichinter/card-rec.php
+++ b/htdocs/fichinter/card-rec.php
@@ -224,7 +224,9 @@ if ($action == 'add') {
* View
*/
-llxHeader('', $langs->trans("RepeatableIntervention"), 'ch-fichinter.html#s-fac-fichinter-rec');
+$help_url = '';
+
+llxHeader('', $langs->trans("RepeatableIntervention"), $help_url);
$form = new Form($db);
$companystatic = new Societe($db);
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index 1b9326468f4..aaab2072013 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -75,7 +75,7 @@ $modulepart = 'fichinter';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
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 58b39cba8d6..52121d8c83d 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -139,6 +139,8 @@ class CommandeFournisseur extends CommonOrder
public $cond_reglement_id;
public $cond_reglement_code;
+ public $cond_reglement_label; // Label
+ public $cond_reglement_doc; // Label on documents
/**
* @var int ID
@@ -202,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),
@@ -303,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,";
@@ -312,7 +314,7 @@ class CommandeFournisseur extends CommonOrder
$sql .= " c.note_private, c.note_public, c.model_pdf, c.extraparams, c.billed,";
$sql .= " c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc,";
$sql .= " cm.libelle as methode_commande,";
- $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc,";
+ $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_label, cr.libelle_facture as cond_reglement_doc,";
$sql .= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle";
$sql .= ', c.fk_incoterms, c.location_incoterms';
$sql .= ', i.libelle as label_incoterms';
@@ -354,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;
@@ -373,8 +375,9 @@ class CommandeFournisseur extends CommonOrder
$this->fk_project = $obj->fk_project;
$this->cond_reglement_id = $obj->fk_cond_reglement;
$this->cond_reglement_code = $obj->cond_reglement_code;
- $this->cond_reglement = $obj->cond_reglement_libelle;
- $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
+ $this->cond_reglement = $obj->cond_reglement_label; // deprecated
+ $this->cond_reglement_label = $obj->cond_reglement_label;
+ $this->cond_reglement_doc = $obj->cond_reglement_doc;
$this->fk_account = $obj->fk_account;
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;
@@ -448,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";
@@ -1562,8 +1565,6 @@ class CommandeFournisseur extends CommonOrder
{
global $langs, $mysoc, $conf;
- $error = 0;
-
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $info_bits, $notrigger, $date_start, $date_end, $fk_unit, $pu_ht_devise, $origin, $origin_id");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 67070b99c57..0157dbd0eec 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -176,8 +176,11 @@ class FactureFournisseur extends CommonInvoice
public $note_private;
public $note_public;
public $propalid;
+
public $cond_reglement_id;
public $cond_reglement_code;
+ public $cond_reglement_label;
+ public $cond_reglement_doc;
/**
* @var int ID
@@ -641,8 +644,8 @@ class FactureFournisseur extends CommonInvoice
$sql .= " t.model_pdf,";
$sql .= " t.import_key,";
$sql .= " t.extraparams,";
- $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
- $sql .= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,";
+ $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_label, cr.libelle_facture as cond_reglement_doc,";
+ $sql .= " p.code as mode_reglement_code, p.libelle as mode_reglement_label,";
$sql .= ' s.nom as socnom, s.rowid as socid,';
$sql .= ' t.fk_incoterms, t.location_incoterms,';
$sql .= " i.libelle as label_incoterms,";
@@ -697,12 +700,13 @@ class FactureFournisseur extends CommonInvoice
$this->fk_project = $obj->fk_project;
$this->cond_reglement_id = $obj->fk_cond_reglement;
$this->cond_reglement_code = $obj->cond_reglement_code;
- $this->cond_reglement = $obj->cond_reglement_libelle;
- $this->cond_reglement_doc = $obj->cond_reglement_libelle;
+ $this->cond_reglement = $obj->cond_reglement_label; // deprecated
+ $this->cond_reglement_label = $obj->cond_reglement_label;
+ $this->cond_reglement_doc = $obj->cond_reglement_doc;
$this->fk_account = $obj->fk_account;
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;
- $this->mode_reglement = $obj->mode_reglement_libelle;
+ $this->mode_reglement = $obj->mode_reglement_label;
$this->date_echeance = $this->db->jdate($obj->date_lim_reglement);
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 2ed7ccab8ef..0aea652de68 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -570,7 +570,9 @@ if (empty($reshook))
$fk_unit = GETPOST('units', 'alpha');
- $tva_tx = price2num($tva_tx); // When vat is text input field
+ if (!preg_match('/\((.*)\)/', $tva_tx)) {
+ $tva_tx = price2num($tva_tx); // When vat is text input field
+ }
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index acfa5a54e16..dbe0bd5d7af 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -525,7 +525,9 @@ $warehouse_static = new Entrepot($db);
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
-llxHeader('', $langs->trans("OrderDispatch"), $help_url, '', 0, 0, array('/fourn/js/lib_dispatch.js.php'));
+$morejs = array('/fourn/js/lib_dispatch.js.php');
+
+llxHeader('', $langs->trans("OrderDispatch"), $help_url, '', 0, 0, $morejs);
if ($id > 0 || !empty($ref)) {
$soc = new Societe($db);
diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php
index d5a4455db06..293edb549ea 100644
--- a/htdocs/fourn/commande/document.php
+++ b/htdocs/fourn/commande/document.php
@@ -78,7 +78,7 @@ $object->fetch_thirdparty();
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
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/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index a8f7fa2cc42..1e88aaf74c4 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -2530,7 +2530,12 @@ if ($action == 'create')
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(0, 0, $object->id);
if ($result > 0) {
- print ' '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).' ';
+ print ' ';
+ $s = $langs->trans("CreditNoteConvertedIntoDiscount", '{s1}', '{s2}');
+ $s = str_replace('{s1}', $object->getLibType(1), $s);
+ $s = str_replace('{s2}', $discount->getNomUrl(1, 'discount'), $s);
+ print $s;
+ print ' ';
}
}
print ' ';
diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php
index 36f5a45b25e..4b2b45c7226 100644
--- a/htdocs/fourn/facture/document.php
+++ b/htdocs/fourn/facture/document.php
@@ -74,7 +74,7 @@ if ($object->fetch($id, $ref))
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php
index 355b84796f2..5dea09eaf09 100644
--- a/htdocs/fourn/paiement/card.php
+++ b/htdocs/fourn/paiement/card.php
@@ -39,11 +39,22 @@ $action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$object = new PaiementFourn($db);
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('supplierpaymentcard', 'globalcard'));
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
+
+$result = restrictedArea($user, $object->element, $object->id, 'paiementfourn', '');
+
+// Security check
+if ($user->socid) $socid = $user->socid;
+// Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice.
+// It should be enough because all payments are done on invoices of the same thirdparty.
+if ($socid && $socid != $object->thirdparty->id) {
+ accessforbidden();
+}
-// PDF
-$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
-$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
-$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
/*
* Actions
@@ -177,41 +188,46 @@ if ($result > 0)
print '';
/*print '';
- print ''.$langs->trans('Ref').' ';
+ print ' '.$langs->trans('Ref').' ';
print $form->showrefnav($object,'id','',1,'rowid','ref');
print ' ';*/
// Date of payment
- print ''.$form->editfieldkey("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer).' ';
+ print ' '.$form->editfieldkey("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer).' ';
+ print '';
print $form->editfieldval("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer, 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'));
print ' ';
// Payment mode
$labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label;
- print ''.$langs->trans('PaymentMode').' '.$labeltype;
+ print ' '.$langs->trans('PaymentMode').' ';
+ print ''.$labeltype;
print $object->num_payment ? ' - '.$object->num_payment : '';
print ' ';
// Payment numero
/* TODO Add field num_payment into payment table and save it
- print ''.$form->editfieldkey("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).' ';
+ print ' '.$form->editfieldkey("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).' ';
+ print '';
print $form->editfieldval("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print ' ';
*/
// Amount
- print ''.$langs->trans('Amount').' '.price($object->amount, '', $langs, 0, 0, -1, $conf->currency).' ';
+ print ''.$langs->trans('Amount').' ';
+ print ''.price($object->amount, '', $langs, 0, 0, -1, $conf->currency).' ';
if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{
- print ''.$langs->trans('Status').' '.$object->getLibStatut(4).' ';
+ print ''.$langs->trans('Status').' ';
+ print ''.$object->getLibStatut(4).' ';
}
$allow_delete = 1;
// Bank account
if (!empty($conf->banque->enabled))
{
- if ($object->bank_account)
+ if ($object->fk_account)
{
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
@@ -222,8 +238,8 @@ if ($result > 0)
}
print '';
- print ''.$langs->trans('BankAccount').' ';
- print '';
+ print ' '.$langs->trans('BankAccount').' ';
+ print '';
$accountstatic = new Account($db);
$accountstatic->fetch($bankline->fk_account);
print $accountstatic->getNomUrl(1);
@@ -231,8 +247,8 @@ if ($result > 0)
print ' ';
print '';
- print ''.$langs->trans('BankTransactionLine').' ';
- print '';
+ print ' '.$langs->trans('BankTransactionLine').' ';
+ print '';
print $bankline->getNomUrl(1, 0, 'showconciliated');
print ' ';
print ' ';
@@ -240,7 +256,8 @@ if ($result > 0)
}
// Note
- print ''.$form->editfieldkey("Note", 'note', $object->note, $object, $user->rights->fournisseur->facture->creer).' ';
+ print ' '.$form->editfieldkey("Comments", 'note', $object->note, $object, $user->rights->fournisseur->facture->creer).' ';
+ print '';
print $form->editfieldval("Note", 'note', $object->note, $object, $user->rights->fournisseur->facture->creer, 'textarea');
print ' ';
diff --git a/htdocs/fourn/paiement/info.php b/htdocs/fourn/paiement/info.php
index 97ac2343c23..9ff0a86931e 100644
--- a/htdocs/fourn/paiement/info.php
+++ b/htdocs/fourn/paiement/info.php
@@ -33,8 +33,26 @@ $langs->loadLangs(array("bills", "suppliers", "companies"));
$id = GETPOST('id', 'int');
$object = new PaiementFourn($db);
-$object->fetch($id);
-$object->info($id);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
+
+$result = restrictedArea($user, $object->element, $object->id, 'paiementfourn', '');
+
+// Security check
+if ($user->socid) $socid = $user->socid;
+// Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice.
+// It should be enough because all payments are done on invoices of the same thirdparty.
+if ($socid && $socid != $object->thirdparty->id) {
+ accessforbidden();
+}
+
+
+/*
+ * Actions
+ */
+
+// None
/*
@@ -43,10 +61,14 @@ $object->info($id);
llxHeader();
+$object->info($id);
+
$head = payment_supplier_prepare_head($object);
print dol_get_fiche_head($head, 'info', $langs->trans("SupplierPayment"), 0, 'payment');
+$linkback = ''.$langs->trans("BackToList").' ';
+
dol_banner_tab($object, 'id', $linkback, -1, 'rowid', 'ref');
print dol_get_fiche_end();
diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php
index 3fca286eff0..1bf8984a6ee 100644
--- a/htdocs/fourn/paiement/list.php
+++ b/htdocs/fourn/paiement/list.php
@@ -178,7 +178,7 @@ if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
-$sql .= ' GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label';
+$sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, s.email, c.code, c.libelle, ba.rowid, ba.label';
if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user';
$sql .= $db->order($sortfield, $sortorder);
diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php
index f366bb50c85..3bb48d1de15 100644
--- a/htdocs/holiday/document.php
+++ b/htdocs/holiday/document.php
@@ -72,7 +72,7 @@ $modulepart = 'holiday';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
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";
print ' '."\n";
@@ -430,11 +494,9 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
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 "
".$langs->trans("FunctionsCreation")." ";
- if ($ok)
- {
+ if ($ok) {
print '';
} else {
print '
';
@@ -475,12 +448,11 @@ if ($action == "set")
/***************************************************************************************
- *
- * Load files data/*.sql
- *
- ***************************************************************************************/
- if ($ok && $createdata)
- {
+ *
+ * Load files data/*.sql
+ *
+ ***************************************************************************************/
+ if ($ok && $createdata) {
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/data/";
@@ -489,17 +461,15 @@ if ($action == "set")
dolibarr_install_syslog("step2: open directory data ".$dir." handle=".$handle);
$tablefound = 0;
$tabledata = array();
- if (is_resource($handle))
- {
- while (($file = readdir($handle)) !== false)
- {
- if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file))
- {
- if (preg_match('/^llx_accounting_account_/', $file)) continue; // We discard data file of chart of account. Will be loaded when a chart is selected.
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) {
+ if (preg_match('/^llx_accounting_account_/', $file)) {
+ continue; // We discard data file of chart of account. Will be loaded when a chart is selected.
+ }
//print 'x'.$file.'-'.$createdata.' ';
- if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file))
- {
+ if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) {
$tablefound++;
$tabledata[] = $file;
}
@@ -510,33 +480,33 @@ if ($action == "set")
// Sort list of data files on alphabetical order (load order is important)
sort($tabledata);
- foreach ($tabledata as $file)
- {
+ foreach ($tabledata as $file) {
$name = substr($file, 0, dol_strlen($file) - 4);
$fp = fopen($dir.$file, "r");
dolibarr_install_syslog("step2: open data file ".$dir.$file." handle=".$fp);
- if ($fp)
- {
+ if ($fp) {
$arrayofrequests = array();
$linefound = 0;
$linegroup = 0;
$sizeofgroup = 1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
// Load all requests
- while (!feof($fp))
- {
+ while (!feof($fp)) {
$buffer = fgets($fp, 4096);
$buffer = trim($buffer);
- if ($buffer)
- {
- if (substr($buffer, 0, 2) == '--') continue;
+ if ($buffer) {
+ if (substr($buffer, 0, 2) == '--') {
+ continue;
+ }
- if ($linefound && ($linefound % $sizeofgroup) == 0)
- {
+ if ($linefound && ($linefound % $sizeofgroup) == 0) {
$linegroup++;
}
- if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup] = $buffer;
- else $arrayofrequests[$linegroup] .= " ".$buffer;
+ if (empty($arrayofrequests[$linegroup])) {
+ $arrayofrequests[$linegroup] = $buffer;
+ } else {
+ $arrayofrequests[$linegroup] .= " ".$buffer;
+ }
$linefound++;
}
@@ -549,22 +519,18 @@ if ($action == "set")
$db->begin();
// We loop on each requests of file
- foreach ($arrayofrequests as $buffer)
- {
+ foreach ($arrayofrequests as $buffer) {
// Replace the prefix tables
- if ($dolibarr_main_db_prefix != 'llx_')
- {
+ if ($dolibarr_main_db_prefix != 'llx_') {
$buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
}
//dolibarr_install_syslog("step2: request: " . $buffer);
$resql = $db->query($buffer, 1);
- if ($resql)
- {
+ if ($resql) {
//$db->free($resql); // Not required as request we launch here does not return memory needs.
} else {
- if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
- {
+ if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
//print "Insertion ligne : $buffer ";
} else {
$ok = 0;
@@ -574,14 +540,16 @@ if ($action == "set")
}
}
- if ($okallfile) $db->commit();
- else $db->rollback();
+ if ($okallfile) {
+ $db->commit();
+ } else {
+ $db->rollback();
+ }
}
}
print " ".$langs->trans("ReferenceDataLoading")." ";
- if ($ok)
- {
+ if ($ok) {
print ' ';
} else {
print ' ';
@@ -595,7 +563,9 @@ if ($action == "set")
$ret = 0;
-if (!$ok && isset($argv[1])) $ret = 1;
+if (!$ok && isset($argv[1])) {
+ $ret = 1;
+}
dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("- step2: end");
@@ -621,7 +591,11 @@ print $out;
pFooter($ok ? 0 : 1, $setuplang);
-if (isset($db) && is_object($db)) $db->close();
+if (isset($db) && is_object($db)) {
+ $db->close();
+}
// Return code if ran from command line
-if ($ret) exit($ret);
+if ($ret) {
+ exit($ret);
+}
diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php
index ca188ae4d5b..7d03c7b6fd0 100644
--- a/htdocs/install/step4.php
+++ b/htdocs/install/step4.php
@@ -40,7 +40,9 @@ $langs->loadLangs(array("admin", "install"));
// Now we load forced value 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;
@@ -60,8 +62,7 @@ $ok = 0;
pHeader($langs->trans("AdminAccountCreation"), "step5");
// Test if we can run a first install process
-if (!is_writable($conffile))
-{
+if (!is_writable($conffile)) {
print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
pFooter(1, $setuplang, 'jscheckparam');
exit;
@@ -77,8 +78,7 @@ print '';
- if (isset($_GET["error"]) && $_GET["error"] == 1)
- {
+ if (isset($_GET["error"]) && $_GET["error"] == 1) {
print ' ';
print ''.$langs->trans("PasswordsMismatch").'
';
$error = 0; // We show button
}
- if (isset($_GET["error"]) && $_GET["error"] == 2)
- {
+ if (isset($_GET["error"]) && $_GET["error"] == 2) {
print ' ';
print '';
print $langs->trans("PleaseTypePassword");
@@ -103,8 +101,7 @@ if ($db->ok)
$error = 0; // We show button
}
- if (isset($_GET["error"]) && $_GET["error"] == 3)
- {
+ if (isset($_GET["error"]) && $_GET["error"] == 3) {
print '
';
print '
'.$langs->trans("PleaseTypeALogin").'
';
$error = 0; // We show button
@@ -112,7 +109,9 @@ if ($db->ok)
}
$ret = 0;
-if ($error && isset($argv[1])) $ret = 1;
+if ($error && isset($argv[1])) {
+ $ret = 1;
+}
dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("- step4: end");
@@ -122,4 +121,6 @@ pFooter($error, $setuplang);
$db->close();
// Return code if ran from command line
-if ($ret) exit($ret);
+if ($ret) {
+ exit($ret);
+}
diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php
index ed64de7cbb1..6ae3bffc59b 100644
--- a/htdocs/install/step5.php
+++ b/htdocs/install/step5.php
@@ -27,7 +27,9 @@
*/
include_once 'inc.php';
-if (file_exists($conffile)) include_once $conffile;
+if (file_exists($conffile)) {
+ include_once $conffile;
+}
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash
@@ -42,13 +44,15 @@ $action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : (empty($argv[
// Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install
// or MAIN_VERSION_LAST_UPGRADE for upgrade.
$targetversion = DOL_VERSION; // If it's latest upgrade
-if (!empty($action) && preg_match('/upgrade/i', $action)) // If it's an old upgrade
-{
+if (!empty($action) && preg_match('/upgrade/i', $action)) {
+ // If it's an old upgrade
$tmp = explode('_', $action, 2);
- if ($tmp[0] == 'upgrade')
- {
- if (!empty($tmp[1])) $targetversion = $tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta'
- else $targetversion = DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION
+ if ($tmp[0] == 'upgrade') {
+ if (!empty($tmp[1])) {
+ $targetversion = $tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta'
+ } else {
+ $targetversion = DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION
+ }
}
}
@@ -63,7 +67,9 @@ $success = 0;
$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;
@@ -110,27 +116,25 @@ pHeader($langs->trans("SetupEnd"), "step5");
print '
';
// Test if we can run a first install process
-if (empty($versionfrom) && empty($versionto) && !is_writable($conffile))
-{
+if (empty($versionfrom) && empty($versionto) && !is_writable($conffile)) {
print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
pFooter(1, $setuplang, 'jscheckparam');
exit;
}
-if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
-{
+if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) {
$error = 0;
// 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_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- } 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->db->type = $dolibarr_main_db_type;
@@ -151,8 +155,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
$ok = 0;
// If first install
- if ($action == "set")
- {
+ if ($action == "set") {
// Active module user
$modName = 'modUser';
$file = $modName.".class.php";
@@ -160,13 +163,16 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
include_once DOL_DOCUMENT_ROOT."/core/modules/".$file;
$objMod = new $modName($db);
$result = $objMod->init();
- if (!$result) print 'ERROR in activating module file='.$file;
+ if (!$result) {
+ print 'ERROR in activating module file='.$file;
+ }
- if ($db->connected)
- {
+ if ($db->connected) {
$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;
// Create admin user
@@ -176,17 +182,17 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
$sql = "SELECT u.rowid, u.pass, u.pass_crypted";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$numrows = $db->num_rows($resql);
- if ($numrows == 0)
- {
+ if ($numrows == 0) {
// Define default setup for password encryption
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities
- if (function_exists('password_hash'))
+ if (function_exists('password_hash')) {
dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'password_hash', 'chaine', 0, '', 0); // All entities
- else dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities
+ } else {
+ dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities
+ }
}
dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO);
@@ -208,13 +214,11 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
$conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email
$result = $newuser->create($createuser, 1);
- if ($result > 0)
- {
+ if ($result > 0) {
print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."
";
$success = 1;
} else {
- if ($newuser->error == 'ErrorLoginAlreadyExists')
- {
+ if ($newuser->error == 'ErrorLoginAlreadyExists') {
dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING);
print '
'.$langs->trans("AdminLoginAlreadyExists", $login)."
";
$success = 1;
@@ -224,14 +228,12 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
}
}
- if ($success)
- {
+ if ($success) {
// Insert MAIN_VERSION_FIRST_INSTALL in a dedicated transaction. So if it fails (when first install was already done), we can do other following requests.
$db->begin();
dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to '.$targetversion, LOG_DEBUG);
$resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_FIRST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when first install',0)");
- if ($resql)
- {
+ if ($resql) {
$conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion;
$db->commit();
} else {
@@ -243,29 +245,36 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
$resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when last install',0)");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion;
- if ($useforcedwizard)
- {
+ if ($useforcedwizard) {
dolibarr_install_syslog('step5: set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
$resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING', 1).",".$db->encrypt(1, 1).",'chaine',1,'Disable install warnings',0)");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$conf->global->MAIN_REMOVE_INSTALL_WARNING = 1;
}
// If we ask to force some modules to be enabled
- if (!empty($force_install_module))
- {
- if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
+ if (!empty($force_install_module)) {
+ if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) {
+ define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
+ }
$tmparray = explode(',', $force_install_module);
- foreach ($tmparray as $modtoactivate)
- {
+ foreach ($tmparray as $modtoactivate) {
$modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate);
print $langs->trans("ActivateModule", $modtoactivatenew).'
';
@@ -274,46 +283,55 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
$res = dol_include_once("/core/modules/".$file);
$res = activateModule($modtoactivatenew, 1);
- if (!empty($res['errors'])) print 'ERROR in activating module file='.$file;
+ if (!empty($res['errors'])) {
+ print 'ERROR in activating module file='.$file;
+ }
}
}
dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const');
$resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$db->commit();
}
} else {
print $langs->trans("ErrorFailedToConnect")."
";
}
- }
- // If upgrade
- elseif (empty($action) || preg_match('/upgrade/i', $action))
- {
- if ($db->connected)
- {
+ } elseif (empty($action) || preg_match('/upgrade/i', $action)) {
+ // If upgrade
+ if ($db->connected) {
$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;
// Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
$tagdatabase = false;
- if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase = true; // We don't know what it was before, so now we consider we are version choosed.
- else {
+ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) {
+ $tagdatabase = true; // We don't know what it was before, so now we consider we are version choosed.
+ } else {
$mainversionlastupgradearray = preg_split('/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE);
$targetversionarray = preg_split('/[.-]/', $targetversion);
- if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) $tagdatabase = true;
+ if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) {
+ $tagdatabase = true;
+ }
}
- if ($tagdatabase)
- {
+ if ($tagdatabase) {
dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion);
$resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) VALUES (".$db->encrypt('MAIN_VERSION_LAST_UPGRADE', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version for last upgrade',0)");
- if (!$resql) dol_print_error($db, 'Error in setup program');
+ if (!$resql) {
+ dol_print_error($db, 'Error in setup program');
+ }
$conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion;
} else {
dolibarr_install_syslog('step5: we run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.');
@@ -337,31 +355,28 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action))
// Create lock file
// If first install
-if ($action == "set" && $success)
-{
- if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
- {
+if ($action == "set" && $success) {
+ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
// Install is finished
print $langs->trans("SystemIsInstalled")."
";
$createlock = 0;
- if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE))
- {
+ if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) {
// Install is finished, we create the lock file
$lockfile = DOL_DATA_ROOT.'/install.lock';
$fp = @fopen($lockfile, "w");
- if ($fp)
- {
- if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility
+ if ($fp) {
+ if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
+ $force_install_lockinstall = 444; // For backward compatibility
+ }
fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
fclose($fp);
@chmod($lockfile, octdec($force_install_lockinstall));
$createlock = 1;
}
}
- if (empty($createlock))
- {
+ if (empty($createlock)) {
print '
'.$langs->trans("WarningRemoveInstallDir")."
";
}
@@ -383,33 +398,29 @@ if ($action == "set" && $success)
print '
'.$langs->trans("GoToUpgradePage");
print '
';
}
-}
-// If upgrade
-elseif (empty($action) || preg_match('/upgrade/i', $action))
-{
- if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
- {
+} elseif (empty($action) || preg_match('/upgrade/i', $action)) {
+ // If upgrade
+ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
// Upgrade is finished
print $langs->trans("SystemIsUpgraded")." ";
$createlock = 0;
- if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE))
- {
+ if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) {
// Upgrade is finished, we create the lock file
$lockfile = DOL_DATA_ROOT.'/install.lock';
$fp = @fopen($lockfile, "w");
- if ($fp)
- {
- if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility
+ if ($fp) {
+ if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
+ $force_install_lockinstall = 444; // For backward compatibility
+ }
fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
fclose($fp);
@chmod($lockfile, octdec($force_install_lockinstall));
$createlock = 1;
}
}
- if (empty($createlock))
- {
+ if (empty($createlock)) {
print ''.$langs->trans("WarningRemoveInstallDir")."
";
}
@@ -437,7 +448,9 @@ elseif (empty($action) || preg_match('/upgrade/i', $action))
clearstatcache();
$ret = 0;
-if ($error && isset($argv[1])) $ret = 1;
+if ($error && isset($argv[1])) {
+ $ret = 1;
+}
dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("- step5: Dolibarr setup finished");
@@ -445,4 +458,6 @@ dolibarr_install_syslog("- step5: Dolibarr setup finished");
pFooter(1, $setuplang);
// Return code if ran from command line
-if ($ret) exit($ret);
+if ($ret) {
+ exit($ret);
+}
diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php
index 29b51746a14..25e3b95af84 100644
--- a/htdocs/install/upgrade.php
+++ b/htdocs/install/upgrade.php
@@ -37,8 +37,7 @@
*/
include_once 'inc.php';
-if (!file_exists($conffile))
-{
+if (!file_exists($conffile)) {
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
require_once $conffile;
@@ -68,29 +67,35 @@ $ignoredbversion = (GETPOST('ignoredbversion', 'alpha', 3) == 'ignoredbversion')
$langs->loadLangs(array("admin", "install", "other", "errors"));
-if ($dolibarr_main_db_type == "mysqli") $choix = 1;
-if ($dolibarr_main_db_type == "pgsql") $choix = 2;
-if ($dolibarr_main_db_type == "mssql") $choix = 3;
+if ($dolibarr_main_db_type == "mysqli") {
+ $choix = 1;
+}
+if ($dolibarr_main_db_type == "pgsql") {
+ $choix = 2;
+}
+if ($dolibarr_main_db_type == "mssql") {
+ $choix = 3;
+}
dolibarr_install_syslog("--- upgrade: Entering upgrade.php page");
-if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR);
+if (!is_object($conf)) {
+ dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR);
+}
/*
* View
*/
-if (!$versionfrom && !$versionto)
-{
+if (!$versionfrom && !$versionto) {
print 'Error: Parameter versionfrom or versionto missing.'."\n";
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n";
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = __DIR__.'/';
- if (substr($sapi_type, 0, 3) == 'cli')
- {
+ if (substr($sapi_type, 0, 3) == 'cli') {
print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n";
}
exit;
@@ -102,8 +107,7 @@ pHeader('', "upgrade2", GETPOST('action', 'aZ09'), 'versionfrom='.$versionfrom.'
$actiondone = 0;
// Action to launch the migrate script
-if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09')))
-{
+if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) {
$actiondone = 1;
print ' '.$langs->trans("DatabaseMigration").' ';
@@ -112,15 +116,15 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$error = 0;
// 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_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- } 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 is already instancied inside inc.php
@@ -132,9 +136,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$conf->db->pass = $dolibarr_main_db_pass;
// Load type and crypt key
- 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;
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
@@ -143,8 +151,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
- if ($db->connected)
- {
+ if ($db->connected) {
print '';
print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.' '.$langs->trans("OK").' '."\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK"));
@@ -155,10 +162,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$ok = 0;
}
- if ($ok)
- {
- if ($db->database_selected)
- {
+ if ($ok) {
+ if ($db->database_selected) {
print '';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.' '.$langs->trans("OK")." \n";
dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name);
@@ -171,15 +176,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
// Affiche version
- if ($ok)
- {
+ if ($ok) {
$version = $db->getVersion();
$versionarray = $db->getVersionArray();
print ''.$langs->trans("ServerVersion").' ';
print ''.$version.' ';
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion").": ".$version);
- if ($db->type == 'mysqli' && function_exists('mysqli_get_charset'))
- {
+ if ($db->type == 'mysqli' && function_exists('mysqli_get_charset')) {
$tmparray = $db->db->get_charset();
print ''.$langs->trans("ClientCharset").' ';
print ''.$tmparray->charset.' ';
@@ -193,8 +196,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$versionmindb = explode('.', $db::VERSIONMIN);
//print join('.',$versionarray).' - '.join('.',$versionmindb);
if (count($versionmindb) && count($versionarray)
- && versioncompare($versionarray, $versionmindb) < 0)
- {
+ && versioncompare($versionarray, $versionmindb) < 0) {
// Warning: database version too low.
print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).' '.$langs->trans("Error")." \n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)));
@@ -202,8 +204,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
// Test database version is not forbidden for migration
- if (empty($ignoredbversion))
- {
+ if (empty($ignoredbversion)) {
$dbversion_disallowed = array(
array('type'=>'mysql', 'version'=>array(5, 5, 40)),
array('type'=>'mysqli', 'version'=>array(5, 5, 40)) //,
@@ -211,17 +212,16 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
//array('type'=>'mysqli','version'=>array(5,5,41))
);
$listofforbiddenversion = '';
- foreach ($dbversion_disallowed as $dbversion_totest)
- {
- if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']);
+ foreach ($dbversion_disallowed as $dbversion_totest) {
+ if ($dbversion_totest['type'] == $db->type) {
+ $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']);
+ }
}
- foreach ($dbversion_disallowed as $dbversion_totest)
- {
+ foreach ($dbversion_disallowed as $dbversion_totest) {
//print $db->type.' - '.join('.',$versionarray).' - '.versioncompare($dbversion_totest['version'],$versionarray)." \n";
if ($dbversion_totest['type'] == $db->type
&& (versioncompare($dbversion_totest['version'], $versionarray) == 0 || versioncompare($dbversion_totest['version'], $versionarray) <= -4 || versioncompare($dbversion_totest['version'], $versionarray) >= 4)
- )
- {
+ ) {
// Warning: database version too low.
print ''.$langs->trans("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)."
".$langs->trans("Error")." \n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion));
@@ -233,8 +233,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
// Force l'affichage de la progression
- if ($ok)
- {
+ if ($ok) {
print ''.$langs->trans("PleaseBePatient").' ';
flush();
}
@@ -243,12 +242,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
/*
* Remove deprecated indexes and constraints for Mysql
*/
- if ($ok && preg_match('/mysql/', $db->type))
- {
+ if ($ok && preg_match('/mysql/', $db->type)) {
$versioncommande = array(4, 0, 0);
if (count($versioncommande) && count($versionarray)
- && versioncompare($versioncommande, $versionarray) <= 0) // Si mysql >= 4.0
- {
+ && versioncompare($versioncommande, $versionarray) <= 0) { // Si mysql >= 4.0
dolibarr_install_syslog("Clean database from bad named constraints");
// Suppression vieilles contraintes sans noms et en doubles
@@ -262,25 +259,20 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
);
$listtables = $db->DDLListTables($conf->db->name, '');
- foreach ($listtables as $val)
- {
+ foreach ($listtables as $val) {
// Database prefix filter
- if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val))
- {
+ if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) {
//print "x".$val." ";
$sql = "SHOW CREATE TABLE ".$val;
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$values = $db->fetch_array($resql);
$i = 0;
$createsql = $values[1];
- while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i', $createsql, $reg) && $i < 100)
- {
+ while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i', $createsql, $reg) && $i < 100) {
$sqldrop = "ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
$resqldrop = $db->query($sqldrop);
- if ($resqldrop)
- {
+ if ($resqldrop) {
print ''.$sqldrop."; \n";
}
$createsql = preg_replace('/CONSTRAINT `'.$reg[1].'`/i', 'XXX', $createsql);
@@ -288,8 +280,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
$db->free($resql);
} else {
- if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE')
- {
+ if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE') {
print ''.$sql.' : '.$db->lasterror()." \n";
}
}
@@ -299,12 +290,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
/*
- * Load sql files
- */
- if ($ok)
- {
+ * Load sql files
+ */
+ if ($ok) {
$dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver
- if (!empty($dirmodule)) $dir = dol_buildpath('/'.$dirmodule.'/sql/', 0);
+ if (!empty($dirmodule)) {
+ $dir = dol_buildpath('/'.$dirmodule.'/sql/', 0);
+ }
dolibarr_install_syslog("Scan sql files for migration files in ".$dir);
// Clean last part to exclude minor version x.y.z -> x.y
@@ -320,11 +312,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Get files list
$filesindir = array();
$handle = opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle)) !== false)
- {
- if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file;
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ if (preg_match('/\.sql$/i', $file)) {
+ $filesindir[] = $file;
+ }
}
sort($filesindir);
} else {
@@ -332,27 +324,24 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
// Define which file to run
- foreach ($filesindir as $file)
- {
- if (preg_match('/'.$from.'/i', $file))
- {
+ foreach ($filesindir as $file) {
+ if (preg_match('/'.$from.'/i', $file)) {
$filelist[] = $file;
- } elseif (preg_match('/'.$to.'/i', $file)) // First test may be false if we migrate from x.y.* to x.y.*
- {
+ } elseif (preg_match('/'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.*
$filelist[] = $file;
}
}
- if (count($filelist) == 0)
- {
+ if (count($filelist) == 0) {
print ''.$langs->trans("ErrorNoMigrationFilesFoundForParameters").'
';
} else {
$listoffileprocessed = array(); // Protection to avoid to process twice the same file
// Loop on each migrate files
- foreach ($filelist as $file)
- {
- if (in_array($dir.$file, $listoffileprocessed)) continue;
+ foreach ($filelist as $file) {
+ if (in_array($dir.$file, $listoffileprocessed)) {
+ continue;
+ }
print ' ';
print ''.$langs->trans("ChoosedMigrateScript").' '.$file.' '."\n";
@@ -364,18 +353,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Scan if there is migration scripts that depends of Dolibarr version
// for modules htdocs/module/sql or htdocs/custom/module/sql (files called "dolibarr_x.y.z-a.b.c.sql")
$modulesfile = array();
- foreach ($conf->file->dol_document_root as $type => $dirroot)
- {
+ foreach ($conf->file->dol_document_root as $type => $dirroot) {
$handlemodule = @opendir($dirroot); // $dirroot may be '..'
- if (is_resource($handlemodule))
- {
- while (($filemodule = readdir($handlemodule)) !== false)
- {
- if (!preg_match('/\./', $filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories.
- {
+ if (is_resource($handlemodule)) {
+ while (($filemodule = readdir($handlemodule)) !== false) {
+ if (!preg_match('/\./', $filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) { // We exclude filemodule that contains . (are not directories) and are not directories.
//print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file;
- if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file))
- {
+ if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) {
$modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file] = '/'.$filemodule.'/sql/dolibarr_'.$file;
}
}
@@ -384,9 +368,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
}
- foreach ($modulesfile as $modulefilelong => $modulefileshort)
- {
- if (in_array($modulefilelong, $listoffileprocessed)) continue;
+ foreach ($modulesfile as $modulefilelong => $modulefileshort) {
+ if (in_array($modulefilelong, $listoffileprocessed)) {
+ continue;
+ }
print ' ';
print ''.$langs->trans("ChoosedMigrateScript").' (external modules) '.$modulefileshort.' '."\n";
@@ -401,24 +386,33 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
print '
';
- if ($db->connected) $db->close();
+ if ($db->connected) {
+ $db->close();
+ }
}
-if (empty($actiondone))
-{
+if (empty($actiondone)) {
print ''.$langs->trans("ErrorWrongParameters").'
';
}
$ret = 0;
-if (!$ok && isset($argv[1])) $ret = 1;
+if (!$ok && isset($argv[1])) {
+ $ret = 1;
+}
dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("--- upgrade: end ".((!$ok && empty($_GET["ignoreerrors"])) || $dirmodule));
$nonext = (!$ok && empty($_GET["ignoreerrors"])) ? 2 : 0;
-if ($dirmodule) $nonext = 1;
+if ($dirmodule) {
+ $nonext = 1;
+}
pFooter($nonext, $setuplang);
-if ($db->connected) $db->close();
+if ($db->connected) {
+ $db->close();
+}
// Return code if ran from command line
-if ($ret) exit($ret);
+if ($ret) {
+ exit($ret);
+}
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 07c68a498b2..d9656231a2c 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -39,8 +39,7 @@
*/
include_once 'inc.php';
-if (!file_exists($conffile))
-{
+if (!file_exists($conffile)) {
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
require_once $conffile;
@@ -64,9 +63,11 @@ $error = 0;
// Ne fonctionne que si on est pas en safe_mode.
$err = error_reporting();
error_reporting(0);
-if (!empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT))
+if (!empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT)) {
@set_time_limit((int) $conf->global->MAIN_OVERRIDE_TIME_LIMIT);
-else @set_time_limit(600);
+} else {
+ @set_time_limit(600);
+}
error_reporting($err);
$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : 'auto';
@@ -77,13 +78,21 @@ $enablemodules = GETPOST("enablemodules", 'alpha', 3) ?GETPOST("enablemodules",
$langs->loadLangs(array("admin", "install", "bills", "suppliers"));
-if ($dolibarr_main_db_type == 'mysqli') $choix = 1;
-if ($dolibarr_main_db_type == 'pgsql') $choix = 2;
-if ($dolibarr_main_db_type == 'mssql') $choix = 3;
+if ($dolibarr_main_db_type == 'mysqli') {
+ $choix = 1;
+}
+if ($dolibarr_main_db_type == 'pgsql') {
+ $choix = 2;
+}
+if ($dolibarr_main_db_type == 'mssql') {
+ $choix = 3;
+}
dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto." ".$enablemodules);
-if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR);
+if (!is_object($conf)) {
+ dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR);
+}
@@ -91,16 +100,14 @@ if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initiali
* View
*/
-if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto)))
-{
+if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) {
print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n";
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n";
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = __DIR__.'/';
- if (substr($sapi_type, 0, 3) == 'cli')
- {
+ if (substr($sapi_type, 0, 3) == 'cli') {
print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n";
}
exit;
@@ -109,22 +116,21 @@ if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto ||
pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto);
-if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09')))
-{
+if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) {
print ' '.$langs->trans('DataMigration').' ';
print '';
// 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_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
- } 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 is already instancied inside inc.php
@@ -142,47 +148,48 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('upgrade'));
- if (!$db->connected)
- {
+ if (!$db->connected) {
print ''.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).' '.$langs->trans('Error').' ';
dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR);
$error++;
}
- if (!$error)
- {
- if ($db->database_selected)
- {
+ if (!$error) {
+ if ($db->database_selected) {
dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name);
} else {
$error++;
}
}
- 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;
// Chargement config
- if (!$error)
- {
+ if (!$error) {
$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;
}
/***************************************************************************************
- *
- * Migration of data
- *
- ***************************************************************************************/
+ *
+ * Migration of data
+ *
+ ***************************************************************************************/
$db->begin();
- if (!$error)
- {
+ if (!$error) {
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
// Version to install is DOL_VERSION
$dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : ''));
@@ -222,8 +229,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '2.0.0');
$beforeversionarray = explode('.', '2.7.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// Script pour V2 -> V2.1
migrate_paiements($db, $langs, $conf);
@@ -286,8 +292,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '2.7.9');
$beforeversionarray = explode('.', '2.8.9');
//print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray);
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx
migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping');
@@ -312,8 +317,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Script for 2.9
$afterversionarray = explode('.', '2.8.9');
$beforeversionarray = explode('.', '2.9.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_project_task_time($db, $langs, $conf);
migrate_customerorder_shipping($db, $langs, $conf);
@@ -326,16 +330,14 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Script for 3.0
$afterversionarray = explode('.', '2.9.9');
$beforeversionarray = explode('.', '3.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// No particular code
}
// Script for 3.1
$afterversionarray = explode('.', '3.0.9');
$beforeversionarray = explode('.', '3.1.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss');
migrate_actioncomm_element($db, $langs, $conf);
@@ -344,8 +346,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Script for 3.2
$afterversionarray = explode('.', '3.1.9');
$beforeversionarray = explode('.', '3.2.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_price_contrat($db, $langs, $conf);
migrate_mode_reglement($db, $langs, $conf);
@@ -356,8 +357,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Script for 3.3
$afterversionarray = explode('.', '3.2.9');
$beforeversionarray = explode('.', '3.3.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_categorie_association($db, $langs, $conf);
}
@@ -367,32 +367,28 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Tasks to do always and only into last targeted version
$afterversionarray = explode('.', '3.6.9'); // target is after this
$beforeversionarray = explode('.', '3.7.9'); // target is before this
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
- migrate_event_assignement($db, $langs, $conf);
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
+ migrate_event_assignement($db, $langs, $conf);
}
// Scripts for 3.9
$afterversionarray = explode('.', '3.7.9');
$beforeversionarray = explode('.', '3.8.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// No particular code
}
// Scripts for 4.0
$afterversionarray = explode('.', '3.9.9');
$beforeversionarray = explode('.', '4.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias');
}
// Scripts for 5.0
$afterversionarray = explode('.', '4.0.9');
$beforeversionarray = explode('.', '5.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// Migrate to add entity value into llx_societe_remise
migrate_remise_entity($db, $langs, $conf);
@@ -403,15 +399,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Scripts for 6.0
$afterversionarray = explode('.', '5.0.9');
$beforeversionarray = explode('.', '6.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
- if (!empty($conf->multicompany->enabled))
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
+ if (!empty($conf->multicompany->enabled)) {
global $multicompany_transverse_mode;
// Only if the transverse mode is not used
- if (empty($multicompany_transverse_mode))
- {
+ if (empty($multicompany_transverse_mode)) {
// Migrate to add entity value into llx_user_rights
migrate_user_rights_entity($db, $langs, $conf);
@@ -424,8 +417,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Scripts for 7.0
$afterversionarray = explode('.', '6.0.9');
$beforeversionarray = explode('.', '7.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
// Migrate contact association
migrate_event_assignement_contact($db, $langs, $conf);
@@ -435,16 +427,14 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Scripts for 8.0
$afterversionarray = explode('.', '7.0.9');
$beforeversionarray = explode('.', '8.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract');
}
// Scripts for 9.0
$afterversionarray = explode('.', '8.0.9');
$beforeversionarray = explode('.', '9.0.9');
- if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0)
- {
+ if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_user_photospath();
}
@@ -460,8 +450,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
// Code executed only if migration is LAST ONE. Must always be done.
- if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3)
- {
+ if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) {
// Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version)
$listofmodule = array(
'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly',
@@ -469,6 +458,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
'MAIN_MODULE_BARCODE'=>'newboxdefonly',
'MAIN_MODULE_CRON'=>'newboxdefonly',
'MAIN_MODULE_COMMANDE'=>'newboxdefonly',
+ 'MAIN_MODULE_BLOCKEDLOG'=>'noboxes',
'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly',
'MAIN_MODULE_DON'=>'newboxdefonly',
'MAIN_MODULE_ECM'=>'newboxdefonly',
@@ -482,7 +472,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
'MAIN_MODULE_PAYBOX'=>'newboxdefonly',
'MAIN_MODULE_PRINTING'=>'newboxdefonly',
'MAIN_MODULE_PRODUIT'=>'newboxdefonly',
- 'MAIN_MODULE_RESOURCE'=>'newboxdefonly',
+ 'MAIN_MODULE_RESOURCE'=>'noboxes',
'MAIN_MODULE_SALARIES'=>'newboxdefonly',
'MAIN_MODULE_SYSLOG'=>'newboxdefonly',
'MAIN_MODULE_SOCIETE'=>'newboxdefonly',
@@ -501,14 +491,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...'
// In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line.
- if (!$error && $enablemodules)
- {
+ if (!$error && $enablemodules) {
// Reload modules (this must be always done and only into last targeted version)
$listofmodules = array();
$enablemodules = preg_replace('/enablemodules=/', '', $enablemodules);
$tmplistofmodules = explode(',', $enablemodules);
- foreach ($tmplistofmodules as $value)
- {
+ foreach ($tmplistofmodules as $value) {
$listofmodules[$value] = 'forceactivate';
}
@@ -520,16 +508,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Can call a dedicated external upgrade process
- if (!$error)
- {
+ if (!$error) {
$parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto);
$object = new stdClass();
$action = "upgrade";
$reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if ($hookmanager->resNbOfHooks > 0)
- {
- if ($reshook < 0)
- {
+ if ($hookmanager->resNbOfHooks > 0) {
+ if ($reshook < 0) {
print '';
print ''.$langs->trans('UpgradeExternalModule').' : ';
print $hookmanager->error;
@@ -543,8 +528,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
} else {
//if (! empty($conf->modules))
- if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done
- {
+ if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done
print ' ';
print ''.$langs->trans('UpgradeExternalModule').' : '.$langs->trans("None");
print ' ';
@@ -586,16 +570,22 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
$ret = 0;
-if ($error && isset($argv[1])) $ret = 1;
+if ($error && isset($argv[1])) {
+ $ret = 1;
+}
dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("--- upgrade2: end");
pFooter($error ? 2 : 0, $setuplang);
-if ($db->connected) $db->close();
+if ($db->connected) {
+ $db->close();
+}
// Return code if ran from command line
-if ($ret) exit($ret);
+if ($ret) {
+ exit($ret);
+}
@@ -616,8 +606,7 @@ function migrate_paiements($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$sql = "SELECT p.rowid, p.fk_facture, p.amount";
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.fk_facture > 0";
@@ -625,14 +614,12 @@ function migrate_paiements($db, $langs, $conf)
$resql = $db->query($sql);
dolibarr_install_syslog("upgrade2::migrate_paiements");
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$row = array();
$num = $db->num_rows($resql);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$row[$i][0] = $obj->rowid;
$row[$i][1] = $obj->fk_facture;
@@ -643,15 +630,12 @@ function migrate_paiements($db, $langs, $conf)
dol_print_error($db);
}
- if ($num)
- {
+ if ($num) {
print $langs->trans('MigrationPaymentsNumberToUpdate', $num)." \n";
- if ($db->begin())
- {
+ if ($db->begin()) {
$res = 0;
$num = count($row);
- for ($i = 0; $i < $num; $i++)
- {
+ for ($i = 0; $i < $num; $i++) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)";
$sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")";
@@ -665,8 +649,7 @@ function migrate_paiements($db, $langs, $conf)
}
}
- if ($res == (2 * count($row)))
- {
+ if ($res == (2 * count($row))) {
$db->commit();
print $langs->trans('MigrationSuccessfullUpdate')." ";
} else {
@@ -702,8 +685,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
// Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
$sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
$sql .= " bu2.url_id as socid";
@@ -718,16 +700,13 @@ function migrate_paiements_orphelins_1($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1");
$row = array();
- if ($resql)
- {
+ if ($resql) {
$i = $j = 0;
$num = $db->num_rows($resql);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
- if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas
- {
+ if ($obj->pamount == $obj->bamount && $obj->socid) { // Pour etre sur d'avoir bon cas
$row[$j]['paymentid'] = $obj->rowid; // paymentid
$row[$j]['pamount'] = $obj->pamount;
$row[$j]['fk_bank'] = $obj->fk_bank;
@@ -742,16 +721,16 @@ function migrate_paiements_orphelins_1($db, $langs, $conf)
dol_print_error($db);
}
- if (count($row))
- {
+ if (count($row)) {
print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)." \n";
$db->begin();
$res = 0;
$num = count($row);
- for ($i = 0; $i < $num; $i++)
- {
- if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
+ for ($i = 0; $i < $num; $i++) {
+ if ($conf->global->MAIN_FEATURES_LEVEL == 2) {
+ print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
+ }
// On cherche facture sans lien paiement et du meme montant et pour meme societe.
$sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f";
@@ -761,12 +740,10 @@ function migrate_paiements_orphelins_1($db, $langs, $conf)
$sql .= " ORDER BY f.fk_statut";
//print $sql.' ';
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
//print 'Nb of invoice found for this amount and company :'.$num.' ';
- if ($num >= 1)
- {
+ if ($num >= 1) {
$obj = $db->fetch_object($resql);
$facid = $obj->rowid;
@@ -782,8 +759,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf)
}
}
- if ($res > 0)
- {
+ if ($res > 0) {
print $langs->trans('MigrationSuccessfullUpdate')." ";
} else {
print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
@@ -819,8 +795,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
// Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
$sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,";
$sql .= " bu2.url_id as socid";
@@ -834,16 +809,13 @@ function migrate_paiements_orphelins_2($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2");
$row = array();
- if ($resql)
- {
+ if ($resql) {
$i = $j = 0;
$num = $db->num_rows($resql);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
- if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas
- {
+ if ($obj->pamount == $obj->bamount && $obj->socid) { // Pour etre sur d'avoir bon cas
$row[$j]['paymentid'] = $obj->rowid; // paymentid
$row[$j]['pamount'] = $obj->pamount;
$row[$j]['fk_bank'] = $obj->fk_bank;
@@ -861,15 +833,15 @@ function migrate_paiements_orphelins_2($db, $langs, $conf)
$nberr = 0;
$num = count($row);
- if ($num)
- {
+ if ($num) {
print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)." \n";
$db->begin();
$res = 0;
- for ($i = 0; $i < $num; $i++)
- {
- if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
+ for ($i = 0; $i < $num; $i++) {
+ if ($conf->global->MAIN_FEATURES_LEVEL == 2) {
+ print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].' ';
+ }
// On cherche facture sans lien paiement et du meme montant et pour meme societe.
$sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f";
@@ -879,12 +851,10 @@ function migrate_paiements_orphelins_2($db, $langs, $conf)
$sql .= " ORDER BY f.fk_statut";
//print $sql.' ';
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
//print 'Nb of invoice found for this amount and company :'.$num.' ';
- if ($num >= 1)
- {
+ if ($num >= 1) {
$obj = $db->fetch_object($resql);
$facid = $obj->rowid;
@@ -900,8 +870,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf)
}
}
- if ($res > 0)
- {
+ if ($res > 0) {
print $langs->trans('MigrationSuccessfullUpdate')." ";
} else {
print $langs->trans('MigrationPaymentsNothingUpdatable')." \n";
@@ -918,8 +887,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf)
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture";
$db->query($sql);
- if (!$nberr)
- {
+ if (!$nberr) {
$db->commit();
} else {
print 'ERROR';
@@ -961,19 +929,16 @@ function migrate_contracts_det($db, $langs, $conf)
$resql = $db->query($sql);
dolibarr_install_syslog("upgrade2::migrate_contracts_det");
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$row = array();
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
print $langs->trans('MigrationContractsNumberToUpdate', $num)." \n";
$db->begin();
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet (";
@@ -992,8 +957,7 @@ function migrate_contracts_det($db, $langs, $conf)
$sql .= "null";
$sql .= ")";
- if ($db->query($sql))
- {
+ if ($db->query($sql)) {
print $langs->trans('MigrationContractsLineCreation', $obj->cref)." \n";
} else {
dol_print_error($db);
@@ -1003,8 +967,7 @@ function migrate_contracts_det($db, $langs, $conf)
$i++;
}
- if (!$nberr)
- {
+ if (!$nberr) {
// $db->rollback();
$db->commit();
print $langs->trans('MigrationSuccessfullUpdate')." ";
@@ -1049,19 +1012,16 @@ function migrate_links_transfert($db, $langs, $conf)
$resql = $db->query($sql);
dolibarr_install_syslog("upgrade2::migrate_links_transfert");
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$row = array();
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
print $langs->trans('MigrationBankTransfertsToUpdate', $num)." \n";
$db->begin();
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
@@ -1074,8 +1034,7 @@ function migrate_links_transfert($db, $langs, $conf)
print $sql.' ';
dolibarr_install_syslog("migrate_links_transfert");
- if (!$db->query($sql))
- {
+ if (!$db->query($sql)) {
dol_print_error($db);
$nberr++;
}
@@ -1083,8 +1042,7 @@ function migrate_links_transfert($db, $langs, $conf)
$i++;
}
- if (!$nberr)
- {
+ if (!$nberr) {
// $db->rollback();
$db->commit();
print $langs->trans('MigrationSuccessfullUpdate')." ";
@@ -1120,18 +1078,26 @@ function migrate_contracts_date1($db, $langs, $conf)
$sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null";
dolibarr_install_syslog("upgrade2::migrate_contracts_date1");
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0)
- print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')." \n";
- else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')." \n";
+ if (!$resql) {
+ dol_print_error($db);
+ }
+ if ($db->affected_rows($resql) > 0) {
+ print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')." \n";
+ } else {
+ print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')." \n";
+ }
$sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null";
dolibarr_install_syslog("upgrade2::migrate_contracts_date1");
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0)
- print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')." \n";
- else print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')." \n";
+ if (!$resql) {
+ dol_print_error($db);
+ }
+ if ($db->affected_rows($resql) > 0) {
+ print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')." \n";
+ } else {
+ print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')." \n";
+ }
print '';
}
@@ -1161,22 +1127,18 @@ function migrate_contracts_date2($db, $langs, $conf)
$resql = $db->query($sql);
dolibarr_install_syslog("upgrade2::migrate_contracts_date2");
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$row = array();
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
$nbcontratsmodifie = 0;
$db->begin();
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
- if ($obj->date_contrat > $obj->datemin)
- {
+ if ($obj->date_contrat > $obj->datemin) {
$datemin = $db->jdate($obj->datemin);
print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)." \n";
@@ -1184,7 +1146,9 @@ function migrate_contracts_date2($db, $langs, $conf)
$sql .= " SET date_contrat='".$db->idate($datemin)."'";
$sql .= " WHERE rowid=".$obj->cref;
$resql2 = $db->query($sql);
- if (!$resql2) dol_print_error($db);
+ if (!$resql2) {
+ dol_print_error($db);
+ }
$nbcontratsmodifie++;
}
@@ -1193,9 +1157,11 @@ function migrate_contracts_date2($db, $langs, $conf)
$db->commit();
- if ($nbcontratsmodifie)
- print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)." \n";
- else print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')." \n";
+ if ($nbcontratsmodifie) {
+ print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)." \n";
+ } else {
+ print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')." \n";
+ }
}
} else {
dol_print_error($db);
@@ -1222,10 +1188,14 @@ function migrate_contracts_date3($db, $langs, $conf)
$sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat";
dolibarr_install_syslog("upgrade2::migrate_contracts_date3");
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
- if ($db->affected_rows($resql) > 0)
- print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')." \n";
- else print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')." \n";
+ if (!$resql) {
+ dol_print_error($db);
+ }
+ if ($db->affected_rows($resql) > 0) {
+ print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')." \n";
+ } else {
+ print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')." \n";
+ }
print '';
}
@@ -1249,19 +1219,19 @@ function migrate_contracts_open($db, $langs, $conf)
$sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat";
dolibarr_install_syslog("upgrade2::migrate_contracts_open");
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
if ($db->affected_rows($resql) > 0) {
$i = 0;
$row = array();
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
$nbcontratsmodifie = 0;
$db->begin();
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print $langs->trans('MigrationReopenThisContract', $obj->cref)." \n";
@@ -1269,7 +1239,9 @@ function migrate_contracts_open($db, $langs, $conf)
$sql .= " SET statut=1";
$sql .= " WHERE rowid=".$obj->cref;
$resql2 = $db->query($sql);
- if (!$resql2) dol_print_error($db);
+ if (!$resql2) {
+ dol_print_error($db);
+ }
$nbcontratsmodifie++;
@@ -1278,11 +1250,15 @@ function migrate_contracts_open($db, $langs, $conf)
$db->commit();
- if ($nbcontratsmodifie)
- print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)." \n";
- else print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
+ if ($nbcontratsmodifie) {
+ print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)." \n";
+ } else {
+ print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
+ }
}
- } else print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
+ } else {
+ print $langs->trans('MigrationReopeningContractsNothingToUpdate')." \n";
+ }
print '';
}
@@ -1306,8 +1282,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn", "fk_facture_fourn");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$error = 0;
$nb = 0;
@@ -1317,15 +1292,13 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn");
$select_resql = $db->query($select_sql);
- if ($select_resql)
- {
+ if ($select_resql) {
$select_num = $db->num_rows($select_resql);
$i = 0;
$var = true;
// Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn
- while (($i < $select_num) && (!$error))
- {
+ while (($i < $select_num) && (!$error)) {
$var = !$var;
$select_obj = $db->fetch_object($select_resql);
@@ -1334,15 +1307,12 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
$check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
$check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn;
$check_resql = $db->query($check_sql);
- if ($check_resql)
- {
+ if ($check_resql) {
$check_num = $db->num_rows($check_resql);
- if ($check_num == 0)
- {
+ if ($check_num == 0) {
$db->begin();
- if ($nb == 0)
- {
+ if ($nb == 0) {
print ''.$langs->trans('SuppliersInvoices').' ';
print 'fk_paiementfourn fk_facturefourn '.$langs->trans('Amount').' ';
}
@@ -1356,8 +1326,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
$insert_sql .= ' amount = \''.$select_obj->amount.'\'';
$insert_resql = $db->query($insert_sql);
- if ($insert_resql)
- {
+ if ($insert_resql) {
$nb++;
print ''.$langs->trans("OK").' ';
} else {
@@ -1375,10 +1344,8 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
$error++;
}
- if (!$error)
- {
- if (!$nb)
- {
+ if (!$error) {
+ if (!$nb) {
print ''.$langs->trans("AlreadyDone").' ';
}
$db->commit();
@@ -1426,14 +1393,11 @@ function migrate_price_facture($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_facture");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1464,15 +1428,12 @@ function migrate_price_facture($db, $langs, $conf)
/* On touche a facture mere uniquement si total_ttc = 0 */
- if (!$total_ttc_f)
- {
+ if (!$total_ttc_f) {
$facture = new Facture($db);
$facture->id = $obj->facid;
- if ($facture->fetch($facture->id) >= 0)
- {
- if ($facture->update_price() > 0)
- {
+ if ($facture->fetch($facture->id) >= 0) {
+ if ($facture->update_price() > 0) {
//print $facture->id;
} else {
print "Error id=".$facture->id;
@@ -1515,7 +1476,7 @@ function migrate_price_facture($db, $langs, $conf)
*/
function migrate_price_propal($db, $langs, $conf)
{
- $tmpmysoc = new Societe($db);
+ $tmpmysoc = new Societe($db);
$tmpmysoc->setMysoc($conf);
$db->begin();
@@ -1534,14 +1495,11 @@ function migrate_price_propal($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_propal");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1571,24 +1529,24 @@ function migrate_price_propal($db, $langs, $conf)
/* On touche pas a propal mere
- $propal = new Propal($db);
- $propal->id=$obj->rowid;
- if ( $propal->fetch($propal->id) >= 0 )
- {
- if ( $propal->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$propal->id;
- }
- }
- else
- {
- print "Error #3";
- }
- */
+ $propal = new Propal($db);
+ $propal->id=$obj->rowid;
+ if ( $propal->fetch($propal->id) >= 0 )
+ {
+ if ( $propal->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$propal->id;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ }
+ */
$i++;
}
} else {
@@ -1621,9 +1579,11 @@ function migrate_price_contrat($db, $langs, $conf)
{
$db->begin();
- $tmpmysoc = new Societe($db);
+ $tmpmysoc = new Societe($db);
$tmpmysoc->setMysoc($conf);
- if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error.
+ if (empty($tmpmysoc->country_id)) {
+ $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error.
+ }
print '';
@@ -1639,14 +1599,11 @@ function migrate_price_contrat($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_contrat");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1723,14 +1680,11 @@ function migrate_price_commande($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_commande");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1759,24 +1713,24 @@ function migrate_price_commande($db, $langs, $conf)
$commandeligne->update_total();
/* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
- {
- if ( $commande->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- }
- }
- else
- {
- print "Error #3";
- }
- */
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
+ {
+ if ( $commande->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$commande->id;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ }
+ */
$i++;
}
} else {
@@ -1786,14 +1740,14 @@ function migrate_price_commande($db, $langs, $conf)
$db->free($resql);
/*
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
- $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- }
- */
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
+ $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ }
+ */
$db->commit();
} else {
@@ -1836,14 +1790,11 @@ function migrate_price_commande_fournisseur($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
@@ -1872,24 +1823,24 @@ function migrate_price_commande_fournisseur($db, $langs, $conf)
$commandeligne->update_total();
/* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
- {
- if ( $commande->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- }
- }
- else
- {
- print "Error #3";
- }
- */
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
+ {
+ if ( $commande->update_price() > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$commande->id;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ }
+ */
$i++;
}
} else {
@@ -1899,14 +1850,14 @@ function migrate_price_commande_fournisseur($db, $langs, $conf)
$db->free($resql);
/*
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
- $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- }
- */
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
+ $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ }
+ */
$db->commit();
} else {
@@ -1935,42 +1886,42 @@ function migrate_modeles($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_modeles");
- if (!empty($conf->facture->enabled))
- {
+ if (!empty($conf->facture->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
$modellist = ModelePDFFactures::liste_modeles($db);
- if (count($modellist) == 0)
- {
+ if (count($modellist) == 0) {
// Aucun model par defaut.
$sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
- if (!empty($conf->commande->enabled))
- {
+ if (!empty($conf->commande->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
$modellist = ModelePDFCommandes::liste_modeles($db);
- if (count($modellist) == 0)
- {
+ if (count($modellist) == 0) {
// Aucun model par defaut.
$sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
- if (!empty($conf->expedition->enabled))
- {
+ if (!empty($conf->expedition->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
$modellist = ModelePDFExpedition::liste_modeles($db);
- if (count($modellist) == 0)
- {
+ if (count($modellist) == 0) {
// Aucun model par defaut.
$sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')";
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
}
}
@@ -1997,31 +1948,26 @@ function migrate_commande_expedition($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "fk_commande");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$error = 0;
$db->begin();
$sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)";
$sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
@@ -2030,8 +1976,7 @@ function migrate_commande_expedition($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
print $langs->trans('FieldRenamed')." \n";
@@ -2068,8 +2013,7 @@ function migrate_commande_livraison($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_commande");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$error = 0;
$db->begin();
@@ -2079,23 +2023,19 @@ function migrate_commande_livraison($db, $langs, $conf)
$sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
$sql .= " WHERE c.rowid = l.fk_commande";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)";
$sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
$resql2 = $db->query($sql);
- if ($resql2)
- {
+ if ($resql2) {
$delivery_date = $db->jdate($obj->delivery_date);
$sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
@@ -2103,8 +2043,7 @@ function migrate_commande_livraison($db, $langs, $conf)
$sqlu .= ", date_livraison='".$db->idate($delivery_date)."'";
$sqlu .= " WHERE rowid = ".$obj->rowid;
$resql3 = $db->query($sqlu);
- if (!$resql3)
- {
+ if (!$resql3) {
$error++;
dol_print_error($db);
}
@@ -2117,8 +2056,7 @@ function migrate_commande_livraison($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande";
print $langs->trans('FieldRenamed')." \n";
@@ -2157,8 +2095,7 @@ function migrate_detail_livraison($db, $langs, $conf)
// If not this means migration was already done.
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_commande_ligne");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$error = 0;
$db->begin();
@@ -2168,15 +2105,12 @@ function migrate_detail_livraison($db, $langs, $conf)
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
$sql .= " WHERE ld.fk_commande_ligne = cd.rowid";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET";
@@ -2187,15 +2121,13 @@ function migrate_detail_livraison($db, $langs, $conf)
$sql .= " WHERE fk_commande_ligne = ".$obj->rowid;
$resql2 = $db->query($sql);
- if ($resql2)
- {
+ if ($resql2) {
$sql = "SELECT total_ht";
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE rowid = ".$obj->fk_livraison;
$resql3 = $db->query($sql);
- if ($resql3)
- {
+ if ($resql3) {
$obju = $db->fetch_object($resql3);
$total_ht = $obju->total_ht + $obj->total_ht;
@@ -2203,8 +2135,7 @@ function migrate_detail_livraison($db, $langs, $conf)
$sqlu .= " total_ht='".$db->escape($total_ht)."'";
$sqlu .= " WHERE rowid=".$obj->fk_livraison;
$resql4 = $db->query($sqlu);
- if (!$resql4)
- {
+ if (!$resql4) {
$error++;
dol_print_error($db);
}
@@ -2221,8 +2152,7 @@ function migrate_detail_livraison($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer";
print $langs->trans('FieldRenamed')." \n";
@@ -2237,8 +2167,7 @@ function migrate_detail_livraison($db, $langs, $conf)
} else {
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_origin_line");
$obj = $db->fetch_object($result);
- if (!$obj)
- {
+ if (!$obj) {
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison";
$db->query($sql);
}
@@ -2272,15 +2201,12 @@ function migrate_stocks($db, $langs, $conf)
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql .= " GROUP BY fk_product";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "UPDATE ".MAIN_DB_PREFIX."product SET";
@@ -2288,8 +2214,7 @@ function migrate_stocks($db, $langs, $conf)
$sql .= " WHERE rowid=".$obj->fk_product;
$resql2 = $db->query($sql);
- if ($resql2)
- {
+ if ($resql2) {
} else {
$error++;
dol_print_error($db);
@@ -2299,8 +2224,7 @@ function migrate_stocks($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
$db->rollback();
@@ -2333,8 +2257,7 @@ function migrate_menus($db, $langs, $conf)
$error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint"))
- {
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) {
$db->begin();
$sql = "SELECT m.rowid, mc.action";
@@ -2342,14 +2265,11 @@ function migrate_menus($db, $langs, $conf)
$sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid";
$sql .= " AND m.enabled = '1'";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
@@ -2358,8 +2278,7 @@ function migrate_menus($db, $langs, $conf)
$sql .= " AND enabled = '1'";
$resql2 = $db->query($sql);
- if ($resql2)
- {
+ if ($resql2) {
} else {
$error++;
dol_print_error($db);
@@ -2369,8 +2288,7 @@ function migrate_menus($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
$db->rollback();
@@ -2406,8 +2324,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf)
$error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp"))
- {
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) {
$db->begin();
$sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition";
@@ -2417,15 +2334,12 @@ function migrate_commande_deliveryaddress($db, $langs, $conf)
$sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
@@ -2433,8 +2347,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf)
$sql .= " WHERE rowid=".$obj->fk_expedition;
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
@@ -2445,8 +2358,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
$db->rollback();
@@ -2475,10 +2387,8 @@ function migrate_restore_missing_links($db, $langs, $conf)
{
dolibarr_install_syslog("upgrade2::migrate_restore_missing_links");
- if (($db->type == 'mysql' || $db->type == 'mysqli'))
- {
- if (versioncompare($db->getVersionArray(), array(4, 0)) < 0)
- {
+ if (($db->type == 'mysql' || $db->type == 'mysqli')) {
+ if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) {
dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action");
return 0;
}
@@ -2505,15 +2415,12 @@ function migrate_restore_missing_links($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. ';
@@ -2522,18 +2429,18 @@ function migrate_restore_missing_links($db, $langs, $conf)
$sql .= " WHERE rowid=".$obj->field;
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
//print ". ";
$i++;
}
- } else print $langs->trans('AlreadyDone')." \n";
+ } else {
+ print $langs->trans('AlreadyDone')." \n";
+ }
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
$db->rollback();
@@ -2565,15 +2472,12 @@ function migrate_restore_missing_links($db, $langs, $conf)
dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this. ';
@@ -2582,8 +2486,7 @@ function migrate_restore_missing_links($db, $langs, $conf)
$sql .= " WHERE rowid=".$obj->field;
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
@@ -2594,8 +2497,7 @@ function migrate_restore_missing_links($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
$db->rollback();
@@ -2627,23 +2529,19 @@ function migrate_project_user_resp($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."projet", "fk_user_resp");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$error = 0;
$db->begin();
$sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact (";
@@ -2660,11 +2558,9 @@ function migrate_project_user_resp($db, $langs, $conf)
$sql2 .= ", ".$obj->fk_user_resp;
$sql2 .= ")";
- if ($obj->fk_user_resp > 0)
- {
+ if ($obj->fk_user_resp > 0) {
$resql2 = $db->query($sql2);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
@@ -2675,11 +2571,9 @@ function migrate_project_user_resp($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp";
- if ($db->query($sqlDrop))
- {
+ if ($db->query($sqlDrop)) {
$db->commit();
} else {
$db->rollback();
@@ -2714,23 +2608,19 @@ function migrate_project_task_actors($db, $langs, $conf)
print ' ';
print ''.$langs->trans('MigrationProjectTaskActors')." \n";
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors"))
- {
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) {
$error = 0;
$db->begin();
$sql = "SELECT fk_projet_task as fk_project_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact (";
@@ -2749,8 +2639,7 @@ function migrate_project_task_actors($db, $langs, $conf)
$resql2 = $db->query($sql2);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
@@ -2759,11 +2648,9 @@ function migrate_project_task_actors($db, $langs, $conf)
}
}
- if ($error == 0)
- {
+ if ($error == 0) {
$sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors";
- if ($db->query($sqlDrop))
- {
+ if ($db->query($sqlDrop)) {
$db->commit();
} else {
$db->rollback();
@@ -2803,8 +2690,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so
$error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table))
- {
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) {
dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table);
$db->begin();
@@ -2813,15 +2699,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so
$sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
@@ -2837,8 +2720,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so
$sqlInsert .= ")";
$result = $db->query($sqlInsert);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -2849,11 +2731,9 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so
print $langs->trans('AlreadyDone')." \n";
}
- if ($error == 0)
- {
+ if ($error == 0) {
$sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table;
- if ($db->query($sqlDrop))
- {
+ if ($db->query($sqlDrop)) {
$db->commit();
} else {
$db->rollback();
@@ -2896,22 +2776,18 @@ function migrate_project_task_time($db, $langs, $conf)
$sql = "SELECT rowid, fk_task, task_duration";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
$totaltime = array();
$oldtime = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
- if ($obj->task_duration > 0)
- {
+ if ($obj->task_duration > 0) {
// convert to second
// only for int time and float time ex: 1,75 for 1h45
list($hour, $min) = explode('.', $obj->task_duration);
@@ -2924,36 +2800,37 @@ function migrate_project_task_time($db, $langs, $conf)
$sql2 .= " WHERE rowid = ".$obj->rowid;
$resql2 = $db->query($sql2);
- if (!$resql2)
- {
+ if (!$resql2) {
$error++;
dol_print_error($db);
}
print ". ";
$oldtime++;
- if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime;
- else $totaltime[$obj->fk_task] = $newtime;
+ if (!empty($totaltime[$obj->fk_task])) {
+ $totaltime[$obj->fk_task] += $newtime;
+ } else {
+ $totaltime[$obj->fk_task] = $newtime;
+ }
} else {
- if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration;
- else $totaltime[$obj->fk_task] = $obj->task_duration;
+ if (!empty($totaltime[$obj->fk_task])) {
+ $totaltime[$obj->fk_task] += $obj->task_duration;
+ } else {
+ $totaltime[$obj->fk_task] = $obj->task_duration;
+ }
}
$i++;
}
- if ($error == 0)
- {
- if ($oldtime > 0)
- {
- foreach ($totaltime as $taskid => $total_duration)
- {
+ if ($error == 0) {
+ if ($oldtime > 0) {
+ foreach ($totaltime as $taskid => $total_duration) {
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
$sql .= " duration_effective = ".$total_duration;
$sql .= " WHERE rowid = ".$taskid;
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
dol_print_error($db);
}
@@ -2971,8 +2848,7 @@ function migrate_project_task_time($db, $langs, $conf)
dol_print_error($db);
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
$db->rollback();
@@ -3002,8 +2878,7 @@ function migrate_customerorder_shipping($db, $langs, $conf)
$result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "date_delivery");
$obj1 = $db->fetch_object($result1);
$obj2 = $db->fetch_object($result2);
- if (!$obj1 && !$obj2)
- {
+ if (!$obj1 && !$obj2) {
dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping");
$db->begin();
@@ -3011,8 +2886,7 @@ function migrate_customerorder_shipping($db, $langs, $conf)
$sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity";
$sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition";
- if ($db->query($sqlAdd1) && $db->query($sqlAdd2))
- {
+ if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) {
$sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison as delivery_date";
$sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el";
@@ -3021,15 +2895,12 @@ function migrate_customerorder_shipping($db, $langs, $conf)
$sqlSelect .= " AND el.targettype = 'shipping'";
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
@@ -3038,8 +2909,7 @@ function migrate_customerorder_shipping($db, $langs, $conf)
$sqlUpdate .= " WHERE rowid = ".$obj->shipping_id;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3050,8 +2920,7 @@ function migrate_customerorder_shipping($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
dol_print_error($db);
@@ -3091,8 +2960,7 @@ function migrate_shipping_delivery($db, $langs, $conf)
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_expedition");
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
dolibarr_install_syslog("upgrade2::migrate_shipping_delivery");
$db->begin();
@@ -3102,15 +2970,12 @@ function migrate_shipping_delivery($db, $langs, $conf)
$sqlSelect .= " WHERE fk_expedition is not null";
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
@@ -3126,14 +2991,12 @@ function migrate_shipping_delivery($db, $langs, $conf)
$sqlInsert .= ")";
$result = $db->query($sqlInsert);
- if ($result)
- {
+ if ($result) {
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL";
$sqlUpdate .= " WHERE rowid = ".$obj->rowid;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3148,8 +3011,7 @@ function migrate_shipping_delivery($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if ($error == 0)
- {
+ if ($error == 0) {
$sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'";
$db->query($sqlDelete);
@@ -3208,15 +3070,12 @@ function migrate_shipping_delivery2($db, $langs, $conf)
$sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")";
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
@@ -3225,8 +3084,7 @@ function migrate_shipping_delivery2($db, $langs, $conf)
$sqlUpdate .= " WHERE rowid = ".$obj->delivery_id;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3237,8 +3095,7 @@ function migrate_shipping_delivery2($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if ($error == 0)
- {
+ if ($error == 0) {
$db->commit();
} else {
dol_print_error($db);
@@ -3276,12 +3133,10 @@ function migrate_actioncomm_element($db, $langs, $conf)
'invoice_supplier' => 'fk_supplier_invoice'
);
- foreach ($elements as $type => $field)
- {
+ foreach ($elements as $type => $field) {
$result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field);
$obj = $db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field);
$db->begin();
@@ -3293,8 +3148,7 @@ function migrate_actioncomm_element($db, $langs, $conf)
$sql .= " AND elementtype IS NULL";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$db->commit();
// DDL commands must not be inside a transaction
@@ -3337,8 +3191,7 @@ function migrate_mode_reglement($db, $langs, $conf)
);
$count = 0;
- foreach ($elements['old_id'] as $key => $old_id)
- {
+ foreach ($elements['old_id'] as $key => $old_id) {
$error = 0;
dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]);
@@ -3349,11 +3202,9 @@ function migrate_mode_reglement($db, $langs, $conf)
$sqlSelect .= " AND code = '".$db->escape($elements['code'][$key])."'";
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
$count++;
$db->begin();
@@ -3370,25 +3221,21 @@ function migrate_mode_reglement($db, $langs, $conf)
$sql .= " AND code = '".$db->escape($elements['code'][$key])."'";
$resql = $db->query($sql);
- if ($resqla && $resql)
- {
- foreach ($elements['tables'] as $table)
- {
+ if ($resqla && $resql) {
+ foreach ($elements['tables'] as $table) {
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
$sql .= "fk_mode_reglement = ".$elements['new_id'][$key];
$sql .= " WHERE fk_mode_reglement = ".$old_id;
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($db);
$error++;
}
print ". ";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
dol_print_error($db);
@@ -3402,7 +3249,9 @@ function migrate_mode_reglement($db, $langs, $conf)
}
}
- if ($count == 0) print $langs->trans('AlreadyDone')." \n";
+ if ($count == 0) {
+ print $langs->trans('AlreadyDone')." \n";
+ }
print ' ';
@@ -3420,26 +3269,20 @@ function migrate_mode_reglement($db, $langs, $conf)
function migrate_clean_association($db, $langs, $conf)
{
$result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association");
- if ($result) // result defined for version 3.2 or -
- {
+ if ($result) { // result defined for version 3.2 or -
$obj = $db->fetch_object($result);
- if ($obj) // It table categorie_association exists
- {
+ if ($obj) { // It table categorie_association exists
$couples = array();
$filles = array();
$sql = "SELECT fk_categorie_mere, fk_categorie_fille";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_install_syslog("upgrade: search duplicate");
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
- while ($obj = $db->fetch_object($resql))
- {
- if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
- {
- if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
- {
+ while ($obj = $db->fetch_object($resql)) {
+ if (!isset($filles[$obj->fk_categorie_fille])) { // Only one record as child (a child has only on parent).
+ if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) {
$filles[$obj->fk_categorie_fille] = 1; // Set record for this child
$couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
}
@@ -3449,8 +3292,7 @@ function migrate_clean_association($db, $langs, $conf)
dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
// If there is duplicates couples or child with two parents
- if (count($couples) > 0 && $num > count($couples))
- {
+ if (count($couples) > 0 && $num > count($couples)) {
$error = 0;
$db->begin();
@@ -3459,21 +3301,20 @@ function migrate_clean_association($db, $langs, $conf)
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_install_syslog("upgrade: delete association");
$resqld = $db->query($sql);
- if ($resqld)
- {
+ if ($resqld) {
// And we insert only each record once
- foreach ($couples as $key => $val)
- {
+ foreach ($couples as $key => $val) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
$sql .= " VALUES(".$val['mere'].", ".$val['fille'].")";
dolibarr_install_syslog("upgrade: insert association");
$resqli = $db->query($sql);
- if (!$resqli) $error++;
+ if (!$resqli) {
+ $error++;
+ }
}
}
- if (!$error)
- {
+ if (!$error) {
print ''.$langs->trans("MigrationCategorieAssociation").' ';
print ''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).') ';
$db->commit();
@@ -3509,8 +3350,7 @@ function migrate_categorie_association($db, $langs, $conf)
$error = 0;
- if ($db->DDLInfoTable(MAIN_DB_PREFIX."categorie_association"))
- {
+ if ($db->DDLInfoTable(MAIN_DB_PREFIX."categorie_association")) {
dolibarr_install_syslog("upgrade2::migrate_categorie_association");
$db->begin();
@@ -3519,15 +3359,12 @@ function migrate_categorie_association($db, $langs, $conf)
$sqlSelect .= " FROM ".MAIN_DB_PREFIX."categorie_association";
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."categorie SET ";
@@ -3535,8 +3372,7 @@ function migrate_categorie_association($db, $langs, $conf)
$sqlUpdate .= " WHERE rowid = ".$obj->fk_categorie_fille;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3547,8 +3383,7 @@ function migrate_categorie_association($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
// TODO DROP table in the next release
/*
$sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."categorie_association";
@@ -3606,23 +3441,19 @@ function migrate_event_assignement($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) ";
$sqlUpdate .= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")";
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3633,8 +3464,7 @@ function migrate_event_assignement($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -3677,23 +3507,19 @@ function migrate_event_assignement_contact($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) ";
$sqlUpdate .= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")";
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3704,8 +3530,7 @@ function migrate_event_assignement_contact($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -3751,34 +3576,28 @@ function migrate_reset_blocked_log($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print 'Process entity '.$obj->entity;
$sqlSearch = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."blockedlog WHERE action = 'MODULE_SET' and entity = ".$obj->entity;
$resqlSearch = $db->query($sqlSearch);
- if ($resqlSearch)
- {
+ if ($resqlSearch) {
$objSearch = $db->fetch_object($resqlSearch);
//var_dump($objSearch);
- if ($objSearch && $objSearch->nb == 0)
- {
+ if ($objSearch && $objSearch->nb == 0) {
print ' - Record for entity must be reset...';
$sqlUpdate = "DELETE FROM ".MAIN_DB_PREFIX."blockedlog";
$sqlUpdate .= " WHERE entity = ".$obj->entity;
$resqlUpdate = $db->query($sqlUpdate);
- if (!$resqlUpdate)
- {
+ if (!$resqlUpdate) {
$error++;
dol_print_error($db);
} else {
@@ -3811,8 +3630,7 @@ function migrate_reset_blocked_log($db, $langs, $conf)
print $langs->trans('NothingToDo')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -3854,15 +3672,12 @@ function migrate_remise_entity($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET";
@@ -3870,8 +3685,7 @@ function migrate_remise_entity($db, $langs, $conf)
$sqlUpdate .= " WHERE rowid = ".$obj->rowid;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3883,8 +3697,7 @@ function migrate_remise_entity($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -3923,26 +3736,21 @@ function migrate_remise_except_entity($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
- if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture))
- {
+ if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture)) {
$fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture);
$sqlSelect2 = "SELECT f.entity";
$sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sqlSelect2 .= " WHERE f.rowid = ".$fk_facture;
- } elseif (!empty($obj->fk_facture_line))
- {
+ } elseif (!empty($obj->fk_facture_line)) {
$sqlSelect2 = "SELECT f.entity";
$sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd";
$sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line;
@@ -3954,10 +3762,8 @@ function migrate_remise_except_entity($db, $langs, $conf)
}
$resql2 = $db->query($sqlSelect2);
- if ($resql2)
- {
- if ($db->num_rows($resql2) > 0)
- {
+ if ($resql2) {
+ if ($db->num_rows($resql2) > 0) {
$obj2 = $db->fetch_object($resql2);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET";
@@ -3965,8 +3771,7 @@ function migrate_remise_except_entity($db, $langs, $conf)
$sqlUpdate .= " WHERE rowid = ".$obj->rowid;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -3983,8 +3788,7 @@ function migrate_remise_except_entity($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -4024,15 +3828,12 @@ function migrate_user_rights_entity($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET";
@@ -4040,8 +3841,7 @@ function migrate_user_rights_entity($db, $langs, $conf)
$sqlUpdate .= " WHERE fk_user = ".$obj->rowid;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -4053,8 +3853,7 @@ function migrate_user_rights_entity($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -4094,15 +3893,12 @@ function migrate_usergroup_rights_entity($db, $langs, $conf)
//print $sqlSelect;
$resql = $db->query($sqlSelect);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET";
@@ -4110,8 +3906,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf)
$sqlUpdate .= " WHERE fk_usergroup = ".$obj->rowid;
$result = $db->query($sqlUpdate);
- if (!$result)
- {
+ if (!$result) {
$error++;
dol_print_error($db);
}
@@ -4123,8 +3918,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf)
print $langs->trans('AlreadyDone')." \n";
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -4152,8 +3946,7 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname)
{
dolibarr_install_syslog("upgrade2::migrate_rename_directories");
- if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname))
- {
+ if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) {
dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname);
@rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname);
}
@@ -4289,18 +4082,22 @@ function migrate_delete_old_dir($db, $langs, $conf)
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
- * @param array $listofmodule List of modules
+ * @param array $listofmodule List of modules, like array('MODULE_KEY_NAME'=>', $reloadmode)
* @param int $force 1=Reload module even if not already loaded
* @return int <0 if KO, >0 if OK
*/
function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $force = 0)
{
- if (count($listofmodule) == 0) return;
+ if (count($listofmodule) == 0) {
+ return;
+ }
dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule)));
foreach ($listofmodule as $moduletoreload => $reloadmode) { // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate'
- if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled
+ if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) {
+ continue; // Discard reload if module not enabled
+ }
$mod = null;
@@ -4328,6 +4125,15 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
$mod->remove('noboxes');
$mod->init($reloadmode);
}
+ } elseif ($moduletoreload == 'MAIN_MODULE_BLOCKEDLOG') {
+ dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate BlockedLog module");
+ $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modBlockedLog.class.php';
+ if ($res) {
+ $mod = new modBlockedLog($db);
+ // For this module we only reload menus.
+ $mod->delete_menus();
+ $mod->insert_menus($reloadmode);
+ }
} elseif ($moduletoreload == 'MAIN_MODULE_CRON') {
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module");
$res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php';
@@ -4472,24 +4278,25 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
$mod->remove('noboxes'); // We need to remove because menu entries has changed
$mod->init($reloadmode);
}
- } else {
+ } else { // Other generic cases/modules
$reg = array();
$tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg);
- if (!empty($reg[1]))
- {
- if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase
- {
+ if (!empty($reg[1])) {
+ if (strtoupper($moduletoreload) == $moduletoreload) { // If key is un uppercase
$moduletoreloadshort = ucfirst(strtolower($reg[1]));
} else // If key is a mix of up and low case
{
$moduletoreloadshort = $reg[1];
}
+
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode);
$res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php';
if ($res) {
$classname = 'mod'.$moduletoreloadshort;
$mod = new $classname($db);
+
//$mod->remove('noboxes');
+ $mod->delete_menus(); // We must delete to be sure it is insert with new values
$mod->init($reloadmode);
} else {
dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php');
@@ -4498,7 +4305,6 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
if ($res) {
$classname = 'mod'.$moduletoreloadshort;
$mod = new $classname($db);
- //$mod->remove('noboxes');
$mod->init($reloadmode);
} else {
dolibarr_install_syslog('Failed to include '.strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php', LOG_ERR);
@@ -4513,8 +4319,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
}
}
- if (!empty($mod) && is_object($mod))
- {
+ if (!empty($mod) && is_object($mod)) {
print '';
print ''.$langs->trans('Upgrade').' : ';
print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated
@@ -4530,7 +4335,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
/**
- * Reload menu if dynamic menus, if modified by version
+ * Reload SQL menu file (if dynamic menus, if modified by version)
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
@@ -4545,13 +4350,11 @@ function migrate_reload_menu($db, $langs, $conf)
// Define list of menu handlers to initialize
$listofmenuhandler = array();
if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu'
- || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu')
- {
+ || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') {
$listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers
}
- foreach ($listofmenuhandler as $key => $val)
- {
+ foreach ($listofmenuhandler as $key => $val) {
print ' ';
//print "x".$key;
@@ -4561,8 +4364,7 @@ function migrate_reload_menu($db, $langs, $conf)
// Load sql ini_menu_handler.sql file
$dir = DOL_DOCUMENT_ROOT."/core/menus/";
$file = 'init_menu_'.$key.'.sql';
- if (file_exists($dir.$file))
- {
+ if (file_exists($dir.$file)) {
$result = run_sql($dir.$file, 1, '', 1, $key);
}
@@ -4586,14 +4388,14 @@ function migrate_user_photospath()
include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$fuser = new User($db);
- if (!is_object($user)) $user = $fuser; // To avoid error during migration
+ if (!is_object($user)) {
+ $user = $fuser; // To avoid error during migration
+ }
$sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users
$resql = $db->query($sql);
- if ($resql)
- {
- while ($obj = $db->fetch_object($resql))
- {
+ if ($resql) {
+ while ($obj = $db->fetch_object($resql)) {
$fuser->fetch($obj->uid);
//echo ' '.$fuser->id.' -> '.$fuser->entity;
$entity = (empty($fuser->entity) ? 1 : $fuser->entity);
@@ -4603,8 +4405,7 @@ function migrate_user_photospath()
$dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module
}
- if ($dir)
- {
+ if ($dir) {
//print "Process user id ".$fuser->id." \n";
$origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path
$destin = $dir.'/'.$fuser->id;
@@ -4614,26 +4415,23 @@ function migrate_user_photospath()
dol_mkdir($destin);
//echo ' '.$origin.' -> '.$destin;
- if (dol_is_dir($origin))
- {
+ if (dol_is_dir($origin)) {
$handle = opendir($origin_osencoded);
- if (is_resource($handle))
- {
- while (($file = readdir($handle)) !== false)
- {
- if ($file == '.' || $file == '..') continue;
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
- if (dol_is_dir($origin.'/'.$file)) // it is a dir (like 'thumbs')
- {
+ if (dol_is_dir($origin.'/'.$file)) { // it is a dir (like 'thumbs')
$thumbs = opendir($origin_osencoded.'/'.$file);
- if (is_resource($thumbs))
- {
- dol_mkdir($destin.'/'.$file);
- while (($thumb = readdir($thumbs)) !== false)
- {
- if (!dol_is_file($destin.'/'.$file.'/'.$thumb))
- {
- if ($thumb == '.' || $thumb == '..') continue;
+ if (is_resource($thumbs)) {
+ dol_mkdir($destin.'/'.$file);
+ while (($thumb = readdir($thumbs)) !== false) {
+ if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) {
+ if ($thumb == '.' || $thumb == '..') {
+ continue;
+ }
//print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.' '."\n";
print '.';
@@ -4645,8 +4443,7 @@ function migrate_user_photospath()
}
} else // it is a file
{
- if (!dol_is_file($destin.'/'.$file))
- {
+ if (!dol_is_file($destin.'/'.$file)) {
//print $origin.'/'.$file.' -> '.$destin.'/'.$file.' '."\n";
print '.';
dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0);
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index de7b0e704b4..b7948532773 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -232,6 +232,7 @@ BoxesAvailable=Widgets available
BoxesActivated=Widgets activated
ActivateOn=Activate on
ActiveOn=Activated on
+ActivatableOn=Activatable on
SourceFile=Source file
AvailableOnlyIfJavascriptAndAjaxNotDisabled=Available only if JavaScript is not disabled
Required=Required
@@ -647,8 +648,8 @@ Module4000Name=HRM
Module4000Desc=Human resources management (management of department, employee contracts and feelings)
Module5000Name=Multi-company
Module5000Desc=Allows you to manage multiple companies
-Module6000Name=Workflow
-Module6000Desc=Workflow management (automatic creation of object and/or automatic status change)
+Module6000Name=Inter-modules Workflow
+Module6000Desc=Workflow management between different modules (automatic creation of object and/or automatic status change)
Module10000Name=Websites
Module10000Desc=Create websites (public) with a WYSIWYG editor. This is a webmaster or developer oriented CMS (it is better to know HTML and CSS language). Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name.
Module20000Name=Leave Request Management
@@ -1741,6 +1742,7 @@ YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Se
AccountancyCode=Accounting Code
AccountancyCodeSell=Sale account. code
AccountancyCodeBuy=Purchase account. code
+CREATE_NEW_VAT_WITHOUT_AUTO_PAYMENT=Keep the checkbox “Automatically create the payment” empty by default when creating a new tax
##### Agenda #####
AgendaSetup=Events and agenda module setup
PasswordTogetVCalExport=Key to authorize export link
@@ -1987,7 +1989,7 @@ SocialNetworkSetup=Setup of module Social Networks
EnableFeatureFor=Enable features for %s
VATIsUsedIsOff=Note: The option to use Sales Tax or VAT has been set to Off in the menu %s - %s, so Sales tax or Vat used will always be 0 for sales.
SwapSenderAndRecipientOnPDF=Swap sender and recipient address position on PDF documents
-FeatureSupportedOnTextFieldsOnly=Warning, feature supported on text fields only. Also an URL parameter action=create or action=edit must be set OR page name must end with 'new.php' to trigger this feature.
+FeatureSupportedOnTextFieldsOnly=Warning, feature supported on text fields and combo lists only. Also an URL parameter action=create or action=edit must be set OR page name must end with 'new.php' to trigger this feature.
EmailCollector=Email collector
EmailCollectorDescription=Add a scheduled job and a setup page to scan regularly email boxes (using IMAP protocol) and record emails received into your application, at the right place and/or create some records automatically (like leads).
NewEmailCollector=New Email Collector
@@ -2102,3 +2104,4 @@ SHOW_SUBPRODUCT_REF_IN_PDF=If the feature "%s" of module %s is used, show
AskThisIDToYourBank=Contact your bank to get this ID
AdvancedModeOnly=Permision available in Advanced permission mode only
ConfFileIsReadableOrWritableByAnyUsers=The conf file is reabable or writable by any users. Give permission to web server user and group only.
+MailToSendEventOrganization=Event Organization
diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang
index 33e0c01aad6..d16188d40d4 100644
--- a/htdocs/langs/en_US/agenda.lang
+++ b/htdocs/langs/en_US/agenda.lang
@@ -4,7 +4,7 @@ Actions=Events
Agenda=Agenda
TMenuAgenda=Agenda
Agendas=Agendas
-LocalAgenda=Internal calendar
+LocalAgenda=Default calendar
ActionsOwnedBy=Event owned by
ActionsOwnedByShort=Owner
AffectedTo=Assigned to
@@ -20,7 +20,7 @@ MenuToDoActions=All incomplete events
MenuDoneActions=All terminated events
MenuToDoMyActions=My incomplete events
MenuDoneMyActions=My terminated events
-ListOfEvents=List of events (internal calendar)
+ListOfEvents=List of events (default calendar)
ActionsAskedBy=Events reported by
ActionsToDoBy=Events assigned to
ActionsDoneBy=Events done by
@@ -131,7 +131,7 @@ AgendaUrlOptions4=logint=%s to restrict output to actions assigned to use
AgendaUrlOptionsProject=project=__PROJECT_ID__ to restrict output to actions linked to project __PROJECT_ID__ .
AgendaUrlOptionsNotAutoEvent=notactiontype=systemauto to exclude automatic events.
AgendaUrlOptionsIncludeHolidays=includeholidays=1 to include events of holidays.
-AgendaShowBirthdayEvents=Show birthdays of contacts
+AgendaShowBirthdayEvents=Birthdays of contacts
AgendaHideBirthdayEvents=Hide birthdays of contacts
Busy=Busy
ExportDataset_event1=List of agenda events
diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang
index ef04723c6c2..afafc98503f 100644
--- a/htdocs/langs/en_US/assets.lang
+++ b/htdocs/langs/en_US/assets.lang
@@ -61,5 +61,7 @@ MenuListTypeAssets = List
#
# Module
#
+Asset=Asset
NewAssetType=New asset type
NewAsset=New asset
+ConfirmDeleteAsset=Are you sure you want to delete this asset ?
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 45246dcc412..1060c02ce96 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -413,7 +413,7 @@ PaymentCondition14DENDMONTH=Within 14 days following the end of the month
FixAmount=Fixed amount - 1 line with label '%s'
VarAmount=Variable amount (%% tot.)
VarAmountOneLine=Variable amount (%% tot.) - 1 line with label '%s'
-VarAmountAllLines=Variable amount (%% tot.) - all same lines
+VarAmountAllLines=Variable amount (%% tot.) - all lines from origin
# PaymentType
PaymentTypeVIR=Bank transfer
PaymentTypeShortVIR=Bank transfer
diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang
index 88ff8fecdb6..7263b04730a 100644
--- a/htdocs/langs/en_US/cashdesk.lang
+++ b/htdocs/langs/en_US/cashdesk.lang
@@ -56,7 +56,8 @@ Paymentnumpad=Type of Pad to enter payment
Numberspad=Numbers Pad
BillsCoinsPad=Coins and banknotes Pad
DolistorePosCategory=TakePOS modules and other POS solutions for Dolibarr
-TakeposNeedsCategories=TakePOS needs product categories to work
+TakeposNeedsCategories=TakePOS needs at least one product categorie to work
+TakeposNeedsAtLeastOnSubCategoryIntoParentCategory=TakePOS needs at least 1 product category under the category %s to work
OrderNotes=Order Notes
CashDeskBankAccountFor=Default account to use for payments in
NoPaimementModesDefined=No paiment mode defined in TakePOS configuration
diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang
index 10c536e0d48..2181b48ecb4 100644
--- a/htdocs/langs/en_US/commercial.lang
+++ b/htdocs/langs/en_US/commercial.lang
@@ -64,10 +64,10 @@ ActionAC_SHIP=Send shipping by mail
ActionAC_SUP_ORD=Send purchase order by mail
ActionAC_SUP_INV=Send vendor invoice by mail
ActionAC_OTH=Other
-ActionAC_OTH_AUTO=Automatically inserted events
+ActionAC_OTH_AUTO=Other auto
ActionAC_MANUAL=Manually inserted events
ActionAC_AUTO=Automatically inserted events
-ActionAC_OTH_AUTOShort=Auto
+ActionAC_OTH_AUTOShort=Other
Stats=Sales statistics
StatusProsp=Prospect status
DraftPropals=Draft commercial proposals
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 99bed13179f..d4c9f95b0b9 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -203,6 +203,7 @@ ProfId2IT=-
ProfId3IT=-
ProfId4IT=-
ProfId5IT=EORI number
+ProfId6IT=-
ProfId1LU=Id. prof. 1 (R.C.S. Luxembourg)
ProfId2LU=Id. prof. 2 (Business permit)
ProfId3LU=-
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 545fcdb62fb..9e56c5f5c3a 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -258,6 +258,8 @@ ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must
ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page
ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation
ErrorDateIsInFuture=Error, the date can't be in the future
+ErrorAnAmountWithoutTaxIsRequired=Error, amount is mandatory
+ErrorAPercentIsRequired=Error, please fill in the percentage correctly
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang
new file mode 100644
index 00000000000..0c7e4f047ce
--- /dev/null
+++ b/htdocs/langs/en_US/eventorganization.lang
@@ -0,0 +1,72 @@
+# Copyright (C) 2021 Florian Henry
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+#
+# Generic
+#
+
+ModuleEventOrganizationName = Event Organization
+EventOrganizationDescription = Event Organization through Module Project
+EventOrganizationDescriptionLong= Manage Event organization for conference, attendees, speaker, and attendees, with public subcription page
+
+#
+# Admin page
+#
+EventOrganizationSetup = Event Organization setup
+Settings = Settings
+EventOrganizationSetupPage = Event Organization setup page
+EVENTORGANIZATION_TASK_LABEL = Task label created when validate
+EVENTORGANIZATION_TASK_LABELTooltip = When validate a Conference or a booth, some tasks will be created in the project for example: Send Call for Conference Send Call for Booth Receive call for conferences Receive call for Booth Open subscriptions to events for attendees Send remind of event to speakers Send remind of event to Booth hoster Send remind of event to attendees
+EVENTORGANIZATION_CATEG_THIRDPARTY_CONF = Category to add to third-parties automatically created when someone suggests a conference
+EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH = Category to add to third-parties automatically created when they suggests a booth
+EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF = Template of email to send after receiving a suggestion of a conference.
+EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH = Template of email to send after receiving a suggestion of a booth.
+EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send after a subscription to a booth has been paid.
+EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid.
+EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes
+EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers
+
+#
+# Object
+#
+EventOrganizationConfOrBooth= Conference Or Booth
+ManageOrganizeEvent = Manage event organisation
+ConferenceOrBooth = Conference Or Booth
+ConferenceOrBoothTab = Conference Or Booth
+
+#
+# Template Mail
+#
+YourOrganizationEventConfRequestWasReceived = Your request for conference was received
+YourOrganizationEventBoothRequestWasReceived = Your request for booth was received
+EventOrganizationEmailAskConf = Request for conference
+EventOrganizationEmailAskBooth = Request for booth
+EventOrganizationEmailSubsBooth = Subscription for booth
+EventOrganizationEmailSubsEvent = Subscription for an event
+EventOrganizationMassEmailAttendees = Communication to attendes
+EventOrganizationMassEmailSpeakers = Communication to speakers
+
+#
+# Event
+#
+AllowUnknownPeopleSuggestConf=Allow unknown people to suggest conferences
+AllowUnknownPeopleSuggestConfHelp=Allow unknown people to suggest conferences
+AllowUnknownPeopleSuggestBooth=Allow unknown people to suggest booth
+AllowUnknownPeopleSuggestBoothHelp=Allow unknown people to suggest booth
+PriceOfRegistration=Price of registration
+PriceOfRegistrationHelp=Price of registration
+PriceOfBooth=Price of subscription
+PriceOfBoothHelp=Price of subscription
+EventOrganizationICSLink=Link ICS for events
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index a5cd750e3d6..67544b46328 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -389,6 +389,8 @@ AmountTotal=Total amount
AmountAverage=Average amount
PriceQtyMinHT=Price quantity min. (excl. tax)
PriceQtyMinHTCurrency=Price quantity min. (excl. tax) (currency)
+PercentOfOriginalObject=Percent of original object
+AmountOrPercent=Amount or percent
Percentage=Percentage
Total=Total
SubTotal=Subtotal
@@ -899,8 +901,10 @@ ViewAccountList=View ledger
ViewSubAccountList=View subaccount ledger
RemoveString=Remove string '%s'
SomeTranslationAreUncomplete=Some of the languages offered may be only partially translated or may contain errors. Please help to correct your language by registering at https://transifex.com/projects/p/dolibarr/ to add your improvements.
-DirectDownloadLink=Direct download link (public/external)
-DirectDownloadInternalLink=Direct download link (need to be logged and need permissions)
+DirectDownloadLink=Public download link
+PublicDownloadLinkDesc=Only the link is required to download the file
+DirectDownloadInternalLink=Private download link
+PrivateDownloadLinkDesc=You need to be logged and you need permissions to view or download the file
Download=Download
DownloadDocument=Download document
ActualizeCurrency=Update currency rate
@@ -1049,7 +1053,7 @@ KeyboardShortcut=Keyboard shortcut
AssignedTo=Assigned to
Deletedraft=Delete draft
ConfirmMassDraftDeletion=Draft mass delete confirmation
-FileSharedViaALink=File shared via a link
+FileSharedViaALink=File shared with a public link
SelectAThirdPartyFirst=Select a third party first...
YouAreCurrentlyInSandboxMode=You are currently in the %s "sandbox" mode
Inventory=Inventory
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index 9ecc11ed93d..9ec22ad00cc 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -141,6 +141,7 @@ VATRateForSupplierProduct=VAT Rate (for this vendor/product)
DiscountQtyMin=Discount for this qty.
NoPriceDefinedForThisSupplier=No price/qty defined for this vendor/product
NoSupplierPriceDefinedForThisProduct=No vendor price/qty defined for this product
+PredefinedItem=Predefined item
PredefinedProductsToSell=Predefined Product
PredefinedServicesToSell=Predefined Service
PredefinedProductsAndServicesToSell=Predefined products/services to sell
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 279bf99d162..33a0fafb5dc 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -269,3 +269,6 @@ OneLinePerPeriod=One line per period
RefTaskParent=Ref. Parent Task
ProfitIsCalculatedWith=Profit is calculated using
AddPersonToTask=Add also to tasks
+UsageOrganizeEvent=Usage: Event Organization
+PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classify project as closed when all its tasks are completed (100%% progress)
+PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks at 100 %% progress won't be affected: you will have to close them manually. This option only affects open projects.
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index ad4946ee9f9..aabbe1791b3 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -99,6 +99,7 @@ VirtualStock=Virtual stock
VirtualStockAtDate=Virtual stock at date
VirtualStockAtDateDesc=Virtual stock once all pending orders that are planned to be done before the date will be finished
VirtualStockDesc=Virtual stock is the calculated stock available once all open/pending actions (that affect stocks) are closed (purchase orders received, sales orders shipped, manufacturing orders produced, etc)
+AtDate=At date
IdWarehouse=Id warehouse
DescWareHouse=Description warehouse
LieuWareHouse=Localisation warehouse
diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang
index ca75eddb7df..a68319fb2df 100644
--- a/htdocs/langs/en_US/supplier_proposal.lang
+++ b/htdocs/langs/en_US/supplier_proposal.lang
@@ -53,3 +53,6 @@ SupplierProposalsToClose=Vendor proposals to close
SupplierProposalsToProcess=Vendor proposals to process
LastSupplierProposals=Latest %s price requests
AllPriceRequests=All requests
+TypeContact_supplier_proposal_external_SHIPPING=Vendor contact for delivery
+TypeContact_supplier_proposal_external_BILLING=Vendor contact for billing
+TypeContact_supplier_proposal_external_SERVICE=Representative following-up proposal
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index 7793fa5dead..b7babd403a1 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -46,12 +46,12 @@ SetHereVirtualHost=Use with Apache/NGinx/... Create on your web server
ExampleToUseInApacheVirtualHostConfig=Example to use in Apache virtual host setup:
YouCanAlsoTestWithPHPS=Use with PHP embedded server On develop environment, you may prefer to test the site with the PHP embedded web server (PHP 5.5 required) by runningphp -S 0.0.0.0:8080 -t %s
YouCanAlsoDeployToAnotherWHP=Run your web site with another Dolibarr Hosting provider If you don't have a web server like Apache or NGinx available on internet, you can export and import your web site onto another Dolibarr instance provided by another Dolibarr hosting provider that provide full integration with the Website module. You can find a list of some Dolibarr hosting providers on https://saas.dolibarr.org
-CheckVirtualHostPerms=Check also that virtual host has permission %s on files into%s
+CheckVirtualHostPerms=Check also that the virtual host user (for example www-data) has %s permissions on files into%s
ReadPerm=Read
WritePerm=Write
TestDeployOnWeb=Test/deploy on web
PreviewSiteServedByWebServer=Preview %s in a new tab. The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:%s URL served by external server:%s
-PreviewSiteServedByDolibarr=Preview %s in a new tab. The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed. The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr. URL served by Dolibarr:%s To use your own external web server to serve this web site, create a virtual host on your web server that point on directory%s then enter the name of this virtual server and click on the other preview button.
+PreviewSiteServedByDolibarr=Preview %s in a new tab. The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed. The inconvenient is that the URLs of pages are not user friendly and start with the path of your Dolibarr. URL served by Dolibarr:%s To use your own external web server to serve this web site, create a virtual host on your web server that points on directory%s then enter the name of this virtual server in the properties of this website and click on the link "Test/Deploy on the web".
VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined
NoPageYet=No pages yet
YouCanCreatePageOrImportTemplate=You can create a new page or import a full website template
diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang
index 072fd057dbf..7ecd5800861 100644
--- a/htdocs/langs/fr_FR/agenda.lang
+++ b/htdocs/langs/fr_FR/agenda.lang
@@ -130,7 +130,7 @@ AgendaUrlOptions4=logint=%s pour limiter l'export aux actions assignées
AgendaUrlOptionsProject=project=__PROJECT_ID__ pour restreindre aux événements associés au projet __PROJECT_ID__ .
AgendaUrlOptionsNotAutoEvent=notactiontype=systemauto pour exclure les événements automatiques.
AgendaUrlOptionsIncludeHolidays=includeholidays=1 pour inclure les événements de type congé.
-AgendaShowBirthdayEvents=Afficher les anniversaires de contacts
+AgendaShowBirthdayEvents=Anniversaires de contacts
AgendaHideBirthdayEvents=Masquer les anniversaires de contacts
Busy=Occupé
ExportDataset_event1=Liste des événements de l'agenda
diff --git a/htdocs/langs/fr_FR/commercial.lang b/htdocs/langs/fr_FR/commercial.lang
index 9b5721326d1..badec05e8c2 100644
--- a/htdocs/langs/fr_FR/commercial.lang
+++ b/htdocs/langs/fr_FR/commercial.lang
@@ -64,10 +64,10 @@ ActionAC_SHIP=Envoi bon d'expédition par email
ActionAC_SUP_ORD=Envoi commande fournisseur par email
ActionAC_SUP_INV=Envoi facture fournisseur par email
ActionAC_OTH=Autre
-ActionAC_OTH_AUTO=Évènements insérés automatiquement
+ActionAC_OTH_AUTO=Autre auto
ActionAC_MANUAL=Événements insérés manuellement
ActionAC_AUTO=Événements insérés automatiquement
-ActionAC_OTH_AUTOShort=Auto
+ActionAC_OTH_AUTOShort=Autre
Stats=Statistiques de vente
StatusProsp=Status prospection
DraftPropals=Propositions brouillons
diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang
index 1affdad0889..a963bffe13d 100644
--- a/htdocs/langs/fr_FR/projects.lang
+++ b/htdocs/langs/fr_FR/projects.lang
@@ -268,3 +268,5 @@ OneLinePerTask=Une ligne par tâche
OneLinePerPeriod=Une ligne par période
RefTaskParent=Réf. Tâche parent
ProfitIsCalculatedWith=Le bénéfice est calculé sur la base de
+PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classer le projet à clôturé lorsque toutes les tâches de ce projet sont à 100 %% de progression
+PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Non rétroactif : l’activation de cette option ne clôturera pas les projets dont les tâches sont déjà à 100 %%. Cette option ne classe que les projets ouverts.
diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php
index 91bfaf1f921..a7811dfa04a 100644
--- a/htdocs/loan/document.php
+++ b/htdocs/loan/document.php
@@ -68,7 +68,7 @@ $modulepart = 'loan';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index c91f4802974..93f445b83d1 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -185,9 +185,12 @@ function analyseVarsForSqlAndScriptsInjection(&$var, $type)
// Check consistency of NOREQUIREXXX DEFINES
-if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU'))
-{
- print 'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them';
+if ((defined('NOREQUIREDB') || defined('NOREQUIRETRAN')) && !defined('NOREQUIREMENU')) {
+ print 'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.';
+ exit;
+}
+if (defined('NOREQUIREUSER') && !defined('NOREQUIREMENU')) {
+ print 'If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it.';
exit;
}
@@ -413,14 +416,16 @@ if ((!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VE
}
// Creation of a token against CSRF vulnerabilities
-if (!defined('NOTOKENRENEWAL'))
-{
+if (!defined('NOTOKENRENEWAL')) {
// Rolling token at each call ($_SESSION['token'] contains token of previous page)
- if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken'];
+ if (isset($_SESSION['newtoken'])) {
+ $_SESSION['token'] = $_SESSION['newtoken'];
+ }
- // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken']
+ // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = newToken();
$token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number
$_SESSION['newtoken'] = $token;
+ dol_syslog("NEW TOKEN reclaimed by : " . $_SERVER['PHP_SELF'], LOG_DEBUG);
}
//dol_syslog("aaaa - ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha').' '.$_SESSION['token']);
@@ -454,8 +459,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl
}
}
- if (GETPOSTISSET('token') && GETPOST('token', 'alpha') != $_SESSION['token'])
- {
+ if (GETPOSTISSET('token') && GETPOST('token', 'alpha') != $_SESSION['token']) {
dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused due to invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING);
//print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers.
setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings');
@@ -595,7 +599,7 @@ if (!defined('NOLOGIN'))
if ($test && GETPOST("username", "alpha", 2) && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) && !isset($_SESSION['dol_bypass_antispam']))
{
$sessionkey = 'dol_antispam_value';
- $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
+ $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'none'))));
// Check code
if (!$ok)
@@ -1007,8 +1011,6 @@ if ((!empty($conf->browser->layout) && $conf->browser->layout == 'phone')
{
$conf->dol_optimize_smallscreen = 1;
}
-// If we force to use jmobile, then we reenable javascript
-if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1;
// Replace themes bugged with jmobile with eldy
if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok')))
{
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 9cbb6ae4167..cbd0dc69375 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1568,13 +1568,16 @@ if (!dol_is_dir($dirins))
}
$dirins_ok = (dol_is_dir($dirins));
-llxHeader('', $langs->trans("ModuleBuilder"), '', '', 0, 0,
- array(
+$help_url = '';
+$morejs = array(
'/includes/ace/src/ace.js',
'/includes/ace/src/ext-statusbar.js',
'/includes/ace/src/ext-language_tools.js',
//'/includes/ace/src/ext-chromevox.js'
- ), array(), '', 'classforhorizontalscrolloftabs');
+);
+$morecss = array();
+
+llxHeader('', $langs->trans("ModuleBuilder"), $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
$text = $langs->trans("ModuleBuilder");
@@ -1701,8 +1704,7 @@ if (is_array($listofmodules) && count($listofmodules) > 0) {
foreach ($objMod->config_page_url as $page)
{
$urlpage = $page;
- if ($i++)
- {
+ if ($i++) {
$linktoenabledisable .= ' '.img_picto(ucfirst($page), "setup").' ';
// print ''.ucfirst($page).' ';
} else {
@@ -1711,7 +1713,8 @@ if (is_array($listofmodules) && count($listofmodules) > 0) {
$urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1);
$linktoenabledisable .= ' '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').' ';
} else {
- // Case standard admin page (not a page provided by the module but a page
+ // Case standard admin page (not a page provided by the
+ // module but a page provided by dolibarr)
$urltouse = DOL_URL_ROOT.'/admin/'.$urlpage;
$linktoenabledisable .= ' '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').' ';
}
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index e93b8686d79..93bbc8a6612 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -61,8 +61,11 @@ $scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
$arrayofparameters = array(
- 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
- 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
+ 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
+ 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
+ //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
+ //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
+ //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
);
$error = 0;
@@ -208,11 +211,57 @@ if ($action == 'edit') {
print '';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- foreach ($arrayofparameters as $key => $val) {
- print '';
- $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
- print $form->textwithpicto($langs->trans($key), $tooltiphelp);
- print ' ';
+ foreach ($arrayofparameters as $constname => $val) {
+ if ($val['enabled']==1) {
+ $setupnotempty++;
+ print '';
+ $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+ print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).' ';
+ print ' ';
+
+ if ($val['type'] == 'textarea') {
+ print '' . "\n";
+ print $conf->global->{$constname};
+ print " \n";
+ } elseif ($val['type']== 'html') {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+ $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor->Create();
+ } elseif ($val['type'] == 'yesno') {
+ print $form->selectyesno($constname, $conf->global->{$constname}, 1);
+ } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $tmp = explode(':', $val['type']);
+ $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
+ //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
+ $arrayofmessagename = array();
+ if (is_array($formmail->lines_model)) {
+ foreach ($formmail->lines_model as $modelmail) {
+ //var_dump($modelmail);
+ $moreonlabel = '';
+ if (!empty($arrayofmessagename[$modelmail->label])) {
+ $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ') ';
+ }
+ // The 'label' is the key that is unique if we exclude the language
+ $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
+ }
+ }
+ print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+ } elseif (preg_match('/category:/', $val['type'])) {
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+ $formother = new FormOther($db);
+
+ $tmp = explode(':', $val['type']);
+ print img_picto('', 'category', 'class="pictofixedwidth"');
+ print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
+ } else {
+ print ' ';
+ }
+ print ' ';
+ }
}
print '
';
@@ -227,13 +276,48 @@ if ($action == 'edit') {
print '';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- foreach ($arrayofparameters as $key => $val) {
- $setupnotempty++;
+ foreach ($arrayofparameters as $constname => $val) {
+ if ($val['enabled']==1) {
+ $setupnotempty++;
+ print '';
+ $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+ print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
+ print ' ';
- print ' ';
- $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
- print $form->textwithpicto($langs->trans($key), $tooltiphelp);
- print ' '.$conf->global->$key.' ';
+ if ($val['type'] == 'textarea') {
+ print dol_nl2br($conf->global->{$constname});
+ } elseif ($val['type']== 'html') {
+ print $conf->global->{$constname};
+ } elseif ($val['type'] == 'yesno') {
+ print ajax_constantonoff($constname);
+ } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $tmp = explode(':', $val['type']);
+
+ $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+ if ($template<0) {
+ setEventMessages(null, $formmail->errors, 'errors');
+ }
+ print $langs->trans($template->label);
+ } elseif (preg_match('/category:/', $val['type'])) {
+ $c = new Categorie($db);
+ $result = $c->fetch($conf->global->{$constname});
+ if ($result < 0) {
+ setEventMessages(null, $c->errors, 'errors');
+ }
+ $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
+ $toprint = array();
+ foreach ($ways as $way) {
+ $toprint[] = 'color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . ' ';
+ }
+ print '' . implode(' ', $toprint) . ' ';
+ } else {
+ print $conf->global->{$constname};
+ }
+ print '';
+ }
}
print '
';
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index e7da913f39c..e07e7757751 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -772,9 +772,17 @@ class MyObject extends CommonObject
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
- $linkstart = '';
- $linkend = ' ';
+ if ($option == 'nolink') {
+ $linkend = '';
+ } else {
+ $linkend = '';
+ }
$result .= $linkstart;
diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php
index dc4426f7df9..0a5e23cb07a 100644
--- a/htdocs/modulebuilder/template/myobject_card.php
+++ b/htdocs/modulebuilder/template/myobject_card.php
@@ -117,9 +117,9 @@ $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object-
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
-//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
+//$result = restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
-//if (!$permissiontoread) accessforbidden();
+//if (empty($permissiontoread)) accessforbidden();
/*
diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php
index 1cd3de2ebd9..f1424906dd6 100644
--- a/htdocs/modulebuilder/template/myobject_document.php
+++ b/htdocs/modulebuilder/template/myobject_document.php
@@ -121,7 +121,7 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the incl
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index e22de010459..2cbccd1523b 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -231,6 +231,8 @@ $now = dol_now();
//$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
$help_url = '';
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects"));
+$morejs = array();
+$morecss = array();
// Build and execute select
@@ -351,7 +353,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
// Output page
// --------------------------------------------------------------------
-llxHeader('', $title, $help_url);
+llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
// Example : Adding jquery code
print '';
+
+
+print ''."\n";
+
+// Lastname
+print ''.$langs->trans("Lastname").' * '."\n";
+// Firstname
+print ''.$langs->trans("Firstname").' * '."\n";
+// Company
+print ''.$langs->trans("Company").' '."\n";
+// Address
+print ''.$langs->trans("Address").' '."\n";
+print ''.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).' '."\n";
+// Zip / Town
+print ''.$langs->trans('Zip').' / '.$langs->trans('Town').' ';
+print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
+print ' / ';
+print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
+print ' ';
+// Country
+print ''.$langs->trans('Country').' ';
+$country_id = GETPOST('country_id');
+if (!$country_id && !empty($conf->global->PROJECT_NEWFORM_FORCECOUNTRYCODE)) {
+ $country_id = getCountry($conf->global->PROJECT_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
+}
+if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
+ $country_code = dol_user_country();
+ //print $country_code;
+ if ($country_code) {
+ $new_country_id = getCountry($country_code, 3, $db, $langs);
+ //print 'xxx'.$country_code.' - '.$new_country_id;
+ if ($new_country_id) $country_id = $new_country_id;
+ }
+}
+$country_code = getCountry($country_id, 2, $db, $langs);
+print $form->select_country($country_id, 'country_id');
+print ' ';
+// State
+if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
+ print ''.$langs->trans('State').' ';
+ if ($country_code) print $formcompany->select_state(GETPOST("state_id"), $country_code);
+ else print '';
+ print ' ';
+}
+// EMail
+print ''.$langs->trans("Email").' * '."\n";
+// Other attributes
+$tpl_context = 'public'; // define template context to public
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
+// Comments
+print '';
+print ''.$langs->trans("Comments").' ';
+print ''.dol_escape_htmltag(GETPOST('note_private', 'restricthtml'), 0, 1).' ';
+print ' '."\n";
+
+print "
\n";
+
+print dol_get_fiche_end();
+
+// Save
+print '';
+print ' ';
+if (!empty($backtopage)) {
+ print ' ';
+}
+print '
';
+
+
+print "\n";
+print " ";
+print '';
+
+
+llxFooterVierge();
+
+$db->close();
diff --git a/htdocs/theme/eldy/doc/badges.php b/htdocs/public/test/badges.php
similarity index 97%
rename from htdocs/theme/eldy/doc/badges.php
rename to htdocs/public/test/badges.php
index 52a422a053c..194e9947624 100644
--- a/htdocs/theme/eldy/doc/badges.php
+++ b/htdocs/public/test/badges.php
@@ -1,17 +1,21 @@
@@ -19,13 +23,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
-
-
-
+
-
-
+
+
Badges
Documentation and examples for badges, our small count and labeling component.
@@ -33,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
Example
Badges scale to match the size of the immediate parent element by using relative font sizing and em units.
-
+
Example heading New
Example heading New
@@ -42,39 +44,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
Example heading New
Example heading New
-
+
-
+
<h1>Example heading <span class="badge badge-secondary">New</span></h1>
<h2>Example heading <span class="badge badge-secondary">New</span></h2>
<h3>Example heading <span class="badge badge-secondary">New</span></h3>
<h4>Example heading <span class="badge badge-secondary">New</span></h4>
<h5>Example heading <span class="badge badge-secondary">New</span></h5>
<h6>Example heading <span class="badge badge-secondary">New</span></h6>
-
+
-
+
Badges can be used as part of links or buttons to provide a counter.
-
+
Notifications 4
-
+
<button type="button" class="button">
Notifications <span class="badge badge-primary">4</span>
</button>
-
-
+
+
Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
-
+
Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.
-
+
Remember to use aria-label attribute for accessibility in Dolibarr. Don't forget to use aria-hidden on icons included in badges
@@ -84,26 +86,26 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
unread messages
-
+
-
-
+
+
<button type="button" class="btn btn-primary">
Profile <span class="badge badge-light" aria-label="9 unread messages" >9</span>
<span class="sr-only">unread messages</span>
</button>
-
-
+
+
-
+
Contextual variations
-
+
Add any of the below mentioned modifier classes to change the appearance of a badge.
-
+
-
+
Primary
Secondary
Success
@@ -113,10 +115,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
Light
Dark
-
+
-
+
<span class="badge badge-primary">Primary</span>
<span class="badge badge-secondary">Secondary</span>
<span class="badge badge-success">Success</span>
@@ -125,22 +127,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
<span class="badge badge-info">Info</span>
<span class="badge badge-light">Light</span>
<span class="badge badge-dark">Dark</span>
-
+
-
+
Conveying meaning to assistive technologies
-
+
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
+
+
Default status
-
+
Add any of the below mentioned modifier classes to change the appearance of a badge to be linked to a default status.
-
+
status-
@@ -152,14 +154,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
<span class="badge badge-status" >status</span>
-
-
+
+
Pill badges
-
+
Use the .badge-pill modifier class to make badges more rounded (with a larger border-radius and additional horizontal padding).
-
+
-
+
Primary
Secondary
Success
@@ -168,16 +170,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
Info
Light
Dark
-
+
status
-
+
-
+
-
+
<span class="badge badge-pill badge-primary">Primary</span>
<span class="badge badge-pill badge-secondary">Secondary</span>
<span class="badge badge-pill badge-success">Success</span>
@@ -190,15 +192,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
<span class="badge badge-pill badge-status" >status</span>
-
-
-
+
+
+
Dot badges
-
+
.dot-pill modifier class to make badges circle.
-
+
-
+
@@ -207,16 +209,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
-
+
-
+
-
+
-
+
<span class="badge badge-dot badge-primary"></span>
<span class="badge badge-dot badge-secondary"></span>
<span class="badge badge-dot badge-success"></span>
@@ -229,23 +231,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
<span class="badge badge-dot badge-status" ></span>
-
-
-
+
+
+
Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
-
+
Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.
-
+
Remember to use aria-label attribute for accessibility in Dolibarr. Don't forget to use aria-hidden on icons included in badges
-
-
-
+
+
+
Links
-
+
Using the contextual .badge-* classes on an <a> element quickly provide actionable badges with hover and focus states.
-
+
-
+
<a href="#" class="badge badge-primary">Primary</a>
<a href="#" class="badge badge-secondary">Secondary</a>
@@ -280,12 +282,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
with html ', 'primary') ?>
with html ', 'danger', 'pill') ?>
with html ', 'warning', 'dot') ?>
-
+
<?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'danger', 'pill') ?>
<?php print dolGetBadge('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'warning', 'dot') ?>
-
+
Use status helper function
Using the dolGetStatus function provide in core/lib/functions.lib.php. This function is recommended for code uniformisation and easy maintain
with html ', 'status4', 6) ?>
global->MAIN_STATUS_USES_CSS = $saveGlobalConf; ?>
-
-
+
+
<?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4') ?>
<?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',1) ?>
@@ -323,8 +325,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
<?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',6) ?>
-
+
-
+
\ No newline at end of file
diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php
index 95265831670..879f37ed5dc 100644
--- a/htdocs/public/test/test_arrays.php
+++ b/htdocs/public/test/test_arrays.php
@@ -1,6 +1,17 @@
This page is a sample of page using tables. It is designed to make test with
+
+
-
Example 0a : Table with div+div+div containg a select that should be overflowed and truncated => Use this to align text or form
@@ -124,7 +135,6 @@ This page is a sample of page using tables. It is designed to make test with
-
@@ -153,6 +163,7 @@ $(document).ready(function() {
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$productspecimen = new Product($db);
$productspecimen->initAsSpecimen();
+$object = $productspecimen;
$sortfield = 'aaa';
$sortorder = 'ASC';
@@ -176,31 +187,30 @@ $nav .= ' trans('This is a select list for a filter A').': ';
+$moreforfilter .= $langs->trans('This is a select list for a filter A (no combo forced)').': ';
$cate_arbo = array('field1'=>'value1a into the select list A', 'field2'=>'value2a');
-$moreforfilter .= $form->selectarray('search_aaa', $cate_arbo, '', 1); // List without js combo
+$moreforfilter .= $form->selectarray('search_aaa', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 0); // List with no js combo
$moreforfilter .= '';
$moreforfilter .= '';
-$moreforfilter .= $langs->trans('This is a select list for a filter B').': ';
+$moreforfilter .= $langs->trans('This is a select list for a filter B (auto combo)').': ';
$cate_arbo = array('field1'=>'value1b into the select list B', 'field2'=>'value2b');
-$moreforfilter .= $form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
+$moreforfilter .= $form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', -1); // List with js combo auto
$moreforfilter .= '
';
$moreforfilter .= '';
-$moreforfilter .= $langs->trans('This is a select list for a filter C').': ';
+$moreforfilter .= $langs->trans('This is a select list for a filter C (combo forced)').': ';
$cate_arbo = array('field1'=>'value1c into the select list C', 'field2'=>'value2c');
-$moreforfilter .= $form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
+$moreforfilter .= $form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 1); // List with js combo forced
$moreforfilter .= '
';
$moreforfilter .= '';
-$moreforfilter .= $langs->trans('This is a select list for a filter D').': ';
+$moreforfilter .= $langs->trans('This is a select list for a filter D (combo forced)').': ';
$cate_arbo = array('field1'=>'value1d into the select list D', 'field2'=>'value2d');
-$moreforfilter .= $form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
+$moreforfilter .= $form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 1); // List with js combo forced
$moreforfilter .= '
';
if (!empty($moreforfilter))
@@ -219,14 +229,14 @@ if (!empty($moreforfilter))
trans('title1'), 0, $_SERVER["PHP_SELF"], 'aaa', '', '', 'align="left"', $sortfield, $sortorder); ?>
-trans('title2'), 0, $_SERVER["PHP_SELF"], 'bbb', '', '', 'align="right"', $sortfield, $sortorder); ?>
-trans('title3'), 0, $_SERVER["PHP_SELF"], 'ccc', '', '', 'align="center"', $sortfield, $sortorder); ?>
+trans('title2'), 0, $_SERVER["PHP_SELF"], 'bbb', '', '', 'align="center"', $sortfield, $sortorder); ?>
+trans('title3'), 0, $_SERVER["PHP_SELF"], 'ccc', '', '', 'align="right"', $sortfield, $sortorder); ?>
-getNomUrl(1); ?> b1 c1
-a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 b2 c2
-a3 b3 c3
+getNomUrl(1); ?> b1 c1
+a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 b2 c2
+a3 b3 c3
@@ -237,8 +247,6 @@ if (!empty($moreforfilter))
@@ -304,13 +311,13 @@ $(document).ready(function(){
diff --git a/htdocs/public/test/test_csrf.php b/htdocs/public/test/test_csrf.php
index 8c242cade64..1c23dc7070a 100644
--- a/htdocs/public/test/test_csrf.php
+++ b/htdocs/public/test/test_csrf.php
@@ -3,14 +3,16 @@
?>
-This is a form to test a CSRF.
+This is a form to test if a CSRF exists into a Dolibarr page.
-Open this form into a Virtual server A.
-Change url to send request to into file to send request to virtual server B.
+- Change url to send request to into this file (server B, hard coded page)
+- Open this form into a virtual server A.
+- Send the request to the virtual server B by clicking submit.
+- Check that Anticsrf protection is triggered.
';
?>
diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php
index bd74ecb0f13..646eeb2abc1 100644
--- a/htdocs/public/test/test_forms.php
+++ b/htdocs/public/test/test_forms.php
@@ -1,7 +1,7 @@
\n";
+print 'PHP_SESSION_DISABLED='.PHP_SESSION_DISABLED."
\n";
+print 'PHP_SESSION_NONE='.PHP_SESSION_NONE."
\n";
+print 'PHP_SESSION_ACTIVE='.PHP_SESSION_ACTIVE."
\n";
+print '
';
+
+print 'session_status='.session_status().' (before main.inc.php)';
print '
';
-print session_status();
require '../../main.inc.php';
-print session_status();
+
+/* No need for this.
+if ($dolibarr_main_prod) {
+ accessforbidden();
+}
+*/
+
+print 'session_status='.session_status().' (after main.inc.php)';
print '
';
//print 'a'.$_SESSION['disablemodules'].'b';
-print 'This page is visible. It means you are not locked.';
+print "\n
This page is visible. It means you are not locked by another page called in same session.";
//session_write_close();
diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php
index 1c81faca1ad..6b035a46643 100644
--- a/htdocs/public/ticket/create_ticket.php
+++ b/htdocs/public/ticket/create_ticket.php
@@ -143,6 +143,17 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('add', 'alpha')) {
$action = '';
}
+ // Check Captcha code if is enabled
+ if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
+ $sessionkey = 'dol_antispam_value';
+ $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'none'))));
+ if (!$ok) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorBadValueForCode"));
+ $action = '';
+ }
+ }
+
if (!$error) {
$object->db->begin();
diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php
index 1c801f27fd4..8c29ef9e46c 100644
--- a/htdocs/recruitment/recruitmentcandidature_document.php
+++ b/htdocs/recruitment/recruitmentcandidature_document.php
@@ -92,7 +92,7 @@ $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; //
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php
index 3005b4cc1be..d05e9945eb5 100644
--- a/htdocs/recruitment/recruitmentjobposition_document.php
+++ b/htdocs/recruitment/recruitmentjobposition_document.php
@@ -92,7 +92,7 @@ $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; //
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php
index 0019d6b99ed..00dc42741e1 100644
--- a/htdocs/resource/document.php
+++ b/htdocs/resource/document.php
@@ -72,7 +72,7 @@ $modulepart = 'resource';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php
index dc86a274837..777686c96db 100644
--- a/htdocs/salaries/document.php
+++ b/htdocs/salaries/document.php
@@ -73,7 +73,7 @@ $modulepart = 'salaries';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php
index daaf9fbd623..3b9c1a9daa4 100644
--- a/htdocs/societe/admin/societe.php
+++ b/htdocs/societe/admin/societe.php
@@ -726,6 +726,7 @@ $form = new Form($db);
print '
';
print ' ';
+print ' ';
print ' ';
print '';
@@ -753,7 +754,7 @@ if (!$conf->use_javascript_ajax)
);
print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
print '
';
- print ' ';
+ print ' ';
print " ";
}
print ' ';
@@ -775,7 +776,7 @@ if (!$conf->use_javascript_ajax)
);
print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
print '
';
- print ' ';
+ print ' ';
print " ";
}
print '';
@@ -861,16 +862,18 @@ if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS))
print '';
print '';
-// Default Prospect/Customer thirdparty type on customer création
-print '
';
-print ''.$langs->trans("DefaultCustomerType").' ';
-print '';
-print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT, 'defaultcustomertype', 'defaultcustomertype', 'admin');
-print ' ';
-print '';
-print ' ';
-print ' ';
-print ' ';
+if (empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+ // Default Prospect/Customer thirdparty type on customer création
+ print '
';
+ print ''.$langs->trans("DefaultCustomerType").' ';
+ print '';
+ print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT, 'defaultcustomertype', 'defaultcustomertype', 'admin');
+ print ' ';
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+}
print '
';
print '';
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index b471ca23ead..5a7de9d9450 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -1121,14 +1121,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$("#radiocompany").click(function() {
$(".individualline").hide();
$("#typent_id").val(0);
+ $("#typent_id").change();
$("#effectif_id").val(0);
+ $("#effectif_id").change();
$("#TypeName").html(document.formsoc.ThirdPartyName.value);
document.formsoc.private.value=0;
});
$("#radioprivate").click(function() {
$(".individualline").show();
$("#typent_id").val(id_te_private);
+ $("#typent_id").change();
$("#effectif_id").val(id_ef15);
+ $("#effectif_id").change();
$("#TypeName").html(document.formsoc.LastName.value);
document.formsoc.private.value=1;
});
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index c4d355ab62c..f855a80ef7f 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -984,6 +984,7 @@ class Societe extends CommonObject
$contact->email = $this->email;
$contact->zip = $this->zip;
$contact->town = $this->town;
+ $this->setUpperOrLowerCase();
$contact->phone_pro = $this->phone;
$contactId = $contact->create($user);
diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php
index 1d7ba3d2925..034522a3652 100644
--- a/htdocs/societe/document.php
+++ b/htdocs/societe/document.php
@@ -81,7 +81,7 @@ $hookmanager->initHooks(array('thirdpartydocument', 'globalcard'));
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 92d38c519de..9b69d12776a 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -720,7 +720,9 @@ if (empty($reshook))
$fk_unit = GETPOST('units', 'alpha');
- $tva_tx = price2num($tva_tx); // When vat is text input field
+ if (!preg_match('/\((.*)\)/', $tva_tx)) {
+ $tva_tx = price2num($tva_tx); // When vat is text input field
+ }
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index 405c34734f3..c56fac31a3f 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -906,8 +906,8 @@ class SupplierProposal extends CommonObject
$sql .= ", remise";
$sql .= ", remise_percent";
$sql .= ", remise_absolue";
- $sql .= ", tva";
- $sql .= ", total";
+ $sql .= ", total_tva";
+ $sql .= ", total_ttc";
$sql .= ", datec";
$sql .= ", ref";
$sql .= ", fk_user_author";
@@ -1200,7 +1200,7 @@ class SupplierProposal extends CommonObject
global $conf;
$sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc";
- $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht";
+ $sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht";
$sql .= ", p.datec";
$sql .= ", p.date_valid as datev";
$sql .= ", p.date_livraison as delivery_date";
@@ -1239,12 +1239,11 @@ class SupplierProposal extends CommonObject
$this->remise = $obj->remise;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
- $this->total = $obj->total; // TODO deprecated
$this->total_ht = $obj->total_ht;
- $this->total_tva = $obj->tva;
+ $this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
- $this->total_ttc = $obj->total;
+ $this->total_ttc = $obj->total_ttc;
$this->socid = $obj->fk_soc;
$this->fk_project = $obj->fk_project;
$this->model_pdf = $obj->model_pdf;
@@ -2784,7 +2783,7 @@ class SupplierProposalLine extends CommonObjectLine
// Bit 0: 0 si TVA normal - 1 si TVA NPR
// Bit 1: 0 ligne normale - 1 si ligne de remise fixe
- public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne
+ public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne
public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne
public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne
diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php
index 127b45466e8..09fb48ab1fb 100644
--- a/htdocs/supplier_proposal/document.php
+++ b/htdocs/supplier_proposal/document.php
@@ -69,7 +69,7 @@ if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref);
- include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
}
diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php
index 476c2a14db2..fd3dccce0bb 100644
--- a/htdocs/supplier_proposal/index.php
+++ b/htdocs/supplier_proposal/index.php
@@ -304,7 +304,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$now = dol_now();
- $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datec as dp";
+ $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total_ttc, p.total_tva, p.total_ht, p.ref, p.fk_statut, p.datec as dp";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php
index 9826c2a409d..04bafe19297 100644
--- a/htdocs/supplier_proposal/list.php
+++ b/htdocs/supplier_proposal/list.php
@@ -152,7 +152,7 @@ $arrayfields = array(
'sp.date_valid'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
- 'sp.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
+ 'sp.total_tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
'sp.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'sp.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
@@ -253,7 +253,7 @@ 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,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
-$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,';
+$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.total_tva, sp.total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,';
$sql .= ' sp.fk_multicurrency, sp.multicurrency_code, sp.multicurrency_tx, sp.multicurrency_total_ht, sp.multicurrency_total_tva as multicurrency_total_vat, sp.multicurrency_total_ttc,';
$sql .= ' sp.datec as date_creation, sp.tms as date_update,';
$sql .= " p.rowid as project_id, p.ref as project_ref,";
@@ -299,8 +299,8 @@ if ($search_ref) $sql .= natural_search('sp.ref', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_login) $sql .= natural_search('u.login', $search_login);
if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1);
-if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1);
-if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1);
+if ($search_montant_vat != '') $sql .= natural_search("sp.total_tva", $search_montant_vat, 1);
+if ($search_montant_ttc != '') $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1);
if ($search_multicurrency_code != '') $sql .= ' AND sp.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
if ($search_multicurrency_tx != '') $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
@@ -552,7 +552,7 @@ if ($resql)
print ' ';
print ' ';
}
- if (!empty($arrayfields['sp.total_vat']['checked']))
+ if (!empty($arrayfields['sp.total_tva']['checked']))
{
// Amount
print '';
@@ -653,7 +653,7 @@ if ($resql)
if (!empty($arrayfields['sp.date_valid']['checked'])) print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['sp.date_livraison']['checked'])) print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['sp.total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($arrayfields['sp.total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.total_vat']['label'], $_SERVER["PHP_SELF"], 'sp.total_vat', '', $param, '', $sortfield, $sortorder, 'right ');
+ if (!empty($arrayfields['sp.total_tva']['checked'])) print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['sp.total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['sp.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
@@ -803,12 +803,12 @@ if ($resql)
$totalarray['val']['sp.total_ht'] += $obj->total_ht;
}
// Amount VAT
- if (!empty($arrayfields['sp.total_vat']['checked']))
+ if (!empty($arrayfields['sp.total_tva']['checked']))
{
- print ' '.price($obj->total_vat)." \n";
+ print ''.price($obj->total_tva)." \n";
if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_vat';
- $totalarray['val']['sp.total_vat'] += $obj->total_vat;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva';
+ $totalarray['val']['sp.total_tva'] += $obj->total_tva;
}
// Amount TTC
if (!empty($arrayfields['sp.total_ttc']['checked']))
diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php
index 43077495238..f50d0099263 100644
--- a/htdocs/support/inc.php
+++ b/htdocs/support/inc.php
@@ -133,9 +133,9 @@ define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
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 == 'mysql' ? 'latin1' : ''); // Old installation
+if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); // Old installation
$conf->db->character_set = $dolibarr_main_db_character_set;
-if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysql' ? 'latin1_swedish_ci' : ''); // Old installation
+if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index a08df6d2b43..6e6bdfa1957 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -140,6 +140,7 @@ if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
}
}
}
+
$levelofmaincategories = $levelofrootcategory + 1;
$maincategories = array();
@@ -961,7 +962,13 @@ if (empty($paiementsModes)) {
setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
}
if (count($maincategories) == 0) {
- setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
+ if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
+ $tmpcategory = new Categorie($db);
+ $tmpcategory->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
+ setEventMessages($langs->trans("TakeposNeedsAtLeastOnSubCategoryIntoParentCategory", $tmpcategory->label), null, 'errors');
+ } else {
+ setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors');
+ }
}
// User menu and external TakePOS modules
$menus = array();
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 8ca516288c1..243b6b5bc49 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -530,7 +530,9 @@ if ($action == "freezone") {
$tva_tx = GETPOST('tva_tx', 'alpha');
if ($tva_tx != '') {
- $tva_tx = price2num($tva_tx);
+ if (!preg_match('/\((.*)\)/', $tva_tx)) {
+ $tva_tx = price2num($tva_tx);
+ }
} else {
$tva_tx = get_default_tva($mysoc, $customer);
}
diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js
index 50bf77c00ff..e041516a292 100644
--- a/htdocs/theme/eldy/ckeditor/config.js
+++ b/htdocs/theme/eldy/ckeditor/config.js
@@ -11,6 +11,7 @@ CKEDITOR.editorConfig = function( config )
config.enterMode = CKEDITOR.ENTER_BR;
//config.forceSimpleAmpersand = true; // When you put a into the textarea, and go into "source", then ckeditor change the & into &. We don't want this. But this option does not fix this.
//config.entities = false; // When you put a into the textarea, and go into "source", then ckeditor change the & into &. We don't want this. But this option does not fix this.
+ //config.entities_greek = false;
config.resize_enabled = false;
//config.resize_maxHeight = 3000;
//config.resize_maxWidth = 3000;
diff --git a/htdocs/theme/eldy/doc/doc.css b/htdocs/theme/eldy/doc/doc.css
deleted file mode 100644
index a8908185d17..00000000000
--- a/htdocs/theme/eldy/doc/doc.css
+++ /dev/null
@@ -1,5 +0,0 @@
-/* Simple css for Doc page */
-body.docpage{
- background: #fff;
- padding:20px;
-}
\ No newline at end of file
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index d39e7a3e1b5..326aac90390 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -621,7 +621,7 @@ textarea.centpercent {
}
.flip {
- transform: scaleX(-1);
+ transform: scaleX(-1) translate(2px, 0);
}
.center {
text-align: center;
@@ -3503,6 +3503,7 @@ table.hidepaginationnext .paginationnext {
}
+
/* Set the color for hover lines */
.oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover
{
@@ -4531,7 +4532,7 @@ div.visible {
display: block;
}
-div.hidden, td.hidden, img.hidden, span.hidden {
+div.hidden, td.hidden, img.hidden, span.hidden, div.showifmore {
display: none;
}
@@ -4632,6 +4633,10 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im
line-height: 1em;
}
+#divbodywebsite section p {
+ margin: unset;
+}
+
/* ============================================================================== */
diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php
index fbccc810fe7..156da9be652 100644
--- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php
+++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php
@@ -103,7 +103,7 @@ div.mainmenu.hrm::before {
}
div.mainmenu.members::before {
- content: "\f0c0";
+ content: "\f007";
}
div.mainmenu.products::before {
@@ -199,3 +199,14 @@ div.mainmenu.generic4::before {
margin-left: 30px;
}
+.menu_titre .em092 {
+ font-size: 0.92em;
+}
+
+.menu_titre .em088 {
+ font-size: 0.88em;
+}
+
+.menu_titre .em080 {
+ font-size: 0.80em;
+}
diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php
index 8af5af5a756..098ceb4aaae 100644
--- a/htdocs/theme/eldy/manifest.json.php
+++ b/htdocs/theme/eldy/manifest.json.php
@@ -34,11 +34,21 @@ if (!defined('NOLOGIN')) define('NOLOGIN', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
+if (!defined('NOSESSION')) define('NOSESSION', '1');
require_once __DIR__.'/../../main.inc.php';
top_httphead('text/json');
+// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
+if (empty($dolibarr_nocache)) {
+ header('Cache-Control: max-age=10800, public, must-revalidate');
+ // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server
+ header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT');
+}
+else {
+ header('Cache-Control: no-cache');
+}
$manifest = new stdClass();
diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js
index 50ff0cc6eed..acd38268f8f 100644
--- a/htdocs/theme/md/ckeditor/config.js
+++ b/htdocs/theme/md/ckeditor/config.js
@@ -9,6 +9,9 @@ CKEDITOR.editorConfig = function( config )
// http://docs.cksource.com/CKEditor_3.x/Developers_Guide
// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
config.enterMode = CKEDITOR.ENTER_BR;
+ //config.forceSimpleAmpersand = true; // When you put a into the textarea, and go into "source", then ckeditor change the & into &. We don't want this. But this option does not fix this.
+ //config.entities = false; // When you put a into the textarea, and go into "source", then ckeditor change the & into &. We don't want this. But this option does not fix this.
+ //config.entities_greek = false;
config.resize_enabled = false;
//config.resize_maxHeight = 3000;
//config.resize_maxWidth = 3000;
diff --git a/htdocs/theme/md/main_menu_fa_icons.inc.php b/htdocs/theme/md/main_menu_fa_icons.inc.php
index 3aa45726975..9326cf40ffe 100644
--- a/htdocs/theme/md/main_menu_fa_icons.inc.php
+++ b/htdocs/theme/md/main_menu_fa_icons.inc.php
@@ -97,3 +97,12 @@ div.mainmenu.generic4::before {
border-bottom: solid 60px currentColor;
margin-left: 30px;
}
+
+
+.menu_titre .em092 {
+ font-size: 0.92em;
+}
+
+.menu_titre .em080 {
+ font-size: 0.80em;
+}
diff --git a/htdocs/theme/md/manifest.json.php b/htdocs/theme/md/manifest.json.php
index 03c5894fdde..6051ff260ef 100644
--- a/htdocs/theme/md/manifest.json.php
+++ b/htdocs/theme/md/manifest.json.php
@@ -35,6 +35,7 @@ if (!defined('NOLOGIN')) define('NOLOGIN', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
+if (!defined('NOSESSION')) define('NOSESSION', '1');
require_once __DIR__.'/../../main.inc.php';
@@ -42,6 +43,15 @@ $appli = constant('DOL_APPLICATION_TITLE');
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE;
top_httphead('text/json');
+// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
+if (empty($dolibarr_nocache)) {
+ header('Cache-Control: max-age=10800, public, must-revalidate');
+ // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server
+ header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT');
+}
+else {
+ header('Cache-Control: no-cache');
+}
?>
{
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 623ecb2a779..81407987c35 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -4402,7 +4402,7 @@ div.visible {
display: block;
}
-div.hidden, td.hidden, img.hidden, span.hidden {
+div.hidden, td.hidden, img.hidden, span.hidden, div.showifmore {
display: none;
}
@@ -4509,6 +4509,10 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im
line-height: 1em;
}
+#divbodywebsite section p {
+ margin: unset;
+}
+
/* ============================================================================== */
/* Module agenda */
diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php
index 45ee7aba268..c876e9d33d8 100644
--- a/htdocs/ticket/document.php
+++ b/htdocs/ticket/document.php
@@ -73,7 +73,7 @@ if ($result < 0) {
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 8f8f8c67ca8..8712bcc4615 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1402,6 +1402,7 @@ class User extends CommonObject
$this->address = $contact->address;
$this->zip = $contact->zip;
$this->town = $contact->town;
+ $this->setUpperOrLowerCase();
$this->state_id = $contact->state_id;
$this->country_id = $contact->country_id;
$this->employee = 0;
@@ -1474,12 +1475,13 @@ class User extends CommonObject
$this->civility_code = $member->civility_id;
$this->lastname = $member->lastname;
$this->firstname = $member->firstname;
- $this->gender = $member->gender;
+ $this->gender = $member->gender;
$this->email = $member->email;
$this->fk_member = $member->id;
$this->address = $member->address;
$this->zip = $member->zip;
$this->town = $member->town;
+ $this->setUpperOrLowerCase();
$this->state_id = $member->state_id;
$this->country_id = $member->country_id;
$this->socialnetworks = $member->socialnetworks;
@@ -1637,6 +1639,7 @@ class User extends CommonObject
$this->address = empty($this->address) ? '' : $this->address;
$this->zip = empty($this->zip) ? '' : $this->zip;
$this->town = empty($this->town) ? '' : $this->town;
+ $this->setUpperOrLowerCase();
$this->accountancy_code = trim($this->accountancy_code);
$this->color = empty($this->color) ? '' : $this->color;
$this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment;
diff --git a/htdocs/user/document.php b/htdocs/user/document.php
index 5440ceeb725..b9f282f17ed 100644
--- a/htdocs/user/document.php
+++ b/htdocs/user/document.php
@@ -106,7 +106,7 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
- include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
}
diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php
index 34cc78e9a05..d0ffc3ccc03 100644
--- a/htdocs/website/class/website.class.php
+++ b/htdocs/website/class/website.class.php
@@ -1396,7 +1396,7 @@ class Website extends CommonObject
'bn'=>'bn_DB',
'bs'=>'bs_BA',
'ca'=>'ca_ES',
- 'zh'=>'zh_TW',
+ 'zh'=>'zh_CN',
'cs'=>'cs_CZ',
'da'=>'da_DK',
'et'=>'et_EE',
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index ebcf31ad2c5..46dfd49ed0a 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -358,7 +358,7 @@ if ($action == 'seteditinline')
{
dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1);
setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings');
- dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content'
+ //dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content'
header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int'));
exit;
}
@@ -371,7 +371,7 @@ if ($action == 'unseteditinline')
if ($action == 'setshowsubcontainers')
{
dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1);
- dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline
+ //dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline
header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int'));
exit;
}
@@ -2743,7 +2743,19 @@ if (!GETPOST('hide_websitemenu'))
print ''."\n";
print '';
- print '
';
+
+ print '
'; // Button include dynamic contant
+ print $langs->trans("ShowSubcontainers");
+ if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
+ {
+ print '
ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
+ }
+ else {
+ print '
ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').' ';
+ }
+ print '
';
+
+ print '
'; // Button edit inline
print ''."\n";
print ''."\n";
@@ -2812,17 +2824,7 @@ if (!GETPOST('hide_websitemenu'))
}
print '
';
- print '
';
- print $langs->trans("ShowSubcontainers");
- if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
- {
- print '
ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').' ';
- }
- else {
- print '
ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').' ';
- }
- /*}*/
- print '
';
+
print '
';
// Set page as homepage
@@ -2853,9 +2855,10 @@ if (!GETPOST('hide_websitemenu'))
$pagealias = $websitepage->pageurl;
$htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot);
- $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT);
- $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}');
- $htmltext = str_replace('{s1}', DOL_DATA_ROOT.'/website
'.DOL_DATA_ROOT.'/medias', $htmltext);
+ $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), '{s1}');
+ $htmltext = str_replace('{s1}', $dataroot.'
'.DOL_DATA_ROOT.'/medias
'.DOL_DOCUMENT_ROOT, $htmltext);
+ //$htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}');
+ //$htmltext = str_replace('{s1}', DOL_DATA_ROOT.'/medias', $htmltext);
print '