Merge branch 'develop' into dev_EventOrganisation_draft

This commit is contained in:
Florian HENRY 2021-02-22 21:02:22 +01:00
commit fa65956801
63 changed files with 2308 additions and 2234 deletions

View File

@ -19,8 +19,8 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup.
* API /setup/shipment_methods has been replaced with API /setup/shipping_methods
* Field tva move to total_tva in llx_propal
* Field "tva" renamed into "total_tva" in llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency
* Field "total" renamed into "total_ttc" in llx_propal, llx_supplier_proposal for better field name consistency
***** ChangeLog for 13.0.1 compared to 13.0.0 *****
@ -30,13 +30,13 @@ FIX: 11.0 when a mandatory extrafield of type sellist contains '0' it should be
FIX: 11.0 when a new intervention is created from an object, a new $extrafields object is instantiated but not initialized
FIX: create MO, Column 'tms' cannot be null
FIX: #14290 #15900
FIX: #16076
FIX: #16077
FIX: #16079
FIX: #16080
FIX: 16084
FIX: #16076 patch user/list.php for extrafields
FIX: #16077 patch wrong timezone
FIX: #16079 error of service date at duplicated invoice
FIX: #16080 mailing list title
FIX: #16084 DB error at projects
FIX: #16107
FIX: #16118 Timezone problem on some fields
FIX: #16118 Timezone problem on some fields
FIX: #16131
FIX: #16135
FIX: #16143
@ -67,7 +67,7 @@ FIX: select default mail template
FIX: Select transport mode function when creating a supplier invoice and add unique key to the table llx_c_transport_mode in migrate sql
FIX: Merge of thirdparties : "unknow column fk_soc" + "Delivery" label
FIX: SQL Error in group by with postgres or mysql strict mode
FIX: takepos : load date function
FIX: TakePOS : load date function
FIX: Timeout during import
FIX: Trigger on expense report was not fired
FIX: User creation of expense report not visible

View File

