diff --git a/ChangeLog b/ChangeLog index 20a01bef1c8..7daade7ae2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 50eb6c84def..6bfbb9c5c9c 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -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, ' '."\n"); - fputs($fp, ' '."\n"); + } + fputs($fp, ' '."\n"); $dir = $newdir; $needtoclose=1; } diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 5c5baaac3bc..0fe73fd9fb8 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -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`; diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 99061b24eab..d50c91d1f05 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -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 diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 065c0b06d08..54364cc3829 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -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"; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index a00c52b88e5..e19f01779aa 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Thibault FOUCART * * 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 '
'; @@ -743,31 +764,31 @@ if ($rowid > 0) { //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); print "\n".''."\n"; @@ -826,9 +847,6 @@ if ($rowid > 0) { print ''; $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 '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; diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 2b3bb6e8d21..46ed0c75934 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -120,7 +120,7 @@ if (function_exists('curl_init')) print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; } } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; } } diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 4ed21144346..42ebe6b97e5 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -374,14 +374,6 @@ if (!$error && $xml) } $out .= ''; $out .= ''; - - // 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.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; + $outcurrentchecksum = $checksumget.' - '.$langs->trans($resultcomment).''; } else { $resultcode = 'ok'; $resultcomment = 'Success'; @@ -426,7 +420,18 @@ if (!$error && $xml) $outcurrentchecksum = ''.$checksumget.''; } - print load_fiche_titre($langs->trans("GlobalChecksum")).'
'; + // 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.'
'; print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 2f5cb064a5e..0858d412b94 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -7,7 +7,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro - * Copyright (C) 2015-2019 Frédéric France + * Copyright (C) 2015-2021 Frédéric France * Copyright (C) 2015 Marcos García * Copyright (C) 2020 Open-Dsi * @@ -38,29 +38,61 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +} +if (!empty($conf->facture->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +} +if (!empty($conf->propal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +} +if (!empty($conf->commande->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +} +if (!empty($conf->expedition->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +} +if (!empty($conf->contrat->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} +if (!empty($conf->adherent->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +} +if (!empty($conf->ficheinter->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('companies', 'banks')); -if (!empty($conf->contrat->enabled)) $langs->load("contracts"); -if (!empty($conf->commande->enabled)) $langs->load("orders"); -if (!empty($conf->expedition->enabled)) $langs->load("sendings"); -if (!empty($conf->facture->enabled)) $langs->load("bills"); -if (!empty($conf->projet->enabled)) $langs->load("projects"); -if (!empty($conf->ficheinter->enabled)) $langs->load("interventions"); -if (!empty($conf->notification->enabled)) $langs->load("mails"); +if (!empty($conf->contrat->enabled)) { + $langs->load("contracts"); +} +if (!empty($conf->commande->enabled)) { + $langs->load("orders"); +} +if (!empty($conf->expedition->enabled)) { + $langs->load("sendings"); +} +if (!empty($conf->facture->enabled)) { + $langs->load("bills"); +} +if (!empty($conf->projet->enabled)) { + $langs->load("projects"); +} +if (!empty($conf->ficheinter->enabled)) { + $langs->load("interventions"); +} +if (!empty($conf->notification->enabled)) { + $langs->load("mails"); +} // Security check $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -if ($user->socid > 0) $id = $user->socid; +if ($user->socid > 0) { + $id = $user->socid; +} $result = restrictedArea($user, 'societe', $id, '&societe'); $action = GETPOST('action', 'aZ09'); @@ -69,12 +101,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "nom"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "nom"; +} $cancelbutton = GETPOST('cancel', 'alpha'); $object = new Client($db); @@ -97,11 +135,12 @@ if ($object->id > 0) { $now = dol_now(); -if ($id > 0 && empty($object->id)) -{ +if ($id > 0 && empty($object->id)) { // Load data of third party $res = $object->fetch($id); - if ($object->id < 0) dol_print_error($db, $object->error, $object->errors); + if ($object->id < 0) { + dol_print_error($db, $object->error, $object->errors); + } } @@ -112,105 +151,115 @@ if ($id > 0 && empty($object->id)) $parameters = array('id' => $id, 'socid' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancelbutton) - { +if (empty($reshook)) { + if ($cancelbutton) { $action = ""; } // set accountancy code - if ($action == 'setcustomeraccountancycode') - { + if ($action == 'setcustomeraccountancycode') { $result = $object->fetch($id); $object->code_compta = $_POST["customeraccountancycode"]; $result = $object->update($object->id, $user, 1, 1, 0); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) - { + if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // mode de reglement - if ($action == 'setmode' && $user->rights->societe->creer) - { + if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Bank account - if ($action == 'setbankaccount' && $user->rights->societe->creer) - { + if ($action == 'setbankaccount' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // customer preferred shipping method - if ($action == 'setshippingmethod' && $user->rights->societe->creer) - { + if ($action == 'setshippingmethod' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // assujetissement a la TVA - if ($action == 'setassujtva' && $user->rights->societe->creer) - { + if ($action == 'setassujtva' && $user->rights->societe->creer) { $object->fetch($id); $object->tva_assuj = $_POST['assujtva_value']; $result = $object->update($object->id); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // set prospect level - if ($action == 'setprospectlevel' && $user->rights->societe->creer) - { + if ($action == 'setprospectlevel' && $user->rights->societe->creer) { $object->fetch($id); $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // set communication status - if ($action == 'setstcomm') - { + if ($action == 'setstcomm') { $object->fetch($id); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - else $result = $object->fetch($object->id); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + $result = $object->fetch($object->id); + } } // update outstandng limit - if ($action == 'setoutstanding_limit') - { + if ($action == 'setoutstanding_limit') { $object->fetch($id); $object->outstanding_limit = GETPOST('outstanding_limit'); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // update order min amount - if ($action == 'setorder_min_amount') - { + if ($action == 'setorder_min_amount') { $object->fetch($id); $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha')); $result = $object->update($object->id, $user); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Set sales representatives - if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) - { + if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setSalesRep(GETPOST('commercial', 'array')); } @@ -222,22 +271,23 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; - if (!$error) - { + if ($ret < 0) { + $error++; + } + if (!$error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if ($error) $action = 'edit_extras'; + if ($error) { + $action = 'edit_extras'; + } } // warehouse - if ($action == 'setwarehouse' && $user->rights->societe->creer) - { + if ($action == 'setwarehouse' && $user->rights->societe->creer) { $result = $object->setWarehouse(GETPOST('fk_warehouse', 'int')); } } @@ -253,13 +303,14 @@ $form = new Form($db); $formcompany = new FormCompany($db); $title = $langs->trans("CustomerCard"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->name; +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($object->id > 0) -{ +if ($object->id > 0) { $head = societe_prepare_head($object); print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company'); @@ -279,15 +330,13 @@ if ($object->id > 0) print ''; // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { + if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print ''.$langs->trans("Prefix").''; print ($object->prefix_comm ? $object->prefix_comm : ' '); print ''; } - if ($object->client) - { + if ($object->client) { $langs->load("compta"); print ''; @@ -324,17 +373,14 @@ if ($object->id > 0) print ''; */ - if ($mysoc->country_code == 'ES') - { + if ($mysoc->country_code == 'ES') { // Local Taxes - if ($mysoc->localtax1_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print ''; } - if ($mysoc->localtax1_assuj == "1") - { + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); print ''; @@ -352,11 +398,12 @@ if ($object->id > 0) print ''; + if (($action != 'editconditions') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('PaymentConditions'); print ''; - if (($action != 'editconditions') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; print ''; - if ($action == 'editconditions') - { + if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none'); @@ -369,11 +416,12 @@ if ($object->id > 0) print ''; + if (($action != 'editmode') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('PaymentMode'); print ''; - if (($action != 'editmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; - if ($action == 'editmode') - { + if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'none'); @@ -381,18 +429,18 @@ if ($object->id > 0) print ""; print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // Compte bancaire par défaut print ''; print ''; + if (($action != 'editbankaccount') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('PaymentBankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print ''; - if ($action == 'editbankaccount') - { + if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'fk_account', 1); } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'none'); @@ -404,14 +452,12 @@ if ($object->id > 0) $isCustomer = ($object->client == 1 || $object->client == 3); // Relative discounts (Discounts-Drawbacks-Rebates) - if ($isCustomer) - { + if ($isCustomer) { print ''; print '
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->socid > 0) - { + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; @@ -424,24 +470,26 @@ if ($object->id > 0) print ''; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->socid > 0) - { + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''; print ''; $amount_discount = $object->getAvailableDiscounts(); - if ($amount_discount < 0) dol_print_error($db, $object->error); - if ($amount_discount > 0) print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + if ($amount_discount < 0) { + dol_print_error($db, $object->error); + } + if ($amount_discount > 0) { + print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + } //else print $langs->trans("DiscountNone"); print ''; print ''; } // Max outstanding bill - if ($object->client) - { + if ($object->client) { print ''; print ''; print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer); @@ -452,10 +500,8 @@ if ($object->id > 0) print ''; } - if ($object->client) - { - if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) - { + if ($object->client) { + if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print ''."\n"; print ''; print ''; @@ -469,27 +515,26 @@ if ($object->id > 0) // Multiprice level - if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print ''; print '
'; print $langs->trans("PriceLevel"); print ''; - if ($user->rights->societe->creer) - { + if ($user->rights->societe->creer) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print ''; print $object->price_level; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level; - if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + if (!empty($conf->global->$keyforlabel)) { + print ' - '.$langs->trans($conf->global->$keyforlabel); + } print ""; print ''; } // Warehouse - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -511,11 +556,12 @@ if ($object->id > 0) print ''; + if (($action != 'editshipping') && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('SendingMethod'); print ''; - if (($action != 'editshipping') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; - if ($action == 'editshipping') - { + if ($action == 'editshipping') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'none'); @@ -524,8 +570,7 @@ if ($object->id > 0) print ''; } - if (!empty($conf->intracommreport->enabled)) - { + if (!empty($conf->intracommreport->enabled)) { // Transport mode by default print ''; print '"; @@ -584,8 +628,7 @@ if ($object->id > 0) print "
'; @@ -538,8 +583,7 @@ if ($object->id > 0) print ''; if ($action == 'edittransportmode') { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); - } - else { + } else { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); } print "
"; // Prospection level and status - if ($object->client == 2 || $object->client == 3) - { + if ($object->client == 2 || $object->client == 3) { print '
'; print '
'; @@ -596,11 +639,12 @@ if ($object->id > 0) print ''; + if ($action != 'editlevel' && $user->rights->societe->creer) { + print ''; + } print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'), 1).'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; print ''; - if ($action == 'editlevel') - { + if ($action == 'editlevel') { $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_prospectlevel, 'prospect_level_id', 1); } else { print $object->getLibProspLevel(); @@ -613,11 +657,14 @@ if ($object->id > 0) print ''.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '     '; print '
'; - foreach ($object->cacheprospectstatus as $key => $val) - { + foreach ($object->cacheprospectstatus as $key => $val) { $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($object->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } } print '
'; print ""; @@ -636,8 +683,7 @@ if ($object->id > 0) $boxstat .= ''; $boxstat .= '
'; - if (!empty($conf->propal->enabled) && $user->rights->propal->lire) - { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { // Box proposals $tmp = $object->getOutstandingProposals(); $outstandingOpened = $tmp['opened']; @@ -646,16 +692,19 @@ if ($object->id > 0) $text = $langs->trans("OverAllProposals"); $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } } - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { // Box commandes $tmp = $object->getOutstandingOrders(); $outstandingOpened = $tmp['opened']; @@ -664,16 +713,19 @@ if ($object->id > 0) $text = $langs->trans("OverAllOrders"); $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } } - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { // Box factures $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; @@ -683,28 +735,35 @@ if ($object->id > 0) $text = $langs->trans("OverAllInvoices"); $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } // Box outstanding bill $warn = ''; - if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) - { + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) { $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } $text = $langs->trans("CurrentOutstandingBill"); $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } $tmp = $object->getOutstandingBills('customer', 1); $outstandingOpenedLate = $tmp['opened']; @@ -716,12 +775,16 @@ if ($object->id > 0) $text = $langs->trans("CurrentOutstandingBillLate"); $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; + if ($link) { + $boxstat .= ''; + } $boxstat .= '
'; $boxstat .= ''.img_object("", $icon).' '.$text.'
'; $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= '
'; - if ($link) $boxstat .= '
'; + if ($link) { + $boxstat .= ''; + } } } @@ -741,13 +804,12 @@ if ($object->id > 0) /* * Latest proposals */ - if (!empty($conf->propal->enabled) && $user->rights->propal->lire) - { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; - $sql .= ", p.tva as total_tva"; - $sql .= ", p.total as total_ttc"; + $sql .= ", p.total_tva"; + $sql .= ", p.total_ttc"; $sql .= ", p.ref, p.ref_client, p.remise"; $sql .= ", p.datep as dp, p.fin_validite as date_limit"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; @@ -757,13 +819,11 @@ if ($object->id > 0) $sql .= " ORDER BY p.datep DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $propal_static = new Propal($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -775,8 +835,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); print ''; @@ -798,8 +857,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -811,11 +869,10 @@ if ($object->id > 0) /* * Latest orders */ - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql = "SELECT s.nom, s.rowid"; $sql .= ", c.rowid as cid, c.total_ht"; - $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture"; $sql .= ", c.date_commande as dc"; @@ -826,13 +883,11 @@ if ($object->id > 0) $sql .= " ORDER BY c.date_commande DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $commande_static = new Commande($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { // Check if there are orders billable $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; @@ -858,8 +913,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $commande_static->id = $objp->cid; @@ -880,8 +934,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print ''; } @@ -891,10 +944,9 @@ if ($object->id > 0) } /* - * Latest shipments - */ - if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) - { + * Latest shipments + */ + if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sql = 'SELECT e.rowid as id'; $sql .= ', e.ref'; $sql .= ', e.date_creation'; @@ -913,8 +965,7 @@ if ($object->id > 0) $sql .= " ORDER BY e.date_creation DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $sendingstatic = new Expedition($db); $num = $db->num_rows($resql); @@ -930,8 +981,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $sendingstatic->id = $objp->id; @@ -953,8 +1003,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print ""; print ''; } @@ -966,8 +1015,7 @@ if ($object->id > 0) /* * Latest contracts */ - if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) - { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; @@ -976,13 +1024,11 @@ if ($object->id > 0) $sql .= " ORDER BY c.datec DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $contrat = new Contrat($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -995,8 +1041,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $contrat->id = $objp->id; @@ -1009,7 +1054,9 @@ if ($object->id > 0) $late = ''; foreach ($contrat->lines as $line) { if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { - if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) { + $late = img_warning($langs->trans("Late")); + } } } @@ -1030,8 +1077,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -1043,8 +1089,7 @@ if ($object->id > 0) /* * Latest interventions */ - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) - { + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; @@ -1053,13 +1098,11 @@ if ($object->id > 0) $sql .= " ORDER BY f.tms DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $fichinter_static = new Fichinter($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -1071,8 +1114,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $fichinter_static->id = $objp->id; @@ -1092,8 +1134,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
"; print '
'; } @@ -1105,8 +1146,7 @@ if ($object->id > 0) /* * Latest invoices templates */ - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as id, f.titre as ref'; $sql .= ', f.total as total_ht'; $sql .= ', f.tva as total_tva'; @@ -1127,13 +1167,11 @@ if ($object->id > 0) $sql .= " ORDER BY f.date_last_gen, f.datec DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $invoicetemplate = new FactureRec($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -1144,8 +1182,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $invoicetemplate->id = $objp->id; @@ -1163,12 +1200,10 @@ if ($object->id > 0) print ''; - if ($objp->frequency && $objp->date_last_gen > 0) - { + if ($objp->frequency && $objp->date_last_gen > 0) { print ''; } else { - if ($objp->dc > 0) - { + if ($objp->dc > 0) { print ''; } else { print ''; @@ -1178,8 +1213,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) - { + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print ''; @@ -1194,8 +1228,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
'; print $invoicetemplate->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->date_last_gen), 'day').''.dol_print_date($db->jdate($objp->dc), 'day').'!!!'; print price($objp->total_ttc); print '
"; print '
'; } @@ -1207,8 +1240,7 @@ if ($object->id > 0) /* * Latest invoices */ - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as facid, f.ref, f.type'; $sql .= ', f.total as total_ht'; $sql .= ', f.tva as total_tva'; @@ -1226,13 +1258,11 @@ if ($object->id > 0) $sql .= " ORDER BY f.datef DESC, f.datec DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $facturestatic = new Facture($db); $num = $db->num_rows($resql); - if ($num > 0) - { + if ($num > 0) { print '
'; print ''; @@ -1244,8 +1274,7 @@ if ($object->id > 0) } $i = 0; - while ($i < $num && $i < $MAXLIST) - { + while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $facturestatic->id = $objp->facid; @@ -1260,8 +1289,7 @@ if ($object->id > 0) print ''; - if ($objp->df > 0) - { + if ($objp->df > 0) { print ''; } else { print ''; @@ -1270,8 +1298,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) - { + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print ''; @@ -1283,8 +1310,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num > 0) - { + if ($num > 0) { print "
'; print $facturestatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->df), 'day').'!!!'; print price($objp->total_ttc); print '
"; print '
'; } @@ -1296,8 +1322,11 @@ if ($object->id > 0) // Allow external modules to add their own shortlist of recent objects $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - else print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } else { + print $hookmanager->resPrint; + } print ''; print '
'; @@ -1314,73 +1343,68 @@ if ($object->id > 0) $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - if (empty($reshook)) - { - if ($object->status != 1) - { + if (empty($reshook)) { + if ($object->status != 1) { print ''; } - if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) - { + if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) { $langs->load("propal"); print ''; } - if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) - { + if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) { $langs->load("orders"); print ''; } - if ($user->rights->contrat->creer && $object->status == 1) - { + if ($user->rights->contrat->creer && $object->status == 1) { $langs->load("contracts"); print ''; } - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) - { + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) { $langs->load("fichinter"); print ''; } // Add invoice - if ($user->socid == 0) - { - if (!empty($conf->deplacement->enabled) && $object->status == 1) - { + if ($user->socid == 0) { + if (!empty($conf->deplacement->enabled) && $object->status == 1) { $langs->load("trips"); print ''; } - if (!empty($conf->facture->enabled) && $object->status == 1) - { - if (empty($user->rights->facture->creer)) - { + if (!empty($conf->facture->enabled) && $object->status == 1) { + if (empty($user->rights->facture->creer)) { print ''; } else { $langs->loadLangs(array("orders", "bills")); - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { if ($object->client != 0 && $object->client != 2) { - if (!empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; - } else print ''; + if (!empty($orders2invoice) && $orders2invoice > 0) { + print ''; + } else { + print ''; + } + } else { + print ''; + } } - if ($object->client != 0 && $object->client != 2) print ''; - else print ''; + if ($object->client != 0 && $object->client != 2) { + print ''; + } else { + print ''; + } } } } // Add action - if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) - { - if ($user->rights->agenda->myactions->create) - { + if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { + if ($user->rights->agenda->myactions->create) { print ''; } else { print ''; @@ -1390,14 +1414,12 @@ if ($object->id > 0) print ''; - if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) - { + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) { // List of contacts show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } - if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { + if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); // List of todo actions diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 46636f93812..899c9275d31 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -29,7 +29,9 @@ require '../main.inc.php'; -if (!$user->rights->societe->lire) accessforbidden(); +if (!$user->rights->societe->lire) { + accessforbidden(); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; @@ -73,10 +75,18 @@ $now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); $companystatic = new Societe($db); -if (!empty($conf->propal->enabled)) $propalstatic = new Propal($db); -if (!empty($conf->supplier_proposal->enabled)) $supplierproposalstatic = new SupplierProposal($db); -if (!empty($conf->commande->enabled)) $orderstatic = new Commande($db); -if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) $supplierorderstatic = new CommandeFournisseur($db); +if (!empty($conf->propal->enabled)) { + $propalstatic = new Propal($db); +} +if (!empty($conf->supplier_proposal->enabled)) { + $supplierproposalstatic = new SupplierProposal($db); +} +if (!empty($conf->commande->enabled)) { + $orderstatic = new Commande($db); +} +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { + $supplierorderstatic = new CommandeFournisseur($db); +} llxHeader("", $langs->trans("CommercialArea")); @@ -118,10 +128,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { print ''; $i = 0; foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; print ''; - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; $i++; } @@ -137,7 +151,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { * Draft customer proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status"; + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -145,12 +159,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -228,7 +248,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { * Draft supplier proposals */ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status"; + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -236,12 +256,18 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")"; $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT; $sql .= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -318,7 +344,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa * Draft customer orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, c.fk_statut as status"; + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -326,12 +352,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT; $sql .= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND c.fk_soc = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -417,12 +449,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")"; $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT; $sql .= " AND cf.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND cf.fk_soc = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -509,11 +547,17 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $sql .= ", s.canvas"; $sql .= ", s.datec, s.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = $socid"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = $socid"; + } $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); @@ -521,11 +565,9 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { if ($resql) { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $header = "BoxTitleLastCustomersOrProspects"; - } - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $header = "BoxTitleLastModifiedProspects"; - } - else { + } else { $header = "BoxTitleLastModifiedCustomers"; } @@ -559,12 +601,10 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $obj = $companystatic; $s = ''; - if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { + if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; } - if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { + if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; } /* @@ -603,11 +643,17 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= ", s.canvas"; $sql .= ", s.datec as dc, s.tms as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; $sql .= " AND s.fournisseur = ".Societe::SUPPLIER; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); @@ -649,8 +695,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; }*/ - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; } print $s; @@ -704,12 +749,18 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max + 1, 0); @@ -765,7 +816,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T * Opened (validated) proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $sql = "SELECT p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -773,12 +824,18 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY p.rowid DESC"; $resql = $db->query($sql); @@ -875,7 +932,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { * Opened (validated) order */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; + $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -883,12 +940,18 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY c.rowid DESC"; $resql = $db->query($sql); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index aadc1f55281..b3da95919e8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -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").","; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index c274ebf74f3..b02ac911bad 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -29,8 +29,7 @@ require '../../main.inc.php'; // Security check $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -66,8 +65,7 @@ print '
'; print '
'; // This is useless due to the global search combo -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) -{ +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { print '
'; print '
'; print ''; @@ -97,16 +95,21 @@ $listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::ST $sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; -if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($user->socid) { + $sql .= ' AND p.fk_soc = '.$user->socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " AND p.fk_statut IN (".implode(" ,", $listofstatus).")"; $sql .= " GROUP BY p.fk_statut"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; @@ -115,11 +118,9 @@ if ($resql) $colorseries = array(); $vals = array(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $vals[$obj->status] = $obj->nb; $totalinprocess += $obj->nb; @@ -140,11 +141,21 @@ if ($resql) foreach ($listofstatus as $status) { $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4; - if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9; - if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6; + if ($status == Propal::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Propal::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Propal::STATUS_SIGNED) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Propal::STATUS_NOTSIGNED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == Propal::STATUS_BILLED) { + $colorseries[$status] = $badgeStatus6; + } if (empty($conf->use_javascript_ajax)) { print '
'; @@ -198,16 +209,22 @@ if ($resql) * Draft proposals */ if (!empty($conf->propal->enabled)) { - $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total as total_ttc"; + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc"; $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut =".Propal::STATUS_DRAFT; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND p.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND p.fk_soc = ".$socid; + } $resql = $db->query($sql); if ($resql) { @@ -271,12 +288,18 @@ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, date_cloture as datec"; $sql .= ", s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE c.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND c.fk_soc = s.rowid"; //$sql.= " AND c.fk_statut > 2"; -if ($socid) $sql .= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) { + $sql .= " AND c.fk_soc = ".$socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max, 0); @@ -336,15 +359,21 @@ if ($resql) { */ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= ", p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY p.rowid DESC"; $resql = $db->query($sql); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d05543530d1..ef78cd32c9d 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -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); diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 7ae61362f09..a9681f199da 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; $langs->load("propal"); -if ($user->socid > 0) -{ +if ($user->socid > 0) { $socid = $user->socid; } @@ -53,8 +52,7 @@ print load_fiche_titre($langs->trans("ProspectionArea")); print '
'; -if (!empty($conf->propal->enabled)) -{ +if (!empty($conf->propal->enabled)) { $var = false; print ''; print ''; @@ -75,26 +73,27 @@ if (!empty($conf->propal->enabled)) $sql = "SELECT count(*) as cc, st.libelle, st.picto, st.id"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE s.fk_stcomm = st.id"; $sql .= " AND s.client IN (2, 3)"; $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " GROUP BY st.id"; $sql .= " ORDER BY st.id"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'
'; print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '"; - if ($ok) - { + if ($ok) { print ''; } else { print ''; @@ -475,12 +448,11 @@ if ($action == "set") /*************************************************************************************** - * - * Load files data/*.sql - * - ***************************************************************************************/ - if ($ok && $createdata) - { + * + * Load files data/*.sql + * + ***************************************************************************************/ + if ($ok && $createdata) { // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax) $dir = "mysql/data/"; @@ -489,17 +461,15 @@ if ($action == "set") dolibarr_install_syslog("step2: open directory data ".$dir." handle=".$handle); $tablefound = 0; $tabledata = array(); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) - { - if (preg_match('/^llx_accounting_account_/', $file)) continue; // We discard data file of chart of account. Will be loaded when a chart is selected. + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) { + if (preg_match('/^llx_accounting_account_/', $file)) { + continue; // We discard data file of chart of account. Will be loaded when a chart is selected. + } //print 'x'.$file.'-'.$createdata.'
'; - if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) - { + if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) { $tablefound++; $tabledata[] = $file; } @@ -510,33 +480,33 @@ if ($action == "set") // Sort list of data files on alphabetical order (load order is important) sort($tabledata); - foreach ($tabledata as $file) - { + foreach ($tabledata as $file) { $name = substr($file, 0, dol_strlen($file) - 4); $fp = fopen($dir.$file, "r"); dolibarr_install_syslog("step2: open data file ".$dir.$file." handle=".$fp); - if ($fp) - { + if ($fp) { $arrayofrequests = array(); $linefound = 0; $linegroup = 0; $sizeofgroup = 1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1. // Load all requests - while (!feof($fp)) - { + while (!feof($fp)) { $buffer = fgets($fp, 4096); $buffer = trim($buffer); - if ($buffer) - { - if (substr($buffer, 0, 2) == '--') continue; + if ($buffer) { + if (substr($buffer, 0, 2) == '--') { + continue; + } - if ($linefound && ($linefound % $sizeofgroup) == 0) - { + if ($linefound && ($linefound % $sizeofgroup) == 0) { $linegroup++; } - if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup] = $buffer; - else $arrayofrequests[$linegroup] .= " ".$buffer; + if (empty($arrayofrequests[$linegroup])) { + $arrayofrequests[$linegroup] = $buffer; + } else { + $arrayofrequests[$linegroup] .= " ".$buffer; + } $linefound++; } @@ -549,22 +519,18 @@ if ($action == "set") $db->begin(); // We loop on each requests of file - foreach ($arrayofrequests as $buffer) - { + foreach ($arrayofrequests as $buffer) { // Replace the prefix tables - if ($dolibarr_main_db_prefix != 'llx_') - { + if ($dolibarr_main_db_prefix != 'llx_') { $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } //dolibarr_install_syslog("step2: request: " . $buffer); $resql = $db->query($buffer, 1); - if ($resql) - { + if ($resql) { //$db->free($resql); // Not required as request we launch here does not return memory needs. } else { - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { //print ""; - if ($ok) - { + if ($ok) { print ''; } else { print ''; @@ -595,7 +563,9 @@ if ($action == "set") $ret = 0; -if (!$ok && isset($argv[1])) $ret = 1; +if (!$ok && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step2: end"); @@ -621,7 +591,11 @@ print $out; pFooter($ok ? 0 : 1, $setuplang); -if (isset($db) && is_object($db)) $db->close(); +if (isset($db) && is_object($db)) { + $db->close(); +} // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index ca188ae4d5b..7d03c7b6fd0 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -40,7 +40,9 @@ $langs->loadLangs(array("admin", "install")); // Now we load forced value from install.forced.php file. $useforcedwizard = false; $forcedfile = "./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -60,8 +62,7 @@ $ok = 0; pHeader($langs->trans("AdminAccountCreation"), "step5"); // Test if we can run a first install process -if (!is_writable($conffile)) -{ +if (!is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); pFooter(1, $setuplang, 'jscheckparam'); exit; @@ -77,8 +78,7 @@ print '
'.$langs->trans("ProspectsByStatus").'
'; @@ -112,31 +111,31 @@ if ($resql) /* * Liste des propal brouillons */ -if (!empty($conf->propal->enabled) && $user->rights->propale->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_statut = 0"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '
'.$langs->trans("ProposalsDraft").'
'; @@ -164,41 +163,45 @@ print '
'; /* * Actions commerciales a faire */ -if (!empty($conf->agenda->enabled)) show_array_actions_to_do(10); +if (!empty($conf->agenda->enabled)) { + show_array_actions_to_do(10); +} /* * Dernieres propales ouvertes */ -if (!empty($conf->propal->enabled) && $user->rights->propale->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,"; - $sql .= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; + $sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."c_propalst as c"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = c.id"; $sql .= " AND p.fk_statut = 1"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.rowid = ".$socid; + } $sql .= " ORDER BY p.rowid DESC"; $sql .= $db->plimit(5, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print '"; } print "
'.$langs->trans("ProposalsOpened").'
'; @@ -218,8 +221,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) $i++; $total += $obj->price; } - if ($total > 0) - { + if ($total > 0) { print '
'.$langs->trans("Total")."".price($total)."

"; @@ -235,25 +237,26 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) */ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE s.fk_stcomm = 1"; $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " ORDER BY s.tms ASC"; $sql .= $db->plimit(15, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index dc397d286cc..8a50619f17c 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -831,7 +831,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $sql .= ", s.nom as name, s.email"; $sql .= ", s.rowid as socid"; $sql .= ", s.code_client, s.code_compta"; - $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.tva as total_tva, c.total_ttc,"; + $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.total_tva, c.total_ttc,"; $sql .= " cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -849,7 +849,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters); $sql .= $hookmanager->resPrint; - $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; + $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_tva, c.total_ttc, cc.rowid, cc.code"; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 943c704b17f..3866405bee8 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -821,7 +821,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; print ''; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index cd1db0bbc9a..d625298b14c 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -9,7 +9,7 @@ * Copyright (C) 2014-2020 Ferran Marcet * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -768,8 +768,7 @@ if (empty($reshook)) } // Close all lines - elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) - { + elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->closeAll($user); if ($result < 0) { @@ -778,15 +777,13 @@ if (empty($reshook)) } // Close all lines - elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) - { + elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->activateAll($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) - { + } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { $result = $object->delete($user); if ($result >= 0) { @@ -795,13 +792,12 @@ if (empty($reshook)) } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) - { + } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { if (GETPOST('newcid') > 0) { $contractline = new ContratLigne($db); - $result = $contractline->fetch(GETPOST('lineid')); - $contractline->fk_contrat = GETPOST('newcid'); + $result = $contractline->fetch(GETPOSTINT('lineid')); + $contractline->fk_contrat = GETPOSTINT('newcid'); $result = $contractline->update($user, 1); if ($result >= 0) { @@ -871,8 +867,7 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } elseif ($action == 'setref') - { + } elseif ($action == 'setref') { $cancelbutton = GETPOST('cancel', 'alpha'); if (!$cancelbutton) { @@ -909,8 +904,7 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - } elseif ($action == 'setdate_contrat') - { + } elseif ($action == 'setdate_contrat') { $cancelbutton = GETPOST('cancel', 'alpha'); if (!$cancelbutton) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4fa506a23f4..892cb8ae4e0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -3,7 +3,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2019 Ferran Marcet - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1126,18 +1126,47 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) if ($result > 0) { $result = $objecttmp->validate($user); - if ($result == 0) - { + if ($result == 0) { $langs->load("errors"); setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); $error++; break; - } elseif ($result < 0) - { + } elseif ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; + } else { + // validate() rename pdf but do not regenerate + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $objecttmp->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->load('products'); + } + $model = $objecttmp->model_pdf; + $ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records + // To be sure vars is defined + $hidedetails = !empty($hidedetails) ? $hidedetails : 0; + $hidedesc = !empty($hidedesc) ? $hidedesc : 0; + $hideref = !empty($hideref) ? $hideref : 0; + $moreparams = !empty($moreparams) ? $moreparams : null; + + $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + } + } + $nbok++; + } } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 1585241b843..b0dc89f5817 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2014-2019 Frederic France + * Copyright (C) 2014-2021 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,8 +100,7 @@ class box_activity extends ModeleBoxes // list the summary of the propals - if (!empty($conf->propal->enabled) && $user->rights->propale->lire) - { + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $propalstatic = new Propal($this->db); @@ -109,24 +108,28 @@ class box_activity extends ModeleBoxes $filename = '/boxactivity-propal'.$fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $data = array(); - if ($refresh) - { - $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; + if ($refresh) { + $sql = "SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= ")"; $sql .= " WHERE p.entity IN (".getEntity('propal').")"; $sql .= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($user->socid) { + $sql .= " AND s.rowid = ".$user->socid; + } $sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; $sql .= " AND p.date_cloture IS NULL"; // just unclosed $sql .= " GROUP BY p.fk_statut"; $sql .= " ORDER BY p.fk_statut DESC"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $j = 0; @@ -145,11 +148,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (!empty($data)) - { + if (!empty($data)) { $j = 0; - while ($j < count($data)) - { + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 9b020a05711..f13f7ffa1f9 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -98,7 +98,7 @@ class box_commandes extends ModeleBoxes $sql .= ", c.fk_user_valid"; $sql .= ", c.facture"; $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 6efd56c01db..a6a023952d4 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015-2019 Frederic France + * Copyright (C) 2015-2021 Frederic France * Copyright (C) 2020 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify @@ -83,26 +83,33 @@ class box_propales extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."Propals", $max)); - if ($user->rights->propale->lire) - { + if ($user->rights->propale->lire) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; + $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; - else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + if (!$user->rights->societe->client->voir && !$user->socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($user->socid) { + $sql .= " AND s.rowid = ".$user->socid; + } + if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) { + $sql .= " ORDER BY p.datep DESC, p.ref DESC "; + } else { + $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + } $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $now = dol_now(); @@ -168,11 +175,12 @@ class box_propales extends ModeleBoxes $line++; } - if ($num == 0) + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProposals"), ); + } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 5074d403231..c91068b1ff3 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -88,7 +88,7 @@ class box_supplier_orders extends ModeleBoxes $sql .= ", s.logo, s.email, s.entity"; $sql .= ", c.rowid, c.ref, c.tms, c.date_commande"; $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; $sql .= ", c.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 22f669966f3..2c1dc49161e 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -88,7 +88,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $sql .= ", s.logo, s.email, s.entity"; $sql .= ", c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison as delivery_date"; $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; $sql .= ", c.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cf22db4670d..09e8ec4a00b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1412,6 +1412,8 @@ abstract class CommonObject if ($resql) { $num = $this->db->num_rows($resql); if ($num > 0) { + $langs->loadLangs(array("propal", "orders", "bills", "suppliers", "contracts", "supplier_proposal")); + while ($obj = $this->db->fetch_object($resql)) { $modulename = $obj->element; if (strpos($obj->element, 'project') !== false) { @@ -1427,11 +1429,15 @@ abstract class CommonObject } if (!empty($conf->{$modulename}->enabled)) { $libelle_element = $langs->trans('ContactDefault_'.$obj->element); - $transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code; + $tmpelement = $obj->element; + $transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); - if (empty($option)) + if (empty($option)) { $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; - else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; + } + else { + $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; + } } } } @@ -3230,12 +3236,11 @@ abstract class CommonObject // Specific code for backward compatibility with old field names if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva'; - if ($this->element == 'propal') { - $fieldttc = 'total'; - $fieldtva = 'total_tva'; - } + if ($this->element == 'propal') $fieldtva = 'total_tva'; if ($this->element == 'expensereport') $fieldtva = 'total_tva'; - if ($this->element == 'supplier_proposal') $fieldttc = 'total'; + if ($this->element == 'supplier_proposal') $fieldtva = 'total_tva'; + if ($this->element == 'commande') $fieldtva = 'total_tva'; + if ($this->element == 'order_supplier') $fieldtva = 'total_tva'; if (empty($nodatabaseupdate)) { diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 8cff096e56a..1ed2af9aa2d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -824,7 +824,7 @@ class FormCompany extends Form } if (count($newselected) > 0) $selected = $newselected; } - return $this->multiselectarray($htmlname, $contactType, $selected); + return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, 'minwidth500'); } return 'ErrorBadValueForParameterRenderMode'; // Should not happened diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4d56fd9697a..310f34a86fb 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -52,10 +52,10 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) { if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; + // Enable caching of thirdrparty count Contacts + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_contacts_thirdparty_'.$object->id; $dataretrieved = dol_getcache($cachekey); @@ -71,7 +71,7 @@ function societe_prepare_head(Societe $object) $nbContact = $obj->nb; } - dol_setcache($cachekey, $nbContact); // If setting cache fails, this is not a problem, so we do not test result. + dol_setcache($cachekey, $nbContact, 120); // If setting cache fails, this is not a problem, so we do not test result. } $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; @@ -129,22 +129,32 @@ function societe_prepare_head(Societe $object) } if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) { - $nbNote = 0; - $sql = "SELECT COUNT(n.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; - $sql .= " WHERE fk_soc = ".$object->id; - $sql .= " AND entity IN (".getEntity('project').")"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $nbNote = $obj->nb; + $nbProject = 0; + // Enable caching of thirdrparty count projects + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_projects_thirdparty_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + + if (!is_null($dataretrieved)) { + $nbProject = $dataretrieved; } else { - dol_print_error($db); + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $sql .= " AND entity IN (".getEntity('project').")"; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbProject = $obj->nb; + } else { + dol_print_error($db); + } + dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result. } $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; $head[$h][1] = $langs->trans("Projects"); - if ($nbNote > 0) { - $head[$h][1] .= ''.$nbNote.''; + if ($nbProject > 0) { + $head[$h][1] .= ''.$nbProject.''; } $head[$h][2] = 'project'; $h++; @@ -271,10 +281,9 @@ function societe_prepare_head(Societe $object) if ($user->socid == 0) { // Notifications if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $nbNotif = 0; // Enable caching of thirdrparty count notifications + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_notifications_thirdparty_'.$object->id; $dataretrieved = dol_getcache($cachekey); if (!is_null($dataretrieved)) { @@ -290,7 +299,7 @@ function societe_prepare_head(Societe $object) } else { dol_print_error($db); } - dol_setcache($cachekey, $nbNotif); // If setting cache fails, this is not a problem, so we do not test result. + dol_setcache($cachekey, $nbNotif, 120); // If setting cache fails, this is not a problem, so we do not test result. } $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id; @@ -318,17 +327,28 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'note'; $h++; - // Attached files - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; - $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); + // Attached files and Links + $totalAttached = 0; + // Enable caching of thirdrparty count attached files and links + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_attached_thirdparty_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $totalAttached = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks = Link::count($db, $object->element, $object->id); + $totalAttached = $nbFiles + $nbLinks; + dol_setcache($cachekey, $totalAttached, 120); // If setting cache fails, this is not a problem, so we do not test result. + } $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles + $nbLinks) > 0) { - $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + if (($totalAttached) > 0) { + $head[$h][1] .= ''.($totalAttached).''; } $head[$h][2] = 'document'; $h++; @@ -337,10 +357,9 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; $head[$h][1] = $langs->trans("Events"); if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $nbEvent = 0; // Enable caching of thirdrparty count actioncomm + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_events_thirdparty_'.$object->id; $dataretrieved = dol_getcache($cachekey); if (!is_null($dataretrieved)) { @@ -356,7 +375,7 @@ function societe_prepare_head(Societe $object) } else { dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR); } - dol_setcache($cachekey, $nbEvent); // If setting cache fails, this is not a problem, so we do not test result. + dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result. } $head[$h][1] .= '/'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7d994616e5c..5457a6859e3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2450,21 +2450,32 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, function getArrayOfSocialNetworks() { global $conf, $db; - $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; - $sql .= " WHERE entity=".$conf->entity; + $socialnetworks = array(); - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $socialnetworks[$obj->code] = array( - 'rowid' => $obj->rowid, - 'label' => $obj->label, - 'url' => $obj->url, - 'icon' => $obj->icon, - 'active' => $obj->active, - ); + // Enable caching of array + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'socialnetworks_' . $conf->entity; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $socialnetworks = $dataretrieved; + } else { + $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; + $sql .= " WHERE entity=".$conf->entity; + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'icon' => $obj->icon, + 'active' => $obj->active, + ); + } } + dol_setcache($cachekey, $socialnetworks); // If setting cache fails, this is not a problem, so we do not test result. } + return $socialnetworks; } @@ -3173,15 +3184,15 @@ function dol_substr($string, $start, $length, $stringencoding = '', $trunconbyte /** - * Truncate a string to a particular length adding '...' if string larger than length. - * If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'. + * Truncate a string to a particular length adding '…' if string larger than length. + * If length = max length+1, we do no truncate to avoid having just 1 char replaced with '…'. * MAIN_DISABLE_TRUNC=1 can disable all truncings * * @param string $string String to truncate - * @param int $size Max string size visible (excluding ...). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added ..., or if size was max+1 or max+2 or max+3 so it does not worse to replace with ...) + * @param int $size Max string size visible (excluding …). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added …, or if size was max+1 so it does not worse to replace with ...) * @param string $trunc Where to trunc: 'right', 'left', 'middle' (size must be a 2 power), 'wrap' * @param string $stringencoding Tell what is source string encoding - * @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation. + * @param int $nodot Truncation do not add … after truncation. So it's an exact truncation. * @param int $display Trunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS) * @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise. */ @@ -3189,42 +3200,53 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF { global $conf; - if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; + if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) { + return $string; + } - if (empty($stringencoding)) $stringencoding = 'UTF-8'; + if (empty($stringencoding)) { + $stringencoding = 'UTF-8'; + } // reduce for small screen if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3); // We go always here - if ($trunc == 'right') - { - $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... - return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...'); - else //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; - return $string; - } elseif ($trunc == 'middle') - { - $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; - if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) - { + if ($trunc == 'right') { + $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) { + // If nodot is 0 and size is 1 chars more, we don't trunc and don't add … + return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '…'); + } else { + //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; + return $string; + } + } elseif ($trunc == 'middle') { + $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) { $size1 = round($size / 2); $size2 = round($size / 2); - return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); - } else return $string; - } elseif ($trunc == 'left') - { - $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... - return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); - else return $string; - } elseif ($trunc == 'wrap') - { - $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; - if (dol_strlen($newstring, $stringencoding) > ($size + 1)) - return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); - else return $string; - } else return 'BadParam3CallingDolTrunc'; + return dol_substr($newstring, 0, $size1, $stringencoding).'…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); + } else { + return $string; + } + } elseif ($trunc == 'left') { + $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) { + // If nodot is 0 and size is 1 chars more, we don't trunc and don't add … + return '…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); + } else { + return $string; + } + } elseif ($trunc == 'wrap') { + $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + 1)) { + return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); + } else { + return $string; + } + } else { + return 'BadParam3CallingDolTrunc'; + } } /** @@ -6386,8 +6408,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); - $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%d") : ''); + $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%A") : ''); + $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%m") : ''); + $substitutionarray['__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%b") : ''); + $substitutionarray['__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%Y") : ''); + $substitutionarray['__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%H") : ''); + $substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : ''); + $substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : ''); // For backward compatibility $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 232b5a9d94a..484b3933e42 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -61,10 +61,11 @@ $shmoffset = 1000; // Max number of entries found into a language file. If too l * * @param string $memoryid Memory id of shared area * @param mixed $data Data to save. It must not be a null value. + * @param int $expire ttl in seconds, 0 never expire * @return int <0 if KO, 0 if nothing is done, Nb of bytes written if OK * @see dol_getcache() */ -function dol_setcache($memoryid, $data) +function dol_setcache($memoryid, $data, $expire = 0) { global $conf; $result = 0; @@ -85,7 +86,7 @@ function dol_setcache($memoryid, $data) $memoryid = session_name() . '_' . $memoryid; //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); - $dolmemcache->add($memoryid, $data); // This fails if key already exists + $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists $rescode = $dolmemcache->getResultCode(); if ($rescode == 0) { return count($data); @@ -104,7 +105,7 @@ function dol_setcache($memoryid, $data) $memoryid = session_name() . '_' . $memoryid; //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); - $result = $dolmemcache->add($memoryid, $data); // This fails if key already exists + $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists if ($result) { return count($data); } else { @@ -112,7 +113,7 @@ function dol_setcache($memoryid, $data) } } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // This is a really not reliable cache ! Use Memcached instead. // Using shmop - $result = dol_setshmop($memoryid, $data); + $result = dol_setshmop($memoryid, $data, $expire); } return $result; @@ -226,9 +227,10 @@ function dol_listshmop() * * @param int $memoryid Memory id of shared area ('main', 'agenda', ...) * @param string $data Data to save. Must be a not null value. + * @param int $expire ttl in seconds, 0 never expire * @return int <0 if KO, 0=Caching not available, Nb of bytes written if OK */ -function dol_setshmop($memoryid, $data) +function dol_setshmop($memoryid, $data, $expire) { global $shmkeys, $shmoffset; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 75a20ac6852..bc232f2cf15 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -205,7 +205,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c /** * Render a string of an HTML content and output it. - * Used to ouput the page when viewed from server (Dolibarr or Apache). + * Used to ouput the page when viewed from a server (Dolibarr or Apache). * * @param string $content Content string * @param string $contenttype Content type @@ -296,7 +296,7 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '') if (empty($includehtmlcontentopened)) { $content = str_replace('!~!~!~', '', $content); } - } else // REPLACEMENT OF LINKS When page called from virtual host + } else // REPLACEMENT OF LINKS When page called from virtual host web server { $symlinktomediaexists = 1; if ($website->virtualhost) { @@ -355,7 +355,9 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '') } } - $content = str_replace(' contenteditable="true"', ' contenteditable="false"', $content); + if (!defined('USEDOLIBARREDITOR')) { + $content = str_replace(' contenteditable="true"', ' contenteditable="false"', $content); + } if (!empty($conf->global->WEBSITE_ADD_CSS_TO_BODY)) { $content = str_replace(''CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"OrderId", 'f.ref'=>"Ref", 'f.ref_supplier'=>"RefSupplier", 'f.date_creation'=>"DateCreation", 'f.date_commande'=>"OrderDate", 'f.date_livraison'=>"DateDeliveryPlanned", - 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2', + 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2', 'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC", 'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId', @@ -544,7 +544,7 @@ class modFournisseur extends DolibarrModules $this->export_TypeFields_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", - 'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", + 'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text", 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.product_type'=>'Numeric', 'fd.ref'=>'Text', 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text' @@ -852,7 +852,7 @@ class modFournisseur extends DolibarrModules 'c.fk_statut' => 'Status*', 'c.billed' => 'Billed(0/1)', 'c.remise_percent' => 'GlobalDiscount', - 'c.tva' => 'TotalTVA', + 'c.total_tva' => 'TotalTVA', 'c.total_ht' => 'TotalHT', 'c.total_ttc' => 'TotalTTC', 'c.note_private' => 'NotePrivate', diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index bb4ba6c1744..af249e3b65c 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -191,7 +191,7 @@ class modPropale extends DolibarrModules 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount", - 'c.total_ht'=>"TotalHT", 'c.total'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', + 'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', 'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', 'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC", @@ -208,14 +208,14 @@ class modPropale extends DolibarrModules //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date", - // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text", + // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text", // 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", // 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' //); $this->export_TypeFields_array[$r] = array( 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date", - 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', + 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text' ); @@ -223,7 +223,7 @@ class modPropale extends DolibarrModules 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"propal", 'c.ref'=>"propal", 'c.ref_client'=>"propal", 'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal", - 'c.total'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', + 'c.total_ttc'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', 'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line", 'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' ); @@ -276,7 +276,7 @@ class modPropale extends DolibarrModules 'c.fin_validite' => 'DateEndPropal', 'c.remise_percent' => 'GlobalDiscount', 'c.total_ht' => 'TotalHT', - 'c.total' => 'TotalTTC', + 'c.total_ttc' => 'TotalTTC', 'c.fk_statut' => 'Status*', 'c.note_public' => 'Note', 'c.date_livraison' => 'DeliveryDate', @@ -313,7 +313,7 @@ class modPropale extends DolibarrModules 'c.fin_validite' => '2020-01-01', 'c.remise_percent' => '', 'c.total_ht' => '0', - 'c.total' => '0', + 'c.total_ttc' => '0', 'c.fk_statut' => '1', 'c.note_public' => '', 'c.date_livraison' => '2020-01-01', diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 5d3381b2719..0a7ed20981e 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -275,6 +275,9 @@ if ($action == 'presend') foreach ($contactarr as $contact) { $contactstatic->fetch($contact['id']); $substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1); + $substitutionarray['__CONTACT_LASTNAME_'.$contact['code'].'__'] = $contactstatic->lastname; + $substitutionarray['__CONTACT_FIRSTNAME_'.$contact['code'].'__'] = $contactstatic->firstname; + $substitutionarray['__CONTACT_TITLE_'.$contact['code'].'__'] = $contactstatic->getCivilityLabel(); } } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9d18f3cfd1a..9794ea3cc11 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -550,7 +550,7 @@ if ($object->id > 0) { $langs->loadLangs(array("supplier_proposal")); - $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc"; + $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p "; $sql .= " WHERE p.fk_soc =".$object->id; $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1e6e0234cdc..52121d8c83d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -204,7 +204,7 @@ class CommandeFournisseur extends CommonOrder 'amount_ht' =>array('type'=>'double(24,8)', 'label'=>'Amount ht', 'enabled'=>1, 'visible'=>-1, 'position'=>115), 'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>120), 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), @@ -305,7 +305,7 @@ class CommandeFournisseur extends CommonOrder // Check parameters if (empty($id) && empty($ref)) return -1; - $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; + $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.total_tva,"; $sql .= " c.localtax1, c.localtax2, "; $sql .= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,"; $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,"; @@ -356,7 +356,7 @@ class CommandeFournisseur extends CommonOrder $this->user_approve_id = $obj->fk_user_approve; $this->user_approve_id2 = $obj->fk_user_approve2; $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->total_vat; + $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; @@ -451,7 +451,7 @@ class CommandeFournisseur extends CommonOrder $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn"; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index aa5f7c3ddc5..0918b316fb3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -78,12 +78,12 @@ $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); -$search_total_vat = GETPOST('search_total_vat', 'alpha'); +$search_total_tva = GETPOST('search_total_tva', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); $search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); $search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); -$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_tva = GETPOST('search_multicurrency_montant_tva', 'alpha'); $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $search_billed = GETPOST('search_billed', 'int'); @@ -155,12 +155,12 @@ $arrayfields = array( 'cf.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1), 'cf.date_livraison'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)), 'cf.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), - 'cf.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), + 'cf.total_tva'=>array('label'=>"AmountVAT", 'checked'=>0), 'cf.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), 'cf.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'cf.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'cf.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'cf.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'cf.multicurrency_total_tva'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'cf.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'cf.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'cf.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), @@ -210,12 +210,12 @@ if (empty($reshook)) $search_type_thirdparty = ''; $search_request_author = ''; $search_total_ht = ''; - $search_total_vat = ''; + $search_total_tva = ''; $search_total_ttc = ''; $search_multicurrency_code = ''; $search_multicurrency_tx = ''; $search_multicurrency_montant_ht = ''; - $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_tva = ''; $search_multicurrency_montant_ttc = ''; $search_project_ref = ''; $search_status = -1; @@ -477,7 +477,7 @@ if (empty($reshook)) if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); - if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_tva != '') $param .= '&search_total_tva='.urlencode($search_total_tva); if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); if ($show_files) $param .= '&show_files='.urlencode($show_files); @@ -539,8 +539,8 @@ if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DI $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; -$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,"; -$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva as multicurrency_total_vat, cf.multicurrency_total_ttc,'; +$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,"; +$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,'; $sql .= ' cf.date_creation as date_creation, cf.tms as date_update,'; $sql .= ' cf.note_public, cf.note_private,'; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; @@ -600,12 +600,12 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1); -if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1); +if ($search_total_tva != '') $sql .= natural_search('cf.total_tva', $search_total_tva, 1); if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); if ($search_multicurrency_code != '') $sql .= ' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); -if ($search_multicurrency_montant_vat != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_tva != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); // Add where from extra fields @@ -672,7 +672,7 @@ if ($resql) if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); - if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_tva != '') $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva); if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); if ($search_refsupp) $param .= "&search_refsupp=".urlencode($search_refsupp); if ($search_status != '' && $search_status != '-1') $param .= "&search_status=".urlencode($search_status); @@ -905,11 +905,11 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['cf.total_vat']['checked'])) + if (!empty($arrayfields['cf.total_tva']['checked'])) { // Amount print ''; } if (!empty($arrayfields['cf.total_ttc']['checked'])) @@ -940,11 +940,11 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['cf.multicurrency_total_vat']['checked'])) + if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { // Amount print ''; } 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 '\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 '\n"; + print '\n"; if (!$i) $totalarray['nbfield']++; } // Amount TTC diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 0a3e49c9600..7594ead39a4 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -43,7 +43,9 @@ $langs->load("install"); // Now we load forced/pre-set values from install.forced.php file. $useforcedwizard = false; $forcedfile = "./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -66,36 +68,36 @@ print '

Error '.$langs->trans("WarningBrowserTooOld")."
\n"; + if ($browsername == 'ie' && $browserversion < 7) { + print 'Error '.$langs->trans("WarningBrowserTooOld")."
\n"; + } } // Check PHP version $arrayphpminversionerror = array(5, 5, 0); $arrayphpminversionwarning = array(5, 6, 0); -if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) // Minimum to use (error if lower) -{ +if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) { // Minimum to use (error if lower) print '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 'Error '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning)); $checksok = 0; // 0=error, 1=warning } else { print 'Ok '.$langs->trans("PHPVersion")." ".versiontostring(versionphparray()); } -if (empty($force_install_nophpinfo)) print ' ('.$langs->trans("MoreInformation").')'; +if (empty($force_install_nophpinfo)) { + print ' ('.$langs->trans("MoreInformation").')'; +} print "
\n"; // Check PHP support for $_GET and $_POST -if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) // We must keep $_GET and $_POST here -{ +if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) { // We must keep $_GET and $_POST here print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); print ' ('.$langs->trans("Recheck").')'; print "
\n"; @@ -106,8 +108,7 @@ if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) // We must keep $_GE // Check if session_id is enabled -if (!function_exists("session_id")) -{ +if (!function_exists("session_id")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportSessions")."
\n"; $checksok = 0; } else { @@ -116,8 +117,7 @@ if (!function_exists("session_id")) // Check if GD is supported (we need GD for image conversion) -if (!function_exists("imagecreate")) -{ +if (!function_exists("imagecreate")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) @@ -127,8 +127,7 @@ if (!function_exists("imagecreate")) // Check if Curl is supported -if (!function_exists("curl_init")) -{ +if (!function_exists("curl_init")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) @@ -137,8 +136,7 @@ if (!function_exists("curl_init")) } // Check if PHP calendar extension is available -if (!function_exists("easter_date")) -{ +if (!function_exists("easter_date")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
\n"; } else { print 'Ok '.$langs->trans("PHPSupport", "Calendar")."
\n"; @@ -146,8 +144,7 @@ if (!function_exists("easter_date")) // Check if UTF8 is supported -if (!function_exists("utf8_encode")) -{ +if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) @@ -157,10 +154,8 @@ if (!function_exists("utf8_encode")) // Check if intl methods are supported -if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') -{ - if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) - { +if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { + if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) @@ -169,8 +164,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc } } -if (!class_exists('ZipArchive')) -{ +if (!class_exists('ZipArchive')) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) @@ -183,17 +177,20 @@ $memrequiredorig = '64M'; $memrequired = 64 * 1024 * 1024; $memmaxorig = @ini_get("memory_limit"); $memmax = @ini_get("memory_limit"); -if ($memmaxorig != '') -{ +if ($memmaxorig != '') { preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg); - if ($reg[2]) - { - if (strtoupper($reg[2]) == 'G') $memmax = $reg[1] * 1024 * 1024 * 1024; - if (strtoupper($reg[2]) == 'M') $memmax = $reg[1] * 1024 * 1024; - if (strtoupper($reg[2]) == 'K') $memmax = $reg[1] * 1024; + if ($reg[2]) { + if (strtoupper($reg[2]) == 'G') { + $memmax = $reg[1] * 1024 * 1024 * 1024; + } + if (strtoupper($reg[2]) == 'M') { + $memmax = $reg[1] * 1024 * 1024; + } + if (strtoupper($reg[2]) == 'K') { + $memmax = $reg[1] * 1024; + } } - if ($memmax >= $memrequired || $memmax == -1) - { + if ($memmax >= $memrequired || $memmax == -1) { print 'Ok '.$langs->trans("PHPMemoryOK", $memmaxorig, $memrequiredorig)."
\n"; } else { print 'Warning '.$langs->trans("PHPMemoryTooLow", $memmaxorig, $memrequiredorig)."
\n"; @@ -203,15 +200,13 @@ if ($memmaxorig != '') // If that config file is present and filled clearstatcache(); -if (is_readable($conffile) && filesize($conffile) > 8) -{ +if (is_readable($conffile) && filesize($conffile) > 8) { dolibarr_install_syslog("check: conf file '".$conffile."' already defined"); $confexists = 1; include_once $conffile; $databaseok = 1; - if ($databaseok) - { + if ($databaseok) { // Already installed for all parts (config and database). We can propose upgrade. $allowupgrade = true; } else { @@ -223,8 +218,7 @@ if (is_readable($conffile) && filesize($conffile) > 8) $confexists = 0; // First we try by copying example - if (@copy($conffile.".example", $conffile)) - { + if (@copy($conffile.".example", $conffile)) { // Success dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile); } else { @@ -232,12 +226,13 @@ if (is_readable($conffile) && filesize($conffile) > 8) dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING); $fp = @fopen($conffile, "w"); - if ($fp) - { + if ($fp) { @fwrite($fp, ' 8) // File is missing and cannot be created -if (!file_exists($conffile)) -{ +if (!file_exists($conffile)) { print 'Error '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow); print "

"; print $langs->trans("YouMustCreateWithPermission", $conffiletoshow); @@ -257,17 +251,13 @@ if (!file_exists($conffile)) print $langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok'); $err++; } else { - if (dol_is_dir($conffile)) - { + if (dol_is_dir($conffile)) { print '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 'Ok '.$langs->trans("ConfFileExists", $conffiletoshow); } else { print 'Ok '.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow); @@ -277,11 +267,9 @@ if (!file_exists($conffile)) print "
\n"; $allowinstall = 0; - } - // File exists and can be modified - else { - if ($confexists) - { + } else { + // File exists and can be modified + if ($confexists) { print 'Ok '.$langs->trans("ConfFileExists", $conffiletoshow); } else { print 'Ok '.$langs->trans("ConfFileCouldBeCreated", $conffiletoshow); @@ -295,32 +283,28 @@ if (!file_exists($conffile)) print "
\n"; // Requirements met/all ok: display the next step button - if ($checksok) - { + if ($checksok) { $ok = 0; // Try to create db connection - if (file_exists($conffile)) - { + if (file_exists($conffile)) { include_once $conffile; - if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) - { - if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) - { + if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) { + if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) { print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.
'."\n"; dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING); } else { require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } // $conf already created in inc.php @@ -331,8 +315,7 @@ if (!file_exists($conffile)) $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); - if ($db->connected && $db->database_selected) - { + if ($db->connected && $db->database_selected) { $ok = true; } } @@ -340,16 +323,21 @@ if (!file_exists($conffile)) } // If database access is available, we set more variables - if ($ok) - { - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; + if ($ok) { + if (empty($dolibarr_main_db_encryption)) { + $dolibarr_main_db_encryption = 0; + } $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; + if (empty($dolibarr_main_db_cryptkey)) { + $dolibarr_main_db_cryptkey = ''; + } $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE @@ -359,14 +347,15 @@ if (!file_exists($conffile)) } // Show title - if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) - { + if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) { print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).' - '; print $langs->trans("VersionProgram").': '.DOL_VERSION.''; //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); print '
'; print '
'; - } else print "
\n"; + } else { + print "
\n"; + } //print $langs->trans("InstallEasy")." "; print '

'.$langs->trans("ChooseYourSetupMode").'

'; @@ -376,8 +365,7 @@ if (!file_exists($conffile)) $available_choices = array(); $notavailable_choices = array(); - if (empty($dolibarr_main_db_host)) // This means install process was not run - { + if (empty($dolibarr_main_db_host)) { // This means install process was not run $foundrecommandedchoice = 1; // To show only once } @@ -387,8 +375,7 @@ if (!file_exists($conffile)) $choice .= ''; $choice .= ''; $choice .= ''; $choice .= '
'.$langs->trans("ProspectToContact").'
'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6b75d57d082..cb16e419ee8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -313,7 +313,7 @@ class Commande extends CommonOrder 'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>110), 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115), //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120), - 'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), @@ -1791,7 +1791,7 @@ class Commande extends CommonOrder if (empty($id) && empty($ref) && empty($ref_ext)) return -1; $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; - $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; + $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql .= ', c.fk_account'; $sql .= ', c.date_commande, c.date_valid, c.tms'; $sql .= ', c.date_livraison as delivery_date'; @@ -3297,7 +3297,7 @@ class Commande extends CommonOrder $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; $sql .= " date_commande=".(strval($this->date_commande) != '' ? "'".$this->db->idate($this->date_commande)."'" : 'null').","; $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; + $sql .= " total_tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; $sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").","; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8b4a79f4dda..a5f548d6e6a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -286,7 +286,7 @@ if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DI $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; -$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; +$sql .= ' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; $sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,'; $sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; @@ -369,7 +369,7 @@ if ($search_company_alias) $sql .= natural_search('s.name_alia if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); -if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1); +if ($search_total_vat != '') $sql .= natural_search('c.total_tva', $search_total_vat, 1); if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; @@ -941,7 +941,7 @@ if ($resql) if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['c.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 7b60dd639f6..249df885435 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1376,7 +1376,7 @@ if ($resql) // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; + print ''; print $obj->name_alias; print '
'.$langs->trans("ContactByDefaultFor").''; $contactType = $object->listeTypeContacts('external', '', 1); - print $form->multiselectarray('roles', $contactType); + print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500'); print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print ''.price($obj->total_tva)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_tva)."'; $choice .= $langs->trans("FreshInstallDesc"); - if (empty($dolibarr_main_db_host)) // This means install process was not run - { + if (empty($dolibarr_main_db_host)) { // This means install process was not run $choice .= '
'; //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; @@ -397,8 +384,7 @@ if (!file_exists($conffile)) $choice .= '
'; - if ($allowinstall) - { + if ($allowinstall) { $choice .= ''.$langs->trans("Start").''; } else { $choice .= ($foundrecommandedchoice ? '' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '' : ''); @@ -415,12 +401,15 @@ if (!file_exists($conffile)) // Show upgrade lines $allowupgrade = true; - if (empty($dolibarr_main_db_host)) // This means install process was not run - { + if (empty($dolibarr_main_db_host)) { // This means install process was not run $allowupgrade = false; } - if (defined("MAIN_NOT_INSTALLED")) $allowupgrade = false; - if (GETPOST('allowupgrade')) $allowupgrade = true; + if (defined("MAIN_NOT_INSTALLED")) { + $allowupgrade = false; + } + if (GETPOST('allowupgrade')) { + $allowupgrade = true; + } $migrationscript = array(array('from'=>'3.0.0', 'to'=>'3.1.0'), array('from'=>'3.1.0', 'to'=>'3.2.0'), array('from'=>'3.2.0', 'to'=>'3.3.0'), @@ -444,8 +433,7 @@ if (!file_exists($conffile)) ); $count = 0; - foreach ($migrationscript as $migarray) - { + foreach ($migrationscript as $migarray) { $choice = ''; $count++; @@ -460,20 +448,16 @@ if (!file_exists($conffile)) $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom); $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto); $newversionfrombis = ''; - if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1 - { + if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) { // From x.y.z -> x.y.z+1 $newversionfrombis = ' '.$langs->trans("or").' '.$versionto; } - if ($ok) - { - if (count($dolibarrlastupgradeversionarray) >= 2) // If database access is available and last upgrade version is known - { + if ($ok) { + if (count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known // Now we check if this is the first qualified choice if ($allowupgrade && empty($foundrecommandedchoice) && (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2) - ) - { + ) { $foundrecommandedchoice = 1; // To show only once $recommended_choice = true; } @@ -489,14 +473,12 @@ if (!file_exists($conffile)) $choice .= ''; $choice .= $langs->trans("UpgradeDesc"); - if ($recommended_choice) - { + if ($recommended_choice) { $choice .= '
'; //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); $choice .= '
'; $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; - if ($count < count($migarray)) // There are other choices after - { + if ($count < count($migarray)) { // There are other choices after print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION); } $choice .= '
'; @@ -504,19 +486,15 @@ if (!file_exists($conffile)) $choice .= '
'; - if ($allowupgrade) - { + if ($allowupgrade) { $disabled = false; - if ($foundrecommandedchoice == 2) - { + if ($foundrecommandedchoice == 2) { $disabled = true; } - if ($foundrecommandedchoice == 1) - { + if ($foundrecommandedchoice == 1) { $foundrecommandedchoice = 2; } - if ($disabled) - { + if ($disabled) { $choice .= ''.$langs->trans("NotYetAvailable").''; } else { $choice .= ''.$langs->trans("Start").''; @@ -535,8 +513,7 @@ if (!file_exists($conffile)) } // If there is no choice at all, we show all of them. - if (empty($available_choices)) - { + if (empty($available_choices)) { $available_choices = $notavailable_choices; $notavailable_choices = array(); } diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 12bab777edb..3f7cb019521 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -5,7 +5,8 @@ * Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2012 Marcos García * Copyright (C) 2016 Raphaël Doursenaud - * + * Copyright (C) 2021 Charlene Benke +* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -27,40 +28,40 @@ */ // Just to define version DOL_VERSION -if (!defined('DOL_INC_FOR_VERSION_ERROR')) define('DOL_INC_FOR_VERSION_ERROR', '1'); +if (!defined('DOL_INC_FOR_VERSION_ERROR')) { + define('DOL_INC_FOR_VERSION_ERROR', '1'); +} require_once '../filefunc.inc.php'; // Define DOL_DOCUMENT_ROOT and ADODB_PATH used for install/upgrade process -if (!defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..'); -if (!defined('ADODB_PATH')) -{ +if (!defined('DOL_DOCUMENT_ROOT')) { + define('DOL_DOCUMENT_ROOT', '..'); +} +if (!defined('ADODB_PATH')) { $foundpath = DOL_DOCUMENT_ROOT.'/includes/adodbtime/'; - if (!is_dir($foundpath)) $foundpath = '/usr/share/php/adodb/'; + if (!is_dir($foundpath)) { + $foundpath = '/usr/share/php/adodb/'; + } define('ADODB_PATH', $foundpath); } require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once ADODB_PATH.'adodb-time.inc.php'; -// Avoid warnings with strict mode E_STRICT -$conf = new stdClass(); // instantiate $conf explicitely -$conf->global = new stdClass(); -$conf->file = new stdClass(); -$conf->db = new stdClass(); -$conf->syslog = new stdClass(); +$conf = new Conf(); // Force $_REQUEST["logtohtml"] $_REQUEST["logtohtml"] = 1; // Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative // et non path absolu. -if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) -{ +if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) { $_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"]; } @@ -79,19 +80,21 @@ $conffiletoshow = "htdocs/conf/conf.php"; // Load conf file if it is already defined -if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just 8) { // Test on filesize is to ensure that conf file is more that an empty template with just $dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) : ''; // Remove last / or \ on directories or url value - if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root); - if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root); - if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root); - if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt); - if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt); + if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) { + $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root); + } + if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) { + $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root); + } + if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) { + $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root); + } + if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) { + $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt); + } + if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) { + $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt); + } // Create conf object - if (!empty($dolibarr_main_document_root)) - { + if (!empty($dolibarr_main_document_root)) { $result = conf($dolibarr_main_document_root); } // Load database driver - if ($result) - { - if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) - { + if ($result) { + if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) { $result = include_once $dolibarr_main_document_root."/core/db/".$dolibarr_main_db_type.'.class.php'; - if (!$result) - { + if (!$result) { $includeconferror = 'ErrorBadValueForDolibarrMainDBType'; } } @@ -133,7 +142,9 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Define prefix -if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) $dolibarr_main_db_prefix = 'llx_'; +if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) { + $dolibarr_main_db_prefix = 'llx_'; +} define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : '')); define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir @@ -141,42 +152,51 @@ define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_r define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* $suburi = strstr($uri, '/'); // $suburi contains url without domain -if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' +if ($suburi == '/') { + $suburi = ''; // If $suburi is /, it is now '' +} define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) -if (empty($conf->file->character_set_client)) $conf->file->character_set_client = "utf-8"; -if (empty($conf->db->character_set)) $conf->db->character_set = 'utf8'; -if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; -if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_encryption = 0; -if (empty($conf->db->dolibarr_main_db_cryptkey)) $conf->db->dolibarr_main_db_cryptkey = ''; -if (empty($conf->db->user)) $conf->db->user = ''; +if (empty($conf->file->character_set_client)) { + $conf->file->character_set_client = "utf-8"; +} +if (empty($conf->db->character_set)) { + $conf->db->character_set = 'utf8'; +} +if (empty($conf->db->dolibarr_main_db_collation)) { + $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; +} +if (empty($conf->db->dolibarr_main_db_encryption)) { + $conf->db->dolibarr_main_db_encryption = 0; +} +if (empty($conf->db->dolibarr_main_db_cryptkey)) { + $conf->db->dolibarr_main_db_cryptkey = ''; +} +if (empty($conf->db->user)) { + $conf->db->user = ''; +} // Define array of document root directories $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT); -if (!empty($dolibarr_main_document_root_alt)) -{ +if (!empty($dolibarr_main_document_root_alt)) { // dolibarr_main_document_root_alt contains several directories $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt); - foreach ($values as $value) - { + foreach ($values as $value) { $conf->file->dol_document_root[] = $value; } } // Security check (old method, when directory is renamed /install.lock) -if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"])) -{ - if (!is_object($langs)) - { +if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"])) { + if (!is_object($langs)) { $langs = new Translate('..', $conf); $langs->setDefaultLang('auto'); } $langs->load("install"); print $langs->trans("YouTryInstallDisabledByDirLock"); - if (!empty($dolibarr_main_url_root)) - { + if (!empty($dolibarr_main_url_root)) { print 'Click on following link, '; print $langs->trans("ClickHereToGoToApp"); print ''; @@ -190,17 +210,14 @@ if (constant('DOL_DATA_ROOT') === null) { // Try to detect any lockfile in the default documents path $lockfile = '../../documents/install.lock'; } -if (@file_exists($lockfile)) -{ - if (!isset($langs) || !is_object($langs)) - { +if (@file_exists($lockfile)) { + if (!isset($langs) || !is_object($langs)) { $langs = new Translate('..', $conf); $langs->setDefaultLang('auto'); } $langs->load("install"); print $langs->trans("YouTryInstallDisabledByFileLock"); - if (!empty($dolibarr_main_url_root)) - { + if (!empty($dolibarr_main_url_root)) { print $langs->trans("ClickOnLinkOrRemoveManualy").'
'; print ''; print $langs->trans("ClickHereToGoToApp"); @@ -215,42 +232,55 @@ if (@file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); -if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); -if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined -{ - if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); - elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); - elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); - elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp - elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others +if (!defined('SYSLOG_HANDLERS')) { + define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); +} +if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined + if (@is_writable('/tmp')) { + define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); + } elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) { + define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); + } elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) { + define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); + } elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) { + define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp + } elseif (@is_writable('../../')) { + define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others + } //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } -if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); -if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1); +if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); +} +if (!defined('SYSLOG_FILE_NO_ERROR')) { + define('SYSLOG_FILE_NO_ERROR', 1); +} // We init log handler for install $handlers = array('mod_syslog_file'); -foreach ($handlers as $handler) -{ +foreach ($handlers as $handler) { $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; - if (!file_exists($file)) - { + if (!file_exists($file)) { throw new Exception('Missing log handler file '.$handler.'.php'); } require_once $file; $loghandlerinstance = new $handler(); - if (!$loghandlerinstance instanceof LogHandlerInterface) - { + if (!$loghandlerinstance instanceof LogHandlerInterface) { throw new Exception('Log handler does not extend LogHandlerInterface'); } - if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance; + if (empty($conf->loghandlers[$handler])) { + $conf->loghandlers[$handler] = $loghandlerinstance; + } } // Define object $langs $langs = new Translate('..', $conf); -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); -else $langs->setDefaultLang('auto'); +if (GETPOST('lang', 'aZ09')) { + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); +} else { + $langs->setDefaultLang('auto'); +} /** @@ -271,7 +301,9 @@ function conf($dolibarr_main_document_root) global $character_set_client; $return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php'; - if (!$return) return -1; + if (!$return) { + return -1; + } $conf = new Conf(); $conf->db->type = trim($dolibarr_main_db_type); @@ -282,51 +314,73 @@ function conf($dolibarr_main_document_root) $conf->db->pass = trim($dolibarr_main_db_pass); // Mysql driver support has been removed in favor of mysqli - if ($conf->db->type == 'mysql') $conf->db->type = 'mysqli'; - if (empty($character_set_client)) $character_set_client = "UTF-8"; + if ($conf->db->type == 'mysql') { + $conf->db->type = 'mysqli'; + } + if (empty($character_set_client)) { + $character_set_client = "UTF-8"; + } $conf->file->character_set_client = strtoupper($character_set_client); - if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); + if (empty($dolibarr_main_db_character_set)) { + $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); + } $conf->db->character_set = $dolibarr_main_db_character_set; - if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); + if (empty($dolibarr_main_db_collation)) { + $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); + } $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; + if (empty($dolibarr_main_db_encryption)) { + $dolibarr_main_db_encryption = 0; + } $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; + if (empty($dolibarr_main_db_cryptkey)) { + $dolibarr_main_db_cryptkey = ''; + } $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Force usage of log file for install and upgrades $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); - if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); - if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined - { - if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); - elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); - elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); - elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp - elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others + if (!defined('SYSLOG_HANDLERS')) { + define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); + } + if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined + if (@is_writable('/tmp')) { + define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); + } elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) { + define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log'); + } elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) { + define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log'); + } elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) { + define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp + } elseif (@is_writable('../../')) { + define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others + } //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); - if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1); + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } + if (!defined('SYSLOG_FILE_NO_ERROR')) { + define('SYSLOG_FILE_NO_ERROR', 1); + } // We init log handler for install $handlers = array('mod_syslog_file'); - foreach ($handlers as $handler) - { + foreach ($handlers as $handler) { $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; - if (!file_exists($file)) - { + if (!file_exists($file)) { throw new Exception('Missing log handler file '.$handler.'.php'); } require_once $file; $loghandlerinstance = new $handler(); - if (!$loghandlerinstance instanceof LogHandlerInterface) - { + if (!$loghandlerinstance instanceof LogHandlerInterface) { throw new Exception('Log handler does not extend LogHandlerInterface'); } - if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance; + if (empty($conf->loghandlers[$handler])) { + $conf->loghandlers[$handler] = $loghandlerinstance; + } } return 1; @@ -354,8 +408,7 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl $jquerytheme = 'base'; - if ($forcejqueryurl) - { + if ($forcejqueryurl) { $jQueryCustomPath = $forcejqueryurl; $jQueryUiCustomPath = $forcejqueryurl; } else { @@ -376,14 +429,23 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl print ''."\n"; print ''."\n"; - if ($jQueryUiCustomPath) print ''."\n"; // JQuery - else print ''."\n"; // JQuery + if ($jQueryUiCustomPath) { + print ''."\n"; // JQuery + } else { + print ''."\n"; // JQuery + } print ''."\n"; - if ($jQueryCustomPath) print ''."\n"; - else print ''."\n"; - if ($jQueryUiCustomPath) print ''."\n"; - else print ''."\n"; + if ($jQueryCustomPath) { + print ''."\n"; + } else { + print ''."\n"; + } + if ($jQueryUiCustomPath) { + print ''."\n"; + } else { + print ''."\n"; + } print ''.$langs->trans("DolibarrSetup").''."\n"; print ''."\n"; @@ -402,7 +464,9 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -430,11 +494,9 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print '
'."\n"; print '
'."\n"; - if (!$nonext || ($nonext == '2')) - { + if (!$nonext || ($nonext == '2')) { print '
'; - if ($nonext == '2') - { + if ($nonext == '2') { print ''; print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : ''); print ''; @@ -442,25 +504,26 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas } print '"'; - if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"'; + if ($jscheckfunction) { + print ' onClick="return '.$jscheckfunction.'();"'; + } print '>
'; - if ($withpleasewait) print ''; + if ($withpleasewait) { + print ''; + } } - if ($setuplang) - { + if ($setuplang) { print ''; } print ''."\n"; // If there is some logs in buffer to show - if (isset($conf->logbuffer) && count($conf->logbuffer)) - { + if (isset($conf->logbuffer) && count($conf->logbuffer)) { print "\n"; print "\n"; $resql = $db->query($buffer, 0, 'dml'); - if ($resql) - { + if ($resql) { $ok = 1; $db->free($resql); } else { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS' - || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') - { + || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') { //print "Insert line : ".$buffer."
\n"; } else { $ok = 0; @@ -463,8 +437,7 @@ if ($action == "set") } print "
".$langs->trans("FunctionsCreation")."Ok
Error
Insertion ligne : $buffer"; } else { $ok = 0; @@ -574,14 +540,16 @@ if ($action == "set") } } - if ($okallfile) $db->commit(); - else $db->rollback(); + if ($okallfile) { + $db->commit(); + } else { + $db->rollback(); + } } } print "
".$langs->trans("ReferenceDataLoading")."Ok
Error
'; $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 ''; print ''; print '
'; print '
'; @@ -87,15 +87,13 @@ if ($db->ok) print '
'; - if (isset($_GET["error"]) && $_GET["error"] == 1) - { + if (isset($_GET["error"]) && $_GET["error"] == 1) { print '
'; print '
'.$langs->trans("PasswordsMismatch").'
'; $error = 0; // We show button } - if (isset($_GET["error"]) && $_GET["error"] == 2) - { + if (isset($_GET["error"]) && $_GET["error"] == 2) { print '
'; print '
'; print $langs->trans("PleaseTypePassword"); @@ -103,8 +101,7 @@ if ($db->ok) $error = 0; // We show button } - if (isset($_GET["error"]) && $_GET["error"] == 3) - { + if (isset($_GET["error"]) && $_GET["error"] == 3) { print '
'; print '
'.$langs->trans("PleaseTypeALogin").'
'; $error = 0; // We show button @@ -112,7 +109,9 @@ if ($db->ok) } $ret = 0; -if ($error && isset($argv[1])) $ret = 1; +if ($error && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step4: end"); @@ -122,4 +121,6 @@ pFooter($error, $setuplang); $db->close(); // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index ed64de7cbb1..6ae3bffc59b 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -27,7 +27,9 @@ */ include_once 'inc.php'; -if (file_exists($conffile)) include_once $conffile; +if (file_exists($conffile)) { + include_once $conffile; +} require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash @@ -42,13 +44,15 @@ $action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : (empty($argv[ // Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install // or MAIN_VERSION_LAST_UPGRADE for upgrade. $targetversion = DOL_VERSION; // If it's latest upgrade -if (!empty($action) && preg_match('/upgrade/i', $action)) // If it's an old upgrade -{ +if (!empty($action) && preg_match('/upgrade/i', $action)) { + // If it's an old upgrade $tmp = explode('_', $action, 2); - if ($tmp[0] == 'upgrade') - { - if (!empty($tmp[1])) $targetversion = $tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta' - else $targetversion = DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION + if ($tmp[0] == 'upgrade') { + if (!empty($tmp[1])) { + $targetversion = $tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta' + } else { + $targetversion = DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION + } } } @@ -63,7 +67,9 @@ $success = 0; $useforcedwizard = false; $forcedfile = "./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -110,27 +116,25 @@ pHeader($langs->trans("SetupEnd"), "step5"); print '
'; // Test if we can run a first install process -if (empty($versionfrom) && empty($versionto) && !is_writable($conffile)) -{ +if (empty($versionfrom) && empty($versionto) && !is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); pFooter(1, $setuplang, 'jscheckparam'); exit; } -if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) -{ +if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { $error = 0; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } $conf->db->type = $dolibarr_main_db_type; @@ -151,8 +155,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $ok = 0; // If first install - if ($action == "set") - { + if ($action == "set") { // Active module user $modName = 'modUser'; $file = $modName.".class.php"; @@ -160,13 +163,16 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) include_once DOL_DOCUMENT_ROOT."/core/modules/".$file; $objMod = new $modName($db); $result = $objMod->init(); - if (!$result) print 'ERROR in activating module file='.$file; + if (!$result) { + print 'ERROR in activating module file='.$file; + } - if ($db->connected) - { + if ($db->connected) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Create admin user @@ -176,17 +182,17 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $numrows = $db->num_rows($resql); - if ($numrows == 0) - { + if ($numrows == 0) { // Define default setup for password encryption dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities - if (function_exists('password_hash')) + if (function_exists('password_hash')) { dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'password_hash', 'chaine', 0, '', 0); // All entities - else dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities + } else { + dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities + } } dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO); @@ -208,13 +214,11 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email $result = $newuser->create($createuser, 1); - if ($result > 0) - { + if ($result > 0) { print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."
"; $success = 1; } else { - if ($newuser->error == 'ErrorLoginAlreadyExists') - { + if ($newuser->error == 'ErrorLoginAlreadyExists') { dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING); print '
'.$langs->trans("AdminLoginAlreadyExists", $login)."

"; $success = 1; @@ -224,14 +228,12 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) } } - if ($success) - { + if ($success) { // Insert MAIN_VERSION_FIRST_INSTALL in a dedicated transaction. So if it fails (when first install was already done), we can do other following requests. $db->begin(); dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to '.$targetversion, LOG_DEBUG); $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_FIRST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when first install',0)"); - if ($resql) - { + if ($resql) { $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion; $db->commit(); } else { @@ -243,29 +245,36 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG); $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version when last install',0)"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion; - if ($useforcedwizard) - { + if ($useforcedwizard) { dolibarr_install_syslog('step5: set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG); $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING', 1).",".$db->encrypt(1, 1).",'chaine',1,'Disable install warnings',0)"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $conf->global->MAIN_REMOVE_INSTALL_WARNING = 1; } // If we ask to force some modules to be enabled - if (!empty($force_install_module)) - { - if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); + if (!empty($force_install_module)) { + if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) { + define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); + } $tmparray = explode(',', $force_install_module); - foreach ($tmparray as $modtoactivate) - { + foreach ($tmparray as $modtoactivate) { $modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate); print $langs->trans("ActivateModule", $modtoactivatenew).'
'; @@ -274,46 +283,55 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) $res = dol_include_once("/core/modules/".$file); $res = activateModule($modtoactivatenew, 1); - if (!empty($res['errors'])) print 'ERROR in activating module file='.$file; + if (!empty($res['errors'])) { + print 'ERROR in activating module file='.$file; + } } } dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const'); $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $db->commit(); } } else { print $langs->trans("ErrorFailedToConnect")."
"; } - } - // If upgrade - elseif (empty($action) || preg_match('/upgrade/i', $action)) - { - if ($db->connected) - { + } elseif (empty($action) || preg_match('/upgrade/i', $action)) { + // If upgrade + if ($db->connected) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database $tagdatabase = false; - if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase = true; // We don't know what it was before, so now we consider we are version choosed. - else { + if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { + $tagdatabase = true; // We don't know what it was before, so now we consider we are version choosed. + } else { $mainversionlastupgradearray = preg_split('/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE); $targetversionarray = preg_split('/[.-]/', $targetversion); - if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) $tagdatabase = true; + if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) { + $tagdatabase = true; + } } - if ($tagdatabase) - { + if ($tagdatabase) { dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion); $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) VALUES (".$db->encrypt('MAIN_VERSION_LAST_UPGRADE', 1).",".$db->encrypt($targetversion, 1).",'chaine',0,'Dolibarr version for last upgrade',0)"); - if (!$resql) dol_print_error($db, 'Error in setup program'); + if (!$resql) { + dol_print_error($db, 'Error in setup program'); + } $conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion; } else { dolibarr_install_syslog('step5: we run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.'); @@ -337,31 +355,28 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) // Create lock file // If first install -if ($action == "set" && $success) -{ - if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) - { +if ($action == "set" && $success) { + if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { // Install is finished print $langs->trans("SystemIsInstalled")."
"; $createlock = 0; - if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) - { + if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) { // Install is finished, we create the lock file $lockfile = DOL_DATA_ROOT.'/install.lock'; $fp = @fopen($lockfile, "w"); - if ($fp) - { - if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility + if ($fp) { + if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { + $force_install_lockinstall = 444; // For backward compatibility + } fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); @chmod($lockfile, octdec($force_install_lockinstall)); $createlock = 1; } } - if (empty($createlock)) - { + if (empty($createlock)) { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } @@ -383,33 +398,29 @@ if ($action == "set" && $success) print ' '.$langs->trans("GoToUpgradePage"); print '
'; } -} -// If upgrade -elseif (empty($action) || preg_match('/upgrade/i', $action)) -{ - if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) - { +} elseif (empty($action) || preg_match('/upgrade/i', $action)) { + // If upgrade + if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { // Upgrade is finished print $langs->trans("SystemIsUpgraded")."
"; $createlock = 0; - if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) - { + if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) { // Upgrade is finished, we create the lock file $lockfile = DOL_DATA_ROOT.'/install.lock'; $fp = @fopen($lockfile, "w"); - if ($fp) - { - if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444; // For backward compatibility + if ($fp) { + if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { + $force_install_lockinstall = 444; // For backward compatibility + } fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); @chmod($lockfile, octdec($force_install_lockinstall)); $createlock = 1; } } - if (empty($createlock)) - { + if (empty($createlock)) { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } @@ -437,7 +448,9 @@ elseif (empty($action) || preg_match('/upgrade/i', $action)) clearstatcache(); $ret = 0; -if ($error && isset($argv[1])) $ret = 1; +if ($error && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("- step5: Dolibarr setup finished"); @@ -445,4 +458,6 @@ dolibarr_install_syslog("- step5: Dolibarr setup finished"); pFooter(1, $setuplang); // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 29b51746a14..25e3b95af84 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -37,8 +37,7 @@ */ include_once 'inc.php'; -if (!file_exists($conffile)) -{ +if (!file_exists($conffile)) { print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } require_once $conffile; @@ -68,29 +67,35 @@ $ignoredbversion = (GETPOST('ignoredbversion', 'alpha', 3) == 'ignoredbversion') $langs->loadLangs(array("admin", "install", "other", "errors")); -if ($dolibarr_main_db_type == "mysqli") $choix = 1; -if ($dolibarr_main_db_type == "pgsql") $choix = 2; -if ($dolibarr_main_db_type == "mssql") $choix = 3; +if ($dolibarr_main_db_type == "mysqli") { + $choix = 1; +} +if ($dolibarr_main_db_type == "pgsql") { + $choix = 2; +} +if ($dolibarr_main_db_type == "mssql") { + $choix = 3; +} dolibarr_install_syslog("--- upgrade: Entering upgrade.php page"); -if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); +if (!is_object($conf)) { + dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); +} /* * View */ -if (!$versionfrom && !$versionto) -{ +if (!$versionfrom && !$versionto) { print 'Error: Parameter versionfrom or versionto missing.'."\n"; print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; - if (substr($sapi_type, 0, 3) == 'cli') - { + if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; } exit; @@ -102,8 +107,7 @@ pHeader('', "upgrade2", GETPOST('action', 'aZ09'), 'versionfrom='.$versionfrom.' $actiondone = 0; // Action to launch the migrate script -if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) -{ +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { $actiondone = 1; print '

Database '.$langs->trans("DatabaseMigration").'

'; @@ -112,15 +116,15 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $error = 0; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } // $conf is already instancied inside inc.php @@ -132,9 +136,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $conf->db->pass = $dolibarr_main_db_pass; // Load type and crypt key - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; + if (empty($dolibarr_main_db_encryption)) { + $dolibarr_main_db_encryption = 0; + } $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; + if (empty($dolibarr_main_db_cryptkey)) { + $dolibarr_main_db_cryptkey = ''; + } $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); @@ -143,8 +151,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); - if ($db->connected) - { + if ($db->connected) { print ''; print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK")); @@ -155,10 +162,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $ok = 0; } - if ($ok) - { - if ($db->database_selected) - { + if ($ok) { + if ($db->database_selected) { print ''; print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name); @@ -171,15 +176,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Affiche version - if ($ok) - { + if ($ok) { $version = $db->getVersion(); $versionarray = $db->getVersionArray(); print ''.$langs->trans("ServerVersion").''; print ''.$version.''; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion").": ".$version); - if ($db->type == 'mysqli' && function_exists('mysqli_get_charset')) - { + if ($db->type == 'mysqli' && function_exists('mysqli_get_charset')) { $tmparray = $db->db->get_charset(); print ''.$langs->trans("ClientCharset").''; print ''.$tmparray->charset.''; @@ -193,8 +196,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $versionmindb = explode('.', $db::VERSIONMIN); //print join('.',$versionarray).' - '.join('.',$versionmindb); if (count($versionmindb) && count($versionarray) - && versioncompare($versionarray, $versionmindb) < 0) - { + && versioncompare($versionarray, $versionmindb) < 0) { // Warning: database version too low. print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))); @@ -202,8 +204,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Test database version is not forbidden for migration - if (empty($ignoredbversion)) - { + if (empty($ignoredbversion)) { $dbversion_disallowed = array( array('type'=>'mysql', 'version'=>array(5, 5, 40)), array('type'=>'mysqli', 'version'=>array(5, 5, 40)) //, @@ -211,17 +212,16 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ //array('type'=>'mysqli','version'=>array(5,5,41)) ); $listofforbiddenversion = ''; - foreach ($dbversion_disallowed as $dbversion_totest) - { - if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']); + foreach ($dbversion_disallowed as $dbversion_totest) { + if ($dbversion_totest['type'] == $db->type) { + $listofforbiddenversion .= ($listofforbiddenversion ? ', ' : '').join('.', $dbversion_totest['version']); + } } - foreach ($dbversion_disallowed as $dbversion_totest) - { + foreach ($dbversion_disallowed as $dbversion_totest) { //print $db->type.' - '.join('.',$versionarray).' - '.versioncompare($dbversion_totest['version'],$versionarray)."
\n"; if ($dbversion_totest['type'] == $db->type && (versioncompare($dbversion_totest['version'], $versionarray) == 0 || versioncompare($dbversion_totest['version'], $versionarray) <= -4 || versioncompare($dbversion_totest['version'], $versionarray) >= 4) - ) - { + ) { // Warning: database version too low. print '
'.$langs->trans("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)."
".$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration", join('.', $versionarray), $listofforbiddenversion)); @@ -233,8 +233,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Force l'affichage de la progression - if ($ok) - { + if ($ok) { print ''.$langs->trans("PleaseBePatient").''; flush(); } @@ -243,12 +242,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ /* * Remove deprecated indexes and constraints for Mysql */ - if ($ok && preg_match('/mysql/', $db->type)) - { + if ($ok && preg_match('/mysql/', $db->type)) { $versioncommande = array(4, 0, 0); if (count($versioncommande) && count($versionarray) - && versioncompare($versioncommande, $versionarray) <= 0) // Si mysql >= 4.0 - { + && versioncompare($versioncommande, $versionarray) <= 0) { // Si mysql >= 4.0 dolibarr_install_syslog("Clean database from bad named constraints"); // Suppression vieilles contraintes sans noms et en doubles @@ -262,25 +259,20 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ ); $listtables = $db->DDLListTables($conf->db->name, ''); - foreach ($listtables as $val) - { + foreach ($listtables as $val) { // Database prefix filter - if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) - { + if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) { //print "x".$val."
"; $sql = "SHOW CREATE TABLE ".$val; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $values = $db->fetch_array($resql); $i = 0; $createsql = $values[1]; - while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i', $createsql, $reg) && $i < 100) - { + while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i', $createsql, $reg) && $i < 100) { $sqldrop = "ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1]; $resqldrop = $db->query($sqldrop); - if ($resqldrop) - { + if ($resqldrop) { print ''.$sqldrop.";\n"; } $createsql = preg_replace('/CONSTRAINT `'.$reg[1].'`/i', 'XXX', $createsql); @@ -288,8 +280,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } $db->free($resql); } else { - if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE') - { + if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE') { print ''.$sql.' : '.$db->lasterror()."\n"; } } @@ -299,12 +290,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } /* - * Load sql files - */ - if ($ok) - { + * Load sql files + */ + if ($ok) { $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver - if (!empty($dirmodule)) $dir = dol_buildpath('/'.$dirmodule.'/sql/', 0); + if (!empty($dirmodule)) { + $dir = dol_buildpath('/'.$dirmodule.'/sql/', 0); + } dolibarr_install_syslog("Scan sql files for migration files in ".$dir); // Clean last part to exclude minor version x.y.z -> x.y @@ -320,11 +312,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Get files list $filesindir = array(); $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file; + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/\.sql$/i', $file)) { + $filesindir[] = $file; + } } sort($filesindir); } else { @@ -332,27 +324,24 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Define which file to run - foreach ($filesindir as $file) - { - if (preg_match('/'.$from.'/i', $file)) - { + foreach ($filesindir as $file) { + if (preg_match('/'.$from.'/i', $file)) { $filelist[] = $file; - } elseif (preg_match('/'.$to.'/i', $file)) // First test may be false if we migrate from x.y.* to x.y.* - { + } elseif (preg_match('/'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.* $filelist[] = $file; } } - if (count($filelist) == 0) - { + if (count($filelist) == 0) { print '
'.$langs->trans("ErrorNoMigrationFilesFoundForParameters").'
'; } else { $listoffileprocessed = array(); // Protection to avoid to process twice the same file // Loop on each migrate files - foreach ($filelist as $file) - { - if (in_array($dir.$file, $listoffileprocessed)) continue; + foreach ($filelist as $file) { + if (in_array($dir.$file, $listoffileprocessed)) { + continue; + } print '
'; print ''.$langs->trans("ChoosedMigrateScript").''.$file.''."\n"; @@ -364,18 +353,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scan if there is migration scripts that depends of Dolibarr version // for modules htdocs/module/sql or htdocs/custom/module/sql (files called "dolibarr_x.y.z-a.b.c.sql") $modulesfile = array(); - foreach ($conf->file->dol_document_root as $type => $dirroot) - { + foreach ($conf->file->dol_document_root as $type => $dirroot) { $handlemodule = @opendir($dirroot); // $dirroot may be '..' - if (is_resource($handlemodule)) - { - while (($filemodule = readdir($handlemodule)) !== false) - { - if (!preg_match('/\./', $filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories. - { + if (is_resource($handlemodule)) { + while (($filemodule = readdir($handlemodule)) !== false) { + if (!preg_match('/\./', $filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) { // We exclude filemodule that contains . (are not directories) and are not directories. //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; - if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) - { + if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) { $modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file] = '/'.$filemodule.'/sql/dolibarr_'.$file; } } @@ -384,9 +368,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } } - foreach ($modulesfile as $modulefilelong => $modulefileshort) - { - if (in_array($modulefilelong, $listoffileprocessed)) continue; + foreach ($modulesfile as $modulefilelong => $modulefileshort) { + if (in_array($modulefilelong, $listoffileprocessed)) { + continue; + } print '
'; print ''.$langs->trans("ChoosedMigrateScript").' (external modules)'.$modulefileshort.''."\n"; @@ -401,24 +386,33 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print ''; - if ($db->connected) $db->close(); + if ($db->connected) { + $db->close(); + } } -if (empty($actiondone)) -{ +if (empty($actiondone)) { print '
'.$langs->trans("ErrorWrongParameters").'
'; } $ret = 0; -if (!$ok && isset($argv[1])) $ret = 1; +if (!$ok && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade: end ".((!$ok && empty($_GET["ignoreerrors"])) || $dirmodule)); $nonext = (!$ok && empty($_GET["ignoreerrors"])) ? 2 : 0; -if ($dirmodule) $nonext = 1; +if ($dirmodule) { + $nonext = 1; +} pFooter($nonext, $setuplang); -if ($db->connected) $db->close(); +if ($db->connected) { + $db->close(); +} // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 1dc7180bc4b..d9656231a2c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -39,8 +39,7 @@ */ include_once 'inc.php'; -if (!file_exists($conffile)) -{ +if (!file_exists($conffile)) { print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } require_once $conffile; @@ -64,9 +63,11 @@ $error = 0; // Ne fonctionne que si on est pas en safe_mode. $err = error_reporting(); error_reporting(0); -if (!empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT)) +if (!empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT)) { @set_time_limit((int) $conf->global->MAIN_OVERRIDE_TIME_LIMIT); -else @set_time_limit(600); +} else { + @set_time_limit(600); +} error_reporting($err); $setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : 'auto'; @@ -77,13 +78,21 @@ $enablemodules = GETPOST("enablemodules", 'alpha', 3) ?GETPOST("enablemodules", $langs->loadLangs(array("admin", "install", "bills", "suppliers")); -if ($dolibarr_main_db_type == 'mysqli') $choix = 1; -if ($dolibarr_main_db_type == 'pgsql') $choix = 2; -if ($dolibarr_main_db_type == 'mssql') $choix = 3; +if ($dolibarr_main_db_type == 'mysqli') { + $choix = 1; +} +if ($dolibarr_main_db_type == 'pgsql') { + $choix = 2; +} +if ($dolibarr_main_db_type == 'mssql') { + $choix = 3; +} dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto." ".$enablemodules); -if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); +if (!is_object($conf)) { + dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); +} @@ -91,16 +100,14 @@ if (!is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initiali * View */ -if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) -{ +if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n"; print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; - if (substr($sapi_type, 0, 3) == 'cli') - { + if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; } exit; @@ -109,22 +116,21 @@ if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); -if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) -{ +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { print '

Database '.$langs->trans('DataMigration').'

'; print ''; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) - { + if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } else { + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } } // $conf is already instancied inside inc.php @@ -142,47 +148,48 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $hookmanager = new HookManager($db); $hookmanager->initHooks(array('upgrade')); - if (!$db->connected) - { + if (!$db->connected) { print ''; dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); $error++; } - if (!$error) - { - if ($db->database_selected) - { + if (!$error) { + if ($db->database_selected) { dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); } else { $error++; } } - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; + if (empty($dolibarr_main_db_encryption)) { + $dolibarr_main_db_encryption = 0; + } $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; + if (empty($dolibarr_main_db_cryptkey)) { + $dolibarr_main_db_cryptkey = ''; + } $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Chargement config - if (!$error) - { + if (!$error) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) { + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + } $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; } /*************************************************************************************** - * - * Migration of data - * - ***************************************************************************************/ + * + * Migration of data + * + ***************************************************************************************/ $db->begin(); - if (!$error) - { + if (!$error) { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); @@ -222,8 +229,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $afterversionarray = explode('.', '2.0.0'); $beforeversionarray = explode('.', '2.7.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Script pour V2 -> V2.1 migrate_paiements($db, $langs, $conf); @@ -286,8 +292,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $afterversionarray = explode('.', '2.7.9'); $beforeversionarray = explode('.', '2.8.9'); //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); @@ -312,8 +317,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 2.9 $afterversionarray = explode('.', '2.8.9'); $beforeversionarray = explode('.', '2.9.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_project_task_time($db, $langs, $conf); migrate_customerorder_shipping($db, $langs, $conf); @@ -326,16 +330,14 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 3.0 $afterversionarray = explode('.', '2.9.9'); $beforeversionarray = explode('.', '3.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Script for 3.1 $afterversionarray = explode('.', '3.0.9'); $beforeversionarray = explode('.', '3.1.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); migrate_actioncomm_element($db, $langs, $conf); @@ -344,8 +346,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 3.2 $afterversionarray = explode('.', '3.1.9'); $beforeversionarray = explode('.', '3.2.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_contrat($db, $langs, $conf); migrate_mode_reglement($db, $langs, $conf); @@ -356,8 +357,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Script for 3.3 $afterversionarray = explode('.', '3.2.9'); $beforeversionarray = explode('.', '3.3.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_categorie_association($db, $langs, $conf); } @@ -367,32 +367,28 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Tasks to do always and only into last targeted version $afterversionarray = explode('.', '3.6.9'); // target is after this $beforeversionarray = explode('.', '3.7.9'); // target is before this - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_event_assignement($db, $langs, $conf); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_event_assignement($db, $langs, $conf); } // Scripts for 3.9 $afterversionarray = explode('.', '3.7.9'); $beforeversionarray = explode('.', '3.8.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Scripts for 4.0 $afterversionarray = explode('.', '3.9.9'); $beforeversionarray = explode('.', '4.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); } // Scripts for 5.0 $afterversionarray = explode('.', '4.0.9'); $beforeversionarray = explode('.', '5.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate to add entity value into llx_societe_remise migrate_remise_entity($db, $langs, $conf); @@ -403,15 +399,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scripts for 6.0 $afterversionarray = explode('.', '5.0.9'); $beforeversionarray = explode('.', '6.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - if (!empty($conf->multicompany->enabled)) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + if (!empty($conf->multicompany->enabled)) { global $multicompany_transverse_mode; // Only if the transverse mode is not used - if (empty($multicompany_transverse_mode)) - { + if (empty($multicompany_transverse_mode)) { // Migrate to add entity value into llx_user_rights migrate_user_rights_entity($db, $langs, $conf); @@ -424,8 +417,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scripts for 7.0 $afterversionarray = explode('.', '6.0.9'); $beforeversionarray = explode('.', '7.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate contact association migrate_event_assignement_contact($db, $langs, $conf); @@ -435,16 +427,14 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Scripts for 8.0 $afterversionarray = explode('.', '7.0.9'); $beforeversionarray = explode('.', '8.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); } // Scripts for 9.0 $afterversionarray = explode('.', '8.0.9'); $beforeversionarray = explode('.', '9.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_user_photospath(); } @@ -460,8 +450,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Code executed only if migration is LAST ONE. Must always be done. - if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) - { + if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', @@ -502,14 +491,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (!$error && $enablemodules) - { + if (!$error && $enablemodules) { // Reload modules (this must be always done and only into last targeted version) $listofmodules = array(); $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); $tmplistofmodules = explode(',', $enablemodules); - foreach ($tmplistofmodules as $value) - { + foreach ($tmplistofmodules as $value) { $listofmodules[$value] = 'forceactivate'; } @@ -521,16 +508,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Can call a dedicated external upgrade process - if (!$error) - { + if (!$error) { $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); $object = new stdClass(); $action = "upgrade"; $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($hookmanager->resNbOfHooks > 0) - { - if ($reshook < 0) - { + if ($hookmanager->resNbOfHooks > 0) { + if ($reshook < 0) { print ''; @@ -587,16 +570,22 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } $ret = 0; -if ($error && isset($argv[1])) $ret = 1; +if ($error && isset($argv[1])) { + $ret = 1; +} dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade2: end"); pFooter($error ? 2 : 0, $setuplang); -if ($db->connected) $db->close(); +if ($db->connected) { + $db->close(); +} // Return code if ran from command line -if ($ret) exit($ret); +if ($ret) { + exit($ret); +} @@ -617,8 +606,7 @@ function migrate_paiements($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $sql = "SELECT p.rowid, p.fk_facture, p.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; $sql .= " WHERE p.fk_facture > 0"; @@ -626,14 +614,12 @@ function migrate_paiements($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_paiements"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $row[$i][0] = $obj->rowid; $row[$i][1] = $obj->fk_facture; @@ -644,15 +630,12 @@ function migrate_paiements($db, $langs, $conf) dol_print_error($db); } - if ($num) - { + if ($num) { print $langs->trans('MigrationPaymentsNumberToUpdate', $num)."
\n"; - if ($db->begin()) - { + if ($db->begin()) { $res = 0; $num = count($row); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; @@ -666,8 +649,7 @@ function migrate_paiements($db, $langs, $conf) } } - if ($res == (2 * count($row))) - { + if ($res == (2 * count($row))) { $db->commit(); print $langs->trans('MigrationSuccessfullUpdate')."
"; } else { @@ -703,8 +685,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql .= " bu2.url_id as socid"; @@ -719,16 +700,13 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1"); $row = array(); - if ($resql) - { + if ($resql) { $i = $j = 0; $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas - { + if ($obj->pamount == $obj->bamount && $obj->socid) { // Pour etre sur d'avoir bon cas $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; @@ -743,16 +721,16 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) dol_print_error($db); } - if (count($row)) - { + if (count($row)) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)."
\n"; $db->begin(); $res = 0; $num = count($row); - for ($i = 0; $i < $num; $i++) - { - if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + for ($i = 0; $i < $num; $i++) { + if ($conf->global->MAIN_FEATURES_LEVEL == 2) { + print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + } // On cherche facture sans lien paiement et du meme montant et pour meme societe. $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; @@ -762,12 +740,10 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; - if ($num >= 1) - { + if ($num >= 1) { $obj = $db->fetch_object($resql); $facid = $obj->rowid; @@ -783,8 +759,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) } } - if ($res > 0) - { + if ($res > 0) { print $langs->trans('MigrationSuccessfullUpdate')."
"; } else { print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; @@ -820,8 +795,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql .= " bu2.url_id as socid"; @@ -835,16 +809,13 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2"); $row = array(); - if ($resql) - { + if ($resql) { $i = $j = 0; $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas - { + if ($obj->pamount == $obj->bamount && $obj->socid) { // Pour etre sur d'avoir bon cas $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; @@ -862,15 +833,15 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $nberr = 0; $num = count($row); - if ($num) - { + if ($num) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
\n"; $db->begin(); $res = 0; - for ($i = 0; $i < $num; $i++) - { - if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + for ($i = 0; $i < $num; $i++) { + if ($conf->global->MAIN_FEATURES_LEVEL == 2) { + print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + } // On cherche facture sans lien paiement et du meme montant et pour meme societe. $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; @@ -880,12 +851,10 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; - if ($num >= 1) - { + if ($num >= 1) { $obj = $db->fetch_object($resql); $facid = $obj->rowid; @@ -901,8 +870,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) } } - if ($res > 0) - { + if ($res > 0) { print $langs->trans('MigrationSuccessfullUpdate')."
"; } else { print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; @@ -919,8 +887,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture"; $db->query($sql); - if (!$nberr) - { + if (!$nberr) { $db->commit(); } else { print 'ERROR'; @@ -962,19 +929,16 @@ function migrate_contracts_det($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_det"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { print $langs->trans('MigrationContractsNumberToUpdate', $num)."
\n"; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; @@ -993,8 +957,7 @@ function migrate_contracts_det($db, $langs, $conf) $sql .= "null"; $sql .= ")"; - if ($db->query($sql)) - { + if ($db->query($sql)) { print $langs->trans('MigrationContractsLineCreation', $obj->cref)."
\n"; } else { dol_print_error($db); @@ -1004,8 +967,7 @@ function migrate_contracts_det($db, $langs, $conf) $i++; } - if (!$nberr) - { + if (!$nberr) { // $db->rollback(); $db->commit(); print $langs->trans('MigrationSuccessfullUpdate')."
"; @@ -1050,19 +1012,16 @@ function migrate_links_transfert($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_links_transfert"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { print $langs->trans('MigrationBankTransfertsToUpdate', $num)."
\n"; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; @@ -1075,8 +1034,7 @@ function migrate_links_transfert($db, $langs, $conf) print $sql.'
'; dolibarr_install_syslog("migrate_links_transfert"); - if (!$db->query($sql)) - { + if (!$db->query($sql)) { dol_print_error($db); $nberr++; } @@ -1084,8 +1042,7 @@ function migrate_links_transfert($db, $langs, $conf) $i++; } - if (!$nberr) - { + if (!$nberr) { // $db->rollback(); $db->commit(); print $langs->trans('MigrationSuccessfullUpdate')."
"; @@ -1121,18 +1078,26 @@ function migrate_contracts_date1($db, $langs, $conf) $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; + if (!$resql) { + dol_print_error($db); + } + if ($db->affected_rows($resql) > 0) { + print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; + } else { + print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; + } $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')."
\n"; + if (!$resql) { + dol_print_error($db); + } + if ($db->affected_rows($resql) > 0) { + print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; + } else { + print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')."
\n"; + } print ''; } @@ -1162,22 +1127,18 @@ function migrate_contracts_date2($db, $langs, $conf) $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); - if ($resql) - { + if ($resql) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $nbcontratsmodifie = 0; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->date_contrat > $obj->datemin) - { + if ($obj->date_contrat > $obj->datemin) { $datemin = $db->jdate($obj->datemin); print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
\n"; @@ -1185,7 +1146,9 @@ function migrate_contracts_date2($db, $langs, $conf) $sql .= " SET date_contrat='".$db->idate($datemin)."'"; $sql .= " WHERE rowid=".$obj->cref; $resql2 = $db->query($sql); - if (!$resql2) dol_print_error($db); + if (!$resql2) { + dol_print_error($db); + } $nbcontratsmodifie++; } @@ -1194,9 +1157,11 @@ function migrate_contracts_date2($db, $langs, $conf) $db->commit(); - if ($nbcontratsmodifie) - print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)."
\n"; - else print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')."
\n"; + if ($nbcontratsmodifie) { + print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)."
\n"; + } else { + print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')."
\n"; + } } } else { dol_print_error($db); @@ -1223,10 +1188,14 @@ function migrate_contracts_date3($db, $langs, $conf) $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')."
\n"; + if (!$resql) { + dol_print_error($db); + } + if ($db->affected_rows($resql) > 0) { + print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; + } else { + print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')."
\n"; + } print ''; } @@ -1250,19 +1219,19 @@ function migrate_contracts_open($db, $langs, $conf) $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } if ($db->affected_rows($resql) > 0) { $i = 0; $row = array(); $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $nbcontratsmodifie = 0; $db->begin(); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); print $langs->trans('MigrationReopenThisContract', $obj->cref)."
\n"; @@ -1270,7 +1239,9 @@ function migrate_contracts_open($db, $langs, $conf) $sql .= " SET statut=1"; $sql .= " WHERE rowid=".$obj->cref; $resql2 = $db->query($sql); - if (!$resql2) dol_print_error($db); + if (!$resql2) { + dol_print_error($db); + } $nbcontratsmodifie++; @@ -1279,11 +1250,15 @@ function migrate_contracts_open($db, $langs, $conf) $db->commit(); - if ($nbcontratsmodifie) - print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)."
\n"; - else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + if ($nbcontratsmodifie) { + print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)."
\n"; + } else { + print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } } - } else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } else { + print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } print ''; } @@ -1307,8 +1282,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn", "fk_facture_fourn"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $nb = 0; @@ -1318,15 +1292,13 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); $select_resql = $db->query($select_sql); - if ($select_resql) - { + if ($select_resql) { $select_num = $db->num_rows($select_resql); $i = 0; $var = true; // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn - while (($i < $select_num) && (!$error)) - { + while (($i < $select_num) && (!$error)) { $var = !$var; $select_obj = $db->fetch_object($select_resql); @@ -1335,15 +1307,12 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; $check_resql = $db->query($check_sql); - if ($check_resql) - { + if ($check_resql) { $check_num = $db->num_rows($check_resql); - if ($check_num == 0) - { + if ($check_num == 0) { $db->begin(); - if ($nb == 0) - { + if ($nb == 0) { print ''; print ''; } @@ -1357,8 +1326,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $insert_sql .= ' amount = \''.$select_obj->amount.'\''; $insert_resql = $db->query($insert_sql); - if ($insert_resql) - { + if ($insert_resql) { $nb++; print ''; } else { @@ -1376,10 +1344,8 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $error++; } - if (!$error) - { - if (!$nb) - { + if (!$error) { + if (!$nb) { print ''; } $db->commit(); @@ -1427,14 +1393,11 @@ function migrate_price_facture($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_facture"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1465,15 +1428,12 @@ function migrate_price_facture($db, $langs, $conf) /* On touche a facture mere uniquement si total_ttc = 0 */ - if (!$total_ttc_f) - { + if (!$total_ttc_f) { $facture = new Facture($db); $facture->id = $obj->facid; - if ($facture->fetch($facture->id) >= 0) - { - if ($facture->update_price() > 0) - { + if ($facture->fetch($facture->id) >= 0) { + if ($facture->update_price() > 0) { //print $facture->id; } else { print "Error id=".$facture->id; @@ -1516,7 +1476,7 @@ function migrate_price_facture($db, $langs, $conf) */ function migrate_price_propal($db, $langs, $conf) { - $tmpmysoc = new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1535,14 +1495,11 @@ function migrate_price_propal($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_propal"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1572,24 +1529,24 @@ function migrate_price_propal($db, $langs, $conf) /* On touche pas a propal mere - $propal = new Propal($db); - $propal->id=$obj->rowid; - if ( $propal->fetch($propal->id) >= 0 ) - { - if ( $propal->update_price() > 0 ) - { - print ". "; - } - else - { - print "Error id=".$propal->id; - } - } - else - { - print "Error #3"; - } - */ + $propal = new Propal($db); + $propal->id=$obj->rowid; + if ( $propal->fetch($propal->id) >= 0 ) + { + if ( $propal->update_price() > 0 ) + { + print ". "; + } + else + { + print "Error id=".$propal->id; + } + } + else + { + print "Error #3"; + } + */ $i++; } } else { @@ -1622,9 +1579,11 @@ function migrate_price_contrat($db, $langs, $conf) { $db->begin(); - $tmpmysoc = new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. + if (empty($tmpmysoc->country_id)) { + $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. + } print ''; @@ -3421,26 +3269,20 @@ function migrate_mode_reglement($db, $langs, $conf) function migrate_clean_association($db, $langs, $conf) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association"); - if ($result) // result defined for version 3.2 or - - { + if ($result) { // result defined for version 3.2 or - $obj = $db->fetch_object($result); - if ($obj) // It table categorie_association exists - { + if ($obj) { // It table categorie_association exists $couples = array(); $filles = array(); $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: search duplicate"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - while ($obj = $db->fetch_object($resql)) - { - if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). - { - if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) - { + while ($obj = $db->fetch_object($resql)) { + if (!isset($filles[$obj->fk_categorie_fille])) { // Only one record as child (a child has only on parent). + if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) { $filles[$obj->fk_categorie_fille] = 1; // Set record for this child $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); } @@ -3450,8 +3292,7 @@ function migrate_clean_association($db, $langs, $conf) dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); // If there is duplicates couples or child with two parents - if (count($couples) > 0 && $num > count($couples)) - { + if (count($couples) > 0 && $num > count($couples)) { $error = 0; $db->begin(); @@ -3460,21 +3301,20 @@ function migrate_clean_association($db, $langs, $conf) $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: delete association"); $resqld = $db->query($sql); - if ($resqld) - { + if ($resqld) { // And we insert only each record once - foreach ($couples as $key => $val) - { + foreach ($couples as $key => $val) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; dolibarr_install_syslog("upgrade: insert association"); $resqli = $db->query($sql); - if (!$resqli) $error++; + if (!$resqli) { + $error++; + } } } - if (!$error) - { + if (!$error) { print ''; print ''; $db->commit(); @@ -3510,8 +3350,7 @@ function migrate_categorie_association($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."categorie_association")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."categorie_association")) { dolibarr_install_syslog("upgrade2::migrate_categorie_association"); $db->begin(); @@ -3520,15 +3359,12 @@ function migrate_categorie_association($db, $langs, $conf) $sqlSelect .= " FROM ".MAIN_DB_PREFIX."categorie_association"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."categorie SET "; @@ -3536,8 +3372,7 @@ function migrate_categorie_association($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->fk_categorie_fille; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3548,8 +3383,7 @@ function migrate_categorie_association($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { // TODO DROP table in the next release /* $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."categorie_association"; @@ -3607,23 +3441,19 @@ function migrate_event_assignement($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; $sqlUpdate .= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3634,8 +3464,7 @@ function migrate_event_assignement($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3678,23 +3507,19 @@ function migrate_event_assignement_contact($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; $sqlUpdate .= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3705,8 +3530,7 @@ function migrate_event_assignement_contact($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3752,34 +3576,28 @@ function migrate_reset_blocked_log($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Process entity '.$obj->entity; $sqlSearch = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."blockedlog WHERE action = 'MODULE_SET' and entity = ".$obj->entity; $resqlSearch = $db->query($sqlSearch); - if ($resqlSearch) - { + if ($resqlSearch) { $objSearch = $db->fetch_object($resqlSearch); //var_dump($objSearch); - if ($objSearch && $objSearch->nb == 0) - { + if ($objSearch && $objSearch->nb == 0) { print ' - Record for entity must be reset...'; $sqlUpdate = "DELETE FROM ".MAIN_DB_PREFIX."blockedlog"; $sqlUpdate .= " WHERE entity = ".$obj->entity; $resqlUpdate = $db->query($sqlUpdate); - if (!$resqlUpdate) - { + if (!$resqlUpdate) { $error++; dol_print_error($db); } else { @@ -3812,8 +3630,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) print $langs->trans('NothingToDo')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3855,15 +3672,12 @@ function migrate_remise_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET"; @@ -3871,8 +3685,7 @@ function migrate_remise_entity($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3884,8 +3697,7 @@ function migrate_remise_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -3924,26 +3736,21 @@ function migrate_remise_except_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); - if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture)) - { + if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture)) { $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture); $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; - } elseif (!empty($obj->fk_facture_line)) - { + } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; @@ -3955,10 +3762,8 @@ function migrate_remise_except_entity($db, $langs, $conf) } $resql2 = $db->query($sqlSelect2); - if ($resql2) - { - if ($db->num_rows($resql2) > 0) - { + if ($resql2) { + if ($db->num_rows($resql2) > 0) { $obj2 = $db->fetch_object($resql2); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET"; @@ -3966,8 +3771,7 @@ function migrate_remise_except_entity($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3984,8 +3788,7 @@ function migrate_remise_except_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -4025,15 +3828,12 @@ function migrate_user_rights_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET"; @@ -4041,8 +3841,7 @@ function migrate_user_rights_entity($db, $langs, $conf) $sqlUpdate .= " WHERE fk_user = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -4054,8 +3853,7 @@ function migrate_user_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -4095,15 +3893,12 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) //print $sqlSelect; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET"; @@ -4111,8 +3906,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $sqlUpdate .= " WHERE fk_usergroup = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -4124,8 +3918,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -4153,8 +3946,7 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) { dolibarr_install_syslog("upgrade2::migrate_rename_directories"); - if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) - { + if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) { dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); } @@ -4296,12 +4088,16 @@ function migrate_delete_old_dir($db, $langs, $conf) */ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $force = 0) { - if (count($listofmodule) == 0) return; + if (count($listofmodule) == 0) { + return; + } dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); foreach ($listofmodule as $moduletoreload => $reloadmode) { // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) { + continue; // Discard reload if module not enabled + } $mod = null; @@ -4485,10 +4281,8 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } else { // Other generic cases/modules $reg = array(); $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); - if (!empty($reg[1])) - { - if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase - { + if (!empty($reg[1])) { + if (strtoupper($moduletoreload) == $moduletoreload) { // If key is un uppercase $moduletoreloadshort = ucfirst(strtolower($reg[1])); } else // If key is a mix of up and low case { @@ -4525,8 +4319,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } } - if (!empty($mod) && is_object($mod)) - { + if (!empty($mod) && is_object($mod)) { print ''; } - if (!empty($arrayfields['sp.total_vat']['checked'])) + if (!empty($arrayfields['sp.total_tva']['checked'])) { // Amount print '\n"; + print '\n"; if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_vat'; - $totalarray['val']['sp.total_vat'] += $obj->total_vat; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva'; + $totalarray['val']['sp.total_tva'] += $obj->total_tva; } // Amount TTC if (!empty($arrayfields['sp.total_ttc']['checked'])) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d2c8ffdbcc4..326aac90390 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -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; +} + /* ============================================================================== */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 186f2e2dfb3..81407987c35 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4509,6 +4509,10 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im line-height: 1em; } +#divbodywebsite section p { + margin: unset; +} + /* ============================================================================== */ /* Module agenda */ diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ca038935af9..46dfd49ed0a 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -358,7 +358,7 @@ if ($action == 'seteditinline') { dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); - dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' + //dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } @@ -371,7 +371,7 @@ if ($action == 'unseteditinline') if ($action == 'setshowsubcontainers') { dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1); - dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline + //dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } @@ -2743,7 +2743,19 @@ if (!GETPOST('hide_websitemenu')) print ''."\n"; print '
'; - print '
'; + + print '
'; // Button include dynamic contant + print $langs->trans("ShowSubcontainers"); + if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) + { + print ''.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').''; + } + else { + print ''.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').''; + } + print '
'; + + print '
'; // Button edit inline print ''."\n"; print ''."\n"; @@ -2812,17 +2824,7 @@ if (!GETPOST('hide_websitemenu')) } print '
'; - print ''; + print '
'; // 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 .= ''."\n"; - $out .= '
'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
'; print ''.$langs->trans('UpgradeExternalModule').': '; print $hookmanager->error; @@ -544,8 +528,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } } else { //if (! empty($conf->modules)) - if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done - { + if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done print '
'; print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); print '
'.$langs->trans('SuppliersInvoices').'
fk_paiementfournfk_facturefourn'.$langs->trans('Amount').' 
'.$langs->trans("OK").'
'.$langs->trans("AlreadyDone").'
'; @@ -1640,14 +1599,11 @@ function migrate_price_contrat($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_contrat"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1724,14 +1680,11 @@ function migrate_price_commande($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_commande"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1760,24 +1713,24 @@ function migrate_price_commande($db, $langs, $conf) $commandeligne->update_total(); /* On touche pas a facture mere - $commande = new Commande($db); - $commande->id = $obj->rowid; - if ( $commande->fetch($commande->id) >= 0 ) - { - if ( $commande->update_price() > 0 ) - { - print ". "; - } - else - { - print "Error id=".$commande->id; - } - } - else - { - print "Error #3"; - } - */ + $commande = new Commande($db); + $commande->id = $obj->rowid; + if ( $commande->fetch($commande->id) >= 0 ) + { + if ( $commande->update_price() > 0 ) + { + print ". "; + } + else + { + print "Error id=".$commande->id; + } + } + else + { + print "Error #3"; + } + */ $i++; } } else { @@ -1787,14 +1740,14 @@ function migrate_price_commande($db, $langs, $conf) $db->free($resql); /* - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; - $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0"; - $resql=$db->query($sql); - if (! $resql) - { - dol_print_error($db); - } - */ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; + $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0"; + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + } + */ $db->commit(); } else { @@ -1837,14 +1790,11 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $rowid = $obj->rowid; @@ -1873,24 +1823,24 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $commandeligne->update_total(); /* On touche pas a facture mere - $commande = new Commande($db); - $commande->id = $obj->rowid; - if ( $commande->fetch($commande->id) >= 0 ) - { - if ( $commande->update_price() > 0 ) - { - print ". "; - } - else - { - print "Error id=".$commande->id; - } - } - else - { - print "Error #3"; - } - */ + $commande = new Commande($db); + $commande->id = $obj->rowid; + if ( $commande->fetch($commande->id) >= 0 ) + { + if ( $commande->update_price() > 0 ) + { + print ". "; + } + else + { + print "Error id=".$commande->id; + } + } + else + { + print "Error #3"; + } + */ $i++; } } else { @@ -1900,14 +1850,14 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $db->free($resql); /* - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet"; - $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0"; - $resql=$db->query($sql); - if (! $resql) - { - dol_print_error($db); - } - */ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet"; + $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0"; + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + } + */ $db->commit(); } else { @@ -1936,42 +1886,42 @@ function migrate_modeles($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_modeles"); - if (!empty($conf->facture->enabled)) - { + if (!empty($conf->facture->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $modellist = ModelePDFFactures::liste_modeles($db); - if (count($modellist) == 0) - { + if (count($modellist) == 0) { // Aucun model par defaut. $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $modellist = ModelePDFCommandes::liste_modeles($db); - if (count($modellist) == 0) - { + if (count($modellist) == 0) { // Aucun model par defaut. $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } - if (!empty($conf->expedition->enabled)) - { + if (!empty($conf->expedition->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; $modellist = ModelePDFExpedition::liste_modeles($db); - if (count($modellist) == 0) - { + if (count($modellist) == 0) { // Aucun model par defaut. $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } @@ -1998,31 +1948,26 @@ function migrate_commande_expedition($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "fk_commande"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2031,8 +1976,7 @@ function migrate_commande_expedition($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande"; print $langs->trans('FieldRenamed')."
\n"; @@ -2069,8 +2013,7 @@ function migrate_commande_livraison($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_commande"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); @@ -2080,23 +2023,19 @@ function migrate_commande_livraison($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; $sql .= " WHERE c.rowid = l.fk_commande"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { $delivery_date = $db->jdate($obj->delivery_date); $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; @@ -2104,8 +2043,7 @@ function migrate_commande_livraison($db, $langs, $conf) $sqlu .= ", date_livraison='".$db->idate($delivery_date)."'"; $sqlu .= " WHERE rowid = ".$obj->rowid; $resql3 = $db->query($sqlu); - if (!$resql3) - { + if (!$resql3) { $error++; dol_print_error($db); } @@ -2118,8 +2056,7 @@ function migrate_commande_livraison($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande"; print $langs->trans('FieldRenamed')."
\n"; @@ -2158,8 +2095,7 @@ function migrate_detail_livraison($db, $langs, $conf) // If not this means migration was already done. $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_commande_ligne"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); @@ -2169,15 +2105,12 @@ function migrate_detail_livraison($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; @@ -2188,15 +2121,13 @@ function migrate_detail_livraison($db, $langs, $conf) $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { $sql = "SELECT total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; $sql .= " WHERE rowid = ".$obj->fk_livraison; $resql3 = $db->query($sql); - if ($resql3) - { + if ($resql3) { $obju = $db->fetch_object($resql3); $total_ht = $obju->total_ht + $obj->total_ht; @@ -2204,8 +2135,7 @@ function migrate_detail_livraison($db, $langs, $conf) $sqlu .= " total_ht='".$db->escape($total_ht)."'"; $sqlu .= " WHERE rowid=".$obj->fk_livraison; $resql4 = $db->query($sqlu); - if (!$resql4) - { + if (!$resql4) { $error++; dol_print_error($db); } @@ -2222,8 +2152,7 @@ function migrate_detail_livraison($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer"; print $langs->trans('FieldRenamed')."
\n"; @@ -2238,8 +2167,7 @@ function migrate_detail_livraison($db, $langs, $conf) } else { $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_origin_line"); $obj = $db->fetch_object($result); - if (!$obj) - { + if (!$obj) { $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison"; $db->query($sql); } @@ -2273,15 +2201,12 @@ function migrate_stocks($db, $langs, $conf) $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " GROUP BY fk_product"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; @@ -2289,8 +2214,7 @@ function migrate_stocks($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->fk_product; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { } else { $error++; dol_print_error($db); @@ -2300,8 +2224,7 @@ function migrate_stocks($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2334,8 +2257,7 @@ function migrate_menus($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) { $db->begin(); $sql = "SELECT m.rowid, mc.action"; @@ -2343,14 +2265,11 @@ function migrate_menus($db, $langs, $conf) $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; $sql .= " AND m.enabled = '1'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; @@ -2359,8 +2278,7 @@ function migrate_menus($db, $langs, $conf) $sql .= " AND enabled = '1'"; $resql2 = $db->query($sql); - if ($resql2) - { + if ($resql2) { } else { $error++; dol_print_error($db); @@ -2370,8 +2288,7 @@ function migrate_menus($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2407,8 +2324,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) { $db->begin(); $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; @@ -2418,15 +2334,12 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; @@ -2434,8 +2347,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->fk_expedition; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2446,8 +2358,7 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2476,10 +2387,8 @@ function migrate_restore_missing_links($db, $langs, $conf) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links"); - if (($db->type == 'mysql' || $db->type == 'mysqli')) - { - if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) - { + if (($db->type == 'mysql' || $db->type == 'mysqli')) { + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); return 0; } @@ -2506,15 +2415,12 @@ function migrate_restore_missing_links($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; @@ -2523,18 +2429,18 @@ function migrate_restore_missing_links($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->field; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } //print ". "; $i++; } - } else print $langs->trans('AlreadyDone')."
\n"; + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2566,15 +2472,12 @@ function migrate_restore_missing_links($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; @@ -2583,8 +2486,7 @@ function migrate_restore_missing_links($db, $langs, $conf) $sql .= " WHERE rowid=".$obj->field; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2595,8 +2497,7 @@ function migrate_restore_missing_links($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -2628,23 +2529,19 @@ function migrate_project_user_resp($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet", "fk_user_resp"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { $error = 0; $db->begin(); $sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; @@ -2661,11 +2558,9 @@ function migrate_project_user_resp($db, $langs, $conf) $sql2 .= ", ".$obj->fk_user_resp; $sql2 .= ")"; - if ($obj->fk_user_resp > 0) - { + if ($obj->fk_user_resp > 0) { $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2676,11 +2571,9 @@ function migrate_project_user_resp($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp"; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2715,23 +2608,19 @@ function migrate_project_task_actors($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationProjectTaskActors')."
\n"; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) { $error = 0; $db->begin(); $sql = "SELECT fk_projet_task as fk_project_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; @@ -2750,8 +2639,7 @@ function migrate_project_task_actors($db, $langs, $conf) $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } @@ -2760,11 +2648,9 @@ function migrate_project_task_actors($db, $langs, $conf) } } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors"; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2804,8 +2690,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) - { + if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) { dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); $db->begin(); @@ -2814,15 +2699,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -2838,8 +2720,7 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $sqlInsert .= ")"; $result = $db->query($sqlInsert); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -2850,11 +2731,9 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table; - if ($db->query($sqlDrop)) - { + if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); @@ -2897,22 +2776,18 @@ function migrate_project_task_time($db, $langs, $conf) $sql = "SELECT rowid, fk_task, task_duration"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $totaltime = array(); $oldtime = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->task_duration > 0) - { + if ($obj->task_duration > 0) { // convert to second // only for int time and float time ex: 1,75 for 1h45 list($hour, $min) = explode('.', $obj->task_duration); @@ -2925,36 +2800,37 @@ function migrate_project_task_time($db, $langs, $conf) $sql2 .= " WHERE rowid = ".$obj->rowid; $resql2 = $db->query($sql2); - if (!$resql2) - { + if (!$resql2) { $error++; dol_print_error($db); } print ". "; $oldtime++; - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; - else $totaltime[$obj->fk_task] = $newtime; + if (!empty($totaltime[$obj->fk_task])) { + $totaltime[$obj->fk_task] += $newtime; + } else { + $totaltime[$obj->fk_task] = $newtime; + } } else { - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; - else $totaltime[$obj->fk_task] = $obj->task_duration; + if (!empty($totaltime[$obj->fk_task])) { + $totaltime[$obj->fk_task] += $obj->task_duration; + } else { + $totaltime[$obj->fk_task] = $obj->task_duration; + } } $i++; } - if ($error == 0) - { - if ($oldtime > 0) - { - foreach ($totaltime as $taskid => $total_duration) - { + if ($error == 0) { + if ($oldtime > 0) { + foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql .= " duration_effective = ".$total_duration; $sql .= " WHERE rowid = ".$taskid; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; dol_print_error($db); } @@ -2972,8 +2848,7 @@ function migrate_project_task_time($db, $langs, $conf) dol_print_error($db); } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { $db->rollback(); @@ -3003,8 +2878,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "date_delivery"); $obj1 = $db->fetch_object($result1); $obj2 = $db->fetch_object($result2); - if (!$obj1 && !$obj2) - { + if (!$obj1 && !$obj2) { dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping"); $db->begin(); @@ -3012,8 +2886,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity"; $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition"; - if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) - { + if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) { $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison as delivery_date"; $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; @@ -3022,15 +2895,12 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlSelect .= " AND el.targettype = 'shipping'"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; @@ -3039,8 +2909,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3051,8 +2920,7 @@ function migrate_customerorder_shipping($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { dol_print_error($db); @@ -3092,8 +2960,7 @@ function migrate_shipping_delivery($db, $langs, $conf) $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_expedition"); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { dolibarr_install_syslog("upgrade2::migrate_shipping_delivery"); $db->begin(); @@ -3103,15 +2970,12 @@ function migrate_shipping_delivery($db, $langs, $conf) $sqlSelect .= " WHERE fk_expedition is not null"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -3127,14 +2991,12 @@ function migrate_shipping_delivery($db, $langs, $conf) $sqlInsert .= ")"; $result = $db->query($sqlInsert); - if ($result) - { + if ($result) { $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; $sqlUpdate .= " WHERE rowid = ".$obj->rowid; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3149,8 +3011,7 @@ function migrate_shipping_delivery($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'"; $db->query($sqlDelete); @@ -3209,15 +3070,12 @@ function migrate_shipping_delivery2($db, $langs, $conf) $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; @@ -3226,8 +3084,7 @@ function migrate_shipping_delivery2($db, $langs, $conf) $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; $result = $db->query($sqlUpdate); - if (!$result) - { + if (!$result) { $error++; dol_print_error($db); } @@ -3238,8 +3095,7 @@ function migrate_shipping_delivery2($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if ($error == 0) - { + if ($error == 0) { $db->commit(); } else { dol_print_error($db); @@ -3277,12 +3133,10 @@ function migrate_actioncomm_element($db, $langs, $conf) 'invoice_supplier' => 'fk_supplier_invoice' ); - foreach ($elements as $type => $field) - { + foreach ($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field); $obj = $db->fetch_object($result); - if ($obj) - { + if ($obj) { dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); $db->begin(); @@ -3294,8 +3148,7 @@ function migrate_actioncomm_element($db, $langs, $conf) $sql .= " AND elementtype IS NULL"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $db->commit(); // DDL commands must not be inside a transaction @@ -3338,8 +3191,7 @@ function migrate_mode_reglement($db, $langs, $conf) ); $count = 0; - foreach ($elements['old_id'] as $key => $old_id) - { + foreach ($elements['old_id'] as $key => $old_id) { $error = 0; dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); @@ -3350,11 +3202,9 @@ function migrate_mode_reglement($db, $langs, $conf) $sqlSelect .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sqlSelect); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $count++; $db->begin(); @@ -3371,25 +3221,21 @@ function migrate_mode_reglement($db, $langs, $conf) $sql .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sql); - if ($resqla && $resql) - { - foreach ($elements['tables'] as $table) - { + if ($resqla && $resql) { + foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; $sql .= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); $error++; } print ". "; } - if (!$error) - { + if (!$error) { $db->commit(); } else { dol_print_error($db); @@ -3403,7 +3249,9 @@ function migrate_mode_reglement($db, $langs, $conf) } } - if ($count == 0) print $langs->trans('AlreadyDone')."
\n"; + if ($count == 0) { + print $langs->trans('AlreadyDone')."
\n"; + } print '
'.$langs->trans("MigrationCategorieAssociation").''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')
'; print ''.$langs->trans('Upgrade').': '; print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated @@ -4557,13 +4350,11 @@ function migrate_reload_menu($db, $langs, $conf) // Define list of menu handlers to initialize $listofmenuhandler = array(); if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' - || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') - { + || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } - foreach ($listofmenuhandler as $key => $val) - { + foreach ($listofmenuhandler as $key => $val) { print '
'; //print "x".$key; @@ -4573,8 +4364,7 @@ function migrate_reload_menu($db, $langs, $conf) // Load sql ini_menu_handler.sql file $dir = DOL_DOCUMENT_ROOT."/core/menus/"; $file = 'init_menu_'.$key.'.sql'; - if (file_exists($dir.$file)) - { + if (file_exists($dir.$file)) { $result = run_sql($dir.$file, 1, '', 1, $key); } @@ -4598,14 +4388,14 @@ function migrate_user_photospath() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (!is_object($user)) $user = $fuser; // To avoid error during migration + if (!is_object($user)) { + $user = $fuser; // To avoid error during migration + } $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $fuser->fetch($obj->uid); //echo '
'.$fuser->id.' -> '.$fuser->entity; $entity = (empty($fuser->entity) ? 1 : $fuser->entity); @@ -4615,8 +4405,7 @@ function migrate_user_photospath() $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module } - if ($dir) - { + if ($dir) { //print "Process user id ".$fuser->id."
\n"; $origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path $destin = $dir.'/'.$fuser->id; @@ -4626,26 +4415,23 @@ function migrate_user_photospath() dol_mkdir($destin); //echo '
'.$origin.' -> '.$destin; - if (dol_is_dir($origin)) - { + if (dol_is_dir($origin)) { $handle = opendir($origin_osencoded); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if ($file == '.' || $file == '..') continue; + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if ($file == '.' || $file == '..') { + continue; + } - if (dol_is_dir($origin.'/'.$file)) // it is a dir (like 'thumbs') - { + if (dol_is_dir($origin.'/'.$file)) { // it is a dir (like 'thumbs') $thumbs = opendir($origin_osencoded.'/'.$file); - if (is_resource($thumbs)) - { - dol_mkdir($destin.'/'.$file); - while (($thumb = readdir($thumbs)) !== false) - { - if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) - { - if ($thumb == '.' || $thumb == '..') continue; + if (is_resource($thumbs)) { + dol_mkdir($destin.'/'.$file); + while (($thumb = readdir($thumbs)) !== false) { + if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) { + if ($thumb == '.' || $thumb == '..') { + continue; + } //print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'
'."\n"; print '.'; @@ -4657,8 +4443,7 @@ function migrate_user_photospath() } } else // it is a file { - if (!dol_is_file($destin.'/'.$file)) - { + if (!dol_is_file($destin.'/'.$file)) { //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; print '.'; dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0); diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index ca75eddb7df..a68319fb2df 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -53,3 +53,6 @@ SupplierProposalsToClose=Vendor proposals to close SupplierProposalsToProcess=Vendor proposals to process LastSupplierProposals=Latest %s price requests AllPriceRequests=All requests +TypeContact_supplier_proposal_external_SHIPPING=Vendor contact for delivery +TypeContact_supplier_proposal_external_BILLING=Vendor contact for billing +TypeContact_supplier_proposal_external_SERVICE=Representative following-up proposal diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 15dfc85c8d2..93f445b83d1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -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'); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 405c34734f3..c56fac31a3f 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -906,8 +906,8 @@ class SupplierProposal extends CommonObject $sql .= ", remise"; $sql .= ", remise_percent"; $sql .= ", remise_absolue"; - $sql .= ", tva"; - $sql .= ", total"; + $sql .= ", total_tva"; + $sql .= ", total_ttc"; $sql .= ", datec"; $sql .= ", ref"; $sql .= ", fk_user_author"; @@ -1200,7 +1200,7 @@ class SupplierProposal extends CommonObject global $conf; $sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; - $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; + $sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht"; $sql .= ", p.datec"; $sql .= ", p.date_valid as datev"; $sql .= ", p.date_livraison as delivery_date"; @@ -1239,12 +1239,11 @@ class SupplierProposal extends CommonObject $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; - $this->total = $obj->total; // TODO deprecated $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->tva; + $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; - $this->total_ttc = $obj->total; + $this->total_ttc = $obj->total_ttc; $this->socid = $obj->fk_soc; $this->fk_project = $obj->fk_project; $this->model_pdf = $obj->model_pdf; @@ -2784,7 +2783,7 @@ class SupplierProposalLine extends CommonObjectLine // Bit 0: 0 si TVA normal - 1 si TVA NPR // Bit 1: 0 ligne normale - 1 si ligne de remise fixe - public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 476c2a14db2..fd3dccce0bb 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -304,7 +304,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $now = dol_now(); - $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datec as dp"; + $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total_ttc, p.total_tva, p.total_ht, p.ref, p.fk_statut, p.datec as dp"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 9826c2a409d..04bafe19297 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -152,7 +152,7 @@ $arrayfields = array( 'sp.date_valid'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), 'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), - 'sp.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), + 'sp.total_tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), 'sp.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'sp.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), @@ -253,7 +253,7 @@ if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DI $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; -$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; +$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.total_tva, sp.total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; $sql .= ' sp.fk_multicurrency, sp.multicurrency_code, sp.multicurrency_tx, sp.multicurrency_total_ht, sp.multicurrency_total_tva as multicurrency_total_vat, sp.multicurrency_total_ttc,'; $sql .= ' sp.datec as date_creation, sp.tms as date_update,'; $sql .= " p.rowid as project_id, p.ref as project_ref,"; @@ -299,8 +299,8 @@ if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search('u.login', $search_login); if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1); -if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1); +if ($search_montant_vat != '') $sql .= natural_search("sp.total_tva", $search_montant_vat, 1); +if ($search_montant_ttc != '') $sql .= natural_search("sp.total_ttc", $search_montant_ttc, 1); if ($search_multicurrency_code != '') $sql .= ' AND sp.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; if ($search_multicurrency_tx != '') $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1); if ($search_multicurrency_montant_ht != '') $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); @@ -552,7 +552,7 @@ if ($resql) print ''; print '
'; @@ -653,7 +653,7 @@ if ($resql) if (!empty($arrayfields['sp.date_valid']['checked'])) print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['sp.date_livraison']['checked'])) print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['sp.total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['sp.total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.total_vat']['label'], $_SERVER["PHP_SELF"], 'sp.total_vat', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['sp.total_tva']['checked'])) print_liste_field_titre($arrayfields['sp.total_tva']['label'], $_SERVER["PHP_SELF"], 'sp.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['sp.total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['sp.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder); @@ -803,12 +803,12 @@ if ($resql) $totalarray['val']['sp.total_ht'] += $obj->total_ht; } // Amount VAT - if (!empty($arrayfields['sp.total_vat']['checked'])) + if (!empty($arrayfields['sp.total_tva']['checked'])) { - print ''.price($obj->total_vat)."'.price($obj->total_tva)."