diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 9f360c3ef19..110eae0a3a2 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -213,6 +213,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/resource +%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/societe %_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal @@ -224,6 +225,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website +%_datadir/dolibarr/htdocs/zapier %_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 9c51feba990..ba5c426ea3f 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -293,6 +293,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/resource +%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/societe %_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal @@ -304,6 +305,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website +%_datadir/dolibarr/htdocs/zapier %_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 9f87638e8ba..073ef0389ce 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -210,6 +210,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/resource +%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/societe %_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal @@ -221,6 +222,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website +%_datadir/dolibarr/htdocs/zapier %_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index f55ca13906d..be61853e165 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -221,6 +221,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/resource +%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/societe %_datadir/dolibarr/htdocs/stripe %_datadir/dolibarr/htdocs/supplier_proposal @@ -232,6 +233,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website +%_datadir/dolibarr/htdocs/zapier %_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.patch %_datadir/dolibarr/htdocs/*.php diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 51eeef8af31..107f561eca6 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -63,10 +63,49 @@ with if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { -// unlink($file); + // DOL CHANGE If we keep this, source image files are physically destroyed + // unlink($file); } } +* Replace in tcpdf.php + + $preserve = array( + 'file_id', + 'internal_encoding', + 'state', + 'bufferlen', + 'buffer', + 'cached_files', + +with + + $preserve = array( + 'file_id', + 'internal_encoding', + 'state', + 'bufferlen', + 'buffer', + 'cached_files', + // @CHANGE DOL + 'imagekeys', + +* Replace in tcpdf.php + + if (!@TCPDF_STATIC::file_exists($file)) { + return false; + } + +with + + if (!@TCPDF_STATIC::file_exists($file)) { + // DOL CHANGE If we keep this, the image is not visible on pages after the first one. + //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); + //return false; + } + + + * In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace if (strpos($filename, '://') === false) { @@ -102,7 +141,7 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php + protected $default_monospaced_font = 'freemono'; - + TCPDI: ------ diff --git a/dev/translation/txpull.sh b/dev/translation/txpull.sh index 664f4cef1f5..3f24bd0912d 100755 --- a/dev/translation/txpull.sh +++ b/dev/translation/txpull.sh @@ -54,3 +54,5 @@ fi echo Think to launch also: echo "> dev/tools/fixaltlanguages.sh fix all" +echo "For v11: Replace also regex \(.*(sponge|cornas|eratosthene|cyan).*\) with ''" + diff --git a/doc/images/dolibarr_screenshot1_1920x1080.jpg b/doc/images/dolibarr_screenshot1_1920x1080.jpg index 67ddece6df5..bc46b00a130 100644 Binary files a/doc/images/dolibarr_screenshot1_1920x1080.jpg and b/doc/images/dolibarr_screenshot1_1920x1080.jpg differ diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index d945513f952..46d3feae5b2 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -125,7 +125,7 @@ class AccountancyExport * @param int $type Format id * @return string Format code */ - private static function getFormatCode($type) + public static function getFormatCode($type) { $formatcode = array( self::$EXPORT_TYPE_CONFIGURABLE => 'csv', diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index b244d8be123..b0007395e0a 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -171,6 +171,7 @@ class AccountingAccount extends CommonObject $sql .= " a.rowid = " . (int) $rowid; } elseif ($account_number) { $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; + $sql .= " AND a.entity = ".$conf->entity; } if (! empty($limittocurrentchart)) { $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 782b151a5a4..48df5ce374a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -152,6 +152,8 @@ if ($action == 'validatehistory') { while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); + $isBuyerInEEC = isInEEC($objp); + // Search suggested account for product/service $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index f6b149de291..d52c4c51f07 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -230,7 +230,7 @@ if (strlen(trim($search_country))) { elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code", "co.label"), $search_country); + else $sql .= natural_search("co.code", $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index e8b898a455d..d964d348889 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -262,7 +262,7 @@ if (strlen(trim($search_country))) { elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code", "co.label"), $search_country); + else $sql .= natural_search("co.code", $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 1a0844436b6..3bc44698029 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -141,12 +141,14 @@ if ($action == 'validatehistory') { } else { $num_lines = $db->num_rows($result); - $isSellerInEEC = isInEEC($mysoc); + $isBuyerInEEC = isInEEC($mysoc); $i = 0; while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); + $isSellerInEEC = isInEEC($objp); + // Search suggested account for product/service $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 7afae1538e7..a035aed2b1f 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -225,7 +225,7 @@ if (strlen(trim($search_country))) { elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code", "co.label"), $search_country); + else $sql .= natural_search("co.code", $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 33e356dddb4..ecd41f2f9da 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -263,7 +263,7 @@ if (strlen(trim($search_country))) { elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code", "co.label"), $search_country); + else $sql .= natural_search("co.code", $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 5c9f7ad48ed..4537c497ff6 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -34,8 +34,10 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); header('Content-Type: text/csv'); +include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; +$accountancyexport = new AccountancyExport($db); -if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger +if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$EXPORT_TYPE_FEC && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger { // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle if (empty($search_date_end)) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ff2e5082736..ec4042cdf88 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2750,6 +2750,9 @@ class Adherent extends CommonObject $nbok = 0; $nbko = 0; + $listofmembersok = array(); + $listofmembersko = array(); + $arraydaysbeforeend=explode(';', $daysbeforeendlist); foreach($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { @@ -2766,7 +2769,8 @@ class Adherent extends CommonObject $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; - $sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'"; + $sql.= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; + $sql.= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; $resql = $this->db->query($sql); if ($resql) @@ -2787,6 +2791,7 @@ class Adherent extends CommonObject if (empty($adherent->email)) { $nbko++; + $listofmembersko[$adherent->id]=$adherent->id; } else { @@ -2828,12 +2833,16 @@ class Adherent extends CommonObject { $error++; $this->error = $cmail->error; - $this->errors += $cmail->errors; + if (! is_null($cmail->errors)) { + $this->errors += $cmail->errors; + } $nbko++; + $listofmembersko[$adherent->id]=$adherent->id; } else { $nbok++; + $listofmembersok[$adherent->id]=$adherent->id; $message = $msg; $sendto = $to; @@ -2892,7 +2901,10 @@ class Adherent extends CommonObject else { $blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding"; + $nbko++; + $listofmembersko[$adherent->id]=$adherent->id; + break; } } @@ -2916,7 +2928,39 @@ class Adherent extends CommonObject { $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.'; $this->output.= ' Send email successfuly to '.$nbok.' members'; - if ($nbko) $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)'; + if (is_array($listofmembersok)) { + $listofids = ''; $i = 0; + foreach($listofmembersok as $idmember) { + if ($i > 100) { + $listofids .= ', ...'; + break; + } + if (empty($listofids)) $listofids .= ' ['; + else $listofids .= ', '; + $listofids .= $idmember; + $i++; + } + if ($listofids) $listofids .= ']'; + $this->output .= $listofids; + } + if ($nbko) { + $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)'; + if (is_array($listofmembersko)) { + $listofids = ''; $i = 0; + foreach($listofmembersko as $idmember) { + if ($i > 100) { + $listofids .= ', ...'; + break; + } + if (empty($listofids)) $listofids .= ' ['; + else $listofids .= ', '; + $listofids .= $idmember; + $i++; + } + if ($listofids) $listofids .= ']'; + $this->output .= $listofids; + } + } } return 0; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index ce75d83505a..df72e1bde04 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -95,15 +95,15 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency", 'aZ09'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); $dirforimage = $conf->mycompany->dir_output.'/logos/'; diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index eed7f40910c..baeac243ce0 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -40,7 +40,7 @@ $update=GETPOST('update', 'alpha'); $delete=GETPOST('delete', 'none'); // Do not use alpha here $debug=GETPOST('debug', 'int'); $consts=GETPOST('const', 'array'); -$constname=GETPOST('constname', 'alpha'); +$constname=GETPOST('constname', 'alphanohtml'); $constvalue=GETPOST('constvalue', 'none'); // We shoul dbe able to send everything here $constnote=GETPOST('constnote', 'alpha'); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 8ddd453b458..d6981448ea6 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2020 Laurent Destailleur * Copyright (C) 2017-2018 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -52,15 +52,15 @@ $pagenext = $page + 1; if (!$sortfield) $sortfield = 'page,param'; if (!$sortorder) $sortorder = 'ASC'; -$defaulturl = GETPOST('defaulturl'); -$defaultkey = GETPOST('defaultkey', 'alpha'); -$defaultvalue = GETPOST('defaultvalue'); +$defaulturl = GETPOST('defaulturl', 'alphanohtml'); +$defaultkey = GETPOST('defaultkey', 'alphanohtml'); +$defaultvalue = GETPOST('defaultvalue', 'none'); $defaulturl = preg_replace('/^\//', '', $defaulturl); -$urlpage = GETPOST('urlpage'); -$key = GETPOST('key'); -$value = GETPOST('value'); +$urlpage = GETPOST('urlpage', 'alphanohtml'); +$key = GETPOST('key', 'alphanohtml'); +$value = GETPOST('value', 'none'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin')); @@ -193,14 +193,14 @@ $enabledisablehtml .= $langs->trans("EnableDefaultValues").' '; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } @@ -210,9 +210,9 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl print ''.$langs->trans("DefaultValuesDesc")."
\n"; print "
\n"; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); @@ -359,7 +359,7 @@ if ($result) // Page print ''; - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; + if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page; else print ''; print ''."\n"; @@ -378,7 +378,7 @@ if ($result) print ''; print ''; */ - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); else print ''; print ''; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index af07dc9bfc6..d634f547ff9 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -58,6 +58,7 @@ if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1 if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account if (!$allowed) accessforbidden(); +$acts =array(); $actl =array(); $acts[0] = "activate"; $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); @@ -76,7 +77,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $search_country_id = GETPOST('search_country_id', 'int'); -if ($search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. +if (! GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. { $search_country_id = $mysoc->country_id; } @@ -178,7 +179,7 @@ $tablib[38] = "DictionarySocialNetworks"; $tabsql = array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; -$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; +$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; @@ -759,12 +760,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } if ($i) $sql .= ","; + if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' { - $sql .= "'".(int) $db->escape($_POST['position'])."'"; + $sql .= "'".(int) $db->escape(GETPOST('position'))."'"; } elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + else $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i], 'nohtml'))."'"; $i++; } $sql .= ",1)"; @@ -1011,6 +1013,7 @@ if ($id) if ($search_code != '' && $id == 9) $sql .= natural_search("code_iso", $search_code); elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code); elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code); + elseif ($search_code != '' && $id == 3) $sql .= natural_search("r.code_region", $search_code); elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code); if ($sortfield) @@ -1146,7 +1149,7 @@ if ($id) if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); } if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); } - if ($id == 2) // Special cas for state page + if ($id == 2) // Special case for state page { if ($fieldlist[$field] == 'region_id') { $valuetoshow = ' '; $showfield = 1; } if ($fieldlist[$field] == 'region') { $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; } @@ -1228,6 +1231,7 @@ if ($id) // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); + $resql = $db->query($sql); if ($resql) { @@ -1620,7 +1624,9 @@ if ($id) $key = $langs->trans($obj->label); $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]}); } - + elseif ($fieldlist[$field] == 'code' && $id == 3) { + $valuetoshow = $obj->state_code; + } $class .= ($class ? ' ' : '').'tddict'; if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200'; if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto'; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 49217b55963..b9a787cc67c 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -349,7 +349,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 58808c00410..d76f77dd018 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -201,7 +201,7 @@ dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'sending'); // Shipment numbering model -print load_fiche_titre($langs->trans("SendingsNumberingModules")); +print load_fiche_titre($langs->trans("SendingsNumberingModules"), '', ''); print ''; print ''; @@ -304,7 +304,7 @@ print '

'; /* * Documents models for Sendings Receipt */ -print load_fiche_titre($langs->trans("SendingsReceiptModel")); +print load_fiche_titre($langs->trans("SendingsReceiptModel"), '', ''); // Defini tableau def de modele invoice $type="shipping"; @@ -463,7 +463,7 @@ print '
'; * Other options * */ -print load_fiche_titre($langs->trans("OtherOptions")); +print load_fiche_titre($langs->trans("OtherOptions"), '', ''); print '
'; print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 2e03eed937c..474c6020610 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -758,13 +758,31 @@ else $text = ''; if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { - $text .= $langs->trans("WarningPHPMail"); + $text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS } - //$conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS='1.2.3.4'; - if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) + + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { - $text .= ($text ? '
' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); + // MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'. + if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) + { + // List of IP show as record to add in SPF if we use the mail method + $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); + } + } else { + if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) + { + // List of IP show as record to add as allowed IP if we use the smtp method + $text .= ($text ? '

' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); + } + if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) + { + // List of string to add in SPF if we use the smtp method + $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD); + } } + + if ($text) print info_admin($text); } @@ -840,6 +858,11 @@ else print $formmail->get_form('addfile', 'removefile'); dol_fiche_end(); + + // References + print ''.$langs->trans("EMailsWillHaveMessageID").': '; + print dol_escape_htmltag(''); + print ''; } } diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 1eddaef9903..fb5ff1df202 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -113,10 +113,12 @@ llxHeader('', $langs->trans("NotificationSetup")); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("NotificationSetup"), $linkback, 'title_setup'); +print ''; print $langs->trans("NotificationsDesc").'
'; print $langs->trans("NotificationsDescUser").'
'; if (!empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'
'; print $langs->trans("NotificationsDescGlobal").'
'; +print '
'; print '
'; print ''; diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php index 5035c6c4a7d..cae6e568d65 100644 --- a/htdocs/admin/system/browser.php +++ b/htdocs/admin/system/browser.php @@ -49,12 +49,15 @@ $tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); print '
'; print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index c3b38ca7a45..c641be11a59 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2020 Laurent Destailleur * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2017 Frédéric France * @@ -35,9 +35,9 @@ if (!$user->admin) accessforbidden(); $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'alpha'); -$langcode = GETPOST('langcode', 'alpha'); -$transkey = GETPOST('transkey', 'alpha'); -$transvalue = GETPOST('transvalue', 'alpha'); +$langcode = GETPOST('langcode', 'alphanohtml'); +$transkey = GETPOST('transkey', 'alphanohtml'); +$transvalue = GETPOST('transvalue', 'none'); $mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite'; @@ -190,7 +190,6 @@ if ($action == 'delete') - /* * View */ @@ -208,14 +207,14 @@ $enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' '; if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } @@ -231,9 +230,9 @@ print ''.$form->textwithpicto($langs->trans("Current print '
'; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($langcode) $param.='&langcode='.urlencode($langcode); if ($transkey) $param.='&transkey='.urlencode($transkey); if ($transvalue) $param.='&transvalue='.urlencode($transvalue); @@ -348,11 +347,11 @@ if ($mode == 'overwrite') */ if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) { - print ''; + print ''; } else { - print $obj->transvalue; + print dol_escape_htmltag($obj->transvalue); } print ''; diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index f4c9076fbd9..26f83f36fd6 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -150,6 +150,12 @@ class DolibarrApi unset($object->context); unset($object->next_prev_filter); + unset($object->region); + unset($object->region_code); + + unset($object->libelle_statut); + unset($object->libelle_paiement); + if ($object->table_element != 'ticket') { unset($object->comments); } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index a42888aad27..66c4c1358cb 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -53,7 +53,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number {@min 0} * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')" + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" * * @url GET dictionary/ordering_methods * diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 5c28e7843ba..b4ff4ebac68 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -224,7 +224,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 70036d6a099..3f1be6c7e4c 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -155,6 +155,8 @@ if (empty($reshook)) if (!$error) { + $lastposition = 0; + $bomline = new BOMLine($db); $bomline->fk_bom = $id; $bomline->fk_product = $idprod; @@ -163,6 +165,12 @@ if (empty($reshook)) $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; + // Rang to use + $rangmax = $object->line_max(0); + $ranktouse = $rangmax + 1; + + $bomline->position = ($ranktouse + 1); + $result = $bomline->create($user); if ($result <= 0) { @@ -449,7 +457,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index acbffa109a2..9540c2b84cd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1116,7 +1116,7 @@ class Categorie extends CommonObject // Include or exclude leaf including $markafterid from tree if (count($markafterid) > 0) { - $keyfiltercatid = implode('|', $markafterid); + $keyfiltercatid = '(' . implode('|', $markafterid) . ')'; //print "Look to discard category ".$markafterid."\n"; $keyfilter1 = '^'.$keyfiltercatid.'$'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 2b96b293f2d..e5755edd40b 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -207,7 +207,7 @@ elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCateg elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); -elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("ProjectsCategoriesShort"); +elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 0d3c5de514d..271257c3ecc 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -229,7 +229,6 @@ class AgendaEvents extends DolibarrApi * * @return int */ - /* public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { @@ -245,11 +244,11 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->fetch_userassigned(); $this->actioncomm->oldcopy = clone $this->actioncomm; } - if ( ! $result ) { + if (! $result ) { throw new RestException(404, 'actioncomm not found'); } - if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { + if (! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { @@ -257,12 +256,11 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->$field = $value; } - if ($this->actioncomm->update($id, DolibarrApiAccess::$user,1,'','','update')) + if ($this->actioncomm->update(DolibarrApiAccess::$user, 1) > 0) return $this->get($id); return false; } - */ /** * Delete Agenda Event diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 947d0a9d2f8..f906c4cab45 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -49,10 +49,10 @@ $usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", $showbirthday = 0; // If not choice done on calendar owner, we filter on user. -if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) +/*if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; -} +}*/ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8c46cb162d3..f55861b00cc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1953,7 +1953,7 @@ if ($action == 'create') } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 7da9fcca7d1..3c1bf672c0f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2064,7 +2064,7 @@ if ($action == 'create' && $usercancreate) } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index db9f9443f0e..297f0dd91d4 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -353,8 +353,13 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { $accline = new AccountLine($db); - $result = $accline->fetch(GETPOST("rowid")); + $result = $accline->fetch(GETPOST("rowid", "int")); $result = $accline->delete($user); + if ($result <= 0) { + setEventMessages($accline->error, $accline->errors, 'errors'); + } else { + setEventMessages('RecordDeleted', null, 'mesgs'); + } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 594cad56ea0..6fc0efbd6e0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1883,13 +1883,15 @@ class AccountLine extends CommonObject } /** - * Delete transaction bank line record + * Delete bank transaction record * * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ public function delete(User $user = null) { + global $conf; + $nbko = 0; if ($this->rappro) @@ -1901,6 +1903,26 @@ class AccountLine extends CommonObject $this->db->begin(); + // Protection to avoid any delete of accounted lines. Protection on by default + if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING)) + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj && $obj->nb) { + $this->error = 'ErrorRecordAlreadyInAccountingDeletionNotPossible'; + $this->db->rollback(); + return -1; + } + } + else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + // Delete urls $result = $this->delete_urls($user); if ($result < 0) @@ -2250,11 +2272,11 @@ class AccountLine extends CommonObject /** - * Return clicable name (with picto eventually) + * Return clickable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlen Longueur max libelle - * @param string $option Option ('showall') + * @param string $option Option ('', 'showall', 'showconciliated', 'showconciliatedandaccounted'). Options may be slow. * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ @@ -2272,7 +2294,7 @@ class AccountLine extends CommonObject if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->rowid); $result .= $linkend; - if ($option == 'showall' || $option == 'showconciliated') $result .= ' ('; + if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') $result .= ' ('; if ($option == 'showall') { $result .= $langs->trans("BankAccount").': '; @@ -2282,12 +2304,25 @@ class AccountLine extends CommonObject $accountstatic->label = $this->bank_account_label; $result .= $accountstatic->getNomUrl(0).', '; } - if ($option == 'showall' || $option == 'showconciliated') + if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') { $result .= $langs->trans("BankLineConciliated").': '; $result .= yn($this->rappro); } - if ($option == 'showall' || $option == 'showconciliated') $result .= ')'; + if ($option == 'showall' || $option == 'showconciliatedandaccounted') + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj && $obj->nb) { + $result .= ' - '.$langs->trans("Accounted").': '.yn(1); + } else { + $result .= ' - '.$langs->trans("Accounted").': '.yn(0); + } + } + } + if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') $result .= ')'; return $result; } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 57aa50f1568..2ecb59861d9 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -411,8 +411,9 @@ class BankAccounts extends DolibarrApi * @throws RestException * * @url GET {id}/lines + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" */ - public function getLines($id) + public function getLines($id, $sqlfilters = '') { $list = array(); @@ -428,6 +429,18 @@ class BankAccounts extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank "; $sql .= " WHERE fk_account = ".$id; + + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 4c60434619a..8e83e6a33a4 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -345,7 +345,8 @@ if ($action == "create" || $action == "start") print '
'; // TODO Use a denormalized field + print ''; // TODO Use a denormalized field if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; $totalarray['val']['rtp'] += $remaintopay; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index edc76de0698..887fe2ec570 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -222,7 +222,7 @@ print ''; // Payment type (VIR, LIQ, ...) $labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; print ''; // Amount @@ -297,7 +297,7 @@ if (!empty($conf->banque->enabled)) print ''; print ''; print ''; print ''; } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 0b8a441dea2..fdb4284e909 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -248,7 +248,7 @@ if ($id > 0 || $ref) } // Call Hook formConfirm - /*$parameters = array(); + /*$parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/ diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 6e91ef53e2b..97b04158e34 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -505,7 +505,7 @@ elseif ($modecompta=="BOOKKEEPING") $resultNP = $totPerAccount[$cpt['account_number']]['NP']; $resultN = $totPerAccount[$cpt['account_number']]['N']; - if ($showaccountdetail == 'all' || $resultN > 0) { + if ($showaccountdetail == 'all' || $resultN != 0) { print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("UserAgent").''.$_SERVER['HTTP_USER_AGENT'].'
'.$langs->trans("UserAgent").''.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).'
'.$langs->trans("BrowserName").''.$tmp['browsername'].'
'.$langs->trans("BrowserOS").''.$tmp['browseros'].'
'.$langs->trans("Version").''.$tmp['browserversion'].'
'.$langs->trans("Layout").' (phone/tablet/classic)'.$tmp['layout'].'
'.$langs->trans("IPAddress").''.$_SERVER['REMOTE_ADDR'].'
'.$langs->trans("IPAddress").''.dol_escape_htmltag($_SERVER['REMOTE_ADDR']); +if (! empty($_SERVER['HTTP_CLIENT_IP'])) print ' (HTTP_CLIENT_IP='.dol_escape_htmltag($_SERVER['HTTP_CLIENT_IP']).')'; +if (! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) print ' (HTTP_X_FORWARDED_FOR='.dol_escape_htmltag($_SERVER['HTTP_X_FORWARDED_FOR']).')'; +print '
'.$langs->trans("SessionName").''.session_name().'
'.$langs->trans("SessionId").''.session_id().'
'; $array = array(); - for($i = 1; $i <= max(1, $conf->global->TAKEPOS_NUM_TERMINALS); $i++) { + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for($i = 1; $i <= $numterminals; $i++) { $array[$i] = $i; } $selectedposnumber = 0; $showempty = 1; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f72a3ed7f13..e0c63ca0a8f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3889,7 +3889,7 @@ elseif ($id > 0 || !empty($ref)) } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid, 'remainingtopay' => &$resteapayer); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4cea8dcad9d..9172993acc7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4005,6 +4005,7 @@ class Facture extends CommonInvoice if ($generic_facture->hasDelay()) { $response->nbtodolate++; + $response->url_late=DOL_URL_ROOT.'/compta/facture/list.php?search_option=late&mainmenu=billing&leftmenu=customers_bills'; } } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 00aa9deb4df..db1ba28c14e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -387,7 +387,7 @@ if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql .= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; -$sql .= ' f.paye as paye, f.fk_statut,'; +$sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; @@ -502,7 +502,7 @@ if (!$sall) $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; $sql .= ' f.localtax1, f.localtax2,'; $sql .= ' f.datef, f.date_lim_reglement, f.module_source, f.pos_source,'; - $sql .= ' f.paye, f.fk_statut,'; + $sql .= ' f.paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec, f.tms, f.date_closing,'; $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; @@ -987,6 +987,7 @@ if ($resql) $facturestatic->total_tva = $obj->total_vat; $facturestatic->total_ttc = $obj->total_ttc; $facturestatic->statut = $obj->fk_statut; + $facturestatic->close_code = $obj->close_code; $facturestatic->total_ttc = $obj->total_ttc; $facturestatic->paye = $obj->paye; $facturestatic->fk_soc = $obj->fk_soc; @@ -1022,7 +1023,11 @@ if ($resql) $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = price2num($facturestatic->total_ttc - $totalpay); - if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { + + if ($facturestatic->statut == Facture::STATUS_CLOSED && $facturestatic->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment + $remaintopay = 0; + } + if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consummed $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id); $remaintopay = -$remaincreditnote; $totalpay = price2num($facturestatic->total_ttc - $remaintopay); @@ -1281,9 +1286,12 @@ if ($resql) $totalarray['val']['totalam'] += $totalpay; } + // Pending amount if (!empty($arrayfields['rtp']['checked'])) { - print ''.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : ' ').''; + print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); + print '
'.$langs->trans('PaymentMode').''.$labeltype; -print $object->num_paiement ? ' - '.$object->num_paiement : ''; +print $object->num_payment? ' - '.$object->num_payment : ''; print '
'.$langs->trans('BankTransactionLine').''; - print $bankline->getNomUrl(1, 0, 'showconciliated'); + print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted'); print '
'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 038cb82845e..465dc4a1e16 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -72,8 +72,8 @@ class Contact extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), 'civility' =>array('type'=>'varchar(6)', 'label'=>'Civility', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>45, 'showoncombobox'=>1), + 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'showoncombobox'=>1), 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'zip' =>array('type'=>'varchar(25)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'town' =>array('type'=>'text', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>65), @@ -988,19 +988,25 @@ class Contact extends CommonObject } + /** - * Set property ->gender from property ->civility_id + * Set the property "gender" of this class, based on the property "civility_id" + * or use property "civility_code" as fallback, when "civility_id" is not available. * * @return void */ public function setGenderFromCivility() { - unset($this->gender); - if (in_array($this->civility_id, array('MR'))) { - $this->gender = 'man'; - } elseif (in_array($this->civility_id, array('MME', 'MLE'))) { - $this->gender = 'woman'; - } + unset($this->gender); + + if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) + { + $this->gender = 'man'; + } + elseif(in_array($this->civility_id, array('MME','MLE')) || in_array($this->civility_code, array('MME','MLE'))) + { + $this->gender = 'woman'; + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index fccae47fd89..c80dda1da91 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1356,6 +1356,7 @@ else // Call Hook formConfirm $parameters = array( + 'formConfirm' => $formconfirm, 'id' => $id, //'lineid' => $lineid, ); diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php index 0dbb5167f9e..7e9fad309d4 100644 --- a/htdocs/core/ajax/pingresult.php +++ b/htdocs/core/ajax/pingresult.php @@ -53,8 +53,8 @@ print ''; $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled')) - || GETPOST('forceping', 'alpha')) + || $forceping) { - if (strpos('alpha', DOL_VERSION) > 0) { + // No ping done if we are into an alpha version + if (strpos('alpha', DOL_VERSION) > 0 && ! $forceping) { print "\n\n"; } - elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) // Cookie is set when we uncheck the checkbox in the installation wizard. + elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) // Cookie is set when we uncheck the checkbox in the installation wizard. { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + // MAIN_LAST_PING_KO_DATE + // Disable ping if MAIN_LAST_PING_KO_DATE is set and is recent + if (! empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) == dol_print_date(dol_now(), '%Y%m') && ! $forceping) { + print "\n\n"; + } else { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print "\n".''."\n"; - print "\n\n"; - $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); - // Try to guess the distrib used - $distrib = 'standard'; - if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; - if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; - ?> - - global->MAIN_FIRST_PING_OK_DATE.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' MAIN_LAST_PING_KO_DATE='.$conf->global->MAIN_LAST_PING_KO_DATE.' -->'."\n"; + print "\n\n"; + $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); + // Try to guess the distrib used + $distrib = 'standard'; + if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp'; + if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib; + ?> + + id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 13f359f43cc..46f347618f4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -122,7 +122,7 @@ $search_all=trim(GETPOST("search_all", 'alpha')); $search=array(); foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key]=GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a87ab150070..e677c64efc0 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -513,7 +513,6 @@ class Mo extends CommonObject return $resarray; } else { $this->error = $this->db->lasterror(); - var_dump($this->error); return array(); } } @@ -559,9 +558,10 @@ class Mo extends CommonObject * Erase and update the line to produce. * * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, >0 if OK */ - public function updateProduction(User $user) + public function updateProduction(User $user, $notrigger = true) { $error = 0; @@ -593,7 +593,7 @@ class Mo extends CommonObject $moline->role = 'toproduce'; $moline->position = 1; - $resultline = $moline->create($user); + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; @@ -625,7 +625,7 @@ class Mo extends CommonObject $moline->qty_frozen = $line->qty_frozen; $moline->disable_stock_change = $line->disable_stock_change; - $resultline = $moline->create($user); + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index bb3b19511ea..abaf216b7ab 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -406,7 +406,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 0d7fb48e45c..873b154ffeb 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -442,7 +442,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index d885b36a877..49df2b36cc9 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -40,7 +40,7 @@ if ($type == '' && !$user->rights->service->lire) $type = '0'; // Force global p // Security check if ($type == '0') $result = restrictedArea($user, 'produit'); elseif ($type == '1') $result = restrictedArea($user, 'service'); -else $result = restrictedArea($user, 'produit|service'); +else $result = restrictedArea($user, 'produit|service|expedition'); // Load translation files required by the page $langs->loadLangs(array('products', 'stocks')); @@ -117,77 +117,80 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles /* * Number of products and/or services */ -$prodser = array(); -$prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0; -$prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0; - -$sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; -$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -$sql .= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; -$result = $db->query($sql); -while ($objp = $db->fetch_object($result)) +if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { - $status = 3; // On sale + On purchase - if (!$objp->tosell && !$objp->tobuy) $status = 0; // Not on sale, not on purchase - if ($objp->tosell && !$objp->tobuy) $status = 1; // On sale only - if (!$objp->tosell && $objp->tobuy) $status = 2; // On purchase only - $prodser[$objp->fk_product_type][$status] = $objp->total; - if ($objp->tosell) $prodser[$objp->fk_product_type]['sell'] += $objp->total; - if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy'] += $objp->total; - if (!$objp->tosell && !$objp->tobuy) $prodser[$objp->fk_product_type]['none'] += $objp->total; -} + $prodser = array(); + $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0; + $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0; -if ($conf->use_javascript_ajax) -{ - print '
'; - print ''; - print ''; - print ''; + print '
'.$langs->trans("Statistics").'
'; - - $SommeA = $prodser[0]['sell']; - $SommeB = $prodser[0]['buy']; - $SommeC = $prodser[0]['none']; - $SommeD = $prodser[1]['sell']; - $SommeE = $prodser[1]['buy']; - $SommeF = $prodser[1]['none']; - $total = 0; - $dataval = array(); - $datalabels = array(); - $i = 0; - - $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF; - $dataseries = array(); - if (!empty($conf->product->enabled)) + $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; + $result = $db->query($sql); + while ($objp = $db->fetch_object($result)) { - $dataseries[] = array($langs->trans("ProductsOnSale"), round($SommeA)); - $dataseries[] = array($langs->trans("ProductsOnPurchase"), round($SommeB)); - $dataseries[] = array($langs->trans("ProductsNotOnSell"), round($SommeC)); - } - if (!empty($conf->service->enabled)) - { - $dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD)); - $dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE)); - $dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF)); + $status = 3; // On sale + On purchase + if (!$objp->tosell && !$objp->tobuy) $status = 0; // Not on sale, not on purchase + if ($objp->tosell && !$objp->tobuy) $status = 1; // On sale only + if (!$objp->tosell && $objp->tobuy) $status = 2; // On purchase only + $prodser[$objp->fk_product_type][$status] = $objp->total; + if ($objp->tosell) $prodser[$objp->fk_product_type]['sell'] += $objp->total; + if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy'] += $objp->total; + if (!$objp->tosell && !$objp->tobuy) $prodser[$objp->fk_product_type]['none'] += $objp->total; } - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); - $dolgraph->setShowPercent(0); - $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + if ($conf->use_javascript_ajax) + { + print '
'; + print ''; + print ''; + print ''; - print '
'.$langs->trans("Statistics").'
'; - print '
'; - print '
'; + $SommeA = $prodser[0]['sell']; + $SommeB = $prodser[0]['buy']; + $SommeC = $prodser[0]['none']; + $SommeD = $prodser[1]['sell']; + $SommeE = $prodser[1]['buy']; + $SommeF = $prodser[1]['none']; + $total = 0; + $dataval = array(); + $datalabels = array(); + $i = 0; + + $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF; + $dataseries = array(); + if (!empty($conf->product->enabled)) + { + $dataseries[] = array($langs->trans("ProductsOnSale"), round($SommeA)); + $dataseries[] = array($langs->trans("ProductsOnPurchase"), round($SommeB)); + $dataseries[] = array($langs->trans("ProductsNotOnSell"), round($SommeC)); + } + if (!empty($conf->service->enabled)) + { + $dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD)); + $dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE)); + $dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF)); + } + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(0); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); + + print '
'; + print '
'; + } } @@ -270,120 +273,123 @@ print '
'; /* * Latest modified products */ -$max = 15; -$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; -$sql .= " p.entity,"; -$sql .= " p.tms as datem"; -$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -$sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; -if ($type != '') $sql .= " AND p.fk_product_type = ".$type; -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql .= $db->order("p.tms", "DESC"); -$sql .= $db->plimit($max, 0); - -//print $sql; -$result = $db->query($sql); -if ($result) +if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { - $num = $db->num_rows($result); + $max = 15; + $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; + $sql .= " p.entity,"; + $sql .= " p.tms as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; + if ($type != '') $sql .= " AND p.fk_product_type = ".$type; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= $db->order("p.tms", "DESC"); + $sql .= $db->plimit($max, 0); - $i = 0; - - if ($num > 0) + //print $sql; + $result = $db->query($sql); + if ($result) { - $transRecordedType = $langs->trans("LastModifiedProductsAndServices", $max); - if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts", $max); - if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices", $max); + $num = $db->num_rows($result); - print '
'; - print ''; + $i = 0; - $colnb = 2; - if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; - - print ''; - print ''; - - while ($i < $num) + if ($num > 0) { - $objp = $db->fetch_object($result); + $transRecordedType = $langs->trans("LastModifiedProductsAndServices", $max); + if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts", $max); + if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices", $max); - $product_static->id = $objp->rowid; - $product_static->ref = $objp->ref; - $product_static->label = $objp->label; - $product_static->type = $objp->fk_product_type; - $product_static->entity = $objp->entity; - $product_static->status = $objp->tosell; - $product_static->status_buy = $objp->tobuy; - $product_static->status_batch = $objp->tobatch; + print '
'; + print '
'.$transRecordedType.''.$langs->trans("FullList").''; - print '
'; - //Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) + $colnb = 2; + if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; + + print ''; + print ''; + + while ($i < $num) { - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product=".$objp->rowid; - $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $objp = $db->fetch_object($result); - $resultd = $db->query($sql); - if ($resultd) + $product_static->id = $objp->rowid; + $product_static->ref = $objp->ref; + $product_static->label = $objp->label; + $product_static->type = $objp->fk_product_type; + $product_static->entity = $objp->entity; + $product_static->status = $objp->tosell; + $product_static->status_buy = $objp->tobuy; + $product_static->status_batch = $objp->tobatch; + + //Multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { - $objtp = $db->fetch_object($resultd); - if ($objtp && $objtp->label != '') $objp->label = $objtp->label; + $sql = "SELECT label"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + + $resultd = $db->query($sql); + if ($resultd) + { + $objtp = $db->fetch_object($resultd); + if ($objtp && $objtp->label != '') $objp->label = $objtp->label; + } } - } - print ''; - print '\n"; - print ''; - print ""; - // Sell price - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) - { - $product = new Product($db); - $product->fetch($objp->rowid); - $priceparser = new PriceParser($db); - $price_result = $priceparser->parseProduct($product); - if ($price_result >= 0) { - $objp->price = $price_result; - } - } - print ''; + print ''; + print '\n"; + print ''; + print ""; + // Sell price + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) + { + $product = new Product($db); + $product->fetch($objp->rowid); + $priceparser = new PriceParser($db); + $price_result = $priceparser->parseProduct($product); + if ($price_result >= 0) { + $objp->price = $price_result; + } + } + print ''; + } + print '"; + print '"; + print "\n"; + $i++; } - print '"; - print '"; - print "\n"; - $i++; + + $db->free($result); + + print "
'.$transRecordedType.''.$langs->trans("FullList").''; + print '
'; - print $product_static->getNomUrl(1, '', 16); - print "'.dol_trunc($objp->label, 32).'"; - print dol_print_date($db->jdate($objp->datem), 'day'); - print "'; - if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); - else print price($objp->price).' '.$langs->trans("HT"); - print '
'; + print $product_static->getNomUrl(1, '', 16); + print "'.dol_trunc($objp->label, 32).'"; + print dol_print_date($db->jdate($objp->datem), 'day'); + print "'; + if (isset($objp->price_base_type) && $objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); + else print price($objp->price).' '.$langs->trans("HT"); + print ''; + print $product_static->LibStatut($objp->tosell, 3, 0); + print "'; + print $product_static->LibStatut($objp->tobuy, 3, 1); + print "
'; - print $product_static->LibStatut($objp->tosell, 3, 0); - print "'; - print $product_static->LibStatut($objp->tobuy, 3, 1); - print "
"; + print '
'; + print '
'; } - - $db->free($result); - - print "
"; - print '
'; - print '
'; } -} -else -{ - dol_print_error($db); + else + { + dol_print_error($db); + } } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 0c913834738..3d389cf7eb2 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -240,7 +240,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f43f1fc3b1c..b6021c82cb8 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -174,7 +174,7 @@ if ($object->id > 0) } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index d6a1914afc5..99dc1978886 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -362,7 +362,7 @@ else } // Call Hook formConfirm - $parameters = array(); + $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 54d13a51549..a17453889c4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -607,18 +607,29 @@ class Project extends CommonObject { $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$ids.") AND ms.type_mouvement = 1"; } + elseif ($type == 'loan') + { + $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').")"; + } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")"; } - if ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table + if($dates > 0 && $type == 'loan'){ + $sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)"; + } + elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table { if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } - if ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table + + if($datee > 0 && $type == 'loan'){ + $sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)"; + } + elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table { if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; @@ -1211,7 +1222,7 @@ class Project extends CommonObject * Return array of projects a user has permission on, is affected to, or all projects * * @param User $user User object - * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts + * @param int $mode 0=All project I have permission on (assigned to me or public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party * @param string $filter additionnal filter on project (statut, ref, ...) @@ -1224,9 +1235,17 @@ class Project extends CommonObject $sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet as p"; - if ($mode == 0 || $mode == 1) + if ($mode == 0) { - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id = p.rowid"; + } + elseif ($mode == 1) + { + $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; + } + elseif ($mode == 2) + { + // No filter. Use this if user has permission to see all project } $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Internal users must see project he is contact to even if project linked to a third party he can't see. @@ -1251,13 +1270,12 @@ class Project extends CommonObject if ($mode == 0) { - $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ( p.public = 1"; $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } - if ($mode == 1) + elseif ($mode == 1) { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ("; @@ -1265,7 +1283,7 @@ class Project extends CommonObject $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } - if ($mode == 2) + elseif ($mode == 2) { // No filter. Use this if user has permission to see all project } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9be63cad242..dd89b3ca9c4 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -49,6 +49,7 @@ if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/exp if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; @@ -650,6 +651,31 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line = price2num($tmp['amount'], 'MT'); } } + elseif ($key == 'loan'){ + if((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)){ + // Get total loan + $total_ht_by_line = -$element->capital; + } + else{ + // Get loan schedule according to date filter + $total_ht_by_line = 0; + $loanScheduleStatic = new LoanSchedule($element->db); + $loanScheduleStatic->fetchAll($element->id); + if(!empty($loanScheduleStatic->lines)){ + foreach($loanScheduleStatic->lines as $loanSchedule){ + /** + * @var $loanSchedule LoanSchedule + */ + if( ($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined + || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now() + || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee + ){ + $total_ht_by_line = -$loanSchedule->amount_capital; + } + } + } + } + } else $total_ht_by_line = $element->total_ht; // Define $total_ttc_by_line @@ -661,6 +687,9 @@ foreach ($listofreferent as $key => $value) $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } + elseif ($key == 'loan'){ + $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr + } else $total_ttc_by_line = $element->total_ttc; // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases @@ -829,11 +858,13 @@ foreach ($listofreferent as $key => $value) // Amount HT //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountHT").''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Amount").''; - if (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").''; + if ($key == 'loan') print ''.$langs->trans("LoanCapital").''; + elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").''; else print ''; // Amount TTC //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountTTC").''; - if (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; + if ($key == 'loan') print ''.$langs->trans("RemainderToPay").''; + elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; else print ''; // Status if (in_array($tablename, array('projet_task'))) print ''.$langs->trans("ProgressDeclared").''; @@ -928,6 +959,10 @@ foreach ($listofreferent as $key => $value) print $element->getNomUrl(1, 'withproject', 'time'); print ' - '.dol_trunc($element->label, 48); } + elseif ($key == 'loan'){ + print $element->getNomUrl(1); + print ' - '.dol_trunc($element->label, 48); + } else print $element->getNomUrl(1); $element_doc = $element->element; @@ -977,6 +1012,10 @@ foreach ($listofreferent as $key => $value) if (empty($date)) $date = $element->datev; } } + elseif ($key == 'loan'){ + $date = $element->datestart; + } + print ''; if ($tablename == 'actioncomm') { @@ -1050,6 +1089,7 @@ foreach ($listofreferent as $key => $value) $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } + elseif ($key == 'loan') $total_ht_by_line = $element->capital; else { $total_ht_by_line = $element->total_ht; @@ -1097,6 +1137,7 @@ foreach ($listofreferent as $key => $value) $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } + elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment(); else { $total_ttc_by_line = $element->total_ttc; @@ -1204,7 +1245,8 @@ foreach ($listofreferent as $key => $value) print ''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); } print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; @@ -1212,7 +1254,8 @@ foreach ($listofreferent as $key => $value) print ''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); } print ''; print ' '; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 0649a937822..5b456893bf9 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -101,7 +101,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $width = 0; - $urllogo = DOL_URL_ROOT.'/theme/login_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index eaec20db955..b2723a0ce6a 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1277,7 +1277,7 @@ elseif ($id || $ref) } if (!$formconfirm) { - $parameters = array(); + $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 7e2f11e1bf5..bf9acde2d50 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -615,7 +615,7 @@ class Dolresource extends CommonObject $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; } else { - $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } @@ -697,7 +697,7 @@ class Dolresource extends CommonObject $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; } else { - $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } @@ -948,7 +948,7 @@ class Dolresource extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $langs; + global $conf, $langs; $result = ''; $label = ''.$langs->trans("ShowResource").''; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 36415c0b951..2053e19dc72 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -52,20 +52,20 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); if (!is_array($search_array_options)) $search_array_options = array(); -$search_ref = GETPOST("search_ref"); -$search_type = GETPOST("search_type"); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_type = GETPOST("search_type", 'alpha'); $filter = array(); if ($search_ref != '') { - $param .= '&search_ref='.$search_ref; + $param.='&search_ref='.urlencode($search_ref); $filter['t.ref'] = $search_ref; } if ($search_type != '') { - $param .= '&search_type='.$search_type; + $param.='&search_type='.urlencode($search_type); $filter['ty.label'] = $search_type; } -if ($search_label != '') $param .= '&search_label='.$search_label; + // Add $param from extra fields foreach ($search_array_options as $key => $val) { @@ -83,7 +83,7 @@ foreach ($search_array_options as $key => $val) $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search); } } -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); $hookmanager->initHooks(array('resourcelist')); @@ -131,7 +131,6 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { $search_ref = ""; - $search_label = ""; $search_type = ""; $search_array_options = array(); $filter = array(); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b6bef4473f3..ab8256f6473 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1988,7 +1988,7 @@ else print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; print ''; print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''; - print ''; + print ''; if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 1952fb8304c..21602dae3c4 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -546,16 +546,14 @@ if (empty($reshook)) if (!$error) { // Creation of Stripe card + update of societe_account + // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to + // ask to create the crdit card from Stripe backoffice. $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); if (!$card) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); } - else - { - $stripecard = $card->id; - } } } } diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index c26f1ea709c..838cc5ca37a 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -467,7 +467,7 @@ $token = ''; include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php'; -print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000000000003220 (3DSecure2 required)', '4000000000000101', '4000000000000069', '4000000000000341')); +print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required the off-seesion allowed)', '4000000000000101', '4000000000000069', '4000000000000341')); if (!empty($conf->use_javascript_ajax)) { diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 7dbf4dd6089..d198555e421 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -139,6 +139,10 @@ if (!$rowid) $type = $langs->trans("card"); } elseif ($charge->payment_method_details->type=='three_d_secure'){ $type = $langs->trans("card3DS"); + } elseif ($charge->payment_method_details->type=='sepa_debit'){ + $type = $langs->trans("sepadebit"); + } elseif ($charge->payment_method_details->type=='ideal'){ + $type = $langs->trans("iDEAL"); } if (! empty($charge->payment_intent)) { @@ -215,7 +219,7 @@ if (!$rowid) print "\n"; // Origine print ""; - if ($charge->metadata->dol_type=="order") { + if ($charge->metadata->dol_type=="order" || $charge->metadata->dol_type=="commande") { $object = new Commande($db); $object->fetch($charge->metadata->dol_id); if ($object->id > 0) { @@ -223,7 +227,7 @@ if (!$rowid) } else { print $FULLTAG; } - } elseif ($charge->metadata->dol_type=="invoice") { + } elseif ($charge->metadata->dol_type=="invoice" || $charge->metadata->dol_type=="facture") { $object = new Facture($db); $object->fetch($charge->metadata->dol_id); if ($object->id > 0) { diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 931cfbfa83e..f5656387192 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -680,18 +680,18 @@ class Stripe extends CommonObject /** - * Get the Stripe card of a company payment mode (with option to create it on Stripe if not linked yet) + * Get the Stripe card of a company payment mode (option to create it on Stripe if not linked yet is no more available on new Stripe API) * * @param \Stripe\StripeCustomer $cu Object stripe customer * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) - * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card + * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card. Deprecated with new Stripe API and SCA. * @return \Stripe\StripeCard|\Stripe\PaymentMethod|null Stripe Card or null if not found */ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) { - global $conf, $user; + global $conf, $user, $langs; $card = null; @@ -754,27 +754,54 @@ class Stripe extends CommonObject //$a = \Stripe\Stripe::getApiKey(); //var_dump($a);var_dump($stripeacc);exit; - dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); $card = $cu->sources->create($dataforcard); + if (! $card) + { + $this->error = 'Creation of card on Stripe has failed'; + } } else { - // TODO - dol_syslog("Error: This case is not supported", LOG_ERR); + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id; + if ($status) + { + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id; + } + $urtoswitchonstripe = ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + + //dol_syslog("Error: This case is not supported", LOG_ERR); + $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe); } } else { if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); + if (! $card) + { + $this->error = 'Creation of card on Stripe has failed'; + } } else { - // TODO - dol_syslog("Error: This case is not supported", LOG_ERR); + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id; + if ($status) + { + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id; + } + $urtoswitchonstripe = ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + + //dol_syslog("Error: This case is not supported", LOG_ERR); + $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe); } } @@ -792,10 +819,6 @@ class Stripe extends CommonObject $this->error = $this->db->lasterror(); } } - else - { - $this->error = 'Call to cu->source->create return empty card'; - } } catch (Exception $e) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index f01ad4c0b1b..5067a4935bc 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1441,7 +1441,7 @@ if ($action == 'create') } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/support/default.css b/htdocs/support/default.css index c0d99f56657..735224254d3 100644 --- a/htdocs/support/default.css +++ b/htdocs/support/default.css @@ -23,6 +23,22 @@ background: #f9f9f9; margin: 5px 5px; } +.center { + text-align: center; +} + +.centpercent { + width: 100%; +} + +.valignmiddle { + vertical-align: middle; +} + +inline-block { + display: inline-block; +} + div.titre { padding: 5px 5px 5px 5px; margin: 0 0 0 0; @@ -147,10 +163,10 @@ padding: 4px 4px 4px 4px; tr.title { -background: #DDDFDD; +background: #EEEEEE; } -table.login { border: 1px solid #C0C0C0; background: #FFF; } +table.login { border: 1px solid #E0E0E0; background: #FFF; } .tablesupport { padding: 6px; diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index dd369e233b9..941bf6bb0d3 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -223,15 +223,12 @@ function pHeader($soutitre, $next, $action = 'none') print ''.$langs->trans("DolibarrHelpCenter").''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; - print ''; - print ''; - print '
'; - print 'logohelpcenter'; - print ''; - print ''.$soutitre.''."\n"; - print '
'; + print '
'; + print 'logohelpcenter

'; + print ''.$soutitre.''."\n"; + print '

'; } /** diff --git a/htdocs/theme/login_logo.png b/htdocs/theme/common/login_logo.png similarity index 100% rename from htdocs/theme/login_logo.png rename to htdocs/theme/common/login_logo.png diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fe42bcfc995..c6386ba7ea2 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2377,9 +2377,14 @@ div.tabs { div.tabsElem { margin-top: 1px; } /* To avoid overlap of tabs when not browser */ -div.tabsElem a { - /* font-weight: normal !important; */ +/* +div.tabsElem a.tabactive::before, div.tabsElem a.tabunactive::before { + content: "\f0da"; + font-family: "Font Awesome 5 Free"; + padding-right: 2px; + font-weight: 900; } +*/ div.tabBar { color: #; padding-top: 16px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index fe23020991f..2f76ee382e9 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1012,7 +1012,8 @@ div.fiche>form>div.div-table-responsive { flex-grow: 1; flex-shrink: 1; /* flex-basis: 140px; */ - min-width: 150px; + /* min-width: 150px; */ + width: 158px; justify-content: flex-start; align-self: flex-start; } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index be768a3e15a..fa139e2c69f 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -132,15 +132,15 @@ class Users extends DolibarrApi /** * Get properties of an user object - * * Return an array with user informations * - * @param int $id ID of user + * @param int $id ID of user + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) * @return array|mixed data without useless information * * @throws RestException */ - public function get($id) + public function get($id, $includepermissions = 0) { //if (!DolibarrApiAccess::$user->rights->user->user->lire) { //throw new RestException(401); @@ -157,6 +157,10 @@ class Users extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + if ($includepermissions) { + $this->useraccount->getRights(); + } + return $this->_cleanObjectDatas($this->useraccount); } @@ -544,6 +548,12 @@ class Users extends DolibarrApi unset($object->clicktodial_password); unset($object->openid); + unset($object->lines); + unset($object->modelpdf); + unset($object->skype); + unset($object->twitter); + unset($object->facebook); + unset($object->linkedin); $canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (!empty($conf->hrm->enabled) && !empty(DolibarrApiAccess::$user->rights->hrm->employee->read))); diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 62509b3e6cb..461ab8e7b4a 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -178,7 +178,7 @@ if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) $disabled = ''; // // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; $rowspan = 2; -$urllogo = DOL_URL_ROOT.'/theme/login_logo.png'; +$urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 26758f52ab0..62070e3b31e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -89,9 +89,13 @@ if (empty($reshook)) { if ($action == 'addrights' && $caneditperms) { $edituser = new User($db); $edituser->fetch($object->id); - $edituser->addrights($rights, $module, '', $entity); + $result = $edituser->addrights($rights, $module, '', $entity); + if ($result < 0) + { + setEventMessages($edituser->error, $edituser->errors, 'errors'); + } - // Si on a touche a ses propres droits, on recharge + // If we are changing our own permissions, we reload if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); @@ -105,9 +109,13 @@ if (empty($reshook)) { if ($action == 'delrights' && $caneditperms) { $edituser = new User($db); $edituser->fetch($object->id); - $edituser->delrights($rights, $module, '', $entity); + $result = $edituser->delrights($rights, $module, '', $entity); + if ($result < 0) + { + setEventMessages($edituser->error, $edituser->errors, 'errors'); + } - // Si on a touche a ses propres droits, on recharge + // If we are changing our own permissions, we reload if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 2f78e66c22d..c722b7adc36 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1145,7 +1145,21 @@ class Website extends CommonObject } } - // Regenerate index page to point to new index page + // Read record of website that has been updated by the run_sql function previously called so we can get the + // value of fk_default_home that is ID of home page + $sql = 'SELECT fk_default_home FROM '.MAIN_DB_PREFIX.'website WHERE rowid = '.$object->id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $object->fk_default_home = $obj->fk_default_home; + } else { + //$this->errors[] = 'Failed to get the Home page'; + //$error++; + } + } + + // Regenerate index page to point to the new index page $pathofwebsite = $conf->website->dir_output.'/'.$object->ref; dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php'); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 3d523a6d48c..85b50b3d13b 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2822,7 +2822,7 @@ if ($action == 'createsite') print ''; print $langs->trans('Ref'); print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 64fbd96dd61..36eb72dd916 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -211,7 +211,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index c2eaa616cae..d4dec007d86 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -247,7 +247,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index fbd4a846024..cd5a9f28138 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -247,21 +247,17 @@ class HolidayTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - //$localobject->fetch($localobject->id); + $result = $localobject->fetchUsers(true, true, ''); + $this->assertNotEquals($result, -1); - /* - $result=$localobject->getNomUrl(1); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertNotEquals($result, ''); + $result = $localobject->fetchUsers(true, false, ''); + $this->assertNotEquals($result, -1); - $result=$localobject->getFullAddress(1); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $result = $localobject->fetchUsers(false, true, ''); + $this->assertNotEquals($result, -1); - $localobject->info($localobject->id); - print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; - $this->assertNotEquals($localobject->date_creation, ''); - */ + $result = $localobject->fetchUsers(false, false, ''); + $this->assertNotEquals($result, -1); return $localobject->id; } diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index 438cbaa9309..96bfbefdf17 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -135,7 +135,7 @@ class PaypalTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - $urltotest=getPaypalPaymentUrl(1, 'free'); + $urltotest=getPaypalPaymentUrl(0, 'free'); print "urltotest=".$urltotest."\n"; $result=getURLContent($urltotest, 'GET');