@ -153,6 +153,7 @@ $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom
$regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
$dir='';
$needtoclose=0;
foreach ($files as $filetmp) {
@ -160,9 +161,10 @@ foreach ($files as $filetmp) {
//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
if ($newdir!=$dir) {
if ($needtoclose)
if ($needtoclose) {
fputs($fp, ' </dir>'."\n");
fputs($fp, ' <dir name="'.$newdir.'" >'."\n");
}
fputs($fp, ' <dir name="'.$newdir.'">'."\n");
$dir = $newdir;
$needtoclose=1;
}

View File

@ -579,7 +579,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/webmail*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/workstation*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`;
@ -624,7 +623,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;

View File

@ -212,6 +212,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/product
%_datadir/dolibarr/htdocs/projet
%_datadir/dolibarr/htdocs/public
%_datadir/dolibarr/htdocs/recruitment
%_datadir/dolibarr/htdocs/reception
%_datadir/dolibarr/htdocs/resource
%_datadir/dolibarr/htdocs/salaries

View File

@ -110,7 +110,7 @@ $form = new Form($db);
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
{
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start'))
{
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
*
* This program is free software; you can redistribute it and/or modify
@ -106,13 +106,22 @@ $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') :
$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));
$datefrom = 0;
$dateto = 0;
$paymentdate = -1;
/*
* Actions
*/
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
// Create third party from a member
if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) {
if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) {
if ($result > 0) {
// Creation of thirdparty
$company = new Societe($db);
@ -129,7 +138,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
}
}
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
$error = 0;
if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only
if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) {
@ -148,7 +157,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
}
}
if ($action == 'setsocid') {
if (empty($reshook) && $action == 'setsocid') {
$error = 0;
if (!$error) {
if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database
@ -208,7 +217,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$emetteur_nom = $_POST["chqemetteur"];
$emetteur_banque = $_POST["chqbank"];
$option = $_POST["paymentsave"];
if (empty($option)) $option = 'none';
if (empty($option)) {
$option = 'none';
}
$sendalsoemail = GETPOST("sendmail", 'alpha');
// Check parameters
@ -247,11 +258,19 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
} else {
if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') {
if ($_POST["subscription"]) {
if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
if (!$_POST["label"]) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
}
if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
}
if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
}
} else {
if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
if ($_POST["accountid"]) {
$errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
}
}
if ($errmsg) {
$error++;
@ -333,7 +352,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
@ -579,8 +600,8 @@ if ($rowid > 0) {
/*
* Action buttons
*/
* Action buttons
*/
// Button to create a new subscription if member no draft neither resiliated
if ($user->rights->adherent->cotisation->creer) {
@ -595,8 +616,8 @@ if ($rowid > 0) {
}
/*
* List of subscriptions
*/
* List of subscriptions
*/
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
$sql .= " c.rowid as crowid, c.subscription,";
@ -716,8 +737,8 @@ if ($rowid > 0) {
}
/*
* Add new subscription form
*/
* Add new subscription form
*/
if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
print '<br>';
@ -743,31 +764,31 @@ if ($rowid > 0) {
//var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE));
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').';
$("#none, #invoiceonly").click(function() {
$(".bankswitchclass").hide();
$(".bankswitchclass2").hide();
});
$("#bankdirect, #bankviainvoice").click(function() {
$(".bankswitchclass").show();
$(".bankswitchclass2").show();
});
$("#selectoperation").change(function() {
var code = $(this).val();
if (code == "CHQ")
{
$(".fieldrequireddyn").addClass("fieldrequired");
if ($("#fieldchqemetteur").val() == "")
{
$("#fieldchqemetteur").val($("#memberlabel").val());
}
}
else
{
$(".fieldrequireddyn").removeClass("fieldrequired");
}
});
';
$(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').';
$("#none, #invoiceonly").click(function() {
$(".bankswitchclass").hide();
$(".bankswitchclass2").hide();
});
$("#bankdirect, #bankviainvoice").click(function() {
$(".bankswitchclass").show();
$(".bankswitchclass2").show();
});
$("#selectoperation").change(function() {
var code = $(this).val();
if (code == "CHQ")
{
$(".fieldrequireddyn").addClass("fieldrequired");
if ($("#fieldchqemetteur").val() == "")
{
$("#fieldchqemetteur").val($("#memberlabel").val());
}
}
else
{
$(".fieldrequireddyn").removeClass("fieldrequired");
}
});
';
if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);';
print '});';
print '</script>'."\n";
@ -826,9 +847,6 @@ if ($rowid > 0) {
print '<tbody>';
$today = dol_now();
$datefrom = 0;
$dateto = 0;
$paymentdate = -1;
// Date payment
if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) {
@ -921,8 +939,9 @@ if ($rowid > 0) {
print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : '');
//if (empty($object->fk_soc)) print ' disabled';
print '> '.$langs->trans("MoreActionBankViaInvoice");
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
else {
if ($object->fk_soc) {
print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
} else {
print ' (';
if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
print $langs->trans("NoThirdPartyAssociatedToMember");
@ -1001,7 +1020,9 @@ if ($rowid > 0) {
$arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;

View File

@ -120,7 +120,7 @@ if (function_exists('curl_init'))
print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("UpdateServerOffline").'</b>';
}
} else {
print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="butAction">'.$langs->trans("Check").'</a>';
print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="butAction smallpaddingimp">'.$langs->trans("Check").'</a>';
}
}

View File

@ -374,14 +374,6 @@ if (!$error && $xml)
}
$out .= '</table>';
$out .= '</div>';
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
{
setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
} else {
setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
}
} else {
print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile;
$error++;
@ -407,6 +399,8 @@ if (!$error && $xml)
var_dump($checksumtoget);
var_dump($checksumget == $checksumtoget);*/
$resultcomment = '';
$outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown"));
if ($checksumget == $checksumtoget)
{
@ -414,7 +408,7 @@ if (!$error && $xml)
{
$resultcode = 'warning';
$resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans($resultcomment).'</span>';
} else {
$resultcode = 'ok';
$resultcomment = 'Success';
@ -426,7 +420,18 @@ if (!$error && $xml)
$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
}
print load_fiche_titre($langs->trans("GlobalChecksum")).'<br>';
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3) && $resultcode == 'ok') {
setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
} else {
if ($resultcode == 'warning') {
setEventMessages($langs->trans($resultcomment), null, 'warnings');
} else {
setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'errors');
}
}
print load_fiche_titre($langs->trans("GlobalChecksum"));
print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'<br>';
print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum;

File diff suppressed because it is too large Load Diff

View File

@ -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 '<table class="noborder nohover centpercent">';
$i = 0;
foreach ($listofsearchfields as $key => $value) {
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
if ($i == 0) {
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
}
print '<tr '.$bc[false].'>';
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
if ($i == 0) print '<td class="noborderbottom" rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button "></td>';
if ($i == 0) {
print '<td class="noborderbottom" rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button "></td>';
}
print '</tr>';
$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 .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
}
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 .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
}
/*
@ -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 .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
}*/
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 .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
}
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);

View File

@ -288,7 +288,7 @@ class Propal extends CommonObject
'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),
@ -1039,7 +1039,7 @@ class Propal extends CommonObject
$sql .= ", remise_percent";
$sql .= ", remise_absolue";
$sql .= ", total_tva";
$sql .= ", total";
$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.total_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";
@ -1622,7 +1622,7 @@ class Propal extends CommonObject
$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").",";

View File

@ -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 '<div class="fichecenter">';
print '<div class="fichethirdleft">';
// 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 '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
print '<div class="div-table-responsive-no-min">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -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 '<tr class="oddeven">';
@ -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.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);

View File

@ -391,7 +391,7 @@ $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.total_tva, 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.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,';
@ -450,7 +450,7 @@ if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_soci
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.total_tva", $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 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);

View File

@ -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 '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->propal->enabled))
{
if (!empty($conf->propal->enabled)) {
$var = false;
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/card.php">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -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 '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("ProspectsByStatus").'</td></tr>';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
@ -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 '<table class="noborder"" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("ProposalsDraft").'</td></tr>';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
@ -164,41 +163,45 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* 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 '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("ProposalsOpened").'</td></tr>';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
@ -218,8 +221,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
$i++;
$total += $obj->price;
}
if ($total > 0)
{
if ($total > 0) {
print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td></tr>";
}
print "</table><br>";
@ -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 '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("ProspectToContact").'</td></tr>';
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td width="12%">';

View File

@ -313,7 +313,7 @@ class Commande extends CommonOrder
'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>110),
'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
//'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1),
@ -1791,7 +1791,7 @@ class Commande extends CommonOrder
if (empty($id) && empty($ref) && empty($ref_ext)) return -1;
$sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
$sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
$sql .= ', c.fk_account';
$sql .= ', c.date_commande, c.date_valid, c.tms';
$sql .= ', c.date_livraison as delivery_date';
@ -3297,7 +3297,7 @@ class Commande extends CommonOrder
$sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").",";
$sql .= " date_commande=".(strval($this->date_commande) != '' ? "'".$this->db->idate($this->date_commande)."'" : 'null').",";
$sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').",";
$sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").",";
$sql .= " total_tva=".(isset($this->total_tva) ? $this->total_tva : "null").",";
$sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").",";
$sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").",";
$sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").",";

View File

@ -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);

View File

@ -1376,7 +1376,7 @@ if ($resql)
// Alias
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td>';
print '<td class="tdoverflowmax150" title="'.$obj->name_alias.'">';
print $obj->name_alias;
print '</td>';
if (!$i) $totalarray['nbfield']++;

View File

@ -831,7 +831,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
$sql .= ", s.nom as name, s.email";
$sql .= ", s.rowid as socid";
$sql .= ", s.code_client, s.code_compta";
$sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.tva as total_tva, c.total_ttc,";
$sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.total_tva, c.total_ttc,";
$sql .= " cc.rowid as country_id, cc.code as country_code";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -849,7 +849,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
$reshook = $hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters);
$sql .= $hookmanager->resPrint;
$sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code";
$sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_tva, c.total_ttc, cc.rowid, cc.code";
$resql = $db->query($sql);
if ($resql)

View File

@ -821,7 +821,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '<tr><td>'.$langs->trans("ContactByDefaultFor").'</td>';
print '<td colspan="3">';
$contactType = $object->listeTypeContacts('external', '', 1);
print $form->multiselectarray('roles', $contactType);
print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500');
print '</td></tr>';
}

View File

@ -9,7 +9,7 @@
* Copyright (C) 2014-2020 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -768,8 +768,7 @@ if (empty($reshook))
}
// Close all lines
elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
{
elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) {
$result = $object->closeAll($user);
if ($result < 0)
{
@ -778,15 +777,13 @@ if (empty($reshook))
}
// Close all lines
elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer)
{
elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) {
$result = $object->activateAll($user);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
{
} elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) {
$result = $object->delete($user);
if ($result >= 0)
{
@ -795,13 +792,12 @@ if (empty($reshook))
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer)
{
} elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) {
if (GETPOST('newcid') > 0)
{
$contractline = new ContratLigne($db);
$result = $contractline->fetch(GETPOST('lineid'));
$contractline->fk_contrat = GETPOST('newcid');
$result = $contractline->fetch(GETPOSTINT('lineid'));
$contractline->fk_contrat = GETPOSTINT('newcid');
$result = $contractline->update($user, 1);
if ($result >= 0)
{
@ -871,8 +867,7 @@ if (empty($reshook))
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
} elseif ($action == 'setref')
{
} elseif ($action == 'setref') {
$cancelbutton = GETPOST('cancel', 'alpha');
if (!$cancelbutton) {
@ -909,8 +904,7 @@ if (empty($reshook))
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
} elseif ($action == 'setdate_contrat')
{
} elseif ($action == 'setdate_contrat') {
$cancelbutton = GETPOST('cancel', 'alpha');
if (!$cancelbutton) {

View File

@ -3,7 +3,7 @@
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1126,18 +1126,47 @@ if (!$error && $massaction == 'validate' && $permissiontoadd)
if ($result > 0)
{
$result = $objecttmp->validate($user);
if ($result == 0)
{
if ($result == 0) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
$error++;
break;
} elseif ($result < 0)
{
} elseif ($result < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
} else $nbok++;
} else {
// validate() rename pdf but do not regenerate
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $objecttmp->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('products');
}
$model = $objecttmp->model_pdf;
$ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records
// To be sure vars is defined
$hidedetails = !empty($hidedetails) ? $hidedetails : 0;
$hidedesc = !empty($hidedesc) ? $hidedesc : 0;
$hideref = !empty($hideref) ? $hideref : 0;
$moreparams = !empty($moreparams) ? $moreparams : null;
$result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
}
}
$nbok++;
}
} else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2012 Charles-François BENKE <charles.fr@benke.fr>
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014-2019 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2014-2021 Frederic France <frederic.france@netlogic.fr>
*
* 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&amp;leftmenu=propals&amp;search_status=".$data[$j]->fk_statut,

View File

@ -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";

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2019 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2015-2021 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
*
* 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 {

View File

@ -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";

View File

@ -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";

View File

@ -1412,6 +1412,8 @@ abstract class CommonObject
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num > 0) {
$langs->loadLangs(array("propal", "orders", "bills", "suppliers", "contracts", "supplier_proposal"));
while ($obj = $this->db->fetch_object($resql)) {
$modulename = $obj->element;
if (strpos($obj->element, 'project') !== false) {
@ -1427,11 +1429,15 @@ abstract class CommonObject
}
if (!empty($conf->{$modulename}->enabled)) {
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
$transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code;
$tmpelement = $obj->element;
$transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code;
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
if (empty($option))
if (empty($option)) {
$tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
}
else {
$tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
}
}
}
}
@ -3230,12 +3236,11 @@ abstract class CommonObject
// Specific code for backward compatibility with old field names
if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total';
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva';
if ($this->element == 'propal') {
$fieldttc = 'total';
$fieldtva = 'total_tva';
}
if ($this->element == 'propal') $fieldtva = 'total_tva';
if ($this->element == 'expensereport') $fieldtva = 'total_tva';
if ($this->element == 'supplier_proposal') $fieldttc = 'total';
if ($this->element == 'supplier_proposal') $fieldtva = 'total_tva';
if ($this->element == 'commande') $fieldtva = 'total_tva';
if ($this->element == 'order_supplier') $fieldtva = 'total_tva';
if (empty($nodatabaseupdate))
{

View File

@ -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

View File

@ -52,10 +52,10 @@ function societe_prepare_head(Societe $object)
if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$nbContact = 0;
// Enable caching of thirdrparty count Contacts
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_contacts_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
@ -71,7 +71,7 @@ function societe_prepare_head(Societe $object)
$nbContact = $obj->nb;
}
dol_setcache($cachekey, $nbContact); // If setting cache fails, this is not a problem, so we do not test result.
dol_setcache($cachekey, $nbContact, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
@ -129,22 +129,32 @@ function societe_prepare_head(Societe $object)
}
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
$nbNote = 0;
$sql = "SELECT COUNT(n.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
$sql .= " WHERE fk_soc = ".$object->id;
$sql .= " AND entity IN (".getEntity('project').")";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbNote = $obj->nb;
$nbProject = 0;
// Enable caching of thirdrparty count projects
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_projects_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$nbProject = $dataretrieved;
} else {
dol_print_error($db);
$sql = "SELECT COUNT(n.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
$sql .= " WHERE fk_soc = ".$object->id;
$sql .= " AND entity IN (".getEntity('project').")";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbProject = $obj->nb;
} else {
dol_print_error($db);
}
dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Projects");
if ($nbNote > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
if ($nbProject > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbProject.'</span>';
}
$head[$h][2] = 'project';
$h++;
@ -271,10 +281,9 @@ function societe_prepare_head(Societe $object)
if ($user->socid == 0) {
// Notifications
if (!empty($conf->notification->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$nbNotif = 0;
// Enable caching of thirdrparty count notifications
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_notifications_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
@ -290,7 +299,7 @@ function societe_prepare_head(Societe $object)
} else {
dol_print_error($db);
}
dol_setcache($cachekey, $nbNotif); // If setting cache fails, this is not a problem, so we do not test result.
dol_setcache($cachekey, $nbNotif, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id;
@ -318,17 +327,28 @@ function societe_prepare_head(Societe $object)
$head[$h][2] = 'note';
$h++;
// Attached files
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
// Attached files and Links
$totalAttached = 0;
// Enable caching of thirdrparty count attached files and links
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_attached_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$totalAttached = $dataretrieved;
} else {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$totalAttached = $nbFiles + $nbLinks;
dol_setcache($cachekey, $totalAttached, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Documents");
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
if (($totalAttached) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($totalAttached).'</span>';
}
$head[$h][2] = 'document';
$h++;
@ -337,10 +357,9 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$nbEvent = 0;
// Enable caching of thirdrparty count actioncomm
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_thirdparty_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
@ -356,7 +375,7 @@ function societe_prepare_head(Societe $object)
} else {
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
}
dol_setcache($cachekey, $nbEvent); // If setting cache fails, this is not a problem, so we do not test result.
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][1] .= '/';

View File

@ -2450,21 +2450,32 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64,
function getArrayOfSocialNetworks()
{
global $conf, $db;
$sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
$sql .= " WHERE entity=".$conf->entity;
$socialnetworks = array();
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$socialnetworks[$obj->code] = array(
'rowid' => $obj->rowid,
'label' => $obj->label,
'url' => $obj->url,
'icon' => $obj->icon,
'active' => $obj->active,
);
// Enable caching of array
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'socialnetworks_' . $conf->entity;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$socialnetworks = $dataretrieved;
} else {
$sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
$sql .= " WHERE entity=".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$socialnetworks[$obj->code] = array(
'rowid' => $obj->rowid,
'label' => $obj->label,
'url' => $obj->url,
'icon' => $obj->icon,
'active' => $obj->active,
);
}
}
dol_setcache($cachekey, $socialnetworks); // If setting cache fails, this is not a problem, so we do not test result.
}
return $socialnetworks;
}
@ -3173,15 +3184,15 @@ function dol_substr($string, $start, $length, $stringencoding = '', $trunconbyte
/**
* Truncate a string to a particular length adding '...' if string larger than length.
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
* Truncate a string to a particular length adding '' if string larger than length.
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with ''.
* MAIN_DISABLE_TRUNC=1 can disable all truncings
*
* @param string $string String to truncate
* @param int $size Max string size visible (excluding ...). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added ..., or if size was max+1 or max+2 or max+3 so it does not worse to replace with ...)
* @param int $size Max string size visible (excluding ). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added , or if size was max+1 so it does not worse to replace with ...)
* @param string $trunc Where to trunc: 'right', 'left', 'middle' (size must be a 2 power), 'wrap'
* @param string $stringencoding Tell what is source string encoding
* @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation.
* @param int $nodot Truncation do not add after truncation. So it's an exact truncation.
* @param int $display Trunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
* @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise.
*/
@ -3189,42 +3200,53 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
{
global $conf;
if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
return $string;
}
if (empty($stringencoding)) $stringencoding = 'UTF-8';
if (empty($stringencoding)) {
$stringencoding = 'UTF-8';
}
// reduce for small screen
if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3);
// We go always here
if ($trunc == 'right')
{
$newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...');
else //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
return $string;
} elseif ($trunc == 'middle')
{
$newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1))
{
if ($trunc == 'right') {
$newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
// If nodot is 0 and size is 1 chars more, we don't trunc and don't add …
return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '');
} else {
//return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
return $string;
}
} elseif ($trunc == 'middle') {
$newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
$size1 = round($size / 2);
$size2 = round($size / 2);
return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
} else return $string;
} elseif ($trunc == 'left')
{
$newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
else return $string;
} elseif ($trunc == 'wrap')
{
$newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + 1))
return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
else return $string;
} else return 'BadParam3CallingDolTrunc';
return dol_substr($newstring, 0, $size1, $stringencoding).'…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
} else {
return $string;
}
} elseif ($trunc == 'left') {
$newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
// If nodot is 0 and size is 1 chars more, we don't trunc and don't add …
return '…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
} else {
return $string;
}
} elseif ($trunc == 'wrap') {
$newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + 1)) {
return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
} else {
return $string;
}
} else {
return 'BadParam3CallingDolTrunc';
}
}
/**
@ -6386,8 +6408,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
$substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null);
$substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null);
$substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : '');
$substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%d") : '');
$substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%A") : '');
$substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%m") : '');
$substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%b") : '');
$substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%Y") : '');
$substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%H") : '');
$substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : '');
$substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : '');
// For backward compatibility
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));

View File

@ -61,10 +61,11 @@ $shmoffset = 1000; // Max number of entries found into a language file. If too l
*
* @param string $memoryid Memory id of shared area
* @param mixed $data Data to save. It must not be a null value.
* @param int $expire ttl in seconds, 0 never expire
* @return int <0 if KO, 0 if nothing is done, Nb of bytes written if OK
* @see dol_getcache()
*/
function dol_setcache($memoryid, $data)
function dol_setcache($memoryid, $data, $expire = 0)
{
global $conf;
$result = 0;
@ -85,7 +86,7 @@ function dol_setcache($memoryid, $data)
$memoryid = session_name() . '_' . $memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
$dolmemcache->add($memoryid, $data); // This fails if key already exists
$dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists
$rescode = $dolmemcache->getResultCode();
if ($rescode == 0) {
return count($data);
@ -104,7 +105,7 @@ function dol_setcache($memoryid, $data)
$memoryid = session_name() . '_' . $memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
$result = $dolmemcache->add($memoryid, $data); // This fails if key already exists
$result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists
if ($result) {
return count($data);
} else {
@ -112,7 +113,7 @@ function dol_setcache($memoryid, $data)
}
} elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // This is a really not reliable cache ! Use Memcached instead.
// Using shmop
$result = dol_setshmop($memoryid, $data);
$result = dol_setshmop($memoryid, $data, $expire);
}
return $result;
@ -226,9 +227,10 @@ function dol_listshmop()
*
* @param int $memoryid Memory id of shared area ('main', 'agenda', ...)
* @param string $data Data to save. Must be a not null value.
* @param int $expire ttl in seconds, 0 never expire
* @return int <0 if KO, 0=Caching not available, Nb of bytes written if OK
*/
function dol_setshmop($memoryid, $data)
function dol_setshmop($memoryid, $data, $expire)
{
global $shmkeys, $shmoffset;

View File

@ -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('<body id="bodywebsite" class="bodywebsite', '<body id="bodywebsite" class="bodywebsite '.$conf->global->WEBSITE_ADD_CSS_TO_BODY, $content);

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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();
}
}

View File

@ -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').")";

View File

@ -204,7 +204,7 @@ class CommandeFournisseur extends CommonOrder
'amount_ht' =>array('type'=>'double(24,8)', 'label'=>'Amount ht', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1),
@ -305,7 +305,7 @@ class CommandeFournisseur extends CommonOrder
// Check parameters
if (empty($id) && empty($ref)) return -1;
$sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,";
$sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.total_tva,";
$sql .= " c.localtax1, c.localtax2, ";
$sql .= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,";
$sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,";
@ -356,7 +356,7 @@ class CommandeFournisseur extends CommonOrder
$this->user_approve_id = $obj->fk_user_approve;
$this->user_approve_id2 = $obj->fk_user_approve2;
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_vat;
$this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc;
@ -451,7 +451,7 @@ class CommandeFournisseur extends CommonOrder
$sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc';
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
$sql .= ", pfp.rowid as fk_pfp, pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn";

View File

@ -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 '<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.'">';
print '</td>';
}
if (!empty($arrayfields['cf.total_vat']['checked']))
if (!empty($arrayfields['cf.total_tva']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="5" name="search_total_vat" value="'.$search_total_vat.'">';
print '<input class="flat" type="text" size="5" name="search_total_tva" value="'.$search_total_tva.'">';
print '</td>';
}
if (!empty($arrayfields['cf.total_ttc']['checked']))
@ -940,11 +940,11 @@ if ($resql)
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
print '</td>';
}
if (!empty($arrayfields['cf.multicurrency_total_vat']['checked']))
if (!empty($arrayfields['cf.multicurrency_total_tva']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_tva" value="'.dol_escape_htmltag($search_multicurrency_montant_tva).'">';
print '</td>';
}
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 '<td class="right">'.price($obj->total_tva)."</td>\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 '<td class="right nowrap">'.price($obj->multicurrency_total_vat)."</td>\n";
print '<td class="right nowrap">'.price($obj->multicurrency_total_tva)."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Amount TTC

View File

@ -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 '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg
// Check browser
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (!empty($useragent))
{
if (!empty($useragent)) {
$tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
$browserversion = $tmp['browserversion'];
$browsername = $tmp['browsername'];
if ($browsername == 'ie' && $browserversion < 7) print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("WarningBrowserTooOld")."<br>\n";
if ($browsername == 'ie' && $browserversion < 7) {
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("WarningBrowserTooOld")."<br>\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 '<img src="../theme/eldy/img/error.png" alt="Error"> '.$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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
$checksok = 0; // 0=error, 1=warning
} else {
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPVersion")." ".versiontostring(versionphparray());
}
if (empty($force_install_nophpinfo)) print ' (<a href="phpinfo.php" target="_blank">'.$langs->trans("MoreInformation").'</a>)';
if (empty($force_install_nophpinfo)) {
print ' (<a href="phpinfo.php" target="_blank">'.$langs->trans("MoreInformation").'</a>)';
}
print "<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
print "<br>\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 '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions")."<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportGD")."<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportCurl")."<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."<br>\n";
} else {
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPSupport", "Calendar")."<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportIntl")."<br>\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 '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."<br>\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 '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPMemoryOK", $memmaxorig, $memrequiredorig)."<br>\n";
} else {
print '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans("PHPMemoryTooLow", $memmaxorig, $memrequiredorig)."<br>\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, '<?php');
@fputs($fp, "\n");
fclose($fp);
} else dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR);
} else {
dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR);
}
}
// First install: no upgrade necessary/required
@ -247,8 +242,7 @@ if (is_readable($conffile) && filesize($conffile) > 8)
// File is missing and cannot be created
if (!file_exists($conffile))
{
if (!file_exists($conffile)) {
print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
print "<br><br>";
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 '<img src="../theme/eldy/img/error.png" alt="Warning"> '.$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 '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileExists", $conffiletoshow);
} else {
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
@ -277,11 +267,9 @@ if (!file_exists($conffile))
print "<br>\n";
$allowinstall = 0;
}
// File exists and can be modified
else {
if ($confexists)
{
} else {
// File exists and can be modified
if ($confexists) {
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileExists", $conffiletoshow);
} else {
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
@ -295,32 +283,28 @@ if (!file_exists($conffile))
print "<br>\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 '<span class="error">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.</span><br>'."\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").': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).'</span></b> - ';
print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b>';
//print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
print '<br>';
print '<br>';
} else print "<br>\n";
} else {
print "<br>\n";
}
//print $langs->trans("InstallEasy")." ";
print '<h3><span class="soustitre">'.$langs->trans("ChooseYourSetupMode").'</span></h3>';
@ -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 .= '</td>';
$choice .= '<td class="listofchoicesdesc">';
$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 .= '<br>';
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= '<div class="center"><div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div></div>';
@ -397,8 +384,7 @@ if (!file_exists($conffile))
$choice .= '</td>';
$choice .= '<td class="center">';
if ($allowinstall)
{
if ($allowinstall) {
$choice .= '<a class="button" href="fileconf.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>';
} else {
$choice .= ($foundrecommandedchoice ? '<span class="warning">' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '</span>' : '');
@ -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 .= '<td class="listofchoicesdesc">';
$choice .= $langs->trans("UpgradeDesc");
if ($recommended_choice)
{
if ($recommended_choice) {
$choice .= '<br>';
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= '<div class="center">';
$choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
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 .= '</div>';
@ -504,19 +486,15 @@ if (!file_exists($conffile))
$choice .= '</td>';
$choice .= '<td class="center">';
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 .= '<span class="opacitymedium">'.$langs->trans("NotYetAvailable").'</span>';
} else {
$choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ? '_'.$versionto : '').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'">'.$langs->trans("Start").'</a>';
@ -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();
}

View File

@ -5,7 +5,8 @@
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* Copyright (C) 2021 Charlene Benke <charlene@patas-monkey.com>
*
* 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 <?php in first line
{
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 <?php in first line
$result = include_once $conffile; // Load conf file
if ($result)
{
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysqli'; // For backward compatibility
if ($result) {
if (empty($dolibarr_main_db_type)) {
$dolibarr_main_db_type = 'mysqli'; // For backward compatibility
}
//Mysql driver support has been removed in favor of mysqli
if ($dolibarr_main_db_type == 'mysql') {
$dolibarr_main_db_type = 'mysqli';
}
if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type == 'mysqli')) $dolibarr_main_db_port = '3306'; // For backward compatibility
if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type == 'mysqli')) {
$dolibarr_main_db_port = '3306'; // For backward compatibility
}
// Clean parameters
$dolibarr_main_data_root = isset($dolibarr_main_data_root) ?trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.'/../documents';
@ -101,25 +104,31 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
$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, <a href="'.$dolibarr_main_url_root.'/admin/index.php?mainmenu=home&leftmenu=setup'.(GETPOSTISSET("login") ? '&username='.urlencode(GETPOST("login")) : '').'">';
print $langs->trans("ClickHereToGoToApp");
print '</a>';
@ -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").'<br>';
print '<a href="'.$dolibarr_main_url_root.'/admin/index.php?mainmenu=home&leftmenu=setup'.(GETPOSTISSET("login") ? '&username='.urlencode(GETPOST("login")) : '').'">';
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 '<link rel="stylesheet" type="text/css" href="default.css">'."\n";
print '<!-- Includes CSS for JQuery -->'."\n";
if ($jQueryUiCustomPath) print '<link rel="stylesheet" type="text/css" href="'.$jQueryUiCustomPath.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
else print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
if ($jQueryUiCustomPath) {
print '<link rel="stylesheet" type="text/css" href="'.$jQueryUiCustomPath.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
} else {
print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
}
print '<!-- Includes JS for JQuery -->'."\n";
if ($jQueryCustomPath) print '<script type="text/javascript" src="'.$jQueryCustomPath.'jquery.min.js"></script>'."\n";
else print '<script type="text/javascript" src="../includes/jquery/js/jquery.min.js"></script>'."\n";
if ($jQueryUiCustomPath) print '<script type="text/javascript" src="'.$jQueryUiCustomPath.'jquery-ui.min.js"></script>'."\n";
else print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui.min.js"></script>'."\n";
if ($jQueryCustomPath) {
print '<script type="text/javascript" src="'.$jQueryCustomPath.'jquery.min.js"></script>'."\n";
} else {
print '<script type="text/javascript" src="../includes/jquery/js/jquery.min.js"></script>'."\n";
}
if ($jQueryUiCustomPath) {
print '<script type="text/javascript" src="'.$jQueryUiCustomPath.'jquery-ui.min.js"></script>'."\n";
} else {
print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui.min.js"></script>'."\n";
}
print '<title>'.$langs->trans("DolibarrSetup").'</title>'."\n";
print '</head>'."\n";
@ -402,7 +464,9 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
print '</span>'."\n";
print '<form name="forminstall" style="width: 100%" action="'.$next.'.php'.($param ? '?'.$param : '').'" method="POST"';
if ($next == 'step5') print ' autocomplete="off"';
if ($next == 'step5') {
print ' autocomplete="off"';
}
print '>'."\n";
print '<input type="hidden" name="testpost" value="ok">'."\n";
print '<input type="hidden" name="action" value="'.$action.'">'."\n";
@ -430,11 +494,9 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
print '</td></tr></table>'."\n";
print '</td></tr></table>'."\n";
if (!$nonext || ($nonext == '2'))
{
if (!$nonext || ($nonext == '2')) {
print '<div class="nextbutton" id="nextbutton">';
if ($nonext == '2')
{
if ($nonext == '2') {
print '<span class="warning">';
print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '');
print '</span>';
@ -442,25 +504,26 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
}
print '<input type="submit" '.($nonext == '2' ? 'disabled="disabled" ' : '').'value="'.$langs->trans("NextStep").' ->"';
if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"';
if ($jscheckfunction) {
print ' onClick="return '.$jscheckfunction.'();"';
}
print '></div>';
if ($withpleasewait) print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>'.$langs->trans("NextStepMightLastALongTime").'<br><br><div class="blinkwait">'.$langs->trans("PleaseBePatient").'</div></div>';
if ($withpleasewait) {
print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>'.$langs->trans("NextStepMightLastALongTime").'<br><br><div class="blinkwait">'.$langs->trans("PleaseBePatient").'</div></div>';
}
}
if ($setuplang)
{
if ($setuplang) {
print '<input type="hidden" name="selectlang" value="'.$setuplang.'">';
}
print '</form>'."\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 "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach ($conf->logbuffer as $logline)
{
foreach ($conf->logbuffer as $logline) {
print $logline."<br>\n";
}
//print '</div>'."\n";
@ -481,7 +544,9 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
*/
function dolibarr_install_syslog($message, $level = LOG_DEBUG)
{
if (!defined('LOG_DEBUG')) define('LOG_DEBUG', 6);
if (!defined('LOG_DEBUG')) {
define('LOG_DEBUG', 6);
}
dol_syslog($message, $level);
}
@ -494,8 +559,7 @@ function detect_dolibarr_main_document_root()
{
// If PHP is in CGI mode, SCRIPT_FILENAME is PHP's path.
// Since that's not what we want, we suggest $_SERVER["DOCUMENT_ROOT"]
if ($_SERVER["SCRIPT_FILENAME"] == 'php' || preg_match('/[\\/]php$/i', $_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i', $_SERVER["SCRIPT_FILENAME"]))
{
if ($_SERVER["SCRIPT_FILENAME"] == 'php' || preg_match('/[\\/]php$/i', $_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i', $_SERVER["SCRIPT_FILENAME"])) {
$dolibarr_main_document_root = $_SERVER["DOCUMENT_ROOT"];
if (!preg_match('/[\\/]dolibarr[\\/]htdocs$/i', $dolibarr_main_document_root)) {
@ -532,11 +596,11 @@ function detect_dolibarr_main_url_root()
// If defined (Ie: Apache with Linux)
if (isset($_SERVER["SCRIPT_URI"])) {
$dolibarr_main_url_root = $_SERVER["SCRIPT_URI"];
} // If defined (Ie: Apache with Caudium)
elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
} elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
// If defined (Ie: Apache with Caudium)
$dolibarr_main_url_root = $_SERVER["SERVER_URL"].$_SERVER["DOCUMENT_URI"];
} // If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
else {
} else {
// If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
$proto = ((!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ? 'https' : 'http';
if (!empty($_SERVER["HTTP_HOST"])) {
$serverport = $_SERVER["HTTP_HOST"];

View File

@ -32,8 +32,7 @@ global $langs;
$err = 0;
// If the config file exists and is filled, we're not on first install so we skip the language selection page
if (file_exists($conffile) && isset($dolibarr_main_url_root))
{
if (file_exists($conffile) && isset($dolibarr_main_url_root)) {
header("Location: check.php?testget=ok");
exit;
}
@ -65,4 +64,6 @@ print '</table></div>';
print '<br><br><span class="opacitymedium">'.$langs->trans("SomeTranslationAreUncomplete").'</span>';
// If there's no error, we display the next step button
if ($err == 0) pFooter(0);
if ($err == 0) {
pFooter(0);
}

View File

@ -35,12 +35,16 @@ function checkElementExist($id, $table)
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table;
$sql .= ' WHERE rowid = '.$id;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
if ($num > 0) return true;
else return false;
} else return true; // for security
if ($num > 0) {
return true;
} else {
return false;
}
} else {
return true; // for security
}
}
/**
@ -60,28 +64,37 @@ function checkLinkedElements($sourcetype, $targettype)
$sourcetable = $sourcetype;
$targettable = $targettype;
if ($sourcetype == 'shipping') $sourcetable = 'expedition';
elseif ($targettype == 'shipping') $targettable = 'expedition';
if ($sourcetype == 'delivery') $sourcetable = 'livraison';
elseif ($targettype == 'delivery') $targettable = 'livraison';
if ($sourcetype == 'order_supplier') $sourcetable = 'commande_fournisseur';
elseif ($targettype == 'order_supplier') $targettable = 'commande_fournisseur';
if ($sourcetype == 'invoice_supplier') $sourcetable = 'facture_fourn';
elseif ($targettype == 'invoice_supplier') $targettable = 'facture_fourn';
if ($sourcetype == 'shipping') {
$sourcetable = 'expedition';
} elseif ($targettype == 'shipping') {
$targettable = 'expedition';
}
if ($sourcetype == 'delivery') {
$sourcetable = 'livraison';
} elseif ($targettype == 'delivery') {
$targettable = 'livraison';
}
if ($sourcetype == 'order_supplier') {
$sourcetable = 'commande_fournisseur';
} elseif ($targettype == 'order_supplier') {
$targettable = 'commande_fournisseur';
}
if ($sourcetype == 'invoice_supplier') {
$sourcetable = 'facture_fourn';
} elseif ($targettype == 'invoice_supplier') {
$targettable = 'facture_fourn';
}
$out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' ';
$sql = 'SELECT rowid, fk_source, fk_target FROM '.MAIN_DB_PREFIX.'element_element';
$sql .= ' WHERE sourcetype="'.$sourcetype.'" AND targettype="'.$targettype.'"';
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
$elements[$obj->rowid] = array($sourcetype => $obj->fk_source, $targettype => $obj->fk_target);
$i++;
@ -89,12 +102,9 @@ function checkLinkedElements($sourcetype, $targettype)
}
}
if (!empty($elements))
{
foreach ($elements as $key => $element)
{
if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable))
{
if (!empty($elements)) {
foreach ($elements as $key => $element) {
if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable)) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_element';
$sql .= ' WHERE rowid = '.$key;
$resql = $db->query($sql);
@ -103,8 +113,11 @@ function checkLinkedElements($sourcetype, $targettype)
}
}
if ($deleted) $out .= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>';
else $out .= '('.$langs->trans('NothingToDelete').')<br>';
if ($deleted) {
$out .= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>';
} else {
$out .= '('.$langs->trans('NothingToDelete').')<br>';
}
return $out;
}
@ -121,22 +134,23 @@ function clean_data_ecm_directories()
// Clean data from ecm_directories
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."ecm_directories";
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$id = $obj->rowid;
$label = $obj->label;
$newlabel = dol_sanitizeFileName($label);
if ($label != $newlabel)
{
if ($label != $newlabel) {
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set label='".$db->escape($newlabel)."' WHERE rowid=".$id;
print '<tr><td>'.$sqlupdate."</td></tr>\n";
$resqlupdate = $db->query($sqlupdate);
if (!$resqlupdate) dol_print_error($db, 'Failed to update');
if (!$resqlupdate) {
dol_print_error($db, 'Failed to update');
}
}
}
} else dol_print_error($db, 'Failed to run request');
} else {
dol_print_error($db, 'Failed to run request');
}
return;
}

View File

@ -179,5 +179,12 @@ ALTER TABLE llx_projet ADD COLUMN accept_booth_suggestions integer DEFAULT 0;
ALTER TABLE llx_projet ADD COLUMN price_registration double(24,8);
ALTER TABLE llx_projet ADD COLUMN price_booth double(24,8);
-- Uniformize field total_ht, total_tva, total_ttc
-- Code enhanced - Standardize field name
ALTER TABLE llx_commande CHANGE COLUMN tva total_tva double(24,8) default 0;
ALTER TABLE llx_supplier_proposal CHANGE COLUMN tva total_tva double(24,8) default 0;
ALTER TABLE llx_supplier_proposal CHANGE COLUMN total total_ttc double(24,8) default 0;
ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0;
ALTER TABLE llx_propal CHANGE COLUMN total total_ttc double(24,8) default 0;
ALTER TABLE llx_commande_fournisseur CHANGE COLUMN tva total_tva double(24,8) default 0;

View File

@ -47,7 +47,7 @@ create table llx_commande
remise_percent real default 0,
remise_absolue real default 0,
remise real default 0,
tva double(24,8) default 0,
total_tva double(24,8) default 0,
localtax1 double(24,8) default 0, -- total localtax1
localtax2 double(24,8) default 0, -- total localtax2
total_ht double(24,8) default 0,

View File

@ -49,7 +49,7 @@ create table llx_commande_fournisseur
amount_ht double(24,8) default 0,
remise_percent real default 0,
remise real default 0,
tva double(24,8) default 0,
total_tva double(24,8) default 0,
localtax1 double(24,8) default 0,
localtax2 double(24,8) default 0,
total_ht double(24,8) default 0,

View File

@ -51,7 +51,7 @@ create table llx_propal
total_tva double(24,8) DEFAULT 0, -- montant total tva apres remise globale
localtax1 double(24,8) DEFAULT 0, -- amount total localtax1
localtax2 double(24,8) DEFAULT 0, -- amount total localtax2
total double(24,8) DEFAULT 0, -- montant total ttc apres remise globale
total_ttc double(24,8) DEFAULT 0, -- montant total ttc apres remise globale
fk_account integer, -- bank account
fk_currency varchar(3), -- currency code

View File

@ -37,10 +37,10 @@ CREATE TABLE llx_supplier_proposal (
remise_absolue double DEFAULT 0,
remise double DEFAULT 0,
total_ht double(24,8) DEFAULT 0,
tva double(24,8) DEFAULT 0,
total_tva double(24,8) DEFAULT 0,
localtax1 double(24,8) DEFAULT 0,
localtax2 double(24,8) DEFAULT 0,
total double(24,8) DEFAULT 0,
total_ttc double(24,8) DEFAULT 0,
fk_account integer DEFAULT NULL,
fk_currency varchar(3) DEFAULT NULL,
fk_cond_reglement integer DEFAULT NULL,

View File

@ -75,14 +75,18 @@ $_SESSION['dol_save_pass'] = $db_pass;
// Now we load forced 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;
// If forced install is enabled, replace the post values. These are empty because form fields are disabled.
if ($force_install_noedit) {
$main_dir = detect_dolibarr_main_document_root();
if (!empty($argv[1])) $main_dir = $argv[1]; // override when executing the script in command line
if (!empty($argv[1])) {
$main_dir = $argv[1]; // override when executing the script in command line
}
if (!empty($force_install_main_data_root)) {
$main_data_dir = $force_install_main_data_root;
} else {
@ -148,8 +152,7 @@ dolibarr_install_syslog("--- step1: entering step1.php page");
pHeader($langs->trans("ConfigurationFile"), "step2");
// 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;
@ -158,57 +161,48 @@ if (!is_writable($conffile))
// Check parameters
$is_sqlite = false;
if (empty($db_type))
{
if (empty($db_type)) {
print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseType")).'</div>';
$error++;
} else {
$is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3');
}
if (empty($db_host) && !$is_sqlite)
{
if (empty($db_host) && !$is_sqlite) {
print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Server")).'</div>';
$error++;
}
if (empty($db_name))
{
if (empty($db_name)) {
print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseName")).'</div>';
$error++;
}
if (empty($db_user) && !$is_sqlite)
{
if (empty($db_user) && !$is_sqlite) {
print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")).'</div>';
$error++;
}
if (!empty($db_port) && !is_numeric($db_port))
{
if (!empty($db_port) && !is_numeric($db_port)) {
print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_port, $langs->transnoentities("Port")).'</div>';
$error++;
}
if (!empty($db_prefix) && !preg_match('/^[a-z0-9]+_$/i', $db_prefix))
{
if (!empty($db_prefix) && !preg_match('/^[a-z0-9]+_$/i', $db_prefix)) {
print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_prefix, $langs->transnoentities("DatabasePrefix")).'</div>';
$error++;
}
// Remove last / into dans main_dir
if (substr($main_dir, dol_strlen($main_dir) - 1) == "/")
{
if (substr($main_dir, dol_strlen($main_dir) - 1) == "/") {
$main_dir = substr($main_dir, 0, dol_strlen($main_dir) - 1);
}
// Remove last / into dans main_url
if (!empty($main_url) && substr($main_url, dol_strlen($main_url) - 1) == "/")
{
if (!empty($main_url) && substr($main_url, dol_strlen($main_url) - 1) == "/") {
$main_url = substr($main_url, 0, dol_strlen($main_url) - 1);
}
// Test database connection
if (!$error) {
$result = @include_once $main_dir."/core/db/".$db_type.'.class.php';
if ($result)
{
if ($result) {
// If we require database or user creation we need to connect as root, so we need root login credentials
if (!empty($db_create_database) && !$userroot) {
print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).'</div>';
@ -229,11 +223,9 @@ if (!$error) {
if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
$databasefortest = $db_name;
if (!empty($db_create_database)) {
if ($db_type == 'mysql' || $db_type == 'mysqli')
{
if ($db_type == 'mysql' || $db_type == 'mysqli') {
$databasefortest = 'mysql';
} elseif ($db_type == 'pgsql')
{
} elseif ($db_type == 'pgsql') {
$databasefortest = 'postgres';
} else {
$databasefortest = 'master';
@ -249,14 +241,21 @@ if (!$error) {
if (empty($db_create_database) && $db->connected && !$db->database_selected) {
print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound", $db_name).'</div>';
print '<br>';
if (!$db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
if (!$db->connected) {
print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
}
print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++;
} elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
// Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
if ($db->error == "No such file or directory") print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
else print '<div class="error">'.$db->error.'</div>';
if (!$db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
if ($db->error == "No such file or directory") {
print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
} else {
print '<div class="error">'.$db->error.'</div>';
}
if (!$db->connected) {
print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
}
//print '<a href="#" onClick="javascript: history.back();">';
print $langs->trans("ErrorGoBackAndCorrectParameters");
//print '</a>';
@ -267,10 +266,11 @@ if (!$error) {
if (!$error && (empty($db_create_database) && empty($db_create_user))) {
$db = getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
if ($db->error)
{
if ($db->error) {
print '<div class="error">'.$db->error.'</div>';
if (!$db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
if (!$db->connected) {
print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
}
//print '<a href="#" onClick="javascript: history.back();">';
print $langs->trans("ErrorGoBackAndCorrectParameters");
//print '</a>';
@ -286,18 +286,20 @@ if (!$error) {
$error++;
}
} else {
if (isset($db)) print $db->lasterror();
if (isset($db) && !$db->connected) print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
if (isset($db)) {
print $db->lasterror();
}
if (isset($db) && !$db->connected) {
print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
}
print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++;
}
if (!$error && $db->connected)
{
if (!$error && $db->connected) {
if (!empty($db_create_database)) {
$result = $db->select_db($db_name);
if ($result)
{
if ($result) {
print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters");
@ -307,10 +309,8 @@ if (!$error && $db->connected)
}
// Define $defaultCharacterSet and $defaultDBSortingCollation
if (!$error && $db->connected)
{
if (!empty($db_create_database)) // If we create database, we force default value
{
if (!$error && $db->connected) {
if (!empty($db_create_database)) { // If we create database, we force default value
// Default values come from the database handler
$defaultCharacterSet = $db->forcecharset;
@ -323,8 +323,7 @@ if (!$error && $db->connected)
// Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
// TODO Remove this when utf8mb4 is supported
if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci')
{
if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci') {
$defaultCharacterSet = 'utf8';
$defaultDBSortingCollation = 'utf8_unicode_ci';
}
@ -338,13 +337,10 @@ if (!$error && $db->connected)
// Create config file
if (!$error && $db->connected && $action == "set")
{
if (!$error && $db->connected && $action == "set") {
umask(0);
if (is_array($_POST))
{
foreach ($_POST as $key => $value)
{
if (is_array($_POST)) {
foreach ($_POST as $key => $value) {
if (!preg_match('/^db_pass/i', $key)) {
dolibarr_install_syslog("step1: choice for ".$key." = ".$value);
}
@ -356,10 +352,8 @@ if (!$error && $db->connected && $action == "set")
print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
// Check parameter main_dir
if (!$error)
{
if (!is_dir($main_dir))
{
if (!$error) {
if (!is_dir($main_dir)) {
dolibarr_install_syslog("step1: directory '".$main_dir."' is unavailable or can't be accessed");
print "<tr><td>";
@ -373,23 +367,19 @@ if (!$error && $db->connected && $action == "set")
}
}
if (!$error)
{
if (!$error) {
dolibarr_install_syslog("step1: directory '".$main_dir."' exists");
}
// Create subdirectory main_data_dir
if (!$error)
{
if (!$error) {
// Create directory for documents
if (!is_dir($main_data_dir))
{
if (!is_dir($main_data_dir)) {
dol_mkdir($main_data_dir);
}
if (!is_dir($main_data_dir))
{
if (!is_dir($main_data_dir)) {
print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
print '</td><td>';
@ -400,12 +390,10 @@ if (!$error && $db->connected && $action == "set")
} else {
// Create .htaccess file in document directory
$pathhtaccess = $main_data_dir.'/.htaccess';
if (!file_exists($pathhtaccess))
{
if (!file_exists($pathhtaccess)) {
dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '".$main_data_dir."'");
$handlehtaccess = @fopen($pathhtaccess, 'w');
if ($handlehtaccess)
{
if ($handlehtaccess) {
fwrite($handlehtaccess, 'Order allow,deny'."\n");
fwrite($handlehtaccess, 'Deny from all'."\n");
@ -427,14 +415,11 @@ if (!$error && $db->connected && $action == "set")
// Loop on each directory of dir [] to create them if they do not exist
$num = count($dir);
for ($i = 0; $i < $num; $i++)
{
if (is_dir($dir[$i]))
{
for ($i = 0; $i < $num; $i++) {
if (is_dir($dir[$i])) {
dolibarr_install_syslog("step1: directory '".$dir[$i]."' exists");
} else {
if (dol_mkdir($dir[$i]) < 0)
{
if (dol_mkdir($dir[$i]) < 0) {
print "<tr><td>";
print "Failed to create directory: ".$dir[$i];
print '</td><td>';
@ -454,8 +439,7 @@ if (!$error && $db->connected && $action == "set")
$destroot = $main_data_dir.'/medias';
dolCopyDir($srcroot, $destroot, 0, 0);
if ($error)
{
if ($error) {
print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
print '</td><td>';
@ -480,16 +464,14 @@ if (!$error && $db->connected && $action == "set")
'usergroups' => 'usergroups',
'users' => 'user',
);
foreach ($docs as $cursordir => $cursorfile)
{
foreach ($docs as $cursordir => $cursorfile) {
$src = $srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
$dirodt = $destroot.'/'.$cursordir;
$dest = $dirodt.'/template_'.$cursorfile.'.odt';
dol_mkdir($dirodt);
$result = dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
if ($result < 0) {
print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile', $src, $dest).'</td></tr>';
}
}
@ -501,11 +483,9 @@ if (!$error && $db->connected && $action == "set")
$main_db_prefix = (!empty($db_prefix) ? $db_prefix : 'llx_');
// Write conf file on disk
if (!$error)
{
if (!$error) {
// Save old conf file on disk
if (file_exists("$conffile"))
{
if (file_exists("$conffile")) {
// We must ignore errors as an existing old file may already exist and not be replaceable or
// the installer (like for ubuntu) may not have permission to create another file than conf.php.
// Also no other process must be able to read file or we expose the new file, so content with password.
@ -516,8 +496,7 @@ if (!$error && $db->connected && $action == "set")
}
// Create database and admin user database
if (!$error)
{
if (!$error) {
// We reload configuration file
conf($dolibarr_main_document_root);
@ -532,14 +511,11 @@ if (!$error && $db->connected && $action == "set")
//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
$databasefortest = $conf->db->name;
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
{
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') {
$databasefortest = 'mysql';
} elseif ($conf->db->type == 'pgsql')
{
} elseif ($conf->db->type == 'pgsql') {
$databasefortest = 'postgres';
} elseif ($conf->db->type == 'mssql')
{
} elseif ($conf->db->type == 'mssql') {
$databasefortest = 'master';
}
@ -547,32 +523,26 @@ if (!$error && $db->connected && $action == "set")
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, $conf->db->port);
if ($db->error)
{
if ($db->error) {
print '<div class="error">'.$db->error.'</div>';
$error++;
}
if (!$error)
{
if ($db->connected)
{
if (!$error) {
if ($db->connected) {
$resultbis = 1;
// Create user
$result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
// Create user bis
if ($databasefortest == 'mysql')
{
if (!in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local')))
{
if ($databasefortest == 'mysql') {
if (!in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local'))) {
$resultbis = $db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
}
}
if ($result > 0 && $resultbis > 0)
{
if ($result > 0 && $resultbis > 0) {
print '<tr><td>';
print $langs->trans("UserCreation").' : ';
print $dolibarr_main_db_user;
@ -581,8 +551,7 @@ if (!$error && $db->connected && $action == "set")
} else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
|| $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
|| $db->errno() == 'DB_ERROR_USER_ALREADY_EXISTS')
{
|| $db->errno() == 'DB_ERROR_USER_ALREADY_EXISTS') {
dolibarr_install_syslog("step1: user already exists");
print '<tr><td>';
print $langs->trans("UserCreation").' : ';
@ -628,12 +597,10 @@ if (!$error && $db->connected && $action == "set")
$newdb = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, '', $conf->db->port);
//print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
if ($newdb->connected)
{
if ($newdb->connected) {
$result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
if ($result)
{
if ($result) {
print '<tr><td>';
print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
print $dolibarr_main_db_name;
@ -683,15 +650,13 @@ if (!$error && $db->connected && $action == "set")
// We test access with dolibarr database user (not admin)
if (!$error)
{
if (!$error) {
dolibarr_install_syslog("step1: connection type=".$conf->db->type." on host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name);
//print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
if ($db->connected)
{
if ($db->connected) {
dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." ok");
print "<tr><td>";
print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
@ -701,8 +666,7 @@ if (!$error && $db->connected && $action == "set")
print "</td></tr>";
// server access ok, basic access ok
if ($db->database_selected)
{
if ($db->database_selected) {
dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." ok");
print "<tr><td>";
print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
@ -773,7 +737,9 @@ function jsinfo()
<?php
$ret = 0;
if ($error && isset($argv[1])) $ret = 1;
if ($error && isset($argv[1])) {
$ret = 1;
}
dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("--- step1: end");
@ -781,7 +747,9 @@ dolibarr_install_syslog("--- step1: end");
pFooter($error ? 1 : 0, $setuplang, 'jsinfo', 1);
// Return code if ran from command line
if ($ret) exit($ret);
if ($ret) {
exit($ret);
}
/**
@ -794,8 +762,7 @@ if ($ret) exit($ret);
function write_main_file($mainfile, $main_dir)
{
$fp = @fopen("$mainfile", "w");
if ($fp)
{
if ($fp) {
clearstatcache();
fputs($fp, '<?php'."\n");
fputs($fp, "// Wrapper to include main into htdocs\n");
@ -815,8 +782,7 @@ function write_main_file($mainfile, $main_dir)
function write_master_file($masterfile, $main_dir)
{
$fp = @fopen("$masterfile", "w");
if ($fp)
{
if ($fp) {
clearstatcache();
fputs($fp, '<?php'."\n");
fputs($fp, "// Wrapper to include master into htdocs\n");
@ -854,8 +820,7 @@ function write_conf_file($conffile)
$key = md5(uniqid(mt_rand(), true)); // Generate random hash
$fp = fopen("$conffile", "w");
if ($fp)
{
if ($fp) {
clearstatcache();
fputs($fp, '<?php'."\n");
@ -940,49 +905,77 @@ function write_conf_file($conffile)
// Write params to overwrites default lib path
fputs($fp, "\n");
if (empty($force_dolibarr_lib_FPDF_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_FPDF_PATH = ''; }
if (empty($force_dolibarr_lib_FPDF_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_FPDF_PATH = '';
}
fputs($fp, '$dolibarr_lib_FPDF_PATH=\''.$force_dolibarr_lib_FPDF_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_TCPDF_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_TCPDF_PATH = ''; }
if (empty($force_dolibarr_lib_TCPDF_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_TCPDF_PATH = '';
}
fputs($fp, '$dolibarr_lib_TCPDF_PATH=\''.$force_dolibarr_lib_TCPDF_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_FPDI_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_FPDI_PATH = ''; }
if (empty($force_dolibarr_lib_FPDI_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_FPDI_PATH = '';
}
fputs($fp, '$dolibarr_lib_FPDI_PATH=\''.$force_dolibarr_lib_FPDI_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_TCPDI_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_TCPDI_PATH = ''; }
if (empty($force_dolibarr_lib_TCPDI_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_TCPDI_PATH = '';
}
fputs($fp, '$dolibarr_lib_TCPDI_PATH=\''.$force_dolibarr_lib_TCPDI_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_ADODB_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_ADODB_PATH = ''; }
if (empty($force_dolibarr_lib_ADODB_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_ADODB_PATH = '';
}
fputs($fp, '$dolibarr_lib_ADODB_PATH=\''.$force_dolibarr_lib_ADODB_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_GEOIP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_GEOIP_PATH = ''; }
if (empty($force_dolibarr_lib_GEOIP_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_GEOIP_PATH = '';
}
fputs($fp, '$dolibarr_lib_GEOIP_PATH=\''.$force_dolibarr_lib_GEOIP_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_NUSOAP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_NUSOAP_PATH = ''; }
if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_NUSOAP_PATH = '';
}
fputs($fp, '$dolibarr_lib_NUSOAP_PATH=\''.$force_dolibarr_lib_NUSOAP_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_ODTPHP_PATH)) { fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATH = ''; }
if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATH = '';
}
fputs($fp, '$dolibarr_lib_ODTPHP_PATH=\''.$force_dolibarr_lib_ODTPHP_PATH.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) { fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP = ''; }
if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP = '';
}
fputs($fp, '$dolibarr_lib_ODTPHP_PATHTOPCLZIP=\''.$force_dolibarr_lib_ODTPHP_PATHTOPCLZIP.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_js_CKEDITOR)) { fputs($fp, '//'); $force_dolibarr_js_CKEDITOR = ''; }
if (empty($force_dolibarr_js_CKEDITOR)) {
fputs($fp, '//'); $force_dolibarr_js_CKEDITOR = '';
}
fputs($fp, '$dolibarr_js_CKEDITOR=\''.$force_dolibarr_js_CKEDITOR.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_js_JQUERY)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY = ''; }
if (empty($force_dolibarr_js_JQUERY)) {
fputs($fp, '//'); $force_dolibarr_js_JQUERY = '';
}
fputs($fp, '$dolibarr_js_JQUERY=\''.$force_dolibarr_js_JQUERY.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_js_JQUERY_UI)) { fputs($fp, '//'); $force_dolibarr_js_JQUERY_UI = ''; }
if (empty($force_dolibarr_js_JQUERY_UI)) {
fputs($fp, '//'); $force_dolibarr_js_JQUERY_UI = '';
}
fputs($fp, '$dolibarr_js_JQUERY_UI=\''.$force_dolibarr_js_JQUERY_UI.'\';');
fputs($fp, "\n");
// Write params to overwrites default font path
fputs($fp, "\n");
if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF = ''; }
fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF=\''.$force_dolibarr_font_DOL_DEFAULT_TTF.'\';');
if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF = '';
}
fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF=\''.$force_dolibarr_font_DOL_DEFAULT_TTF.'\';');
fputs($fp, "\n");
if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD = ''; }
if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD = '';
}
fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.'\';');
fputs($fp, "\n");
@ -992,8 +985,7 @@ function write_conf_file($conffile)
fclose($fp);
if (file_exists("$conffile"))
{
if (file_exists("$conffile")) {
include $conffile; // force config reload, do not put include_once
conf($dolibarr_main_document_root);

View File

@ -49,23 +49,37 @@ $langs->setDefaultLang($setuplang);
$langs->loadLangs(array("admin", "install"));
$choix = 0;
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 == "sqlite") $choix = 4;
if ($dolibarr_main_db_type == "sqlite3") $choix = 5;
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 == "sqlite") {
$choix = 4;
}
if ($dolibarr_main_db_type == "sqlite3") {
$choix = 5;
}
//if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into step2.php page');
// Now we load forced 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;
// test for travis
if (!empty($argv[1]) && $argv[1] == "set") $action = "set";
if (!empty($argv[1]) && $argv[1] == "set") {
$action = "set";
}
}
dolibarr_install_syslog("- step2: entering step2.php page");
@ -78,15 +92,13 @@ dolibarr_install_syslog("- step2: entering step2.php page");
pHeader($langs->trans("CreateDatabaseObjects"), "step4");
// 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;
}
if ($action == "set")
{
if ($action == "set") {
print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans("Database").'</h3>';
print '<table cellspacing="0" style="padding: 4px 4px 4px 0" border="0" width="100%">';
@ -94,8 +106,7 @@ if ($action == "set")
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
if ($db->connected)
{
if ($db->connected) {
print "<tr><td>";
print $langs->trans("ServerConnection")." : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
$ok = 1;
@ -103,10 +114,8 @@ if ($action == "set")
print "<tr><td>Failed to connect to server : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
}
if ($ok)
{
if ($db->database_selected)
{
if ($ok) {
if ($db->database_selected) {
dolibarr_install_syslog("step2: successful connection to database: ".$conf->db->name);
} else {
dolibarr_install_syslog("step2: failed connection to database :".$conf->db->name, LOG_ERR);
@ -117,8 +126,7 @@ if ($action == "set")
// Affiche version
if ($ok)
{
if ($ok) {
$version = $db->getVersion();
$versionarray = $db->getVersionArray();
print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
@ -145,13 +153,12 @@ if ($action == "set")
/**************************************************************************************
*
* Chargement fichiers tables/*.sql (non *.key.sql)
* A faire avant les fichiers *.key.sql
*
***************************************************************************************/
if ($ok && $createtables)
{
*
* Chargement fichiers tables/*.sql (non *.key.sql)
* A faire avant les fichiers *.key.sql
*
***************************************************************************************/
if ($ok && $createtables) {
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/tables/";
@ -160,12 +167,9 @@ if ($action == "set")
dolibarr_install_syslog("step2: open tables directory ".$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) && !preg_match('/\.key\.sql$/i', $file))
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file)) {
$tablefound++;
$tabledata[] = $file;
}
@ -175,18 +179,14 @@ if ($action == "set")
// Sort list of sql 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);
$buffer = '';
$fp = fopen($dir.$file, "r");
if ($fp)
{
while (!feof($fp))
{
if ($fp) {
while (!feof($fp)) {
$buf = fgets($fp, 4096);
if (substr($buf, 0, 2) <> '--')
{
if (substr($buf, 0, 2) <> '--') {
$buf = preg_replace('/--(.+)*/', '', $buf);
$buffer .= $buf;
}
@ -194,8 +194,7 @@ if ($action == "set")
fclose($fp);
$buffer = trim($buffer);
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
{
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
$buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer);
} else {
// Keyword ENGINE is MySQL-specific, so scrub it for
@ -205,8 +204,7 @@ if ($action == "set")
}
// 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);
}
@ -215,14 +213,12 @@ if ($action == "set")
dolibarr_install_syslog("step2: request: ".$buffer);
$resql = $db->query($buffer, 0, 'dml');
if ($resql)
{
if ($resql) {
// print "<td>OK requete ==== $buffer</td></tr>";
$db->free($resql);
} else {
if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
{
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS') {
//print "<td>Deja existante</td></tr>";
} else {
print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
@ -241,10 +237,8 @@ if ($action == "set")
}
}
if ($tablefound)
{
if ($error == 0)
{
if ($tablefound) {
if ($error == 0) {
print '<tr><td>';
print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
$ok = 1;
@ -257,13 +251,12 @@ if ($action == "set")
/***************************************************************************************
*
* Chargement fichiers tables/*.key.sql
* A faire apres les fichiers *.sql
*
***************************************************************************************/
if ($ok && $createkeys)
{
*
* Chargement fichiers tables/*.key.sql
* A faire apres les fichiers *.sql
*
***************************************************************************************/
if ($ok && $createkeys) {
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/tables/";
@ -272,12 +265,9 @@ if ($action == "set")
dolibarr_install_syslog("step2: open keys directory ".$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) && preg_match('/\.key\.sql$/i', $file))
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file)) {
$tablefound++;
$tabledata[] = $file;
}
@ -287,40 +277,33 @@ if ($action == "set")
// Sort list of sql 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);
//print "<tr><td>Creation de la table $name</td>";
$buffer = '';
$fp = fopen($dir.$file, "r");
if ($fp)
{
while (!feof($fp))
{
if ($fp) {
while (!feof($fp)) {
$buf = fgets($fp, 4096);
// Special case of lines allowed for some version only
if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg))
{
if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) {
$versioncommande = explode('.', $reg[1]);
//print var_dump($versioncommande);
//print var_dump($versionarray);
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande, $versionarray) <= 0)
{
&& versioncompare($versioncommande, $versionarray) <= 0) {
// Version qualified, delete SQL comments
$buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf);
//print "Ligne $i qualifiee par version: ".$buf.'<br>';
}
}
if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg))
{
if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) {
$versioncommande = explode('.', $reg[1]);
//print var_dump($versioncommande);
//print var_dump($versionarray);
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande, $versionarray) <= 0)
{
&& versioncompare($versioncommande, $versionarray) <= 0) {
// Version qualified, delete SQL comments
$buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf);
//print "Ligne $i qualifiee par version: ".$buf.'<br>';
@ -328,20 +311,19 @@ if ($action == "set")
}
// Ajout ligne si non commentaire
if (!preg_match('/^--/i', $buf)) $buffer .= $buf;
if (!preg_match('/^--/i', $buf)) {
$buffer .= $buf;
}
}
fclose($fp);
// Si plusieurs requetes, on boucle sur chaque
$listesql = explode(';', $buffer);
foreach ($listesql as $req)
{
foreach ($listesql as $req) {
$buffer = trim($req);
if ($buffer)
{
if ($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);
}
@ -350,8 +332,7 @@ if ($action == "set")
dolibarr_install_syslog("step2: request: ".$buffer);
$resql = $db->query($buffer, 0, 'dml');
if ($resql)
{
if ($resql) {
//print "<td>OK requete ==== $buffer</td></tr>";
$db->free($resql);
} else {
@ -359,8 +340,7 @@ if ($action == "set")
$db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
$db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
preg_match('/duplicate key name/i', $db->error()))
{
preg_match('/duplicate key name/i', $db->error())) {
//print "<td>Deja existante</td></tr>";
$key_exists = 1;
} else {
@ -382,8 +362,7 @@ if ($action == "set")
}
}
if ($tablefound && $error == 0)
{
if ($tablefound && $error == 0) {
print '<tr><td>';
print $langs->trans("OtherKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
$okkeys = 1;
@ -392,32 +371,32 @@ if ($action == "set")
/***************************************************************************************
*
* Chargement fichier functions.sql
*
***************************************************************************************/
if ($ok && $createfunctions)
{
*
* Chargement fichier functions.sql
*
***************************************************************************************/
if ($ok && $createfunctions) {
// For this file, we use a directory according to database type
if ($choix == 1) $dir = "mysql/functions/";
elseif ($choix == 2) $dir = "pgsql/functions/";
elseif ($choix == 3) $dir = "mssql/functions/";
elseif ($choix == 4) { $dir = "sqlite3/functions/"; }
if ($choix == 1) {
$dir = "mysql/functions/";
} elseif ($choix == 2) {
$dir = "pgsql/functions/";
} elseif ($choix == 3) {
$dir = "mssql/functions/";
} elseif ($choix == 4) {
$dir = "sqlite3/functions/";
}
// Creation donnees
$file = "functions.sql";
if (file_exists($dir.$file))
{
if (file_exists($dir.$file)) {
$fp = fopen($dir.$file, "r");
dolibarr_install_syslog("step2: open function file ".$dir.$file." handle=".$fp);
if ($fp)
{
if ($fp) {
$buffer = '';
while (!feof($fp))
{
while (!feof($fp)) {
$buf = fgets($fp, 4096);
if (substr($buf, 0, 2) <> '--')
{
if (substr($buf, 0, 2) <> '--') {
$buffer .= $buf."§";
}
}
@ -427,27 +406,22 @@ if ($action == "set")
// If several requests, we loop on each of them
$listesql = explode('§', $buffer);
foreach ($listesql as $buffer)
{
foreach ($listesql as $buffer) {
$buffer = trim($buffer);
if ($buffer)
{
if ($buffer) {
// Replace the prefix in table names
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);
print "<!-- Insert line : ".$buffer."<br>-->\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."<br>\n";
} else {
$ok = 0;
@ -463,8 +437,7 @@ if ($action == "set")
}
print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
if ($ok)
{
if ($ok) {
print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
} else {
print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
@ -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.'<br>';
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 "<tr><td>Insertion ligne : $buffer</td><td>";
} 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 "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
if ($ok)
{
if ($ok) {
print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
} else {
print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
@ -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);
}

View File

@ -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 '<table cellspacing="0" cellpadding="2">';
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
if ($db->ok)
{
if ($db->ok) {
print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
print '<input id="login" name="login" type="text" value="'.(!empty($_GET["login"]) ? GETPOST("login", 'alpha') : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')).'"'.(@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '').'></td></tr>';
print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
@ -87,15 +87,13 @@ if ($db->ok)
print '<input type="password" id="pass_verif" name="pass_verif" autocomplete="new-password"></td></tr>';
print '</table>';
if (isset($_GET["error"]) && $_GET["error"] == 1)
{
if (isset($_GET["error"]) && $_GET["error"] == 1) {
print '<br>';
print '<div class="error">'.$langs->trans("PasswordsMismatch").'</div>';
$error = 0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 2)
{
if (isset($_GET["error"]) && $_GET["error"] == 2) {
print '<br>';
print '<div class="error">';
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 '<br>';
print '<div class="error">'.$langs->trans("PleaseTypeALogin").'</div>';
$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);
}

View File

@ -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 '<br>';
// 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)."<br>";
$success = 1;
} else {
if ($newuser->error == 'ErrorLoginAlreadyExists')
{
if ($newuser->error == 'ErrorLoginAlreadyExists') {
dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING);
print '<br><div class="warning">'.$langs->trans("AdminLoginAlreadyExists", $login)."</div><br>";
$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).'<br>';
@ -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")."<br>";
}
}
// 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")."<br>";
$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 '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
@ -383,33 +398,29 @@ if ($action == "set" && $success)
print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
print '</a></div>';
}
}
// 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")."<br>";
$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 '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
@ -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);
}

View File

@ -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 '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans("DatabaseMigration").'</h3>';
@ -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 '<tr><td class="nowrap">';
print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.'</td><td class="right"><span class="neutral">'.$langs->trans("OK").'</span></td></tr>'."\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 '<tr><td class="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.'</td><td class="right"><span class="neutral">'.$langs->trans("OK")."</span></td></tr>\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 '<tr><td>'.$langs->trans("ServerVersion").'</td>';
print '<td class="right">'.$version.'</td></tr>';
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 '<tr><td>'.$langs->trans("ClientCharset").'</td>';
print '<td class="right">'.$tmparray->charset.'</td></tr>';
@ -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 "<tr><td>".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).'</td><td class="right"><span class="error">'.$langs->trans("Error")."</span></td></tr>\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)."<br>\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 '<tr><td><div class="warning">'.$langs->trans("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)."</div></td><td class=\"right\">".$langs->trans("Error")."</td></tr>\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 '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
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."<br>";
$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 '<tr><td colspan="2">'.$sqldrop.";</td></tr>\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 '<tr><td colspan="2"><span class="error">'.$sql.' : '.$db->lasterror()."</font></td></tr>\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 '<div class="error">'.$langs->trans("ErrorNoMigrationFilesFoundForParameters").'</div>';
} 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 '<tr><td colspan="2"><hr style="border-color: #ccc; border-top-style: none;"></td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ChoosedMigrateScript").'</td><td class="right">'.$file.'</td></tr>'."\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 '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ChoosedMigrateScript").' (external modules)</td><td class="right">'.$modulefileshort.'</td></tr>'."\n";
@ -401,24 +386,33 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
print '</table>';
if ($db->connected) $db->close();
if ($db->connected) {
$db->close();
}
}
if (empty($actiondone))
{
if (empty($actiondone)) {
print '<div class="error">'.$langs->trans("ErrorWrongParameters").'</div>';
}
$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);
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -416,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']);
@ -457,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');

View File

@ -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

View File

@ -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";

View File

@ -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 '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
print '</td>';
}
if (!empty($arrayfields['sp.total_vat']['checked']))
if (!empty($arrayfields['sp.total_tva']['checked']))
{
// Amount
print '<td class="liste_titre right">';
@ -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 '<td class="right">'.price($obj->total_vat)."</td>\n";
print '<td class="right">'.price($obj->total_tva)."</td>\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']))

View File

@ -3503,6 +3503,7 @@ table.hidepaginationnext .paginationnext {
}
/* Set the color for hover lines */
.oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover
{
@ -4632,6 +4633,10 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im
line-height: 1em;
}
#divbodywebsite section p {
margin: unset;
}
/* ============================================================================== */

View File

@ -4509,6 +4509,10 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im
line-height: 1em;
}
#divbodywebsite section p {
margin: unset;
}
/* ============================================================================== */
/* Module agenda */

View File

@ -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 '<!-- button EditInLine and ShowSubcontainers -->'."\n";
print '<div class="websiteselectionsection inline-block">';
print '<div class="inline-block marginrightonly">';
print '<div class="inline-block marginrightonly">'; // Button include dynamic contant
print $langs->trans("ShowSubcontainers");
if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
{
print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
else {
print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
print '</div>';
print '<div class="inline-block marginrightonly">'; // Button edit inline
print '<span id="switchckeditorinline">'."\n";
print '<!-- Code to enabled edit inline ckeditor -->'."\n";
@ -2812,17 +2824,7 @@ if (!GETPOST('hide_websitemenu'))
}
print '</div>';
print '<div class="inline-block marginrightonly">';
print $langs->trans("ShowSubcontainers");
if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
{
print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
else {
print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
/*}*/
print '</div>';
print '</div>';
// Set page as homepage
@ -4275,7 +4277,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
// REPLACEMENT OF LINKS When page called by website editor
$out .= '<!-- style of website from file -->'."\n";
$out .= '<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif !
$out .= '<style scoped>'."\n"; // "scoped" means "apply to parent element only and not grand parent". No more supported by browsers, snif !
$tmpout = '';
$tmpout .= '/* Include website CSS file */'."\n";
//$csscontent = @file_get_contents($filecss);

View File

@ -765,36 +765,36 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
*/
public function testDolTrunc()
{
// Default trunc (will add ... if truncation truncation or keep last char if only one char)
// Default trunc (will add if truncation truncation or keep last char if only one char)
$input="éeéeéeàa";
$after=dol_trunc($input, 3);
$this->assertEquals("éeé...", $after, 'Test A1');
$this->assertEquals("éeé", $after, 'Test A1');
$after=dol_trunc($input, 2);
$this->assertEquals("ée...", $after, 'Test A2');
$this->assertEquals("ée", $after, 'Test A2');
$after=dol_trunc($input, 1);
$this->assertEquals("é...", $after, 'Test A3');
$input="éeéeé";
$this->assertEquals("é", $after, 'Test A3');
$input="éeée";
$after=dol_trunc($input, 3);
$this->assertEquals("éeéeé", $after, 'Test B1');
$this->assertEquals("éeée", $after, 'Test B1');
$after=dol_trunc($input, 2);
$this->assertEquals("éeéeé", $after, 'Test B2');
$this->assertEquals("ée", $after, 'Test B2');
$after=dol_trunc($input, 1);
$this->assertEquals("é...", $after, 'Test B3');
$this->assertEquals("é", $after, 'Test B3');
$input="éeée";
$after=dol_trunc($input, 3);
$this->assertEquals("éeée", $after, 'Test C1');
$after=dol_trunc($input, 2);
$this->assertEquals("éeée", $after, 'Test C2');
$this->assertEquals("ée", $after, 'Test C2');
$after=dol_trunc($input, 1);
$this->assertEquals("éeée", $after, 'Test C3');
$this->assertEquals("é", $after, 'Test C3');
$input="éeé";
$after=dol_trunc($input, 3);
$this->assertEquals("éeé", $after, 'Test C');
$after=dol_trunc($input, 2);
$this->assertEquals("éeé", $after, 'Test D');
$after=dol_trunc($input, 1);
$this->assertEquals("é", $after, 'Test E');
// Trunc with no ...
$this->assertEquals("é", $after, 'Test E');
// Trunc with no
$input="éeéeéeàa";
$after=dol_trunc($input, 3, 'right', 'UTF-8', 1);
$this->assertEquals("éeé", $after, 'Test F');
@ -809,7 +809,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
$this->assertEquals("é", $after, 'Test J');
$input="éeéeéeàa";
$after=dol_trunc($input, 4, 'middle');
$this->assertEquals("ée...àa", $after, 'Test K');
$this->assertEquals("éeàa", $after, 'Test K');
return true;
}