From b2252106c3c31c3a2c3983d2b7b0a0c1a648885d Mon Sep 17 00:00:00 2001 From: henrynopo Date: Fri, 20 Aug 2021 10:43:34 +0800 Subject: [PATCH 001/229] Added function - using list of location_incoterms Added function to call for list of location_incoterms from the existing order records or table of location_incoterms. Accordingly, an dditional ajex file namely "locationincoterms.php" and a database table namely c_location_incoterms are required. --- htdocs/core/class/html.form.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 07abdb4b465..b78dc7d17a2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1055,8 +1055,12 @@ class Form } } $out .= ''; - - $out .= ''; + + if ($conf->use_javascript_ajax && empty($disableautocomplete = 0)) { + $out .= ajax_multiautocompleter('location_incoterms', '', DOL_URL_ROOT.'/core/ajax/locationincoterms.php')."\n"; + $moreattrib .= ' autocomplete="off"'; + } + $out .= ''."\n"; if (!empty($page)) { $out .= ''; From 0933b6c39ff8d6baaf39badec5c9d5c0031e80bf Mon Sep 17 00:00:00 2001 From: henrynopo Date: Fri, 20 Aug 2021 20:04:53 +0800 Subject: [PATCH 002/229] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b78dc7d17a2..5d919f160f4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1056,7 +1056,7 @@ class Form } $out .= ''; - if ($conf->use_javascript_ajax && empty($disableautocomplete = 0)) { + if ($conf->use_javascript_ajax && empty($disableautocomplete)) { $out .= ajax_multiautocompleter('location_incoterms', '', DOL_URL_ROOT.'/core/ajax/locationincoterms.php')."\n"; $moreattrib .= ' autocomplete="off"'; } From 07dd9d90f55db58b755f2f8789718e2a76db780c Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Wed, 25 Aug 2021 17:29:29 +0800 Subject: [PATCH 003/229] Fix undef vars To remove PHP8 warnings --- htdocs/blockedlog/admin/blockedlog_list.php | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 385101c7468..2a15aa0965b 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -47,11 +47,17 @@ if ($search_showonlyerrors < 0) { $search_showonlyerrors = 0; } +$search_startyear = GETPOST('search_startyear', 'int'); +$search_startmonth = GETPOST('search_startmonth', 'int'); +$search_startday = GETPOST('search_startday', 'int'); +$search_endyear = GETPOST('search_endyear', 'int'); +$search_endmonth = GETPOST('search_endmonth', 'int'); +$search_endday = GETPOST('search_endday', 'int'); $search_id = GETPOST('search_id', 'alpha'); $search_fk_user = GETPOST('search_fk_user', 'intcomma'); $search_start = -1; -if (GETPOST('search_startyear') != '') { - $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear')); +if ($search_startyear != '') { + $search_start = dol_mktime(0, 0, 0, $search_startmonth, $search_startday, $search_startyear); } $search_end = -1; if (GETPOST('search_endyear') != '') { @@ -321,22 +327,22 @@ if ($search_fk_user > 0) { $param .= '&search_fk_user='.urlencode($search_fk_user); } if ($search_startyear > 0) { - $param .= '&search_startyear='.urlencode(GETPOST('search_startyear', 'int')); + $param .= '&search_startyear='.urlencode($search_startyear); } if ($search_startmonth > 0) { - $param .= '&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int')); + $param .= '&search_startmonth='.urlencode($search_startmonth); } if ($search_startday > 0) { - $param .= '&search_startday='.urlencode(GETPOST('search_startday', 'int')); + $param .= '&search_startday='.urlencode($search_startday); } if ($search_endyear > 0) { - $param .= '&search_endyear='.urlencode(GETPOST('search_endyear', 'int')); + $param .= '&search_endyear='.urlencode($search_endyear); } if ($search_endmonth > 0) { - $param .= '&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int')); + $param .= '&search_endmonth='.urlencode($search_endmonth); } if ($search_endday > 0) { - $param .= '&search_endday='.urlencode(GETPOST('search_endday', 'int')); + $param .= '&search_endday='.urlencode($search_endday); } if ($search_showonlyerrors > 0) { $param .= '&search_showonlyerrors='.urlencode($search_showonlyerrors); From d34e44e55c67ea6f44e22c0cd4e595d7c5fb0902 Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Wed, 25 Aug 2021 18:02:57 +0800 Subject: [PATCH 004/229] Fix undef vars 3 To remove PHP8 warnings --- htdocs/comm/action/peruser.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 413de33db1f..38a316f4357 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -470,6 +470,9 @@ $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton = dol_getdate(dol_now(), true); + if(empty($newparam)) { + $newparam = ''; + } $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); if ($begin_h !== '') { $newparam .= '&begin_h='.urlencode($begin_h); @@ -489,6 +492,9 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } +if(empty($num)) { + $num = ''; +} print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); $link = ''; @@ -505,6 +511,9 @@ $s = $newtitle; print $s; print '
'; +if(empty($search_status)) { + $search_status = ''; +} print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print '
'; @@ -1378,10 +1387,10 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $ids1 = ''; $ids2 = ''; - if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) { + if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) { $ids1 = join(',', array_keys($cases1[$h])); } - if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) { + if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) { $ids2 = join(',', array_keys($cases2[$h])); } @@ -1390,7 +1399,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } else { echo ''; } - if (is_array($cases1[$h]) && count($cases1[$h]) == 1) { // only 1 event + if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) { // only 1 event $output = array_slice($cases1[$h], 0, 1); $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); if ($output[0]['string']) { @@ -1399,12 +1408,12 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if ($output[0]['color']) { $color1 = $output[0]['color']; } - } elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1) { + } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) { $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); $color1 = '222222'; } - if (is_array($cases2[$h]) && count($cases2[$h]) == 1) { // only 1 event + if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) { // only 1 event $output = array_slice($cases2[$h], 0, 1); $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); if ($output[0]['string']) { @@ -1413,7 +1422,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if ($output[0]['color']) { $color2 = $output[0]['color']; } - } elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1) { + } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) { $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $color2 = '222222'; } From 628bfc9963aa65c1447967e67949f21388ad569c Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Wed, 25 Aug 2021 18:15:32 +0800 Subject: [PATCH 005/229] Fix undef vars 4 To remove PHP8 warnings --- htdocs/ticket/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index c79a75e851c..b1922cf4aac 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -390,7 +390,7 @@ foreach ($search as $key => $val) { } continue; } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + $mode_search = ((!empty($object->fields[$key]) && $object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if ($search[$key] != '') { $sql .= natural_search($key, $search[$key], $mode_search); } @@ -897,7 +897,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object From 8c992916382d1db535697f838400f4d784a0fc33 Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Wed, 25 Aug 2021 18:28:32 +0800 Subject: [PATCH 006/229] Fix undef vars 5 To remove PHP8 warnings --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e1d3c5b14f6..78b78185ca0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1397,7 +1397,7 @@ class Form if ($resql) { if (!$forcecombo) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlname, $events, getDolGlobalString("COMPANY_USE_SEARCH_TO_SELECT")); } // Construct $out and $outarray @@ -1678,7 +1678,7 @@ class Form if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlid, $events, getDolGlobalString("CONTACT_USE_SEARCH_TO_SELECT")); } if ($htmlname != 'none' && !$options_only) { From 7161b1ba59b235d1a6bfc30a72b9611dc8d5811e Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Wed, 25 Aug 2021 18:45:40 +0800 Subject: [PATCH 007/229] Fix undef vars 6 To remove PHP8 warnings --- htdocs/core/menus/standard/eldy.lib.php | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 26aa5df16ad..7f8c2ba7072 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -85,9 +85,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 10, 'id' => $id, 'idsel' => 'home', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1), 'loadLangs' => array(), 'submenus' => array(), ); @@ -110,9 +110,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 18, 'id' => $id, 'idsel' => 'members', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'member', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 0 : 1), 'loadLangs' => array(), 'submenus' => array(), ); @@ -139,9 +139,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 20, 'id' => $id, 'idsel' => 'companies', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'company', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 0 : 1), 'loadLangs' => array("companies", "suppliers"), 'submenus' => array(), ); @@ -166,9 +166,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 30, 'id' => $id, 'idsel' => 'products', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'product', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 0 : 1), 'loadLangs' => array("products"), 'submenus' => array(), ); @@ -191,9 +191,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 31, 'id' => $id, 'idsel' => 'mrp', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'mrp', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 0 : 1), 'loadLangs' => array("mrp"), 'submenus' => array(), ); @@ -216,9 +216,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 35, 'id' => $id, 'idsel' => 'project', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'project', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 0 : 1), 'loadLangs' => array("projects"), 'submenus' => array(), ); @@ -265,9 +265,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 40, 'id' => $id, 'idsel' => 'commercial', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'contract', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 0 : 1), 'loadLangs' => array("commercial"), 'submenus' => array(), ); @@ -299,9 +299,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 50, 'id' => $id, 'idsel' => 'billing', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'bill', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 0 : 1), 'loadLangs' => array("compta"), 'submenus' => array(), ); @@ -324,9 +324,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 52, 'id' => $id, 'idsel' => 'bank', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'bank_account', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 0 : 1), 'loadLangs' => array("compta", "banks"), 'submenus' => array(), ); @@ -349,9 +349,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 54, 'id' => $id, 'idsel' => 'accountancy', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'accountancy', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"), 'submenus' => array(), ); @@ -375,9 +375,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 80, 'id' => $id, 'idsel' => 'hrm', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'hrm', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 0 : 1), 'loadLangs' => array("holiday"), 'submenus' => array(), ); @@ -400,9 +400,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 88, 'id' => $id, 'idsel' => 'ticket', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'ticket', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "ticket") ? 0 : 1), + 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 0 : 1), 'loadLangs' => array("other"), 'submenus' => array(), ); @@ -425,9 +425,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 90, 'id' => $id, 'idsel' => 'tools', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'tools', 'class="fa-fw paddingright"'), - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 0 : 1), 'loadLangs' => array("other"), 'submenus' => array(), ); @@ -1567,7 +1567,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Cash Control if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) { - $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run); + $permtomakecashfence = ($user->hasRight('cashdesk', 'run')|| $user->hasRight('takepos', 'run')); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"')); $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence); From 03b04bea089d3f1460ca4d0fb3bab6937f93df83 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 25 Aug 2021 12:46:56 +0200 Subject: [PATCH 008/229] NEW: date filter on project list and task list From->To --- htdocs/projet/list.php | 120 +++++++++++++++++++++++++++++++++-- htdocs/projet/tasks.php | 116 +++++++++++++++++++++++++++++++-- htdocs/projet/tasks/list.php | 70 ++++++++++++++++++-- 3 files changed, 294 insertions(+), 12 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 43f5bd6ff2f..0df6c88a5a6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -120,6 +120,26 @@ $search_eday = GETPOST('search_eday', 'int'); $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); + +$search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int'); +$search_date_start_startyear = GETPOST('search_date_start_startyear', 'int'); +$search_date_start_startday = GETPOST('search_date_start_startday', 'int'); +$search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver +$search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int'); +$search_date_start_endyear = GETPOST('search_date_start_endyear', 'int'); +$search_date_start_endday = GETPOST('search_date_start_endday', 'int'); +$search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver + +$search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int'); +$search_date_end_startyear = GETPOST('search_date_end_startyear', 'int'); +$search_date_end_startday = GETPOST('search_date_end_startday', 'int'); +$search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver +$search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int'); +$search_date_end_endyear = GETPOST('search_date_end_endyear', 'int'); +$search_date_end_endday = GETPOST('search_date_end_endday', 'int'); +$search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver + + if ($search_status == '') { $search_status = -1; // -1 or 1 } @@ -237,6 +257,22 @@ if (empty($reshook)) { $search_eday = ""; $search_emonth = ""; $search_eyear = ""; + $search_date_start_startmonth = ""; + $search_date_start_startyear = ""; + $search_date_start_startday = ""; + $search_date_start_start = ""; + $search_date_start_endmonth = ""; + $search_date_start_endyear = ""; + $search_date_start_endday = ""; + $search_date_start_end = ""; + $search_date_end_startmonth = ""; + $search_date_end_startyear = ""; + $search_date_end_startday = ""; + $search_date_end_start = ""; + $search_date_end_endmonth = ""; + $search_date_end_endyear = ""; + $search_date_end_endday = ""; + $search_date_end_end = ""; $search_usage_opportunity = ''; $search_usage_task = ''; $search_usage_bill_time = ''; @@ -408,6 +444,22 @@ if ($search_opp_percent) { } $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear); + + +if ($search_date_start_start) { + $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'"; +} +if ($search_date_start_end) { + $sql .= " AND p.dateo <= '".$db->idate($search_date_start_end)."'"; +} + +if ($search_date_end_start) { + $sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'"; +} +if ($search_date_end_end) { + $sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'"; +} + if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -558,6 +610,54 @@ if ($search_emonth) { if ($search_eyear) { $param .= '&search_eyear='.urlencode($search_eyear); } +if ($search_date_start_startmonth) { + $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth); +} +if ($search_date_start_startyear) { + $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear); +} +if ($search_date_start_startday) { + $param .= '&search_date_start_startday='.urlencode($search_date_start_startday); +} +if ($search_date_start_start) { + $param .= '&search_date_start_start='.urlencode($search_date_start_start); +} +if ($search_date_start_endmonth) { + $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth); +} +if ($search_date_start_endyear) { + $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear); +} +if ($search_date_start_endday) { + $param .= '&search_date_start_endday='.urlencode($search_date_start_endday); +} +if ($search_date_start_end) { + $param .= '&search_date_start_end='.urlencode($search_date_start_end); +} +if ($search_date_end_startmonth) { + $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth); +} +if ($search_date_end_startyear) { + $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear); +} +if ($search_date_end_startday) { + $param .= '&search_date_end_startday='.urlencode($search_date_end_startday); +} +if ($search_date_end_start) { + $param .= '&search_date_end_start='.urlencode($search_date_end_start); +} +if ($search_date_end_endmonth) { + $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth); +} +if ($search_date_end_endyear) { + $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear); +} +if ($search_date_end_endday) { + $param .= '&search_date_end_endday='.urlencode($search_date_end_endday); +} +if ($search_date_end_end) { + $param .= '&search_date_end_end=' . urlencode($search_date_end_end); +} if ($socid) { $param .= '&socid='.urlencode($socid); } @@ -769,21 +869,33 @@ if (!empty($arrayfields['commercial']['checked'])) { // Start date if (!empty($arrayfields['p.dateo']['checked'])) { print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } print ''; - $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/ + print '
'; + print $form->selectDate($search_date_start_start ? $search_date_start_start : -1, 'search_date_start_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_start_end ? $search_date_start_end : -1, 'search_date_start_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } // End date if (!empty($arrayfields['p.datee']['checked'])) { print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } print ''; - $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/ + print '
'; + print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } if (!empty($arrayfields['p.public']['checked'])) { diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 367f7a27681..aec790b9240 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -83,6 +83,24 @@ $search_timespend = GETPOST('search_timespend'); $search_progresscalc = GETPOST('search_progresscalc'); $search_progressdeclare = GETPOST('search_progressdeclare'); +$search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int'); +$search_date_start_startyear = GETPOST('search_date_start_startyear', 'int'); +$search_date_start_startday = GETPOST('search_date_start_startday', 'int'); +$search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver +$search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int'); +$search_date_start_endyear = GETPOST('search_date_start_endyear', 'int'); +$search_date_start_endday = GETPOST('search_date_start_endday', 'int'); +$search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver + +$search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int'); +$search_date_end_startyear = GETPOST('search_date_end_startyear', 'int'); +$search_date_end_startday = GETPOST('search_date_end_startday', 'int'); +$search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver +$search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int'); +$search_date_end_endyear = GETPOST('search_date_end_endyear', 'int'); +$search_date_end_endday = GETPOST('search_date_end_endday', 'int'); +$search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver + $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projecttasklist'; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects @@ -188,6 +206,22 @@ if (empty($reshook)) { $search_progressdeclare = ''; $toselect = ''; $search_array_options = array(); + $search_date_start_startmonth = ""; + $search_date_start_startyear = ""; + $search_date_start_startday = ""; + $search_date_start_start = ""; + $search_date_start_endmonth = ""; + $search_date_start_endyear = ""; + $search_date_start_endday = ""; + $search_date_start_end = ""; + $search_date_end_startmonth = ""; + $search_date_end_startyear = ""; + $search_date_end_startday = ""; + $search_date_end_start = ""; + $search_date_end_endmonth = ""; + $search_date_end_endyear = ""; + $search_date_end_endday = ""; + $search_date_end_end = ""; } // Mass actions @@ -219,6 +253,20 @@ if ($moresql) { $morewherefilterarray[] = $moresql; } +if ($search_date_start_start) { + $morewherefilterarray[] = " t.dateo >= '".$db->idate($search_date_start_start)."'"; +} +if ($search_date_start_end) { + $morewherefilterarray[] = " t.dateo <= '".$db->idate($search_date_start_end)."'"; +} + +if ($search_date_end_start) { + $morewherefilterarray[] = " t.datee >= '".$db->idate($search_date_end_start)."'"; +} +if ($search_date_end_end) { + $morewherefilterarray[] = " t.datee <= '".$db->idate($search_date_end_end)."'"; +} + if (!empty($search_planedworkload)) { $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1); } @@ -416,6 +464,54 @@ if ($id > 0 || !empty($ref)) { if ($search_dtendyear) { $param .= '&search_dtendyear='.urlencode($search_dtendyear); } + if ($search_date_start_startmonth) { + $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth); + } + if ($search_date_start_startyear) { + $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear); + } + if ($search_date_start_startday) { + $param .= '&search_date_start_startday='.urlencode($search_date_start_startday); + } + if ($search_date_start_start) { + $param .= '&search_date_start_start='.urlencode($search_date_start_start); + } + if ($search_date_start_endmonth) { + $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth); + } + if ($search_date_start_endyear) { + $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear); + } + if ($search_date_start_endday) { + $param .= '&search_date_start_endday='.urlencode($search_date_start_endday); + } + if ($search_date_start_end) { + $param .= '&search_date_start_end='.urlencode($search_date_start_end); + } + if ($search_date_end_startmonth) { + $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth); + } + if ($search_date_end_startyear) { + $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear); + } + if ($search_date_end_startday) { + $param .= '&search_date_end_startday='.urlencode($search_date_end_startday); + } + if ($search_date_end_start) { + $param .= '&search_date_end_start='.urlencode($search_date_end_start); + } + if ($search_date_end_endmonth) { + $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth); + } + if ($search_date_end_endyear) { + $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear); + } + if ($search_date_end_endday) { + $param .= '&search_date_end_endday='.urlencode($search_date_end_endday); + } + if ($search_date_end_end) { + $param .= '&search_date_end_end=' . urlencode($search_date_end_end); + } if ($search_planedworkload) { $param .= '&search_planedworkload='.urlencode($search_planedworkload); } @@ -777,17 +873,29 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (!empty($arrayfields['t.dateo']['checked'])) { print ''; - print ''; + /*print ''; print ''; - $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); + $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5);*/ + print '
'; + print $form->selectDate($search_date_start_start ? $search_date_start_start : -1, 'search_date_start_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_start_end ? $search_date_start_end : -1, 'search_date_start_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } if (!empty($arrayfields['t.datee']['checked'])) { print ''; - print ''; + /*print ''; print ''; - $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); + $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5);*/ + print '
'; + print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 8dc369b6a0a..8ffbcf7d609 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -78,6 +78,24 @@ $search_eday = GETPOST('search_eday', 'int'); $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); +$search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int'); +$search_date_start_startyear = GETPOST('search_date_start_startyear', 'int'); +$search_date_start_startday = GETPOST('search_date_start_startday', 'int'); +$search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver +$search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int'); +$search_date_start_endyear = GETPOST('search_date_start_endyear', 'int'); +$search_date_start_endday = GETPOST('search_date_start_endday', 'int'); +$search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver + +$search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int'); +$search_date_end_startyear = GETPOST('search_date_end_startyear', 'int'); +$search_date_end_startday = GETPOST('search_date_end_startday', 'int'); +$search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver +$search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int'); +$search_date_end_endyear = GETPOST('search_date_end_endyear', 'int'); +$search_date_end_endday = GETPOST('search_date_end_endday', 'int'); +$search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver + // Initialize context for list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'tasklist'; @@ -197,6 +215,22 @@ if (empty($reshook)) { $search_eday = ''; $search_emonth = ''; $search_eyear = ''; + $search_date_start_startmonth = ""; + $search_date_start_startyear = ""; + $search_date_start_startday = ""; + $search_date_start_start = ""; + $search_date_start_endmonth = ""; + $search_date_start_endyear = ""; + $search_date_start_endday = ""; + $search_date_start_end = ""; + $search_date_end_startmonth = ""; + $search_date_end_startyear = ""; + $search_date_end_startday = ""; + $search_date_end_start = ""; + $search_date_end_endmonth = ""; + $search_date_end_endyear = ""; + $search_date_end_endday = ""; + $search_date_end_end = ""; $toselect = ''; $search_array_options = array(); } @@ -372,8 +406,24 @@ if ($search_task_progress) { if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } + $sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); + +if ($search_date_start_start) { + $sql .= " AND t.dateo >= '".$db->idate($search_date_start_start)."'"; +} +if ($search_date_start_end) { + $sql .= " AND t.dateo <= '".$db->idate($search_date_start_end)."'"; +} + +if ($search_date_end_start) { + $sql .= " AND t.datee >= '".$db->idate($search_date_end_start)."'"; +} +if ($search_date_end_end) { + $sql .= " AND t.datee <= '".$db->idate($search_date_end_end)."'"; +} + if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -647,21 +697,33 @@ if (!empty($arrayfields['t.description']['checked'])) { // Start date if (!empty($arrayfields['t.dateo']['checked'])) { print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } print ''; - print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1); + print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1);*/ + print '
'; + print $form->selectDate($search_date_start_start ? $search_date_start_start : -1, 'search_date_start_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_start_end ? $search_date_start_end : -1, 'search_date_start_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } // End date if (!empty($arrayfields['t.datee']['checked'])) { print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } print ''; - print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1); + print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1);*/ + print '
'; + print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } if (!empty($arrayfields['p.ref']['checked'])) { From 5e795e74d7de87af9b07315e5f202ac24b3c3939 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 25 Aug 2021 12:48:32 +0200 Subject: [PATCH 009/229] NEW: date filter on project list and task list From->To --- htdocs/projet/tasks/list.php | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 8ffbcf7d609..26e6a6f17ac 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -522,6 +522,54 @@ if ($search_emonth) { if ($search_eyear) { $param .= '&search_eyear='.urlencode($search_eyear); } +if ($search_date_start_startmonth) { + $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth); +} +if ($search_date_start_startyear) { + $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear); +} +if ($search_date_start_startday) { + $param .= '&search_date_start_startday='.urlencode($search_date_start_startday); +} +if ($search_date_start_start) { + $param .= '&search_date_start_start='.urlencode($search_date_start_start); +} +if ($search_date_start_endmonth) { + $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth); +} +if ($search_date_start_endyear) { + $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear); +} +if ($search_date_start_endday) { + $param .= '&search_date_start_endday='.urlencode($search_date_start_endday); +} +if ($search_date_start_end) { + $param .= '&search_date_start_end='.urlencode($search_date_start_end); +} +if ($search_date_end_startmonth) { + $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth); +} +if ($search_date_end_startyear) { + $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear); +} +if ($search_date_end_startday) { + $param .= '&search_date_end_startday='.urlencode($search_date_end_startday); +} +if ($search_date_end_start) { + $param .= '&search_date_end_start='.urlencode($search_date_end_start); +} +if ($search_date_end_endmonth) { + $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth); +} +if ($search_date_end_endyear) { + $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear); +} +if ($search_date_end_endday) { + $param .= '&search_date_end_endday='.urlencode($search_date_end_endday); +} +if ($search_date_end_end) { + $param .= '&search_date_end_end=' . urlencode($search_date_end_end); +} if ($socid) { $param .= '&socid='.urlencode($socid); } From 15445e9bbae5c725d6ff627cd595fcd2d04fa418 Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Wed, 25 Aug 2021 18:50:05 +0800 Subject: [PATCH 010/229] Fix undef vars 7 To remove PHP8 warnings --- htdocs/projet/list.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 43f5bd6ff2f..50e4cfc0094 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -42,7 +42,7 @@ if (!empty($conf->categorie->enabled)) { // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'commercial')); -if ($conf->eventorganization->enabled) { +if (!empty($conf->eventorganization->enabled) && $conf->eventorganization->enabled) { $langs->loadLangs(array('eventorganization')); } @@ -56,7 +56,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'pro $title = $langs->trans("Projects"); // Security check -$socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0); +$socid = (!empty($_GET["socid"]) && is_numeric($_GET["socid"]) ? $_GET["socid"] : 0); //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if ($socid > 0) { $soc = new Societe($db); @@ -108,7 +108,7 @@ $search_price_registration = GETPOST("search_price_registration", 'alpha'); $search_price_booth = GETPOST("search_price_booth", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = (!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'mine') ? 1 : 0; if ($mine) { $search_project_user = $user->id; $mine = 0; } @@ -365,7 +365,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid"); } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty( $extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; @@ -561,7 +561,7 @@ if ($search_eyear) { if ($socid) { $param .= '&socid='.urlencode($socid); } -if ($search_categ) { +if (!empty($search_categ)) { $param .= '&search_categ='.urlencode($search_categ); } if ($search_ref != '') { From 601cc865fb47077a5b89bd37092e8bb0dc081a51 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 25 Aug 2021 10:54:09 +0000 Subject: [PATCH 011/229] Fixing style errors. --- htdocs/comm/action/peruser.php | 14 +++++++------- htdocs/projet/list.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 38a316f4357..7370eac03ed 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -470,9 +470,9 @@ $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton = dol_getdate(dol_now(), true); - if(empty($newparam)) { - $newparam = ''; - } + if (empty($newparam)) { + $newparam = ''; + } $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); if ($begin_h !== '') { $newparam .= '&begin_h='.urlencode($begin_h); @@ -492,8 +492,8 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } -if(empty($num)) { - $num = ''; +if (empty($num)) { + $num = ''; } print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); @@ -511,8 +511,8 @@ $s = $newtitle; print $s; print '
'; -if(empty($search_status)) { - $search_status = ''; +if (empty($search_status)) { + $search_status = ''; } print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print '
'; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 50e4cfc0094..9440a284a6d 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -365,7 +365,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid"); } -if (!empty( $extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; From 236554948c018f4af92364fc23be24db2dde79d8 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Wed, 25 Aug 2021 19:40:58 +0800 Subject: [PATCH 012/229] Add files via upload --- htdocs/core/ajax/locationincoterms.php | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 htdocs/core/ajax/locationincoterms.php diff --git a/htdocs/core/ajax/locationincoterms.php b/htdocs/core/ajax/locationincoterms.php new file mode 100644 index 00000000000..04e4a27b2a8 --- /dev/null +++ b/htdocs/core/ajax/locationincoterms.php @@ -0,0 +1,110 @@ + + * Copyright (C) 2011-2014 Laurent Destailleur + * Copyright (C) 2021 Henry Guo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/locationincoterms.php + * \ingroup core + * \brief File to return Ajax response on location_incoterms request + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +//print ''."\n"; + +dol_syslog('location_incoterms call with MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY='.(empty($conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY) ? '' : $conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY)); +//var_dump($_GET); + +// Generation of list of zip-town +if (GETPOST('location_incoterms')) { + $return_arr = array(); + + // Define filter on text typed + $location_incoterms = GETPOST('location_incoterms'); + + if (!empty($conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY)) { // Use location_incoterms + $sql = "SELECT z.location as location_incoterms, z.label as label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_location_incoterms as z"; + $sql .= " WHERE z.active = 1 AND UPPER(z.location) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; + $sql .= " ORDER BY z.location"; + $sql .= $db->plimit(100); // Avoid pb with bad criteria + } else // Use table of commande + { + $sql = "SELECT DISTINCT s.location_incoterms FROM ".MAIN_DB_PREFIX.'commande as s'; + $sql .= " WHERE UPPER(s.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; + + //Todo: merge with data from table of supplier order + /* $sql .=" UNION"; + $sql .= " SELECT DISTINCT p.location_incoterms FROM ".MAIN_DB_PREFIX.'commande_fournisseur as p'; + $sql .= " WHERE UPPER(p.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; + */ + $sql .= " ORDER BY s.location_incoterms"; + $sql .= $db->plimit(100); // Avoid pb with bad criteria + } + + //print $sql; + $resql = $db->query($sql); + //var_dump($db); + if ($resql) { + while ($row = $db->fetch_array($resql)) { + $row_array['label'] = $row['location_incoterms'].($row['label']?' - '.$row['label'] : ''); + if ($location_incoterms) { + $row_array['value'] = $row['location_incoterms']; + } + // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs) + + array_push($return_arr, $row_array); + } + } + + echo json_encode($return_arr); +} + +$db->close(); From 951286191336aeb131aecdb7721e50461376319f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 25 Aug 2021 11:43:32 +0000 Subject: [PATCH 013/229] Fixing style errors. --- htdocs/core/ajax/locationincoterms.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/ajax/locationincoterms.php b/htdocs/core/ajax/locationincoterms.php index 04e4a27b2a8..3a508a07057 100644 --- a/htdocs/core/ajax/locationincoterms.php +++ b/htdocs/core/ajax/locationincoterms.php @@ -65,7 +65,7 @@ dol_syslog('location_incoterms call with MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY // Generation of list of zip-town if (GETPOST('location_incoterms')) { $return_arr = array(); - + // Define filter on text typed $location_incoterms = GETPOST('location_incoterms'); @@ -79,13 +79,13 @@ if (GETPOST('location_incoterms')) { { $sql = "SELECT DISTINCT s.location_incoterms FROM ".MAIN_DB_PREFIX.'commande as s'; $sql .= " WHERE UPPER(s.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; - - //Todo: merge with data from table of supplier order - /* $sql .=" UNION"; + + //Todo: merge with data from table of supplier order + /* $sql .=" UNION"; $sql .= " SELECT DISTINCT p.location_incoterms FROM ".MAIN_DB_PREFIX.'commande_fournisseur as p'; $sql .= " WHERE UPPER(p.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; - */ - $sql .= " ORDER BY s.location_incoterms"; + */ + $sql .= " ORDER BY s.location_incoterms"; $sql .= $db->plimit(100); // Avoid pb with bad criteria } @@ -94,7 +94,7 @@ if (GETPOST('location_incoterms')) { //var_dump($db); if ($resql) { while ($row = $db->fetch_array($resql)) { - $row_array['label'] = $row['location_incoterms'].($row['label']?' - '.$row['label'] : ''); + $row_array['label'] = $row['location_incoterms'].($row['label']?' - '.$row['label'] : ''); if ($location_incoterms) { $row_array['value'] = $row['location_incoterms']; } From a5bb833a0afdcdd423dd6f23cc558789e9c39967 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Aug 2021 17:39:23 +0200 Subject: [PATCH 014/229] Update peruser.php --- htdocs/comm/action/peruser.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 7370eac03ed..57bebf4fc16 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -466,13 +466,11 @@ if (empty($reshook)) { } +$newparam = ''; $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton = dol_getdate(dol_now(), true); - if (empty($newparam)) { - $newparam = ''; - } $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); if ($begin_h !== '') { $newparam .= '&begin_h='.urlencode($begin_h); From 5fd0e6ac28407bf7efc49695d4165654022178fb Mon Sep 17 00:00:00 2001 From: Gurvan Kervern Date: Sun, 29 Aug 2021 00:50:00 +0800 Subject: [PATCH 015/229] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7f8c2ba7072..f1c66caae42 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -87,7 +87,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'idsel' => 'home', 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1), 'loadLangs' => array(), 'submenus' => array(), ); From 39fcc53fa746160cef9fca66e793b84152fb81b7 Mon Sep 17 00:00:00 2001 From: Gurvan Kervern Date: Sun, 29 Aug 2021 00:51:01 +0800 Subject: [PATCH 016/229] Update peruser.php --- htdocs/comm/action/peruser.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 57bebf4fc16..dbda8f0ae46 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -490,9 +490,8 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } -if (empty($num)) { - $num = ''; -} +$num = ''; + print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); $link = ''; From 38a225a03529be64f92c7275115bd8abb2c95bcb Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Sat, 28 Aug 2021 20:28:09 +0200 Subject: [PATCH 017/229] fix product nature on create --- htdocs/product/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 44c7fd9ca51..5107ed14b0a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1268,8 +1268,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { // Nature print ''.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; - $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); + print $formproduct->selectProductNature('finished', $object->finished); print ''; } } From 71f6b472e34be43e3e3599013d078b9780ea3cf5 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Sun, 29 Aug 2021 07:51:29 +0800 Subject: [PATCH 018/229] Update stocks.lang --- htdocs/langs/en_US/stocks.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 78b095d9f11..39617f34344 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -12,7 +12,7 @@ AddWarehouse=Create warehouse AddOne=Add one DefaultWarehouse=Default warehouse WarehouseTarget=Target warehouse -ValidateSending=Delete sending +ValidateSending=Confirm sending CancelSending=Cancel sending DeleteSending=Delete sending Stock=Stock From c9db6bfdf64e1a0ed7e4e6acc924b5791a20e388 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Sun, 29 Aug 2021 08:51:02 +0800 Subject: [PATCH 019/229] Update remx.php --- htdocs/comm/remx.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 42a5ee42e16..e9419480ed6 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -709,8 +709,8 @@ if ($socid > 0) { //$sql.= " UNION "; // Discount linked to invoices $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; - $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; - $sql2 .= " rc.fk_facture_source,"; + $sql2 .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; + $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture, rc.fk_facture_source,"; $sql2 .= " u.login, u.rowid as user_id,"; $sql2 .= " f.rowid as invoiceid, f.ref,"; $sql2 .= " fa.ref as invoice_source_ref, fa.type as type"; @@ -850,7 +850,7 @@ if ($socid > 0) { // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; $sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; + $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line,"; $sql .= " rc.fk_invoice_supplier_source,"; $sql .= " u.login, u.rowid as user_id,"; $sql .= " f.rowid as invoiceid, f.ref as ref,"; @@ -869,7 +869,8 @@ if ($socid > 0) { //$sql.= " UNION "; // Discount linked to invoices $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; - $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; + $sql2 .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; + $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier,"; $sql2 .= " rc.fk_invoice_supplier_source,"; $sql2 .= " u.login, u.rowid as user_id,"; $sql2 .= " f.rowid as invoiceid, f.ref as ref,"; From 66d1e5c74d7c065394d9c911127799f408922bec Mon Sep 17 00:00:00 2001 From: Gurvan Kervern Date: Sun, 29 Aug 2021 18:15:09 +0800 Subject: [PATCH 020/229] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 48 ++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f1c66caae42..ca6a736d755 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -85,7 +85,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 10, 'id' => $id, 'idsel' => 'home', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "home") ? 0 : 1), 'loadLangs' => array(), @@ -110,9 +110,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 18, 'id' => $id, 'idsel' => 'members', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'member', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "members") ? 0 : 1), 'loadLangs' => array(), 'submenus' => array(), ); @@ -139,9 +139,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 20, 'id' => $id, 'idsel' => 'companies', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'company', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "companies") ? 0 : 1), 'loadLangs' => array("companies", "suppliers"), 'submenus' => array(), ); @@ -166,9 +166,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 30, 'id' => $id, 'idsel' => 'products', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'product', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "products") ? 0 : 1), 'loadLangs' => array("products"), 'submenus' => array(), ); @@ -191,9 +191,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 31, 'id' => $id, 'idsel' => 'mrp', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'mrp', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "mrp") ? 0 : 1), 'loadLangs' => array("mrp"), 'submenus' => array(), ); @@ -216,9 +216,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 35, 'id' => $id, 'idsel' => 'project', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'project', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "project") ? 0 : 1), 'loadLangs' => array("projects"), 'submenus' => array(), ); @@ -265,9 +265,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 40, 'id' => $id, 'idsel' => 'commercial', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'contract', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "commercial") ? 0 : 1), 'loadLangs' => array("commercial"), 'submenus' => array(), ); @@ -299,9 +299,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 50, 'id' => $id, 'idsel' => 'billing', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'bill', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "billing") ? 0 : 1), 'loadLangs' => array("compta"), 'submenus' => array(), ); @@ -324,9 +324,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 52, 'id' => $id, 'idsel' => 'bank', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'bank_account', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "bank") ? 0 : 1), 'loadLangs' => array("compta", "banks"), 'submenus' => array(), ); @@ -349,9 +349,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 54, 'id' => $id, 'idsel' => 'accountancy', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'accountancy', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"), 'submenus' => array(), ); @@ -375,9 +375,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 80, 'id' => $id, 'idsel' => 'hrm', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'hrm', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "hrm") ? 0 : 1), 'loadLangs' => array("holiday"), 'submenus' => array(), ); @@ -400,9 +400,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 88, 'id' => $id, 'idsel' => 'ticket', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'ticket', 'class="fa-fw paddingright"'), - 'session' => ((!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 0 : 1), + 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "ticket") ? 0 : 1), 'loadLangs' => array("other"), 'submenus' => array(), ); @@ -425,7 +425,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'position' => 90, 'id' => $id, 'idsel' => 'tools', - 'classname' => $classname = (!isset($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"', + 'classname' => $classname = (!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => img_picto('', 'tools', 'class="fa-fw paddingright"'), 'session' => ((!empty($_SESSION["mainmenu"]) && $_SESSION["mainmenu"] == "tools") ? 0 : 1), 'loadLangs' => array("other"), From ebd1b49d2a0bee8b5f963ebf47343893a02f350c Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Sun, 29 Aug 2021 22:41:22 +0800 Subject: [PATCH 021/229] Fix undef 4-1 PHP8 warnings --- htdocs/takepos/invoice.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 96b06d09271..d94fdb9e181 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -152,19 +152,19 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $ret = $invoice->fetch($invoiceid); } else { - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $ret = $invoice->fetch('', '(PROV-POS'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' .'-'.$place.')'); } if ($ret > 0) { $placeid = $invoice->id; } -$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; +$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $soc = new Societe($db); if ($invoice->socid > 0) { $soc->fetch($invoice->socid); } else { - $soc->fetch($conf->global->$constforcompanyid); + $soc->fetch(getDolGlobalString("$constforcompanyid")); } @@ -477,10 +477,10 @@ if ($action == 'history' || $action == 'creditnote') { } if (($action == "addline" || $action == "freezone") && $placeid == 0) { - $invoice->socid = $conf->global->$constforcompanyid; + $invoice->socid = getDolGlobalString("$constforcompanyid"); $invoice->date = dol_now(); $invoice->module_source = 'takepos'; - $invoice->pos_source = $_SESSION["takeposterminal"]; + $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; if ($invoice->socid <= 0) { @@ -549,7 +549,7 @@ if ($action == "addline") { } if ($idoflineadded <= 0) { $invoice->fetch_thirdparty(); - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, '', '', 0, 100, '', null, 0); + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { $CUSTOMER_DISPLAY_line1 = $prod->label; $CUSTOMER_DISPLAY_line2 = price($price_ttc); @@ -930,7 +930,7 @@ $(document).ready(function() { } global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -951,7 +951,7 @@ if ($action == "order" and $order_receipt_printer1 != "") { } } -if ($action == "order" and $order_receipt_printer2 != "") { +if ($action == "order" and !empty($order_receipt_printer2)) { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -972,7 +972,7 @@ if ($action == "order" and $order_receipt_printer2 != "") { } } -if ($action == "order" and $order_receipt_printer3 != "") { +if ($action == "order" and !empty($order_receipt_printer3)) { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -992,7 +992,7 @@ if ($action == "search" || $action == "valid") { } -if ($action == "temp" and $ticket_printer1 != "") { +if ($action == "temp" and !empty($ticket_printer1)) { ?> $.ajax({ type: "POST", @@ -1039,7 +1039,7 @@ function TakeposPrinting(id){ function TakeposConnector(id){ console.log("TakeposConnector" + id); - $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { + $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { $.ajax({ type: "POST", url: '/printer/index.php', @@ -1053,7 +1053,7 @@ function DolibarrTakeposPrinting(id) { $.ajax({ type: "GET", data: { token: '' }, - url: "" + id, + url: "" + id, }); } @@ -1086,7 +1086,7 @@ $( document ).ready(function() { $sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture"; if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { // By default, only invoices with a ref not already defined can in list of open invoice we can edit. - $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape($_SESSION["takeposterminal"])."-0%' AND entity IN (".getEntity('invoice').")"; + $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape( isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; } else { // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined $sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; @@ -1127,12 +1127,12 @@ $( document ).ready(function() { $s = ''; - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; + if (!empty($conf->stock->enabled) && getDolGlobalString("$constantforkey") != "1") { $s = ''; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; $warehouse = new Entrepot($db); - $warehouse->fetch($conf->global->$constantforkey); + $warehouse->fetch(getDolGlobalString("$constantforkey")); $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; $s .= '
'; } From b242387c4353f9634786a995157608cb27ae4b67 Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Sun, 29 Aug 2021 22:46:39 +0800 Subject: [PATCH 022/229] Fix undef4-2 PHP8 warnings --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a54797323a3..cf7aa02f0f5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -253,7 +253,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { +if (getDolGlobalString("INVOICE_USE_SITUATION") && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } // Overwrite $arrayfields from columns into ->fields (transition before removal of $arrayoffields) From 6417d3ddf73d9b256da32c7dd5c074e8aa5f1406 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 29 Aug 2021 14:48:25 +0000 Subject: [PATCH 023/229] Fixing style errors. --- htdocs/takepos/invoice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d94fdb9e181..45c266b5816 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1039,7 +1039,7 @@ function TakeposPrinting(id){ function TakeposConnector(id){ console.log("TakeposConnector" + id); - $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { + $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { $.ajax({ type: "POST", url: '/printer/index.php', @@ -1053,7 +1053,7 @@ function DolibarrTakeposPrinting(id) { $.ajax({ type: "GET", data: { token: '' }, - url: "" + id, + url: "" + id, }); } @@ -1086,7 +1086,7 @@ $( document ).ready(function() { $sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture"; if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { // By default, only invoices with a ref not already defined can in list of open invoice we can edit. - $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape( isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; + $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; } else { // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined $sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; From 359dae6af876c8b970e0db79c54436b787539823 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Sun, 29 Aug 2021 23:13:41 +0400 Subject: [PATCH 024/229] FIX #18542 REST API: set global $user variable to DolibarrApiAccess::user. --- htdocs/api/class/api_access.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 99582b62047..eaaa29d7aa1 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate public function __isAllowed() { // phpcs:enable - global $conf, $db; + global $conf, $db, $user; $login = ''; $stored_key = ''; @@ -149,6 +149,7 @@ class DolibarrApiAccess implements iAuthenticate } $fuser->getrights(); static::$user = $fuser; + $user = $fuser; if ($fuser->socid) { static::$role = 'external'; From 4381f67a64bc90c2c2df6b8a8084c169e5aef7e5 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Mon, 30 Aug 2021 00:08:43 +0400 Subject: [PATCH 025/229] FIX #18544 Shipment REST API: load thirdparty object into the shipment before validating. --- htdocs/commande/class/api_orders.class.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 745fea5ab76..f5e9aea75bd 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -716,7 +716,9 @@ class Orders extends DolibarrApi if (!$result) { throw new RestException(404, 'Order not found'); } - + + $result = $this->commande->fetch_thirdparty(); // do not check result, as failure is not fatal (used only for mail notification substitutes) + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -729,13 +731,6 @@ class Orders extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } $this->commande->fetchObjectLinked(); From 01a44760a868b8d2099f058738d4ed79bde68257 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 29 Aug 2021 20:14:19 +0000 Subject: [PATCH 026/229] Fixing style errors. --- htdocs/commande/class/api_orders.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index f5e9aea75bd..b550139cd94 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -716,9 +716,9 @@ class Orders extends DolibarrApi if (!$result) { throw new RestException(404, 'Order not found'); } - + $result = $this->commande->fetch_thirdparty(); // do not check result, as failure is not fatal (used only for mail notification substitutes) - + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From 7bf6daaca7704e891198c385da7c5f0adcf1f433 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Mon, 30 Aug 2021 15:33:26 +0800 Subject: [PATCH 027/229] Update card.php --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6cf2f27844a..a784431c841 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -538,7 +538,7 @@ if (empty($reshook)) { } // If some payments were already done, we change the amount to pay using same prorate - if (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + if (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) && $object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); From 3240a3652dbd3959239b0e832f206b3353c41627 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Mon, 30 Aug 2021 15:34:59 +0800 Subject: [PATCH 028/229] Update card.php --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3deb7b346c5..a09bc6853d0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -834,7 +834,7 @@ if (empty($reshook)) { } // If some payments were already done, we change the amount to pay using same prorate - if (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + if (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) && $object->type == Facture::TYPE_CREDIT_NOTE) { $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); From 0132788266aee6f63ee101aa20228c2b1e2765f0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 30 Aug 2021 13:56:31 +0200 Subject: [PATCH 029/229] NEW Invoice list - Use complete country select field with EEC or not --- htdocs/compta/facture/list.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a54797323a3..9c247f4e146 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -106,7 +106,7 @@ $search_pos_source = GETPOST('search_pos_source', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST("search_state"); -$search_country = GETPOST("search_country", 'int'); +$search_country = GETPOST("search_country", 'alpha'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); @@ -652,8 +652,26 @@ if ($search_zip) { if ($search_state) { $sql .= natural_search("state.nom", $search_state); } -if ($search_country) { - $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; +if (strlen(trim($search_country))) { + $arrayofcode = getCountriesInEEC(); + $country_code_in_EEC = $country_code_in_EEC_without_me = ''; + foreach ($arrayofcode as $key => $value) { + $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; + if ($value != $mysoc->country_code) { + $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; + } + } + if ($search_country == 'special_allnotme') { + $sql .= " AND country.code <> '".$db->escape($mysoc->country_code)."'"; + } elseif ($search_country == 'special_eec') { + $sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).")"; + } elseif ($search_country == 'special_eecnotme') { + $sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")"; + } elseif ($search_country == 'special_noteec') { + $sql .= " AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")"; + } else { + $sql .= natural_search("country.code", $search_country); + } } if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') { $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; @@ -941,6 +959,9 @@ if ($resql) { if ($search_zip) { $param .= '&search_zip='.urlencode($search_zip); } + if ($search_country) { + $param .= "&search_country=".urlencode($search_country); + } if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); } @@ -1259,7 +1280,7 @@ if ($resql) { // Country if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, null, 1); print ''; } // Company type From 31abb98a9137d7516f87827fcc64d1c3288f957b Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 30 Aug 2021 14:38:36 +0200 Subject: [PATCH 030/229] Fix : KnowledgeManagement menu permission --- htdocs/core/modules/modKnowledgeManagement.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php index 5957158e893..c3be87963c8 100644 --- a/htdocs/core/modules/modKnowledgeManagement.class.php +++ b/htdocs/core/modules/modKnowledgeManagement.class.php @@ -317,7 +317,7 @@ class modKnowledgeManagement extends DolibarrModules // Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->knowledgemanagement->enabled', // Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', + 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read', 'target'=>'', // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, @@ -337,7 +337,7 @@ class modKnowledgeManagement extends DolibarrModules // Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->knowledgemanagement->enabled', // Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', + 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read', 'target'=>'', // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, @@ -357,7 +357,7 @@ class modKnowledgeManagement extends DolibarrModules // Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->knowledgemanagement->enabled', // Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules - 'perms'=>'1', + 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->write', 'target'=>'', // 0=Menu for internal users, 1=external users, 2=both 'user'=>2 From 0ae4e721c42bdd06e09e01537941c10def9f62f5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 30 Aug 2021 23:50:33 +0200 Subject: [PATCH 031/229] merge --- htdocs/projet/tasks/list.php | 48 ------------------------------------ 1 file changed, 48 deletions(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 5e1f3d26ee5..e6d8e5c6dfa 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -521,54 +521,6 @@ if ($search_datelimit_endmonth) { if ($search_datelimit_endyear) { $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear); } -if ($search_date_start_startmonth) { - $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth); -} -if ($search_date_start_startyear) { - $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear); -} -if ($search_date_start_startday) { - $param .= '&search_date_start_startday='.urlencode($search_date_start_startday); -} -if ($search_date_start_start) { - $param .= '&search_date_start_start='.urlencode($search_date_start_start); -} -if ($search_date_start_endmonth) { - $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth); -} -if ($search_date_start_endyear) { - $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear); -} -if ($search_date_start_endday) { - $param .= '&search_date_start_endday='.urlencode($search_date_start_endday); -} -if ($search_date_start_end) { - $param .= '&search_date_start_end='.urlencode($search_date_start_end); -} -if ($search_date_end_startmonth) { - $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth); -} -if ($search_date_end_startyear) { - $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear); -} -if ($search_date_end_startday) { - $param .= '&search_date_end_startday='.urlencode($search_date_end_startday); -} -if ($search_date_end_start) { - $param .= '&search_date_end_start='.urlencode($search_date_end_start); -} -if ($search_date_end_endmonth) { - $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth); -} -if ($search_date_end_endyear) { - $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear); -} -if ($search_date_end_endday) { - $param .= '&search_date_end_endday='.urlencode($search_date_end_endday); -} -if ($search_date_end_end) { - $param .= '&search_date_end_end=' . urlencode($search_date_end_end); -} if ($socid) { $param .= '&socid='.urlencode($socid); } From 009fa41762b507e24405b57f51acd6405d8f8b43 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 31 Aug 2021 09:10:57 +0200 Subject: [PATCH 032/229] add checkbox to ask detail on line desc --- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/tasks/time.php | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index e6a84ad9736..6709a1de200 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -274,6 +274,7 @@ NewInter=New intervention OneLinePerTask=One line per task OneLinePerPeriod=One line per period OneLinePerTimeSpentLine=One line for each time spent declaration +AddDetailDateAndDuration=With date and duration into line description RefTaskParent=Ref. Parent Task ProfitIsCalculatedWith=Profit is calculated using AddPersonToTask=Add also to tasks diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 634b3c136d9..338962c1e74 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -449,6 +449,7 @@ if ($action == 'confirm_generateinvoice') { } } elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line $arrayoftasks = array(); + $withdetail=GETPOST('detail_time_duration', 'alpha'); foreach ($toselect as $key => $value) { // Get userid, timepent $object->fetchTimeSpent($value); @@ -462,7 +463,7 @@ if ($action == 'confirm_generateinvoice') { $arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration; $arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm; $arrayoftasks[$object->timespent_id]['note'] = $ftask->ref.' - '.$ftask->label.' - '.$username.($object->timespent_note ? ' - '.$object->timespent_note : ''); // TODO Add user name in note - if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_ADD_TIME_DT)) { + if (!empty($withdetail)) { $arrayoftasks[$object->timespent_id]['note'] .= "\n"; if (!empty($object->timespent_withhour)) { $arrayoftasks[$object->timespent_id]['note'] .= $langs->trans("Date") . ': ' . dol_print_date($object->timespent_datehour); @@ -1103,6 +1104,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { 'onelineperperiod'=>'OneLinePerTimeSpentLine', ); print $form->selectarray('generateinvoicemode', $tmparray, 'onelineperuser', 0, 0, 0, '', 1); + print "\n".''."\n"; + print ''; print ''; print ''; From 673852c7399faabd92857c833543a82d7e1f7d7b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 31 Aug 2021 09:24:41 +0200 Subject: [PATCH 033/229] better line desc --- htdocs/projet/tasks/time.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 338962c1e74..71219be4e57 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -464,7 +464,12 @@ if ($action == 'confirm_generateinvoice') { $arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm; $arrayoftasks[$object->timespent_id]['note'] = $ftask->ref.' - '.$ftask->label.' - '.$username.($object->timespent_note ? ' - '.$object->timespent_note : ''); // TODO Add user name in note if (!empty($withdetail)) { - $arrayoftasks[$object->timespent_id]['note'] .= "\n"; + if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { + $arrayoftasks[$object->timespent_id]['note'] .= "
"; + } else { + $arrayoftasks[$object->timespent_id]['note'] .= "\n"; + } + if (!empty($object->timespent_withhour)) { $arrayoftasks[$object->timespent_id]['note'] .= $langs->trans("Date") . ': ' . dol_print_date($object->timespent_datehour); } else { From cd47bede37717dc18fc915f79a073d1537f42ad9 Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Tue, 31 Aug 2021 09:26:00 +0200 Subject: [PATCH 034/229] FournisseurCommandDispatch extends CommonObjectLine instead of CommonObject --- htdocs/fourn/class/fournisseur.commande.dispatch.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index cd1ff267fb7..b2c4d101b74 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php"; /** * Class to manage table commandefournisseurdispatch */ -class CommandeFournisseurDispatch extends CommonObject +class CommandeFournisseurDispatch extends CommonObjectLine { /** * @var DoliDB Database handler. From 19587fb88bb66d9a0edd1eb8dbdd377dfba41b59 Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Tue, 31 Aug 2021 12:25:36 +0200 Subject: [PATCH 035/229] Regroup BILL_SUPPLIER_VALIDATE triggers under the same condition --- .../triggers/interface_20_modWorkflow_WorkflowManager.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 7b669578a53..993c4136660 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -209,7 +209,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } } - return $ret; } // Second classify billed the proposal. From a3f4ba11aaf4368a94a5f110bb8c1befdebcce1e Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Tue, 31 Aug 2021 12:25:50 +0200 Subject: [PATCH 036/229] regroup BILL_SUPPLIER_VALIDATE actions --- ...e_20_modWorkflow_WorkflowManager.class.php | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 993c4136660..b410cdb3f54 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -206,6 +206,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach ($object->linkedObjects['order_supplier'] as $element) { $ret = $element->classifyBilled($user); + if ($ret < 0) { + return $ret; + } } } } @@ -225,11 +228,34 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach ($object->linkedObjects['supplier_proposal'] as $element) { $ret = $element->classifyBilled($user); + if ($ret < 0) { + return $ret; + } } } } - return $ret; } + + // classify billed reception + if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { + $object->fetchObjectLinked('', 'reception', $object->id, $object->element); + if (!empty($object->linkedObjects)) { + $totalonlinkedelements = 0; + foreach ($object->linkedObjects['reception'] as $element) { + if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht; + } + dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); + if ($totalonlinkedelements == $object->total_ht) { + foreach ($object->linkedObjects['reception'] as $element) { + $ret = $element->set_billed(); + if ($ret < 0) { + return $ret; + } + } + } + } + } + return $ret; } // Invoice classify billed order @@ -324,30 +350,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } - // classify billed reception - if ($action == 'BILL_SUPPLIER_VALIDATE') { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); - - if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { - $object->fetchObjectLinked('', 'reception', $object->id, $object->element); - if (!empty($object->linkedObjects)) { - $totalonlinkedelements = 0; - foreach ($object->linkedObjects['reception'] as $element) { - if ($element->statut == Reception::STATUS_VALIDATED) { - $totalonlinkedelements += $element->total_ht; - } - } - dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); - if ($totalonlinkedelements == $object->total_ht) { - foreach ($object->linkedObjects['reception'] as $element) { - $ret = $element->setBilled(); - } - } - } - return $ret; - } - } - return 0; } From c7444865a1e0d1a03e90fefaacac50049b4a4559 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Aug 2021 13:16:37 +0200 Subject: [PATCH 037/229] Fix css --- htdocs/core/class/html.formticket.class.php | 2 +- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 76789ebe6de..55f4aa9124d 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -263,7 +263,7 @@ class FormTicket require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 1fd3e062515..1d25249da75 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -212,7 +212,7 @@ if ($captcha) { - " class="flat input-icon-security width150" type="text" maxlength="5" name="code" tabindex="3" autocomplete="off" /> + " class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" autocomplete="off" /> diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 8964145b430..6c6e2ca9dc3 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -150,7 +150,7 @@ if (!empty($captcha)) { - " class="flat input-icon-security width150" type="text" maxlength="5" name="code" tabindex="3" autocomplete="off" /> + " class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" autocomplete="off" /> From d09d036f06acfeb5959c3b4489ceac4008286328 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 31 Aug 2021 16:10:55 +0200 Subject: [PATCH 038/229] Fix supplier invoice pdf generation canelle Thirdparty wrongly fetched was causing errors on mass generation --- .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 01f6369055b..3ef1bc45e5e 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -208,7 +208,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices global $user, $langs, $conf, $mysoc, $hookmanager, $nblines; // Get source company - if (!is_object($object->thirdparty)) $object->fetch_thirdparty(); + $object->fetch_thirdparty(); if (!is_object($object->thirdparty)) $object->thirdparty = $mysoc; // If fetch_thirdparty fails, object has no socid (specimen) $this->emetteur = $object->thirdparty; if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined @@ -224,8 +224,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($conf->fournisseur->facture->dir_output) { - $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); From 6c2cf4377a9253915c14d1a1fa6496f542474132 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 31 Aug 2021 18:14:16 +0200 Subject: [PATCH 039/229] NEW can enable/disable external calendar by default --- htdocs/admin/agenda_extsites.php | 69 +++++++++++++++++++++++++++++--- htdocs/comm/action/index.php | 22 +++++++++- htdocs/langs/en_US/agenda.lang | 3 +- htdocs/langs/fr_FR/agenda.lang | 1 + 4 files changed, 88 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 272da835741..bf6c8bdee2a 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -41,8 +41,7 @@ if (!$user->admin) { $langs->loadLangs(array('agenda', 'admin', 'other')); $def = array(); -$actiontest = GETPOST('test', 'alpha'); -$actionsave = GETPOST('save', 'alpha'); +$action = GETPOST('action', 'alpha'); if (empty($conf->global->AGENDA_EXT_NB)) { $conf->global->AGENDA_EXT_NB = 5; @@ -57,14 +56,57 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', ' * Actions */ -if ($actionsave) { +$error = 0; +$errors = array(); + +if (preg_match('/set_(.*)/', $action,$reg)) { + $db->begin(); + + $code=$reg[1]; + $value=(GETPOST($code) ? GETPOST($code) : 1); + + $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + $errors[] = $db->lasterror(); + } + + if ($error) { + $db->rollback(); + setEventMessages('', $errors, 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('SetupSaved')); + header('Location: ' . $_SERVER["PHP_SELF"]); + exit(); + } +} elseif (preg_match('/del_(.*)/', $action,$reg)) { + $db->begin(); + + $code = $reg[1]; + + $res = dolibarr_del_const($db, $code, $conf->entity); + if (!$res > 0) { + $error++; + $errors[] = $db->lasterror(); + } + + if ($error) { + $db->rollback(); + setEventMessages('', $errors, 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('SetupSaved')); + header('Location: ' . $_SERVER["PHP_SELF"]); + exit(); + } +} elseif ($action == 'save') { $db->begin(); $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); $i = 1; $errorsaved = 0; - $error = 0; // Save agendas while ($i <= $MAXAGENDA) { @@ -159,6 +201,10 @@ print dol_get_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; + +$selectedvalue=$conf->global->AGENDA_DISABLE_EXT; +if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; + print ""; print ""; @@ -203,6 +249,7 @@ print ""; print "'; print "'; print ''; +print ''; print ""; $i = 1; @@ -213,7 +260,7 @@ while ($i <= $MAXAGENDA) { $offsettz = 'AGENDA_EXT_OFFSETTZ'.$key; $color = 'AGENDA_EXT_COLOR'.$key; $enabled = 'AGENDA_EXT_ENABLED'.$key; - + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$key; print ''; // Nb @@ -229,6 +276,18 @@ while ($i <= $MAXAGENDA) { //print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist); print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key) ?GETPOST("AGENDA_EXT_COLOR".$key) : getDolGlobalString($color)), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset'); print ''; + // Calendar active by default + print ''; print ""; $i++; } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 19aff1699c8..321457445aa 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -265,6 +265,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) { $name = 'AGENDA_EXT_NAME'.$i; $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; $color = 'AGENDA_EXT_COLOR'.$i; + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; if (!empty($conf->global->$source) && !empty($conf->global->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' @@ -273,6 +274,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) { 'name'=>$conf->global->$name, 'offsettz' => (!empty($conf->global->$offsettz) ? $conf->global->$offsettz : 0), 'color'=>$conf->global->$color, + 'default'=>$conf->global->$default, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0) ); } @@ -288,6 +290,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; if (!empty($user->conf->$source) && !empty($user->conf->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' @@ -296,6 +299,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { 'name'=>$user->conf->$name, 'offsettz' => (!empty($user->conf->$offsettz) ? $user->conf->$offsettz : 0), 'color'=>$user->conf->$color, + 'default'=>$user->conf->$default, 'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0) ); } @@ -576,6 +580,15 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on if (is_array($showextcals) && count($showextcals) > 0) { $s .= ''."\n"; + // Formulaire de demande - print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -1084,11 +1103,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print dol_get_fiche_end(); - print '
'; - print ''; - print '    '; - print ''; - print '
'; + print $form->buttonsSaveCancel("SendRequestCP"); print ''."\n"; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 6eec5cb956d..12b6d8f32df 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -103,6 +103,8 @@ if ($reshook < 0) { } if (empty($reshook)) { + $backurlforlist = DOL_URL_ROOT.'/projet/list.php'; + // Cancel if ($cancel) { if (GETPOST("comefromclone") == 1) { @@ -115,11 +117,26 @@ if (empty($reshook)) { setEventMessages($langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")), null, 'errors'); } } - if ($backtopage) { + } + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + + if ($cancel) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action = ''; } diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 70f652ebc05..e621feb6653 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -93,7 +93,7 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } // Add file in email form -if (empty($reshook) && GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) { +if (empty($reshook) && GETPOST('addfile', 'alpha') && !GETPOST('save', 'alpha')) { ////$res = $object->fetch('','',GETPOST('track_id')); ////if($res > 0) ////{ @@ -112,7 +112,7 @@ if (empty($reshook) && GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) } // Remove file -if (empty($reshook) && GETPOST('removedfile', 'alpha') && !GETPOST('add', 'alpha')) { +if (empty($reshook) && GETPOST('removedfile', 'alpha') && !GETPOST('save', 'alpha')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp directory @@ -124,7 +124,7 @@ if (empty($reshook) && GETPOST('removedfile', 'alpha') && !GETPOST('add', 'alpha $action = 'create_ticket'; } -if (empty($reshook) && $action == 'create_ticket' && GETPOST('add', 'alpha')) { +if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { $error = 0; $origin_email = GETPOST('email', 'alpha'); if (empty($origin_email)) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 65d509854e4..52805d96c42 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -60,6 +60,7 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); @@ -132,8 +133,23 @@ if ($reshook < 0) { } if (empty($reshook)) { + $backurlforlist = DOL_URL_ROOT.'/supplier_proposal/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + if ($cancel) { - if (!empty($backtopage)) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index e2872004323..0e9015ec95f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -144,17 +144,31 @@ if (empty($reshook)) { $search_agenda_label = ''; } + $backurlforlist = DOL_URL_ROOT.'/ticket/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/ticket/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + if ($cancel) { - if (!empty($backtopage)) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action = 'view'; } // Action to add an action (not a message) - if (GETPOST('add', 'alpha') && !empty($user->rights->ticket->write)) { + if (GETPOST('save', 'alpha') && !empty($user->rights->ticket->write)) { $error = 0; if (!GETPOST("subject", 'alphanohtml')) { @@ -276,9 +290,13 @@ if (empty($reshook)) { $db->commit(); if (!empty($backtopage)) { - $url = $backtopage; + if (empty($id)) { + $url = $backtopage; + } else { + $url = 'card.php?track_id='.urlencode($object->track_id); + } } else { - $url = 'card.php?track_id='.$object->track_id; + $url = 'card.php?track_id='.urlencode($object->track_id); } header("Location: ".$url); @@ -342,9 +360,13 @@ if (empty($reshook)) { $action = 'edit'; } else { if (!empty($backtopage)) { - $url = $backtopage; + if (empty($id)) { + $url = $backtopage; + } else { + $url = 'card.php?track_id='.urlencode($object->track_id); + } } else { - $url = 'card.php?track_id='.$object->track_id; + $url = 'card.php?track_id='.urlencode($object->track_id); } header('Location: '.$url); @@ -427,9 +449,13 @@ if (empty($reshook)) { if ($ret > 0) { if (!empty($backtopage)) { - $url = $backtopage; + if (empty($id)) { + $url = $backtopage; + } else { + $url = 'card.php?track_id='.urlencode($object->track_id); + } } else { - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?action=view&track_id='.urlencode($object->track_id); } header("Location: ".$url); @@ -707,6 +733,8 @@ if ($action == 'create' || $action == 'presend') { $formticket->withextrafields = 1; $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid')); + $formticket->withcancel = 1; + $formticket->showForm(1, 'create', 0); /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { $formticket = new FormTicket($db); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index be91f302b97..ee1ebf71493 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -138,6 +138,29 @@ if ($reshook < 0) { } if (empty($reshook)) { + $backurlforlist = DOL_URL_ROOT.'/user/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/user/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + + if ($cancel) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } + if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { if ($id != $user->id) { // A user can't disable itself $object->fetch($id); From 35e5480f2fefb06640b4b85ed6cdeacdc48ee861 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 10:58:43 +0200 Subject: [PATCH 101/229] Fix var init --- .../triggers/interface_20_modWorkflow_WorkflowManager.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index db3b3c56855..0ea378672c1 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -66,6 +66,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers return 0; // Module not active, we do nothing } + $ret = 0; + // Proposals to order if ($action == 'PROPAL_CLOSE_SIGNED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); From dc81f1de68dbe44afab3a7749f98f2f5d287e952 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 11:00:14 +0200 Subject: [PATCH 102/229] Fix var_dump --- htdocs/core/modules/DolibarrModules.class.php | 6 ++---- htdocs/install/upgrade2.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 4191a3492ca..d1089e5e0e0 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -2126,7 +2126,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $entity = $conf->entity; // Reset the current entity $newvalue = $value; - var_dump($newvalue); + // Serialize array parameters if (is_array($value)) { // Can defined other parameters @@ -2145,8 +2145,6 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $newvalue = json_encode($value); } } - var_dump($newvalue); - var_dump($this->db->escape($newvalue)); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; $sql .= "name"; @@ -2164,7 +2162,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $sql .= ", '0'"; $sql .= ", ".((int) $entity); $sql .= ")"; - print $sql; + dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG); $resql = $this->db->query($sql, 1); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 368e05c5b04..f2cb92efc7f 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1087,7 +1087,7 @@ function migrate_links_transfert($db, $langs, $conf) $sql .= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; $sql .= ")"; - print $sql.'
'; + //print $sql.'
'; dolibarr_install_syslog("migrate_links_transfert"); if (!$db->query($sql)) { From 531037ddb69a73e234c6b7ae9ac02333d49f489f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 11:04:49 +0200 Subject: [PATCH 103/229] Prepare 14.0.2 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index deb194de170..b37d9fdde7c 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '14.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '14.0.2'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { From 30c29f13c8357a20663c131ef064daf4b9d69bb6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 13:19:37 +0200 Subject: [PATCH 104/229] Fix go back on thirdparty file after Save --- htdocs/societe/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ac134bd88b6..96142f65cd6 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -76,7 +76,7 @@ if (!empty($conf->notification->enabled)) { $langs->load("mails"); } -$mesg = ''; $error = 0; $errors = array(); +$error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); @@ -90,6 +90,7 @@ if ($user->socid) { if (empty($socid) && $action == 'view') { $action = 'create'; } +$id = $socid; $object = new Societe($db); $extrafields = new ExtraFields($db); From 248e68aadae1fd632399b85a991beb03c2ce4c80 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 13:39:08 +0200 Subject: [PATCH 105/229] Code comment --- htdocs/comm/action/list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 95d882f8076..477146fbfd1 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -529,7 +529,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { while ($db->fetch_object($resql)) { $nbtotalofrecords++; }*/ - /* This fast and low memory method to get and count full list converts the sql into a sql count */ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 3319ca1909d..12ecd427255 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -364,7 +364,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { while ($db->fetch_object($resql)) { $nbtotalofrecords++; }*/ - /* This fast and low memory method to get and count full list convert the sql into a sql count */ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 3a162cc640f..2b93d881cb9 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -579,7 +579,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { while ($db->fetch_object($resql)) { $nbtotalofrecords++; }*/ - /* This fast and low memory method to get and count full list converts the sql into a sql count */ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); From a89a6b63436cfd28039a82fdc7f2044895b22e04 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Fri, 3 Sep 2021 14:18:44 +0200 Subject: [PATCH 106/229] bug image delete Remove linked image from card.php (section builddoc) dont remove the thumbs of image file --- htdocs/core/actions_builddoc.inc.php | 15 ++++++++++++++ htdocs/core/actions_linkedfiles.inc.php | 27 ++++++++++++------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 7cde7e6f886..4e2165d6f38 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -127,8 +127,23 @@ if ($action == 'remove_file' && $permissiontoadd) { $langs->load("other"); $filetodelete = GETPOST('file', 'alpha'); $file = $upload_dir.'/'.$filetodelete; + $dirthumb = dirname($file).'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) { + // If it exists, remove thumb. + $regs = array(); + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { + $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { + dol_delete_file($dirthumb.$photo_vignette); + } + + $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { + dol_delete_file($dirthumb.$photo_vignette); + } + } + setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); } else { setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 3e2438f63d3..ad9ca441e8a 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -112,21 +112,20 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && (!isset($permissiont dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path } - // If it exists, remove thumb. - $regs = array(); - if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { - $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { - dol_delete_file($dirthumb.$photo_vignette); - } - - $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { - dol_delete_file($dirthumb.$photo_vignette); - } - } - if ($ret) { + // If it exists, remove thumb. + $regs = array(); + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { + $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { + dol_delete_file($dirthumb.$photo_vignette); + } + + $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { + dol_delete_file($dirthumb.$photo_vignette); + } + } setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); } else { setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); From 96f9f8ae9803d66eb1c52845db60f90bc0d6bcf9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Sep 2021 15:40:33 +0200 Subject: [PATCH 107/229] work on event --- .../class/conferenceorbooth.class.php | 2 +- .../class/conferenceorboothattendee.class.php | 5 +- .../conferenceorbooth_list.php | 13 +- .../conferenceorboothattendee_card.php | 1 + .../conferenceorboothattendee_list.php | 113 +++++++++++++----- ...ventorganization_conferenceorbooth.lib.php | 74 ++++++++++++ ...nization_conferenceorboothattendee.key.sql | 4 +- ...organization_conferenceorboothattendee.sql | 3 +- htdocs/langs/en_US/eventorganization.lang | 3 +- .../attendee_subscription.php | 63 +++++++--- 10 files changed, 228 insertions(+), 53 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 869a96e464e..100c5559ca1 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -246,7 +246,7 @@ class ConferenceOrBooth extends ActionComm $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.urlencode($id); + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.urlencode($id).'&type=conf'; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index b6c80feadd4..985c61376b6 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -103,7 +103,8 @@ class ConferenceOrBoothAttendee extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>0, 'index'=>1,), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>0, 'index'=>1,), 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'index'=>1,), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), @@ -403,7 +404,7 @@ class ConferenceOrBoothAttendee extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; } else { diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 2306066f9a7..5376acb3289 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -266,7 +267,7 @@ if ($projectid > 0) { //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($project); - print dol_get_fiche_head($head, 'eventorganisation', $langs->trans("Project"), -1, ($project->public ? 'projectpub' : 'project')); + print dol_get_fiche_head($head, 'eventorganisation', $langs->trans("ConferenceOrBoothTab"), -1, ($project->public ? 'projectpub' : 'project')); // Project card $linkback = ''.$langs->trans("BackToList").''; @@ -440,10 +441,10 @@ if ($projectid > 0) { // Link to the subscribe print '
".$langs->trans("Name")."".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics)".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFixTZOnlyIfRequired"), 1).''.$langs->trans("Color").''.$langs->trans("ActiveByDefault").'
'; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('AGENDA_EXT_ACTIVEBYDEFAULT'.$key); + } else { + if (empty($conf->global->{$default})) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } + } + print '
'; //print ''; - print $langs->trans("PublicAttendeeSubscriptionPage"); + print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); //print ''; print ''; - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$project->id; + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$project->id.'&type=global'; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); //print '
'; + print ''; + print ''; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); + } } $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -612,7 +669,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index 7d6339a2ed0..fcdd3c296e1 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -106,6 +106,80 @@ function conferenceorboothPrepareHead($object, $with_project = 0) return $head; } +/** + * Prepare array of tabs for ConferenceOrBooth Project tab + * + * @param $object Project Project + * @return array + */ +function conferenceorboothProjectPrepareHead($object) +{ + + global $db, $langs, $conf; + + $langs->load("eventorganization"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_list.php", 1).'?projectid='.$object->id; + $head[$h][1] = $langs->trans("ConferenceOrBooth"); + $head[$h][2] = 'conferenceorbooth'; + // Enable caching of conf or booth count attendees + $nbAttendees = 0; + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_conferenceorbooth_project_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbAttendees = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; + $conforbooth=new ConferenceOrBooth($db); + $result = $conforbooth->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id)); + if (!is_array($result) && $result<0) { + setEventMessages($conforbooth->error, $conforbooth->errors, 'errors'); + } else { + $nbConferenceOrBooth = count($result); + } + dol_setcache($cachekey, $nbConferenceOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + if ($nbConferenceOrBooth > 0) { + $head[$h][1] .= ''.$nbConferenceOrBooth.''; + } + $h++; + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?fk_project='.$object->id.'&withproject=1'; + $head[$h][1] = $langs->trans("Attendees"); + $head[$h][2] = 'attendees'; + // Enable caching of conf or booth count attendees + $nbAttendees = 0; + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_attendees_conferenceorbooth_project_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbAttendees = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + $attendees=new ConferenceOrBoothAttendee($db); + $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id)); + if (!is_array($result) && $result<0) { + setEventMessages($attendees->error, $attendees->errors, 'errors'); + } else { + $nbAttendees = count($result); + } + dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + if ($nbAttendees > 0) { + $head[$h][1] .= ''.$nbAttendees.''; + } + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization', 'remove'); + + return $head; +} + /** * Prepare array of tabs for ConferenceOrBoothAttendees diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql index 3b9cc52e68f..0633e3cc2a2 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql @@ -21,10 +21,12 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_evento ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet(rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); -- END MODULEBUILDER INDEXES -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email); diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql index 026295627d0..6d01cf4bba1 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql @@ -19,7 +19,8 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) NOT NULL, fk_soc integer, - fk_actioncomm integer NOT NULL, + fk_actioncomm integer, + fk_project integer NOT NULL, email varchar(100), date_subscription datetime, amount double DEFAULT NULL, diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index d2840be73f2..7c07b853a6b 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -110,7 +110,8 @@ ListOfConferencesOrBooths=List of conferences or booths SuggestConference = Suggest a new conference SuggestBooth = Suggest a booth ViewAndVote = View and vote for suggested events -PublicAttendeeSubscriptionPage = Public link for registration to the event +PublicAttendeeSubscriptionGlobalPage = Public link for registration to the event +PublicAttendeeSubscriptionPage = Public link for registration to this event only MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference : '%s' EvntOrgDuration = This conference starts on %s and ends on %s. diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 0387843cf94..506b7215211 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -80,20 +80,35 @@ $societe = GETPOST("societe"); // Getting id from Post and decoding it $id = GETPOST('id', 'int'); +$type = GETPOST('type', 'alpha'); $conference = new ConferenceOrBooth($db); -$resultconf = $conference->fetch($id); -if ($resultconf < 0) { - print 'Bad value for parameter id'; - exit; +$project = new Project($db); + +if ($type=='conf') { + $resultconf = $conference->fetch($id); + if ($resultconf < 0) { + print 'Bad value for parameter id'; + exit; + } + $resultproject = $project->fetch($conference->fk_project); + if ($resultproject < 0) { + $error++; + $errmsg .= $project->error; + } +} +if ($type=='global') { + $project = new Project($db); + if (empty($id)) { + $id = GETPOST('fk_project', 'int'); + } + $resultproject = $project->fetch($id); + if ($resultproject < 0) { + $error++; + $errmsg .= $project->error; + } } -$project = new Project($db); -$resultproject = $project->fetch($conference->fk_project); -if ($resultproject < 0) { - $error++; - $errmsg .= $project->error; -} // Security check @@ -206,7 +221,7 @@ if ($reshook < 0) { } // Action called when page is submitted -if (empty($reshook) && $action == 'add' && $conference->status == 2) { +if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status==Project::STATUS_VALIDATED)) { $error = 0; $urlback = ''; @@ -235,7 +250,15 @@ if (empty($reshook) && $action == 'add' && $conference->status == 2) { if (!$error) { // Check if attendee already exists (by email and for this event) $confattendee = new ConferenceOrBoothAttendee($db); - $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"')); + + if ($type=='global') { + $filter = array('t.fk_project'=>$id, 'customsql'=>'t.email="'.$email.'"'); + } + if ($action='conf') { + $filter = array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"'); + } + + $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, $filter); if ($resultfetchconfattendee > 0 && count($resultfetchconfattendee)>0) { // Found confattendee $confattendee = array_shift($resultfetchconfattendee); @@ -243,6 +266,7 @@ if (empty($reshook) && $action == 'add' && $conference->status == 2) { // Need to create a confattendee $confattendee->date_subscription = dol_now(); $confattendee->email = $email; + $confattendee->fk_project = $project->id; $confattendee->fk_actioncomm = $id; $resultconfattendee = $confattendee->create($user); if ($resultconfattendee < 0) { @@ -470,16 +494,21 @@ print '
'; print '
'; // Welcome message -print $langs->trans("EvntOrgWelcomeMessage", $conference->label); + +print $langs->trans("EvntOrgWelcomeMessage", $project->title . ' '. $conference->label); print '
'; -print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); +if ($conference->id) { + print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); +} else { + print $langs->trans("EvntOrgDuration", dol_print_date($project->date_start), dol_print_date($project->date_end)); +} print '
'; print '
'; dol_htmloutput_errors($errmsg); -if ($conference->status!=2) { +if (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status==Project::STATUS_VALIDATED) { print $langs->trans("ConferenceIsNotConfirmed"); } else { // Print form @@ -487,7 +516,9 @@ if ($conference->status!=2) { print ''; print ''; print ''; - print ''; + print ''; + print ''; + print ''; print ''; print '
'; From 628c7158785a48c1a8dc3009844c9328448158fc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Sep 2021 16:39:10 +0200 Subject: [PATCH 108/229] ok for prod --- htdocs/admin/eventorganization.php | 4 +- .../class/conferenceorboothattendee.class.php | 4 + .../conferenceorboothattendee_card.php | 121 +++++++----------- .../conferenceorboothattendee_list.php | 11 +- .../attendee_subscription.php | 24 ++-- 5 files changed, 74 insertions(+), 90 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index d01aece1ca0..439a3d9cafa 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -48,8 +48,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), + 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1), diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 985c61376b6..61d8e7c32b2 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -747,6 +747,10 @@ class ConferenceOrBoothAttendee extends CommonObject $url .= '&conforboothid='.$this->fk_actioncomm; } + if ($option == 'projectid') { + $url .= '&fk_project='.$this->fk_project.'&withproject=1'; + } + if ($option == 'conforboothidproject') { $url .= '&conforboothid='.$this->fk_actioncomm.'&withproject=1' ; } diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 80b4b00dc9f..ff46f7b4a7b 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -47,6 +47,7 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); //$lineid = GETPOST('lineid', 'int'); $conf_or_booth_id = GETPOST('conforboothid', 'int'); +$fk_project = GETPOST('fk_project', 'int'); $withproject = GETPOST('withproject', 'int'); // Initialize technical objects @@ -174,7 +175,7 @@ $title = $langs->trans("ConferenceOrBoothAttendee"); $help_url = ''; llxHeader('', $title, $help_url); -$result = $projectstatic->fetch($confOrBooth->fk_project); +$result = $projectstatic->fetch(empty($confOrBooth->fk_project)?$fk_project:$confOrBooth->fk_project); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { $projectstatic->fetchComments(); } @@ -343,10 +344,44 @@ if (!empty($withproject)) { // Show message $message = 'global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); - $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').''; + $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; print ""; + // Link to the submit vote/register page + print ''; + //print ''; + print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage")); + //print ''; + print ''; + $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$projectstatic->id; + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2); + $linksuggest .= '&securekey='.urlencode($encodedsecurekey); + //print ''; + //print ajax_autoselect("linkregister"); + print ''; + + // Link to the subscribe + print ''; + //print ''; + print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); + //print ''; + print ''; + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$projectstatic->id.'&type=global'; + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2); + $link_subscription .= '&securekey='.urlencode($encodedsecurekey); + //print ''; + //print ajax_autoselect("linkregister"); + print ''; + print ''; print '
'; @@ -370,7 +405,10 @@ if ($action == 'create') { if ($confOrBooth->id > 0) { print ''; } - print ''; + if ($projectstatic->id > 0) { + print ''; + } + print ''; if ($backtopage) { @@ -382,9 +420,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; - print ''."\n"; // Common attributes @@ -428,6 +463,9 @@ if (($id || $ref) && $action == 'edit') { if ($backtopageforcancel) { print ''; } + if ($projectstatic->id > 0) { + print ''; + } print dol_get_fiche_head(); @@ -477,16 +515,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation of action xxxx if ($action == 'xxx') { $formquestion = array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } @@ -502,61 +530,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Print form confirm print $formconfirm; - // Object card // ------------------------------------------------------------ $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; print '
'; print '
'; print '
'."\n"; // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field - //unset($object->fields['fk_project']); // Hide field already shown in banner - //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes. Fields from hook formObjectOptions and Extrafields. @@ -635,29 +624,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').'&action=presend&mode=init#formmailbeforetitle'); } - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&conforboothid='.$confOrBooth->id.'&action=edit', '', $permissiontoadd); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').'&action=edit', '', $permissiontoadd); // Clone print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); - /* - if ($permissiontoadd) { - if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; - } else { - print ''.$langs->trans("Enable").''."\n"; - } - } - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED) { - print ''.$langs->trans("Cancel").''."\n"; - } else { - print ''.$langs->trans("Re-Open").''."\n"; - } - } - */ // Delete (need delete permission, or if draft, just need create/modify permission) print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index d1dfccf2652..401f3367044 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -571,7 +571,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print dol_get_fiche_end(); - if (!empty($fk_project)) { + if (empty($confOrBooth->id)) { $head = conferenceorboothProjectPrepareHead($projectstatic); $tab = 'attendees'; print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($project->public ? 'projectpub' : 'project'), 0, '', ''); @@ -632,6 +632,9 @@ foreach ($search as $key => $val) { if ($confOrBooth->id > 0) { $param .= '&conforboothid='.urlencode($confOrBooth->id).$withProjectUrl; } +if ($projectstatic->id > 0) { + $param .= '&fk_project='.urlencode($projectstatic->id).$withProjectUrl; +} if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); @@ -841,7 +844,11 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'ref') { - print $object->getNomUrl(1, (!empty($withproject)?'conforboothidproject':'conforboothid')); + $optionLink = (!empty($withproject)?'conforboothidproject':'conforboothid'); + if (empty($confOrBooth->id)) { + $optionLink='projectid'; + } + print $object->getNomUrl(1, $optionLink); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 506b7215211..79688bffcf6 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -508,9 +508,7 @@ print '
'; dol_htmloutput_errors($errmsg); -if (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status==Project::STATUS_VALIDATED) { - print $langs->trans("ConferenceIsNotConfirmed"); -} else { +if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CONFIRMED || (!empty($project->id) && $project->status==Project::STATUS_VALIDATED)) { // Print form print '' . "\n"; print ''; @@ -529,15 +527,15 @@ if (!empty($conference->id) && $conference->status!=2 || !empty($project->id) & print dol_get_fiche_head(''); print ''; + jQuery(document).ready(function () { + jQuery(document).ready(function () { + jQuery("#selectcountry_id").change(function() { + document.newmember.action.value="create"; + document.newmember.submit(); + }); + }); + }); + '; print '
' . "\n"; @@ -605,6 +603,8 @@ jQuery(document).ready(function () { print "\n"; print "
"; print ''; +} else { + print $langs->trans("ConferenceIsNotConfirmed"); } llxFooterVierge(); From 2e3b6b2fc8022df39600de4902ec302e5c2200c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 18:00:28 +0200 Subject: [PATCH 109/229] Backport sql injection fix from develop --- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/fourn/facture/card.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6859a510e93..02889c4c4ef 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -678,8 +678,8 @@ class Facture extends CommonInvoice $sql .= ", ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null"); $sql .= ", ".($user->id > 0 ? (int) $user->id : "null"); $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); - $sql .= ", ".$this->cond_reglement_id; - $sql .= ", ".$this->mode_reglement_id; + $sql .= ", ".((int) $this->cond_reglement_id); + $sql .= ", ".((int) $this->mode_reglement_id); $sql .= ", '".$this->db->idate($this->date_lim_reglement)."'"; $sql .= ", ".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); $sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null"); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a784431c841..04d99240f6b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -725,8 +725,8 @@ if (empty($reshook)) { $object->date_echeance = $datedue; $object->note_public = GETPOST('note_public', 'restricthtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); + $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); @@ -736,7 +736,7 @@ if (empty($reshook)) { $object->transport_mode_id = GETPOST('transport_mode_id', 'int'); // Proprietes particulieres a facture de remplacement - $object->fk_facture_source = GETPOST('fac_replacement'); + $object->fk_facture_source = GETPOST('fac_replacement', 'int'); $object->type = FactureFournisseur::TYPE_REPLACEMENT; $id = $object->createFromCurrent($user); From ee066ad725f1958960aa5db7a0723972c9185f6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 21:25:17 +0200 Subject: [PATCH 110/229] Cast sql var --- .../class/accountancycategory.class.php | 2 +- .../class/accountingaccount.class.php | 4 +- .../accountancy/class/bookkeeping.class.php | 10 ++-- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/asset/class/asset_type.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 40 +++++++------- htdocs/commande/class/commande.class.php | 24 ++++----- htdocs/compta/bank/class/account.class.php | 8 +-- htdocs/compta/bank/class/bankcateg.class.php | 2 +- .../bank/class/paymentvarious.class.php | 6 +-- .../cashcontrol/class/cashcontrol.class.php | 12 ++--- .../deplacement/class/deplacement.class.php | 10 ++-- .../facture/class/facture-rec.class.php | 54 +++++++++---------- .../cheque/class/remisecheque.class.php | 4 +- .../class/bonprelevement.class.php | 4 +- .../class/rejetprelevement.class.php | 8 +-- .../sociales/class/chargesociales.class.php | 14 ++--- htdocs/compta/tva/class/tva.class.php | 2 +- htdocs/core/class/comment.class.php | 2 +- htdocs/core/class/commonobject.class.php | 4 +- htdocs/core/class/fiscalyear.class.php | 4 +- htdocs/core/class/link.class.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 2 +- htdocs/delivery/class/delivery.class.php | 6 +-- htdocs/don/class/don.class.php | 4 +- htdocs/expedition/class/expedition.class.php | 17 +++--- .../class/expensereport.class.php | 22 ++++---- htdocs/fichinter/class/fichinter.class.php | 12 ++--- htdocs/fichinter/class/fichinterrec.class.php | 16 +++--- .../class/fournisseur.commande.class.php | 10 ++-- htdocs/fourn/commande/list.php | 2 +- htdocs/hrm/class/establishment.class.php | 10 ++-- htdocs/product/class/product.class.php | 20 +++---- htdocs/projet/class/project.class.php | 10 ++-- htdocs/projet/class/task.class.php | 18 +++---- htdocs/reception/class/reception.class.php | 22 ++++---- htdocs/salaries/class/salary.class.php | 12 ++--- .../class/supplier_proposal.class.php | 50 ++++++++--------- htdocs/ticket/class/ticket.class.php | 2 +- 39 files changed, 226 insertions(+), 229 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index bc7226edb22..7657e997ff6 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -212,7 +212,7 @@ class AccountancyCategory // extends CommonObject $sql .= " ".(!isset($this->position) ? 'NULL' : ((int) $this->position)).","; $sql .= " ".(!isset($this->fk_country) ? 'NULL' : ((int) $this->fk_country)).","; $sql .= " ".(!isset($this->active) ? 'NULL' : ((int) $this->active)); - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; $this->db->begin(); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 35178e43947..fc6acffb46f 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -274,7 +274,7 @@ class AccountingAccount extends CommonObject $sql .= ", reconcilable"; $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", ".(empty($this->fk_pcg_version) ? 'NULL' : "'".$this->db->escape($this->fk_pcg_version)."'"); $sql .= ", ".(empty($this->pcg_type) ? 'NULL' : "'".$this->db->escape($this->pcg_type)."'"); $sql .= ", ".(empty($this->account_number) ? 'NULL' : "'".$this->db->escape($this->account_number)."'"); @@ -282,7 +282,7 @@ class AccountingAccount extends CommonObject $sql .= ", ".(empty($this->label) ? "''" : "'".$this->db->escape($this->label)."'"); $sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'"); $sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".(int) $this->active; $sql .= ", ".(int) $this->reconcilable; $sql .= ")"; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index e1a54edf3cd..d47078af06c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -382,9 +382,9 @@ class BookKeeping extends CommonObject $sql .= ", '".$this->db->escape($this->numero_compte)."'"; $sql .= ", ".(!empty($this->label_compte) ? ("'".$this->db->escape($this->label_compte)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->label_operation)."'"; - $sql .= ", ".$this->debit; - $sql .= ", ".$this->credit; - $sql .= ", ".$this->montant; + $sql .= ", ".((float) $this->debit); + $sql .= ", ".((float) $this->credit); + $sql .= ", ".((float) $this->montant); $sql .= ", ".(!empty($this->sens) ? ("'".$this->db->escape($this->sens)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->fk_user_author)."'"; $sql .= ", '".$this->db->idate($now)."'"; @@ -893,9 +893,7 @@ class BookKeeping extends CommonObject $sql .= ' ORDER BY t.numero_compte ASC'; } - if (!empty($sortfield)) { - $sql .= ", ".$sortfield." ".$sortorder; - } + $sql .= $this->db->order($sortfield, $sortorder); if (!empty($limit)) { $sql .= $this->db->plimit($limit + 1, $offset); } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index bdb77982733..0d1d1bae48b 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -574,7 +574,7 @@ class Adherent extends CommonObject $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script $sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; - $sql .= ", ".$this->typeid; + $sql .= ", ".((int) $this->typeid); $sql .= ", ".$conf->entity; $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ")"; diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 335cd63115a..75b3030eac9 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -126,7 +126,7 @@ class AssetType extends CommonObject $sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; $sql .= ", '".$this->db->escape($this->note)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; dol_syslog("Asset_type::create", LOG_DEBUG); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d92638d7347..a7b5c465226 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1099,22 +1099,22 @@ class Propal extends CommonObject $sql .= " VALUES ("; $sql .= $this->socid; $sql .= ", 0"; - $sql .= ", ".$this->remise; - $sql .= ", ".($this->remise_percent ? $this->db->escape($this->remise_percent) : 'NULL'); - $sql .= ", ".($this->remise_absolue ? $this->db->escape($this->remise_absolue) : 'NULL'); + $sql .= ", ".((float) $this->remise); + $sql .= ", ".($this->remise_percent ? ((float) $this->remise_percent) : 'NULL'); + $sql .= ", ".($this->remise_absolue ? ((float) $this->remise_absolue) : 'NULL'); $sql .= ", 0"; $sql .= ", 0"; $sql .= ", '".$this->db->idate($this->date)."'"; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '(PROV)'"; - $sql .= ", ".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "NULL"); + $sql .= ", ".($user->id > 0 ? ((int) $user->id) : "NULL"); $sql .= ", '".$this->db->escape($this->note_private)."'"; $sql .= ", '".$this->db->escape($this->note_public)."'"; $sql .= ", '".$this->db->escape($this->model_pdf)."'"; $sql .= ", ".($this->fin_validite != '' ? "'".$this->db->idate($this->fin_validite)."'" : "NULL"); - $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); - $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); - $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : 'NULL'); + $sql .= ", ".($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL'); $sql .= ", '".$this->db->escape($this->ref_client)."'"; $sql .= ", ".(empty($delivery_date) ? "NULL" : "'".$this->db->idate($delivery_date)."'"); $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); @@ -4080,21 +4080,21 @@ class PropaleLigne extends CommonObjectLine $sql .= " ".($this->fk_product ? "'".$this->db->escape($this->fk_product)."'" : "null").","; $sql .= " '".$this->db->escape($this->product_type)."',"; $sql .= " ".($this->fk_remise_except ? "'".$this->db->escape($this->fk_remise_except)."'" : "null").","; - $sql .= " ".price2num($this->qty).","; + $sql .= " ".price2num($this->qty, 'MS').","; $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; $sql .= " ".price2num($this->tva_tx).","; $sql .= " ".price2num($this->localtax1_tx).","; $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= " ".(price2num($this->subprice) !== '' ? price2num($this->subprice) : "null").","; - $sql .= " ".price2num($this->remise_percent).","; - $sql .= " ".(isset($this->info_bits) ? "'".$this->db->escape($this->info_bits)."'" : "null").","; - $sql .= " ".price2num($this->total_ht).","; - $sql .= " ".price2num($this->total_tva).","; - $sql .= " ".price2num($this->total_localtax1).","; - $sql .= " ".price2num($this->total_localtax2).","; - $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".(price2num($this->subprice) !== '' ? price2num($this->subprice, 'MU') : "null").","; + $sql .= " ".price2num($this->remise_percent, 3).","; + $sql .= " ".(isset($this->info_bits) ? ((int) $this->info_bits) : "null").","; + $sql .= " ".price2num($this->total_ht, 'MT').","; + $sql .= " ".price2num($this->total_tva, 'MT').","; + $sql .= " ".price2num($this->total_localtax1, 'MT').","; + $sql .= " ".price2num($this->total_localtax2, 'MT').","; + $sql .= " ".price2num($this->total_ttc, 'MT').","; $sql .= " ".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null").","; $sql .= " ".(isset($this->pa_ht) ? "'".price2num($this->pa_ht)."'" : "null").","; $sql .= ' '.((int) $this->special_code).','; @@ -4104,10 +4104,10 @@ class PropaleLigne extends CommonObjectLine $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql .= ", ".($this->fk_multicurrency > 0 ? ((int) $this->fk_multicurrency) : 'null'); $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", ".$this->multicurrency_subprice; - $sql .= ", ".$this->multicurrency_total_ht; - $sql .= ", ".$this->multicurrency_total_tva; - $sql .= ", ".$this->multicurrency_total_ttc; + $sql .= ", ".price2num($this->multicurrency_subprice, 'CU'); + $sql .= ", ".price2num($this->multicurrency_total_ht, 'CT'); + $sql .= ", ".price2num($this->multicurrency_total_tva, 'CT'); + $sql .= ", ".price2num($this->multicurrency_total_ttc, 'CT'); $sql .= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index daf55e81605..5fce8a81a30 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4400,21 +4400,21 @@ class OrderLine extends CommonOrderLine $sql .= ' '.((int) $this->rang).','; $sql .= ' '.(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null").','; $sql .= ' '.price2num($this->pa_ht).','; - $sql .= " '".$this->db->escape($this->info_bits)."',"; - $sql .= " ".price2num($this->total_ht).","; - $sql .= " ".price2num($this->total_tva).","; - $sql .= " ".price2num($this->total_localtax1).","; - $sql .= " ".price2num($this->total_localtax2).","; - $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".((int) $this->info_bits).","; + $sql .= " ".price2num($this->total_ht, 'MT').","; + $sql .= " ".price2num($this->total_tva, 'MT').","; + $sql .= " ".price2num($this->total_localtax1, 'MT').","; + $sql .= " ".price2num($this->total_localtax2, 'MT').","; + $sql .= " ".price2num($this->total_ttc, 'MT').","; $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").','; $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").','; - $sql .= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql .= ", ".(!empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL'); + $sql .= ' '.(!$this->fk_unit ? 'NULL' : ((int) $this->fk_unit)); + $sql .= ", ".(!empty($this->fk_multicurrency) ? ((int) $this->fk_multicurrency) : 'NULL'); $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", ".$this->multicurrency_subprice; - $sql .= ", ".$this->multicurrency_total_ht; - $sql .= ", ".$this->multicurrency_total_tva; - $sql .= ", ".$this->multicurrency_total_ttc; + $sql .= ", ".price2num($this->multicurrency_subprice, 'CU'); + $sql .= ", ".price2num($this->multicurrency_total_ht, 'CT'); + $sql .= ", ".price2num($this->multicurrency_total_tva, 'CT'); + $sql .= ", ".price2num($this->multicurrency_total_ttc, 'CT'); $sql .= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 804cfa09281..9fd88f44d4f 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -687,7 +687,7 @@ class Account extends CommonObject $sql .= "'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->escape($this->ref)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->escape($this->account_number)."'"; $sql .= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); $sql .= ", '".$this->db->escape($this->bank)."'"; @@ -702,8 +702,8 @@ class Account extends CommonObject $sql .= ", '".$this->db->escape($this->owner_address)."'"; $sql .= ", '".$this->db->escape($this->currency_code)."'"; $sql .= ", ".((int) $this->rappro); - $sql .= ", ".price2num($this->min_allowed); - $sql .= ", ".price2num($this->min_desired); + $sql .= ", ".price2num($this->min_allowed, 'MT'); + $sql .= ", ".price2num($this->min_desired, 'MT'); $sql .= ", '".$this->db->escape($this->comment)."'"; $sql .= ", ".($this->state_id > 0 ? ((int) $this->state_id) : "null"); $sql .= ", ".($this->country_id > 0 ? ((int) $this->country_id) : "null"); @@ -2152,7 +2152,7 @@ class AccountLine extends CommonObject $sql .= ", fk_categ"; $sql .= ") VALUES ("; $sql .= $this->id; - $sql .= ", ".$cat; + $sql .= ", ".((int) $cat); $sql .= ")"; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index ab58cb8287c..1795704d4ff 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -81,7 +81,7 @@ class BankCateg // extends CommonObject $sql .= ", entity"; $sql .= ") VALUES ("; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").""; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; $this->db->begin(); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 5a6aa81d663..d88676563d6 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -467,11 +467,11 @@ class PaymentVarious extends CommonObject $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code)."'"; $sql .= ", '".$this->db->escape($this->subledger_account)."'"; - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); - $sql .= ", ".$user->id; + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 0); + $sql .= ", ".((int) $user->id); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", NULL"; // Filled later - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 1cf964815d5..27f3b974a79 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -192,18 +192,18 @@ class CashControl extends CommonObject $sql .= ", card"; $sql .= ") VALUES ("; //$sql .= "'(PROV)', "; - $sql .= $conf->entity; - $sql .= ", ".(is_numeric($this->opening) ? $this->opening : 0); + $sql .= ((int) $conf->entity); + $sql .= ", ".(is_numeric($this->opening) ? price2num($this->opening, 'MT') : 0); $sql .= ", 0"; // Draft by default $sql .= ", '".$this->db->idate(dol_now())."'"; $sql .= ", '".$this->db->escape($this->posmodule)."'"; $sql .= ", '".$this->db->escape($this->posnumber)."'"; $sql .= ", ".($this->day_close > 0 ? $this->day_close : "null"); $sql .= ", ".($this->month_close > 0 ? $this->month_close : "null"); - $sql .= ", ".$this->year_close; - $sql .= ", ".$this->cash; - $sql .= ", ".$this->cheque; - $sql .= ", ".$this->card; + $sql .= ", ".((int) $this->year_close); + $sql .= ", ".price2num($this->cash, 'MT'); + $sql .= ", ".price2num($this->cheque, 'MT'); + $sql .= ", ".price2num($this->card, 'MT'); $sql .= ")"; $this->db->begin(); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 81022e9bc71..e05750918da 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -167,14 +167,14 @@ class Deplacement extends CommonObject $sql .= ", fk_soc"; $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."'"; - $sql .= ", ".$conf->entity; - $sql .= ", ".$user->id; - $sql .= ", ".$this->fk_user; + $sql .= ", ".((int) $conf->entity); + $sql .= ", ".((int) $user->id); + $sql .= ", ".((int) $this->fk_user); $sql .= ", '".$this->db->escape($this->type)."'"; $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); - $sql .= ", ".($this->fk_soc > 0 ? $this->fk_soc : "null"); + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 0); + $sql .= ", ".($this->fk_soc > 0 ? ((int) $this->fk_soc) : "null"); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index a0509774998..92615658a58 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -300,32 +300,32 @@ class FactureRec extends CommonInvoice $sql .= ", suspended"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; - $sql .= ", ".$facsrc->socid; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $facsrc->socid); + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".(!empty($facsrc->amount) ? $facsrc->amount : '0'); - $sql .= ", ".(!empty($facsrc->remise) ? $this->remise : '0'); + $sql .= ", ".(!empty($facsrc->amount) ? ((float) $facsrc->amount) : '0'); + $sql .= ", ".(!empty($facsrc->remise) ? ((float) $this->remise) : '0'); $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ", ".(!empty($this->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL"); - $sql .= ", '".$this->db->escape($user->id)."'"; - $sql .= ", ".(!empty($facsrc->fk_project) ? "'".$this->db->escape($facsrc->fk_project)."'" : "null"); - $sql .= ", ".(!empty($facsrc->fk_account) ? "'".$this->db->escape($facsrc->fk_account)."'" : "null"); - $sql .= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); - $sql .= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); - $sql .= ", ".$this->usenewprice; - $sql .= ", ".$this->frequency; + $sql .= ", ".((int) $user->id); + $sql .= ", ".(!empty($facsrc->fk_project) ? ((int) $facsrc->fk_project) : "null"); + $sql .= ", ".(!empty($facsrc->fk_account) ? ((int) $facsrc->fk_account) : "null"); + $sql .= ", ".($facsrc->cond_reglement_id > 0 ? ((int) $facsrc->cond_reglement_id) : "null"); + $sql .= ", ".($facsrc->mode_reglement_id > 0 ? ((int) $facsrc->mode_reglement_id) : "null"); + $sql .= ", ".((int) $this->usenewprice); + $sql .= ", ".((int) $this->frequency); $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; $sql .= ", ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); $sql .= ", ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); - $sql .= ", ".$this->db->escape($this->nb_gen_done); - $sql .= ", ".$this->db->escape($this->nb_gen_max); - $sql .= ", ".$this->db->escape($this->auto_validate); - $sql .= ", ".$this->db->escape($this->generate_pdf); - $sql .= ", ".$this->db->escape($facsrc->fk_multicurrency); + $sql .= ", ".((int) $this->nb_gen_done); + $sql .= ", ".((int) $this->nb_gen_max); + $sql .= ", ".((int) $this->auto_validate); + $sql .= ", ".((int) $this->generate_pdf); + $sql .= ", ".((int) $facsrc->fk_multicurrency); $sql .= ", '".$this->db->escape($facsrc->multicurrency_code)."'"; - $sql .= ", ".$this->db->escape($facsrc->multicurrency_tx); - $sql .= ", ".$this->db->escape($this->suspended); + $sql .= ", ".((float) $facsrc->multicurrency_tx); + $sql .= ", ".((int) $this->suspended); $sql .= ")"; if ($this->db->query($sql)) { @@ -963,7 +963,7 @@ class FactureRec extends CommonInvoice $sql .= ", ".price2num($txlocaltax2); $sql .= ", '".$this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '')."'"; $sql .= ", ".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); - $sql .= ", ".$product_type; + $sql .= ", ".((int) $product_type); $sql .= ", ".price2num($remise_percent); $sql .= ", ".price2num($pu_ht); $sql .= ", null"; @@ -976,16 +976,16 @@ class FactureRec extends CommonInvoice $sql .= ", ".(int) $date_end_fill; $sql .= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); $sql .= ", ".($pa_ht ? price2num($pa_ht) : 0); - $sql .= ", ".$info_bits; - $sql .= ", ".$rang; - $sql .= ", ".$special_code; - $sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ", ".((int) $info_bits); + $sql .= ", ".((int) $rang); + $sql .= ", ".((int) $special_code); + $sql .= ", ".($fk_unit ? ((int) $fk_unit) : "null"); $sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", ".price2num($pu_ht_devise); - $sql .= ", ".price2num($multicurrency_total_ht); - $sql .= ", ".price2num($multicurrency_total_tva); - $sql .= ", ".price2num($multicurrency_total_ttc); + $sql .= ", ".price2num($pu_ht_devise, 'CU'); + $sql .= ", ".price2num($multicurrency_total_ht, 'CT'); + $sql .= ", ".price2num($multicurrency_total_tva, 'CT'); + $sql .= ", ".price2num($multicurrency_total_ttc, 'CT'); $sql .= ")"; dol_syslog(get_class($this)."::addline", LOG_DEBUG); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index fe967543fdc..1d8fd5b3392 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -170,12 +170,12 @@ class RemiseCheque extends CommonObject $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".((int) $account_id); $sql .= ", 0"; $sql .= ", 0"; $sql .= ", 0"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", 0"; $sql .= ", ''"; $sql .= ")"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ed7ecae5cf9..f4b4b725ed3 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -155,8 +155,8 @@ class BonPrelevement extends CommonObject } $sql .= ",fk_prelevement_lignes"; $sql .= ") VALUES ("; - $sql .= $invoice_id; - $sql .= ", ".$line_id; + $sql .= ((int) $invoice_id); + $sql .= ", ".((int) $line_id); $sql .= ")"; if ($this->db->query($sql)) { diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index c10b0de662c..f88ff5201f3 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -114,12 +114,12 @@ class RejetPrelevement $sql .= ", date_creation"; $sql .= ", afacturer"; $sql .= ") VALUES ("; - $sql .= $id; + $sql .= ((int) $id); $sql .= ", '".$this->db->idate($date_rejet)."'"; - $sql .= ", ".$motif; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $motif); + $sql .= ", ".((int) $user->id); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$facturation; + $sql .= ", ".((int) $facturation); $sql .= ")"; $result = $this->db->query($sql); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index a7c6ab2c593..0cb7220cfd7 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -230,17 +230,17 @@ class ChargeSociales extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, fk_user, date_creation)"; - $sql .= " VALUES (".$this->type; - $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); - $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); + $sql .= " VALUES (".((int) $this->type); + $sql .= ", ".($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "NULL"); $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; $sql .= ", '".$this->db->idate($this->date_ech)."'"; $sql .= ", '".$this->db->idate($this->periode)."'"; $sql .= ", '".price2num($newamount)."'"; - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); - $sql .= ", ".$conf->entity; - $sql .= ", ".$user->id; - $sql .= ", ".($this->fk_user > 0 ? $this->db->escape($this->fk_user) : 'NULL'); + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 'NULL'); + $sql .= ", ".((int) $conf->entity); + $sql .= ", ".((int) $user->id); + $sql .= ", ".($this->fk_user > 0 ? ((int) $this->fk_user) : 'NULL'); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ")"; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 38da3c21eae..4ca16ceeecf 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -596,7 +596,7 @@ class Tva extends CommonObject } $sql .= ", '".$this->db->escape($user->id)."'"; $sql .= ", NULL"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 7184d7846b0..c2dd055522e 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -128,7 +128,7 @@ class Comment extends CommonObject $sql .= ", '".(isset($this->fk_element) ? $this->fk_element : "null")."'"; $sql .= ", '".$this->db->escape($this->element_type)."'"; $sql .= ", '".(isset($this->fk_user_author) ? $this->fk_user_author : "null")."'"; - $sql .= ", ".$user->id.""; + $sql .= ", ".((int) $user->id); $sql .= ", ".(!empty($this->entity) ? $this->entity : '1'); $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ")"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5cdb83194f4..119ea398ead 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1941,9 +1941,9 @@ abstract class CommonObject if ($fk_user_field) { if (!empty($fuser) && is_object($fuser)) { - $sql .= ", ".$fk_user_field." = ".$fuser->id; + $sql .= ", ".$fk_user_field." = ".((int) $fuser->id); } elseif (empty($fuser) || $fuser != 'none') { - $sql .= ", ".$fk_user_field." = ".$user->id; + $sql .= ", ".$fk_user_field." = ".((int) $user->id); } } diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 7356e53dc0a..2a1f769e15c 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -147,9 +147,9 @@ class Fiscalyear extends CommonObject $sql .= ", '".$this->db->idate($this->date_start)."'"; $sql .= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql .= ", 0"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 5e008a1e1ac..2a5e0f99c64 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -102,7 +102,7 @@ class Link extends CommonObject $sql .= ", '".$this->db->escape($this->url)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->objecttype)."'"; - $sql .= ", ".$this->objectid.")"; + $sql .= ", ".((int) $this->objectid).")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index d1089e5e0e0..50171253938 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1560,7 +1560,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $sql .= ", ".$this->db->encrypt($newvalue); $sql .= ", null"; $sql .= ", '0'"; - $sql .= ", ".$entity; + $sql .= ", ".((int) $entity); $sql .= ")"; $resql = $this->db->query($sql); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index de991d50f4e..60c134661ce 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -166,11 +166,11 @@ class Delivery extends CommonObject $sql .= ", fk_incoterms, location_incoterms"; $sql .= ") VALUES ("; $sql .= "'(PROV)'"; - $sql .= ", ".$conf->entity; - $sql .= ", ".$this->socid; + $sql .= ", ".((int) $conf->entity); + $sql .= ", ".((int) $this->socid); $sql .= ", '".$this->db->escape($this->ref_customer)."'"; $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".($this->date_delivery ? "'".$this->db->idate($this->date_delivery)."'" : "null"); $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 85a95905073..792edbcc928 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -381,7 +381,7 @@ class Don extends CommonObject $sql .= ", phone_mobile"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->date ? $this->date : $now)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", ".price2num($this->amount); $sql .= ", ".($this->modepaymentid ? $this->modepaymentid : "null"); $sql .= ", ".($this->socid > 0 ? $this->socid : "null"); @@ -396,7 +396,7 @@ class Don extends CommonObject $sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null"); $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", null"; $sql .= ", '".$this->db->idate($this->date)."'"; $sql .= ", '".$this->db->escape(trim($this->email))."'"; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 049ef7832b0..830a582db03 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -303,7 +303,6 @@ class Expedition extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition ("; - $sql .= "ref"; $sql .= ", entity"; $sql .= ", ref_customer"; @@ -330,18 +329,18 @@ class Expedition extends CommonObject $sql .= ", fk_incoterms, location_incoterms"; $sql .= ") VALUES ("; $sql .= "'(PROV)'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", ".($this->ref_customer ? "'".$this->db->escape($this->ref_customer)."'" : "null"); $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".($this->date_expedition > 0 ? "'".$this->db->idate($this->date_expedition)."'" : "null"); $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); - $sql .= ", ".$this->socid; - $sql .= ", ".$this->fk_project; + $sql .= ", ".($this->socid > 0 ? ((int) $this->socid) : "null"); + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "null"); $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); - $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); + $sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : "null"); $sql .= ", '".$this->db->escape($this->tracking_number)."'"; $sql .= ", ".(is_numeric($this->weight) ? $this->weight : 'NULL'); $sql .= ", ".(is_numeric($this->sizeS) ? $this->sizeS : 'NULL'); // TODO Should use this->trueDepth @@ -2744,9 +2743,9 @@ class ExpeditionLigne extends CommonObjectLine $sql .= ") VALUES ("; $sql .= $this->fk_expedition; $sql .= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id); - $sql .= ", ".$this->fk_origin_line; - $sql .= ", ".$this->qty; - $sql .= ", ".$ranktouse; + $sql .= ", ".((int) $this->fk_origin_line); + $sql .= ", ".price2num($this->qty, 'MS'); + $sql .= ", ".((int) $ranktouse); $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a67b447ca9c..6dfe761195e 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -270,23 +270,23 @@ class ExpenseReport extends CommonObject $sql .= ",entity"; $sql .= ") VALUES("; $sql .= "'(PROV)'"; - $sql .= ", ".$this->total_ht; - $sql .= ", ".$this->total_ttc; - $sql .= ", ".$this->total_tva; + $sql .= ", ".price2num($this->total_ht, 'MT'); + $sql .= ", ".price2num($this->total_ttc, 'MT'); + $sql .= ", ".price2num($this->total_tva, 'MT'); $sql .= ", '".$this->db->idate($this->date_debut)."'"; $sql .= ", '".$this->db->idate($this->date_fin)."'"; $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; - $sql .= ", ".$fuserid; - $sql .= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator : "null"); - $sql .= ", ".($this->fk_user_approve > 0 ? $this->fk_user_approve : "null"); - $sql .= ", ".($this->fk_user_modif > 0 ? $this->fk_user_modif : "null"); - $sql .= ", ".($this->fk_statut > 1 ? $this->fk_statut : 0); - $sql .= ", ".($this->modepaymentid ? $this->modepaymentid : "null"); + $sql .= ", ".((int) $user->id); + $sql .= ", ".((int) $fuserid); + $sql .= ", ".($this->fk_user_validator > 0 ? ((int) $this->fk_user_validator) : "null"); + $sql .= ", ".($this->fk_user_approve > 0 ? ((int) $this->fk_user_approve) : "null"); + $sql .= ", ".($this->fk_user_modif > 0 ? ((int) $this->fk_user_modif) : "null"); + $sql .= ", ".($this->fk_statut > 1 ? ((int) $this->fk_statut) : 0); + $sql .= ", ".($this->modepaymentid ? ((int) $this->modepaymentid) : "null"); $sql .= ", 0"; $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; $result = $this->db->query($sql); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 23766a91bbe..9bd3f17da25 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -286,14 +286,14 @@ class Fichinter extends CommonObject $sql .= $this->socid; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->escape($this->ref)."'"; - $sql .= ", ".$conf->entity; - $sql .= ", ".$user->id; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $conf->entity); + $sql .= ", ".((int) $user->id); + $sql .= ", ".((int) $user->id); $sql .= ", ".($this->description ? "'".$this->db->escape($this->description)."'" : "null"); $sql .= ", '".$this->db->escape($this->model_pdf)."'"; - $sql .= ", ".($this->fk_project ? $this->fk_project : 0); - $sql .= ", ".($this->fk_contrat ? $this->fk_contrat : 0); - $sql .= ", ".$this->statut; + $sql .= ", ".($this->fk_project ? ((int) $this->fk_project) : 0); + $sql .= ", ".($this->fk_contrat ? ((int) $this->fk_contrat) : 0); + $sql .= ", ".((int) $this->statut); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ")"; diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index d23c25253ac..d5690265028 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -182,18 +182,18 @@ class FichinterRec extends Fichinter $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->title)."'"; - $sql .= ", ".($this->socid > 0 ? $this->socid : 'null'); - $sql .= ", ".$conf->entity; + $sql .= ", ".($this->socid > 0 ? ((int) $this->socid) : 'null'); + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".(!empty($fichintsrc->duration) ? $fichintsrc->duration : '0'); + $sql .= ", ".(!empty($fichintsrc->duration) ? ((int) $fichintsrc->duration) : '0'); $sql .= ", ".(!empty($this->description) ? ("'".$this->db->escape($this->description)."'") : "null"); $sql .= ", ".(!empty($fichintsrc->note_private) ? ("'".$this->db->escape($fichintsrc->note_private)."'") : "null"); $sql .= ", ".(!empty($fichintsrc->note_public) ? ("'".$this->db->escape($fichintsrc->note_public)."'") : "null"); - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); // si c'est la même société on conserve les liens vers le projet et le contrat if ($this->socid == $fichintsrc->socid) { - $sql .= ", ".(!empty($fichintsrc->fk_project) ? $fichintsrc->fk_project : "null"); - $sql .= ", ".(!empty($fichintsrc->fk_contrat) ? $fichintsrc->fk_contrat : "null"); + $sql .= ", ".(!empty($fichintsrc->fk_project) ? ((int) $fichintsrc->fk_project) : "null"); + $sql .= ", ".(!empty($fichintsrc->fk_contrat) ? ((int) $fichintsrc->fk_contrat) : "null"); } else { $sql .= ", null, null"; } @@ -201,12 +201,12 @@ class FichinterRec extends Fichinter $sql .= ", ".(!empty($fichintsrc->model_pdf) ? "'".$this->db->escape($fichintsrc->model_pdf)."'" : "''"); // récurrence - $sql .= ", ".(!empty($this->frequency) ? $this->frequency : "null"); + $sql .= ", ".(!empty($this->frequency) ? ((int) $this->frequency) : "null"); $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; $sql .= ", ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'null'); $sql .= ", ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'null'); $sql .= ", 0"; // we start à 0 - $sql .= ", ".$this->nb_gen_max; + $sql .= ", ".((int) $this->nb_gen_max); // $sql.= ", ".$this->auto_validate; $sql .= ")"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9d965ee034e..09a43fb95ab 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1335,14 +1335,14 @@ class CommandeFournisseur extends CommonOrder $sql .= ", '".$this->db->escape($this->ref_supplier)."'"; $sql .= ", '".$this->db->escape($this->note_private)."'"; $sql .= ", '".$this->db->escape($this->note_public)."'"; - $sql .= ", ".$conf->entity; - $sql .= ", ".$this->socid; - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", ".((int) $conf->entity); + $sql .= ", ".((int) $this->socid); + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "null"); $sql .= ", '".$this->db->idate($date)."'"; $sql .= ", ".($delivery_date ? "'".$this->db->idate($delivery_date)."'" : "null"); - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".self::STATUS_DRAFT; - $sql .= ", ".$this->db->escape($this->source); + $sql .= ", ".((int) $this->source); $sql .= ", '".$this->db->escape($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)."'"; $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null'); $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null'); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ef39e7502f6..4ceea8fde2c 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -342,7 +342,7 @@ if (empty($reshook)) { $sql .= ") VALUES ("; $sql .= $id_order; $sql .= ", '".$db->escape($objecttmp->origin)."'"; - $sql .= ", ".$objecttmp->id; + $sql .= ", ".((int) $objecttmp->id); $sql .= ", '".$db->escape($objecttmp->element)."'"; $sql .= ")"; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index d26a10a923a..a9082a02b5e 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -204,12 +204,12 @@ class Establishment extends CommonObject $sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", '".$this->db->escape($this->zip)."'"; $sql .= ", '".$this->db->escape($this->town)."'"; - $sql .= ", ".$this->country_id; - $sql .= ", ".$this->status; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $this->country_id); + $sql .= ", ".((int) $this->status); + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); + $sql .= ", ".((int) $user->id); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e51c553809d..818ee620821 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -718,19 +718,19 @@ class Product extends CommonObject $sql .= ", fk_unit"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->escape($this->ref)."'"; $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", ".price2num($price_min_ht); $sql .= ", ".price2num($price_min_ttc); $sql .= ", ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", ".$user->id; - $sql .= ", ".$this->type; - $sql .= ", ".price2num($price_ht); - $sql .= ", ".price2num($price_ttc); + $sql .= ", ".((int) $user->id); + $sql .= ", ".((int) $this->type); + $sql .= ", ".price2num($price_ht, 'MT'); + $sql .= ", ".price2num($price_ttc, 'MT'); $sql .= ", '".$this->db->escape($this->price_base_type)."'"; - $sql .= ", ".$this->status; - $sql .= ", ".$this->status_buy; + $sql .= ", ".((int) $this->status); + $sql .= ", ".((int) $this->status_buy); if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; @@ -740,10 +740,10 @@ class Product extends CommonObject $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; } $sql .= ", '".$this->db->escape($this->canvas)."'"; - $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); - $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); + $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'NULL' : (int) $this->finished); + $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : ((int) $this->status_batch)); $sql .= ", '".$this->db->escape($this->batch_mask)."'"; - $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", ".($this->fk_unit > 0 ? ((int) $this->fk_unit) : 'NULL'); $sql .= ")"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 02939ead090..00394dda384 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -381,10 +381,10 @@ class Project extends CommonObject $sql .= ", '".$this->db->escape($this->title)."'"; $sql .= ", '".$this->db->escape($this->description)."'"; $sql .= ", ".($this->socid > 0 ? $this->socid : "null"); - $sql .= ", ".$user->id; - $sql .= ", ".(is_numeric($this->statut) ? $this->statut : '0'); - $sql .= ", ".((is_numeric($this->opp_status) && $this->opp_status > 0) ? $this->opp_status : 'NULL'); - $sql .= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); + $sql .= ", ".((int) $user->id); + $sql .= ", ".(is_numeric($this->statut) ? ((int) $this->statut) : '0'); + $sql .= ", ".((is_numeric($this->opp_status) && $this->opp_status > 0) ? ((int) $this->opp_status) : 'NULL'); + $sql .= ", ".(is_numeric($this->opp_percent) ? ((int) $this->opp_percent) : 'NULL'); $sql .= ", ".($this->public ? 1 : 0); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); @@ -402,7 +402,7 @@ class Project extends CommonObject $sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null'); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null'); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null'); - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index c05f726031c..cd18a9b6819 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -173,18 +173,18 @@ class Task extends CommonObject $sql .= ", planned_workload"; $sql .= ", progress"; $sql .= ") VALUES ("; - $sql .= $conf->entity; - $sql .= ", ".$this->fk_project; + $sql .= ((int) $conf->entity); + $sql .= ", ".((int) $this->fk_project); $sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null'); - $sql .= ", ".$this->fk_task_parent; + $sql .= ", ".((int) $this->fk_task_parent); $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->description)."'"; $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); $sql .= ", ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); - $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? $this->planned_workload : 'null'); - $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null'); + $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? ((int) $this->planned_workload) : 'null'); + $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? ((int) $this->progress) : 'null'); $sql .= ")"; $this->db->begin(); @@ -1182,12 +1182,12 @@ class Task extends CommonObject $sql .= ", fk_user"; $sql .= ", note"; $sql .= ") VALUES ("; - $sql .= $this->id; + $sql .= ((int) $this->id); $sql .= ", '".$this->db->idate($this->timespent_date)."'"; $sql .= ", '".$this->db->idate($this->timespent_datehour)."'"; $sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1); - $sql .= ", ".$this->timespent_duration; - $sql .= ", ".$this->timespent_fk_user; + $sql .= ", ".((int) $this->timespent_duration); + $sql .= ", ".((int) $this->timespent_fk_user); $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); $sql .= ")"; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 6a4301d86df..add1be5e831 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -256,22 +256,22 @@ class Reception extends CommonObject $sql .= ", fk_incoterms, location_incoterms"; $sql .= ") VALUES ("; $sql .= "'(PROV)'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", ".($this->ref_supplier ? "'".$this->db->escape($this->ref_supplier)."'" : "null"); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", ".$user->id; + $sql .= ", ".((int) $user->id); $sql .= ", ".($this->date_reception > 0 ? "'".$this->db->idate($this->date_reception)."'" : "null"); $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); - $sql .= ", ".$this->socid; - $sql .= ", ".$this->fk_project; - $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); + $sql .= ", ".((int) $this->socid); + $sql .= ", ".((int) $this->fk_project); + $sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : "null"); $sql .= ", '".$this->db->escape($this->tracking_number)."'"; - $sql .= ", ".$this->weight; - $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth - $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth - $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql .= ", ".$this->weight_units; - $sql .= ", ".$this->size_units; + $sql .= ", ".((double) $this->weight); + $sql .= ", ".((double) $this->sizeS); // TODO Should use this->trueDepth + $sql .= ", ".((double) $this->sizeW); // TODO Should use this->trueWidth + $sql .= ", ".((double) $this->sizeH); // TODO Should use this->trueHeight + $sql .= ", ".((double) $this->weight_units); + $sql .= ", ".((double) $this->size_units); $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 8fdd741efee..5c87b3c53b9 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -406,11 +406,11 @@ class Salary extends CommonObject $sql .= "'".$this->db->escape($this->fk_user)."'"; //$sql .= ", '".$this->db->idate($this->datep)."'"; //$sql .= ", '".$this->db->idate($this->datev)."'"; - $sql .= ", ".$this->amount; - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); - $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql .= ", ".($this->type_payment > 0 ? $this->type_payment : 0); - $sql .= ", ".($this->accountid > 0 ? $this->accountid : "null"); + $sql .= ", ".((double) $this->amount); + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 0); + $sql .= ", ".($this->salary > 0 ? ((double) $this->salary) : "null"); + $sql .= ", ".($this->type_payment > 0 ? ((int) $this->type_payment) : 0); + $sql .= ", ".($this->accountid > 0 ? ((int) $this->accountid) : "null"); if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->idate($this->datesp)."'"; @@ -418,7 +418,7 @@ class Salary extends CommonObject $sql .= ", '".$this->db->escape($user->id)."'"; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", NULL"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e35051829cb..882c4bc5f3a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -931,9 +931,9 @@ class SupplierProposal extends CommonObject $sql .= " VALUES ("; $sql .= $this->socid; $sql .= ", 0"; - $sql .= ", ".$this->remise; - $sql .= ", ".($this->remise_percent ? $this->db->escape($this->remise_percent) : 'null'); - $sql .= ", ".($this->remise_absolue ? $this->db->escape($this->remise_absolue) : 'null'); + $sql .= ", ".((double) $this->remise); + $sql .= ", ".($this->remise_percent ? ((double) $this->remise_percent) : 'null'); + $sql .= ", ".($this->remise_absolue ? ((double) $this->remise_absolue) : 'null'); $sql .= ", 0"; $sql .= ", 0"; $sql .= ", '".$this->db->idate($now)."'"; @@ -942,13 +942,13 @@ class SupplierProposal extends CommonObject $sql .= ", '".$this->db->escape($this->note_private)."'"; $sql .= ", '".$this->db->escape($this->note_public)."'"; $sql .= ", '".$this->db->escape($this->model_pdf)."'"; - $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); - $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); - $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : 'NULL'); + $sql .= ", ".($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL'); $sql .= ", ".($delivery_date ? "'".$this->db->idate($delivery_date)."'" : "null"); - $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); - $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); - $sql .= ", ".$conf->entity; + $sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : 'NULL'); + $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "null"); + $sql .= ", ".((int) $conf->entity); $sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql .= ", ".(double) $this->multicurrency_tx; @@ -3029,32 +3029,32 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; $sql .= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; $sql .= " ".($this->fk_remise_except ? "'".$this->db->escape($this->fk_remise_except)."'" : "null").","; - $sql .= " ".price2num($this->qty).","; + $sql .= " ".price2num($this->qty, 'MS').","; $sql .= " ".price2num($this->tva_tx).","; $sql .= " ".price2num($this->localtax1_tx).","; $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= " ".(!empty($this->subprice) ?price2num($this->subprice) : "null").","; - $sql .= " ".price2num($this->remise_percent).","; - $sql .= " ".(isset($this->info_bits) ? "'".$this->db->escape($this->info_bits)."'" : "null").","; - $sql .= " ".price2num($this->total_ht).","; - $sql .= " ".price2num($this->total_tva).","; - $sql .= " ".price2num($this->total_localtax1).","; - $sql .= " ".price2num($this->total_localtax2).","; - $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".(!empty($this->subprice) ?price2num($this->subprice, 'MU') : "null").","; + $sql .= " ".((float) $this->remise_percent).","; + $sql .= " ".(isset($this->info_bits) ? ((int) $this->info_bits)."'" : "null").","; + $sql .= " ".price2num($this->total_ht, 'MT').","; + $sql .= " ".price2num($this->total_tva, 'MT').","; + $sql .= " ".price2num($this->total_localtax1, 'MT').","; + $sql .= " ".price2num($this->total_localtax2, 'MT').","; + $sql .= " ".price2num($this->total_ttc, 'MT').","; $sql .= " ".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null").","; - $sql .= " ".(isset($this->pa_ht) ? "'".price2num($this->pa_ht)."'" : "null").","; + $sql .= " ".(isset($this->pa_ht) ? price2num($this->pa_ht, 'MU') : "null").","; $sql .= ' '.((int) $this->special_code).','; $sql .= ' '.((int) $this->rang).','; $sql .= " '".$this->db->escape($this->ref_fourn)."'"; - $sql .= ", ".($this->fk_multicurrency > 0 ? $this->fk_multicurrency : 'null'); + $sql .= ", ".($this->fk_multicurrency > 0 ? ((int) $this->fk_multicurrency) : 'null'); $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", ".$this->multicurrency_subprice; - $sql .= ", ".$this->multicurrency_total_ht; - $sql .= ", ".$this->multicurrency_total_tva; - $sql .= ", ".$this->multicurrency_total_ttc; - $sql .= ", ".($this->fk_unit ? $this->fk_unit : 'null'); + $sql .= ", ".price2num($this->multicurrency_subprice, 'CU'); + $sql .= ", ".price2num($this->multicurrency_total_ht, 'CT'); + $sql .= ", ".price2num($this->multicurrency_total_tva, 'CT'); + $sql .= ", ".price2num($this->multicurrency_total_ttc, 'CT'); + $sql .= ", ".($this->fk_unit ? ((int) $this->fk_unit) : 'null'); $sql .= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 9bf53fb5271..8e8f04df04a 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -466,7 +466,7 @@ class Ticket extends CommonObject $sql .= " ".(!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'".$this->db->idate($this->datec)."'").","; $sql .= " ".(!isset($this->date_read) || dol_strlen($this->date_read) == 0 ? 'NULL' : "'".$this->db->idate($this->date_read)."'").","; $sql .= " ".(!isset($this->date_close) || dol_strlen($this->date_close) == 0 ? 'NULL' : "'".$this->db->idate($this->date_close)."'").""; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", ".(!isset($this->notify_tiers_at_create) ? '1' : "'".$this->db->escape($this->notify_tiers_at_create)."'"); $sql .= ")"; From 94e708d19634ed501f0018230be0ffded1d0e18c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Sep 2021 21:59:13 +0200 Subject: [PATCH 111/229] Fix sql error --- .../class/supplier_proposal.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 882c4bc5f3a..de73b7a0296 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -929,7 +929,7 @@ class SupplierProposal extends CommonObject $sql .= ", multicurrency_tx"; $sql .= ") "; $sql .= " VALUES ("; - $sql .= $this->socid; + $sql .= ((int) $this->socid); $sql .= ", 0"; $sql .= ", ".((double) $this->remise); $sql .= ", ".($this->remise_percent ? ((double) $this->remise_percent) : 'null'); @@ -949,9 +949,9 @@ class SupplierProposal extends CommonObject $sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : 'NULL'); $sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "null"); $sql .= ", ".((int) $conf->entity); - $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", ".((int) $this->fk_multicurrency); $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", ".(double) $this->multicurrency_tx; + $sql .= ", ".((double) $this->multicurrency_tx); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -3021,29 +3021,29 @@ class SupplierProposalLine extends CommonObjectLine $sql .= ' ref_fourn,'; $sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; $sql .= " VALUES (".$this->fk_supplier_proposal.","; - $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape($this->fk_parent_line)."'" : "null").","; + $sql .= " ".($this->fk_parent_line > 0 ? ((int) $this->db->escape($this->fk_parent_line)) : "null").","; $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " '".$this->db->escape($this->desc)."',"; - $sql .= " ".($this->fk_product ? "'".$this->db->escape($this->fk_product)."'" : "null").","; + $sql .= " ".($this->fk_product ? ((int) $this->fk_product) : "null").","; $sql .= " '".$this->db->escape($this->product_type)."',"; $sql .= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; $sql .= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; - $sql .= " ".($this->fk_remise_except ? "'".$this->db->escape($this->fk_remise_except)."'" : "null").","; + $sql .= " ".($this->fk_remise_except ? ((int) $this->db->escape($this->fk_remise_except)) : "null").","; $sql .= " ".price2num($this->qty, 'MS').","; $sql .= " ".price2num($this->tva_tx).","; $sql .= " ".price2num($this->localtax1_tx).","; $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= " ".(!empty($this->subprice) ?price2num($this->subprice, 'MU') : "null").","; + $sql .= " ".(!empty($this->subprice) ? price2num($this->subprice, 'MU') : "null").","; $sql .= " ".((float) $this->remise_percent).","; - $sql .= " ".(isset($this->info_bits) ? ((int) $this->info_bits)."'" : "null").","; + $sql .= " ".(isset($this->info_bits) ? ((int) $this->info_bits) : "null").","; $sql .= " ".price2num($this->total_ht, 'MT').","; $sql .= " ".price2num($this->total_tva, 'MT').","; $sql .= " ".price2num($this->total_localtax1, 'MT').","; $sql .= " ".price2num($this->total_localtax2, 'MT').","; $sql .= " ".price2num($this->total_ttc, 'MT').","; - $sql .= " ".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null").","; + $sql .= " ".(!empty($this->fk_fournprice) ? ((int) $this->fk_fournprice) : "null").","; $sql .= " ".(isset($this->pa_ht) ? price2num($this->pa_ht, 'MU') : "null").","; $sql .= ' '.((int) $this->special_code).','; $sql .= ' '.((int) $this->rang).','; From b13fc30a0a7a96ac152b68813aade802cf032234 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 4 Sep 2021 12:25:40 +0800 Subject: [PATCH 112/229] Update dolibarr.php --- htdocs/admin/system/dolibarr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 0271488b65a..a39d4dc2a8c 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -505,7 +505,7 @@ if ($resql) { $obj = $db->fetch_object($resql); print ''; - print ''."\n"; + print ''."\n"; print ''; } // Action column diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 32442dcc330..4fcd5a91723 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -176,6 +176,21 @@ if (empty($dolibarr_strict_mode)) { $dolibarr_strict_mode = 0; // For debug in php strict mode } +define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem core php (htdocs) + +if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php")) { + print "Error: Dolibarr config file content seems to be not correctly defined.
\n"; + print "Please run dolibarr setup by calling page /install.
\n"; + exit; +} + + +// Included by default (must be before the CSRF check so wa can use the dol_syslog) +include_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; +//print memory_get_usage(); + + // Security: CSRF protection // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']) // when we post forms (we allow GET and HEAD to accept direct link from a particular page). @@ -228,7 +243,6 @@ if (empty($dolibarr_main_data_root)) { // Define some constants define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir (defined only for some code that want to be compatible with old versions without this parameter) define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem data (documents) -define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem core php (htdocs) // Try to autodetect DOL_MAIN_URL_ROOT and DOL_URL_ROOT. // Note: autodetect works only in case 1, 2, 3 and 4 of phpunit test CoreTest.php. For case 5, 6, only setting value into conf.php will works. $tmp = ''; @@ -333,18 +347,6 @@ if (!defined('ADODB_DATE_VERSION')) { include_once ADODB_PATH.'adodb-time.inc.php'; } -if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php")) { - print "Error: Dolibarr config file content seems to be not correctly defined.
\n"; - print "Please run dolibarr setup by calling page /install.
\n"; - exit; -} - - -// Included by default -include_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; -include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; -//print memory_get_usage(); - // If password is encoded, we decode it. Note: When page is called for install, $dolibarr_main_db_pass may not be defined yet. if ((!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) { if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) { From f79b883a4ad07756f7ac17a2751f9da100bd15eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 01:57:05 +0200 Subject: [PATCH 123/229] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 5a95128c090..520fe8dccdb 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1132,7 +1132,7 @@ $( document ).ready(function() { $s = ''; $constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); $warehouse = new Entrepot($db); - $warehouse->fetch(getDolGlobalString("$constantforkey")); + $warehouse->fetch(getDolGlobalString($constantforkey)); $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; $s .= '
'; } From 2928c3dc9b876e8f659e6761b6d1e0b60c3e1a5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 02:18:53 +0200 Subject: [PATCH 124/229] NEW Add a PDF document template for Manufacturing Orders --- htdocs/admin/mrp.php | 4 +-- ...estD.modules.php => pdf_vinci.modules.php} | 34 ++++++++++--------- htdocs/mrp/class/mo.class.php | 2 ++ 3 files changed, 22 insertions(+), 18 deletions(-) rename htdocs/core/modules/mrp/doc/{pdf_testD.modules.php => pdf_vinci.modules.php} (98%) diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 08e257b0188..3760c300a6c 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -69,7 +69,7 @@ if ($action == 'updateMask') { $modele = GETPOST('module', 'alpha'); $mo = new MO($db); - $mrp->initAsSpecimen(); + $mo->initAsSpecimen(); // Search template files $file = ''; $classname = ''; $filefound = 0; @@ -88,7 +88,7 @@ if ($action == 'updateMask') { $module = new $classname($db); - if ($module->write_file($mrp, $langs) > 0) { + if ($module->write_file($mo, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf"); return; } else { diff --git a/htdocs/core/modules/mrp/doc/pdf_testD.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php similarity index 98% rename from htdocs/core/modules/mrp/doc/pdf_testD.modules.php rename to htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index f370fe21b2b..5f6a03f2caa 100644 --- a/htdocs/core/modules/mrp/doc/pdf_testD.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -23,13 +23,14 @@ */ /** - * \file htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php - * \ingroup fournisseur - * \brief File of class to generate suppliers orders from cornas model + * \file htdocs/core/modules/mrp/doc/pdf_vinci.php + * \ingroup mrp + * \brief File of class to generate MO document from vinci model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -37,9 +38,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Class to generate the manufacturing orders with the cornas model + * Class to generate the manufacturing orders with the vinci model */ -class pdf_testD extends ModelePDFMo +class pdf_vinci extends ModelePDFMo { /** * @var DoliDb Database handler @@ -133,8 +134,8 @@ class pdf_testD extends ModelePDFMo $langs->loadLangs(array("main", "bills")); $this->db = $db; - $this->name = "pdf_testD"; - $this->description = $langs->trans('DocumentModel'); + $this->name = "vinci"; + $this->description = $langs->trans('DocumentModelStandardPDF'); $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format @@ -203,10 +204,11 @@ class pdf_testD extends ModelePDFMo $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); } - $nblines = count($object->lines); + if (!isset($object->lines) || !is_array($object->lines)) { + $object->lines = array(); + } - //Change descriptionfield - $showsupplierSKU = false; + $nblines = count($object->lines); $hidetop = 0; if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { @@ -281,10 +283,10 @@ class pdf_testD extends ModelePDFMo $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetSubject($outputlangs->transnoentities("Mo")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Mo")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } @@ -1116,7 +1118,7 @@ class pdf_testD extends ModelePDFMo $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); + $title = $outputlangs->transnoentities("Mo")." ".$outputlangs->convToOutputCharset($object->ref); $pdf->MultiCell(100, 3, $title, '', 'R'); $posy += 1; @@ -1152,16 +1154,16 @@ class pdf_testD extends ModelePDFMo } } - if (!empty($object->date_commande)) { + if (!empty($object->date_approve)) { $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("MoDate")." : ".dol_print_date($object->date_approve, "day", false, $outputlangs, true), '', 'R'); } else { $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(255, 0, 0); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToApprove"), '', 'R'); } // product info diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index fcf54eb364e..f4069bfc518 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1186,6 +1186,8 @@ class Mo extends CommonObject public function initAsSpecimen() { $this->initAsSpecimenCommon(); + + $this->lines = array(); } /** From ed3919da139761cf7c22e33b6a7d321a96cc707a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 02:25:32 +0200 Subject: [PATCH 125/229] Look and feel --- htdocs/admin/bom.php | 2 +- htdocs/admin/chequereceipts.php | 2 +- htdocs/admin/commande.php | 2 +- htdocs/admin/contract.php | 2 +- htdocs/admin/delivery.php | 2 +- htdocs/admin/eventorganization.php | 2 +- htdocs/admin/expedition.php | 2 +- htdocs/admin/expensereport.php | 2 +- htdocs/admin/facture.php | 2 +- htdocs/admin/fichinter.php | 2 +- htdocs/admin/holiday.php | 2 +- htdocs/admin/knowledgemanagement.php | 2 +- htdocs/admin/mrp.php | 2 +- htdocs/admin/payment.php | 2 +- htdocs/admin/propal.php | 2 +- htdocs/admin/reception_setup.php | 2 +- htdocs/admin/security.php | 2 +- htdocs/admin/supplier_invoice.php | 2 +- htdocs/admin/supplier_order.php | 2 +- htdocs/admin/supplier_payment.php | 2 +- htdocs/admin/supplier_proposal.php | 2 +- htdocs/admin/ticket.php | 2 +- htdocs/admin/workstation.php | 2 +- htdocs/core/modules/facture/mod_facture_mercure.php | 8 ++++---- 24 files changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 021233ef449..0aae15eef3e 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 837d8d997b2..3ba8c3b854a 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -174,7 +174,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index c10fdd5bbdf..d57292e3562 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -289,7 +289,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index ea8a80b17d6..b5e0c3ae28b 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -220,7 +220,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index 04d52c491b2..4fa7b2b79c7 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index ab90334b972..2c0c42dbb14 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -445,7 +445,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index ee3d4f18562..32f82f5dad5 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 0b6beb2abc6..1553f6887f8 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -228,7 +228,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 8b88b9a9ac8..bf4e2ea9eb6 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -312,7 +312,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index b878c40138e..4d9304472d5 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -284,7 +284,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 9dfb15477cc..81db1cbe58d 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -220,7 +220,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index 457303c9798..477f38fa663 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -396,7 +396,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 3760c300a6c..7cd3c095955 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index b4b06d62e5e..089ddbafd23 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -178,7 +178,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 3e75836e9fe..dcd91df0dbc 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -268,7 +268,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index e049985c61e..6367b80c150 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -225,7 +225,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 064fb5650a4..a86ca272b85 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -249,7 +249,7 @@ foreach ($arrayhandler as $key => $module) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print ''.$tmp.''; } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index c4958083181..a888a248d11 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -246,7 +246,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 27629d99a82..cfa6c878a74 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -259,7 +259,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 863674bab75..15210f89360 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -247,7 +247,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 869ee4ca4fb..980ebe10fff 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -247,7 +247,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index bfd2ae4b09b..c3778861ddf 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -266,7 +266,7 @@ foreach ($dirmodels as $reldir) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 1157000fd6b..f14393e2588 100755 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -286,7 +286,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { - print $langs->trans($tmp); + print ''.$langs->trans($tmp).''; } else { print $tmp; } diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 706c35a9f82..621bb8e6d2d 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -75,7 +75,7 @@ class mod_facture_mercure extends ModeleNumRefFactures $tooltip .= $langs->trans("GenericMaskCodes5"); // Setting the prefix - $texte .= '
'; + $texte .= ''; $texte .= ''; $texte .= ''; @@ -83,17 +83,17 @@ class mod_facture_mercure extends ModeleNumRefFactures $texte .= ''; // Prefix setting of replacement invoices - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; // Prefix setting of credit note - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; // Prefix setting of deposit - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; From b58684af980dcfb132094213d6d42db2e4d07165 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 14:31:33 +0200 Subject: [PATCH 126/229] Fix trans --- htdocs/langs/en_US/contracts.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index 49a65fdb39d..937c5a7397b 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -36,7 +36,7 @@ CloseAContract=Close a contract ConfirmDeleteAContract=Are you sure you want to delete this contract and all its services? ConfirmValidateContract=Are you sure you want to validate this contract under name %s? ConfirmActivateAllOnContract=This will open all services (not yet active). Are you sure you want to open all services? -ConfirmCloseContract=This will close all services (active or not). Are you sure you want to close this contract? +ConfirmCloseContract=This will close all services (expired or not). Are you sure you want to close this contract? ConfirmCloseService=Are you sure you want to close this service with date %s? ValidateAContract=Validate a contract ActivateService=Activate service From 1c97393a6900c8e1af792408fe405842b90494c0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Sep 2021 15:35:06 +0200 Subject: [PATCH 127/229] FIX increase maxlength of password input --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index cb7aa69949c..8622e293906 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2018 Regis Houssin + * Copyright (C) 2005-2021 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2012-2018 Juanjo Menent @@ -2290,7 +2290,7 @@ if ($action == 'create' || $action == 'adduserldap') { } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { if ($caneditpassword) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); } From f288f36b71c83cfa91c94f9036675042b2647867 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 01:42:54 +0200 Subject: [PATCH 128/229] NEW Can use textarea field into confirm popup. Reponsive --- htdocs/contrat/card.php | 8 ++--- htdocs/core/class/html.form.class.php | 12 +++++++ .../core/tpl/admin_extrafields_view.tpl.php | 33 +++++++++++++------ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5aba990c14f..bd360a7e481 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1202,12 +1202,8 @@ if ($action == 'create') { } print "\n"; -} else /* *************************************************************************** */ -/* */ -/* Mode vue et edition */ -/* */ -/* *************************************************************************** */ -{ +} else { + // View and edit mode $now = dol_now(); if ($object->id > 0) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 48774c0fe66..0cd217010c5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4745,6 +4745,18 @@ class Form $more .= '
'.$input['label'].'
'."\n"; } elseif ($input['type'] == 'password') { $more .= '
'.$input['label'].'
'."\n"; + } elseif ($input['type'] == 'textarea') { + /*$more .= '
'.$input['label'].'
'; + $more .= ''; + $more .= '
'."\n";*/ + $moreonecolumn .= '
'; + $moreonecolumn .= $input['label'].'
'; + $moreonecolumn .= ''; + $moreonecolumn .= '
'; } elseif ($input['type'] == 'select') { if (empty($morecss)) { $morecss = 'minwidth100'; diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 284407383d4..c6d25410713 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -84,18 +84,31 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel } print '
'; - print "\n"; - print "\n"; // We don't translate here, we want admin to know what is the key not translated value + // Position + print "\n"; + // Label + print "\n"; // We don't translate here, we want admin to know what is the key not translated value + // Label translated print "\n"; - print "\n"; - print "\n"; - print '\n"; - print '\n"; + // Key + print "\n"; + // Type + print "\n"; + // Size + print '\n"; + // Computed field + print '\n"; + // Is unique ? print '\n"; + // Is mandatory ? print '\n"; + // Can always be editable ? print '\n"; - print '\n"; - print '\n"; + // Visible + print '\n"; + // Print on PDF + print '\n"; + // Summable print '\n"; if (!empty($conf->multicompany->enabled)) { print ''; } print ''."\n"; print ""; } From 8e90a374e064dbc218fa79d13329cff2465a2bb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 01:47:18 +0200 Subject: [PATCH 129/229] Responsive --- htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index c6d25410713..2f1c113fcf5 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -89,7 +89,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel // Label print "\n"; // We don't translate here, we want admin to know what is the key not translated value // Label translated - print "\n"; + print '\n"; // Key print "\n"; // Type From 319a531571fab4091b6d6e20275f8ece51d30e62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 01:51:25 +0200 Subject: [PATCH 130/229] Trans --- htdocs/langs/en_US/admin.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 76dd117dbd8..eb1ce338864 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2163,4 +2163,5 @@ APIsAreNotEnabled=APIs modules are not enabled YouShouldSetThisToOff=You should set this to 0 or off InstallAndUpgradeLockedBy=Install and upgrades are locked by the file %s OldImplementation=Old implementation -PDF_SHOW_LINK_TO_ONLINE_PAYMENT=If some online payment modules are enabled (Paypal, Stripe, ...), add a link on the PDF to make the online payment \ No newline at end of file +PDF_SHOW_LINK_TO_ONLINE_PAYMENT=If some online payment modules are enabled (Paypal, Stripe, ...), add a link on the PDF to make the online payment +EnabledCondition=Condition to have field enabled (if not enabled, visibility will always be off) \ No newline at end of file From 7d77a71696c147e2c72b5c1798dc63438a75a27f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 02:17:08 +0200 Subject: [PATCH 131/229] Fix missing id --- htdocs/core/class/html.form.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0cd217010c5..fc83af67851 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4727,7 +4727,7 @@ class Form foreach ($formquestion as $key => $input) { if (is_array($input) && !empty($input)) { if ($input['type'] == 'hidden') { - $more .= ''."\n"; + $more .= ''."\n"; } } } @@ -4742,9 +4742,9 @@ class Form $morecss = (!empty($input['morecss']) ? ' '.$input['morecss'] : ''); if ($input['type'] == 'text') { - $more .= '
'.$input['label'].'
'."\n"; + $more .= '
'.$input['label'].'
'."\n"; } elseif ($input['type'] == 'password') { - $more .= '
'.$input['label'].'
'."\n"; + $more .= '
'.$input['label'].'
'."\n"; } elseif ($input['type'] == 'textarea') { /*$more .= '
'.$input['label'].'
'; $more .= ''; $moreonecolumn .= '
'; @@ -4779,7 +4779,7 @@ class Form } elseif ($input['type'] == 'checkbox') { $more .= '
'; $more .= '
'.$input['label'].'
'; - $more .= ' 
'; } - $more .= '
'.$selval.''; + $more .= ''; $more .= '
'."\n"; $i++; } @@ -4933,7 +4933,7 @@ class Form inputvalue = $("#" + inputname + more).val(); } if (typeof inputvalue == "undefined") { inputvalue=""; } - console.log("check inputname="+inputname+" inputvalue="+inputvalue); + console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue); options += "&" + inputname + "=" + encodeURIComponent(inputvalue); }); } From 5850b68f79408942047794291ccf6454c548fa3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 03:22:06 +0200 Subject: [PATCH 132/229] Fix css --- htdocs/salaries/paiement_salary.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index a266a2ed88b..749ce8f9575 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -315,8 +315,11 @@ if ($action == 'create') { print "
'.$obj->name.''.$obj->name.''; if (isASecretKey($obj->name)) { if (empty($dolibarr_main_prod)) { From 456f25d57e95ed5528e3f1eb08a034f5268547ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Sep 2021 11:30:03 +0200 Subject: [PATCH 113/229] fix #17634 --- htdocs/main.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a56054b9594..cc2a21b9f84 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1766,6 +1766,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; + $langs->load('companies'); $userImage = $userDropDownImage = ''; if (!empty($user->photo)) { From db6a2844ad20a9c09e47cb161f4696c74abfaf73 Mon Sep 17 00:00:00 2001 From: mschamp <34092708+mschamp@users.noreply.github.com> Date: Sat, 4 Sep 2021 12:36:54 +0200 Subject: [PATCH 114/229] Add files via upload --- .../modules/mrp/doc/pdf_testD.modules.php | 1512 +++++++++++++++++ 1 file changed, 1512 insertions(+) create mode 100644 htdocs/core/modules/mrp/doc/pdf_testD.modules.php diff --git a/htdocs/core/modules/mrp/doc/pdf_testD.modules.php b/htdocs/core/modules/mrp/doc/pdf_testD.modules.php new file mode 100644 index 00000000000..59843be1a89 --- /dev/null +++ b/htdocs/core/modules/mrp/doc/pdf_testD.modules.php @@ -0,0 +1,1512 @@ + + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2015 Marcos García + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php + * \ingroup fournisseur + * \brief File of class to generate suppliers orders from cornas model + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to generate the manufacturing orders with the cornas model + */ +class pdf_testD extends ModelePDFMo +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.6 = array(5, 6) + */ + public $phpmin = array(5, 6); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe object that emits + */ + public $emetteur; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main", "bills")); + + $this->db = $db; + $this->name = "pdf_testD"; + $this->description = $langs->trans('DocumentModel'); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + + // Page size for A4 format + $this->type = 'pdf'; + $formatarray = pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; + + $this->option_logo = 1; // Display logo + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; //Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } + + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build pdf onto disk + * + * @param CommandeFournisseur $object Id of object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO + */ + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user, $langs, $conf, $hookmanager, $mysoc; + + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (!empty($conf->global->MAIN_USE_FPDF)) { + $outputlangs->charset_output = 'ISO-8859-1'; + } + + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); + + global $outputlangsbis; + $outputlangsbis = null; + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); + } + + $nblines = count($object->lines); + + //Change descriptionfield + $showsupplierSKU = False; + + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + } + + // Loop on each lines to detect if there is at least one image to show + $realpatharray = array(); + + if ($conf->mrp->dir_output) { + $object->fetch_thirdparty(); + + $deja_regle = 0; + $amount_credit_notes_included = 0; + $amount_deposits_included = 0; + //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); + //$amount_deposits_included = $object->getSumDepositsUsed(); + + // Definition of $dir and $file + if ($object->specimen) { + $dir = $conf->mrp->dir_output; + $file = $dir."/SPECIMEN.pdf"; + } else { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->mrp->dir_output.'/'.$objectref; + $file = $dir."/".$objectref.".pdf"; + } + + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); + return 0; + } + } + + if (file_exists($dir)) { + // Add pdfgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + global $action; + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + + $nblines = count($object->lines); + + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) { + $heightforfooter += 6; + } + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb = 0; + $pdf->SetDrawColor(128, 128, 128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { + $pdf->SetCompression(false); + } + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // Does we have at least one line with discount $this->atleastonediscount + + // New page + $pdf->AddPage(); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + $pagenb++; + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0, 0, 0); + + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + + + // Affiche notes + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + + // Extrafields in note + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + + $pagenb = $pdf->getPage(); + if ($notetoshow) { + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; + $pageposbeforenote = $pagenb; + + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); + + $tab_top -= 2; + + $pdf->startTransaction(); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + // Description + $pageposafternote = $pdf->getPage(); + $posyafter = $pdf->GetY(); + + if ($pageposafternote > $pageposbeforenote) { + $pdf->rollbackTransaction(true); + + // prepar pages to receive notes + while ($pagenb < $pageposafternote) { + $pdf->AddPage(); + $pagenb++; + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + // $this->_pagefoot($pdf,$object,$outputlangs,1); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + } + + // back to start + $pdf->setPage($pageposbeforenote); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); + + $posyafter = $pdf->GetY(); + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + //$posyafter = $tab_top_newpage; + } + + + // apply note frame to previus pages + $i = $pageposbeforenote; + while ($i < $pageposafternote) { + $pdf->setPage($i); + + + $pdf->SetDrawColor(128, 128, 128); + // Draw note frame + if ($i > $pageposbeforenote) { + $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else { + $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + } + + // Add footer + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $this->_pagefoot($pdf, $object, $outputlangs, 1); + + $i++; + } + + // apply note frame to last page + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else // No pagebreak + { + $pdf->commitTransaction(); + $posyafter = $pdf->GetY(); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { + // not enough space, need to add page + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + + $posyafter = $tab_top_newpage; + } + } + + $tab_height = $tab_height - $height_note; + $tab_top = $posyafter + 6; + } else { + $height_note = 0; + } + + $nexY = $tab_top + 5; + + // Use new auto collum system + $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); + + // Loop on each lines + $pageposbeforeprintlines = $pdf->getPage(); + $pagenb = $pageposbeforeprintlines; + + $bom = new BOM($this->db); + $bom -> fetch($object->fk_bom); + + $nblines = count($bom->lines); + + for ($i = 0; $i < $nblines; $i++) { + $curY = $nexY; + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0, 0, 0); + + $prod = new Product($this->db); + $prod->fetch($bom->lines[$i]->fk_product); + + // Define size of image if we need it + $imglinesize = array(); + if (!empty($realpatharray[$i])) { + $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + } + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); + + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; + + // We start with Photo of product line + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + $pdf->setPage($pageposbefore + 1); + + $curY = $tab_top_newpage; + + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + + if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage = $curY + $imglinesize['height']; + } + // Description of product line + $curX = $this->posxdesc - 1; + $showpricebeforepagebreak = 1; + + if ($this->getColumnStatus('code')) { + $pdf->startTransaction(); //description + //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU); + $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak + $pdf->rollbackTransaction(true); + + //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU); + $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } else { + // We found a page break + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + } else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = $pdf->GetY(); + } + + $nexY = $pdf->GetY(); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; + } + + if ($this->getColumnStatus('desc')) { + $pdf->startTransaction(); //description + $des = $prod -> description; + $descr = $des;//implode("
", $des); + + $this->printStdColumnContent($pdf, $curY, 'desc', $descr); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak + $pdf->rollbackTransaction(true); + + $this->printStdColumnContent($pdf, $curY, 'desc', $descr); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } else { + // We found a page break + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + } else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = max($posYAfterDescription,$pdf->GetY()); + } + + $nexY = max($nexY,$pdf->GetY()); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; + } + + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + + // Quantity + // Enough for 6 chars + if ($this->getColumnStatus('qty')) { + $qty = $bom->lines[$i]->qty; + $this->printStdColumnContent($pdf, $curY, 'qty', $qty); + $nexY = max($pdf->GetY(), $nexY); + } + + // Quantity + // Enough for 6 chars + if ($this->getColumnStatus('qtytot')) { + $qtytot = $object->qty * $bom->lines[$i]->qty; + $this->printStdColumnContent($pdf, $curY, 'qtytot', $qtytot); + $nexY = max($pdf->GetY(), $nexY); + } + + // Dimensions + if ($this->getColumnStatus('dim')) { + $array = array_filter(array($prod->length, $prod->width, $prod->height)); + $dim = implode("x", $array); + $this->printStdColumnContent($pdf, $curY, 'dim', $dim); + $nexY = max($pdf->GetY(), $nexY); + } + } + + + + + // Show square + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + // Affiche zone infos + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + //$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Affiche zone versements + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); + } + + // Pied de page + $this->_pagefoot($pdf, $object, $outputlangs); + if (method_exists($pdf, 'AliasNbPages')) { + $pdf->AliasNbPages(); + } + + $pdf->Close(); + + $pdf->Output($file, 'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + global $action; + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } + + $this->result = array('fullpath'=>$file); + + return 1; // No error + } else { + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); + return 0; + } + } else { + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + return 0; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show payments table + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object order + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK + */ + protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + { + // phpcs:enable + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show miscellaneous information (payment mode, payment term, ...) + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object to show + * @param int $posy Y + * @param Translate $outputlangs Langs object + * @return integer + */ + protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + // phpcs:enable + global $conf, $mysoc; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // If France, show VAT mention if not applicable + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + + $posy = $pdf->GetY() + 4; + } + + $posxval = 52; + + // Show payments conditions + if (!empty($object->cond_reglement_code) || $object->cond_reglement) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentConditions").':'; + $pdf->MultiCell(80, 4, $titre, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); + $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); + + $posy = $pdf->GetY() + 3; + } + + // Show payment mode + if (!empty($object->mode_reglement_code)) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); + + $posy = $pdf->GetY() + 2; + } + + + return $posy; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show total to pay + * + * @param TCPDF $pdf Object PDF + * @param Facture $object Object invoice + * @param int $deja_regle Montant deja regle + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position pour suite + */ + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + { + // phpcs:enable + global $conf, $mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $tab2_top = $posy; + $tab2_hl = 4; + $pdf->SetFont('', '', $default_font_size - 1); + + // Tableau total + $col1x = 120; + $col2x = 170; + if ($this->page_largeur < 210) { // To work with US executive format + $col2x -= 20; + } + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); + + $useborder = 0; + $index = 0; + + // Total HT + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); + $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); + + // Show VAT by rates and total + $pdf->SetFillColor(248, 248, 248); + + $this->atleastoneratenotnull = 0; + foreach ($this->tva as $tvakey => $tvaval) { + if ($tvakey > 0) { // On affiche pas taux 0 + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($tvakey, 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + if (!$this->atleastoneratenotnull) { // If no vat at all + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + + // Total LocalTax1 + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + } + + // Total LocalTax2 + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + } + } else { + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + //{ + //Local tax 1 + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2', '4', '6'))) { + continue; + } + + foreach ($localtax_rate as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + } + + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //{ + //Local tax 2 + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2', '4', '6'))) { + continue; + } + + foreach ($localtax_rate as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + } + } + + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + + $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetTextColor(0, 0, 0); + + $creditnoteamount = 0; + $depositsamount = 0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (!empty($object->paye)) { + $resteapayer = 0; + } + + if ($deja_regle > 0) { + // Already paid + Deposits + $index++; + + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); + + $index++; + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetTextColor(0, 0, 0); + } + + $index++; + return ($tab2_top + ($tab2_hl * $index)); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop Hide top bar of array + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom = 0; + if ($hidetop) { + $hidetop = -1; + } + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + + if (empty($hidetop)) { + //$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + } + + $pdf->SetDrawColor(128, 128, 128); + $pdf->SetFont('', '', $default_font_size - 1); + + // Output Rect + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + + foreach ($this->cols as $colKey => $colDef) { + if (!$this->getColumnStatus($colKey)) { + continue; + } + + // get title label + $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']); + + // Add column separator + if (!empty($colDef['border-left'])) { + $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); + } + + if (empty($hidetop)) { + $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); + + $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; + $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); + } + } + + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $langs, $conf, $mysoc; + + $ltrdirection = 'L'; + if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; + + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Do not add the BACKGROUND as this is for suppliers + //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + //Affiche le filigrane brouillon - Print Draft Watermark + /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + }*/ + //Print content + + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFont('', 'B', $default_font_size + 3); + + $posx = $this->page_largeur - $this->marge_droite - 100; + $posy = $this->marge_haute; + + $pdf->SetXY($this->marge_gauche, $posy); + + // Logo + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { + if (is_readable($logo)) { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } else { + $pdf->SetTextColor(200, 0, 0); + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); + } + } else { + $text = $this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); + } + + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); + $pdf->MultiCell(100, 3, $title, '', 'R'); + $posy += 1; + + if ($object->ref_supplier) { + $posy += 4; + $pdf->SetFont('', 'B', $default_font_size); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); + $posy += 1; + } + + $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + + if (!empty($conf->global->PDF_SHOW_PROJECT)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $outputlangs->load("projects"); + $posy += 4; + $pdf->SetXY($posx, $posy); + $langs->load("projects"); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); + } + } + + if (!empty($object->date_commande)) { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); + } else { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(255, 0, 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); + } + +// product info + $posy += 7; + $prodToMake = new Product($this->db); + $prodToMake->fetch($object->fk_product); + $pdf->SetFont('', 'B', $default_font_size + 1); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $prodToMake->ref, '', 'R'); + + $posy += 5; + $prodToMake = new Product($this->db); + $prodToMake->fetch($object->fk_product); + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $prodToMake->description, '', 'R'); + + $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height)); + $dim = implode("x", $array); + if (!empty($dim)){ + $posy += 5; + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $dim, '', 'R'); + } + + $posy += 5; + $prodToMake = new Product($this->db); + $prodToMake->fetch($object->fk_product); + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("QtyToProduce").": " .$object->qty, '', 'R'); + + + $pdf->SetTextColor(0, 0, 60); + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { + $usehourmin = 'dayhour'; + } + if (!empty($object->delivery_date)) { + $posy += 4; + $pdf->SetXY($posx - 90, $posy); + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R'); + } + + if ($object->thirdparty->code_fournisseur) { + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + } + + // Get contact + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); + if (count($arrayidcontact) > 0) { + $usertmp = new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); + } + } + + $posy += 1; + $pdf->SetTextColor(0, 0, 60); + + $top_shift = 0; + // Show list of linked objects + $current_y = $pdf->getY(); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + if ($current_y < $pdf->getY()) { + $top_shift = $pdf->getY() - $current_y; + } + + if ($showaddress) { + // Sender properties + $carac_emetteur = ''; + // Add internal contact of proposal if defined + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); + if (count($arrayidcontact) > 0) { + $object->fetch_user($arrayidcontact[0]); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + + // Show sender + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->page_largeur - $this->marge_droite - 80; + } + $hautcadre = 40; + + // Show sender frame + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posx, $posy - 5); + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); + $pdf->SetXY($posx, $posy); + $pdf->SetFillColor(230, 230, 230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0, 0, 60); + + // Show sender name + $pdf->SetXY($posx + 2, $posy + 3); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection); + $posy = $pdf->getY(); + + // Show sender information + $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection); + + + + // If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER' + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) { + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->thirdparty; + } + + //$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + + //$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + + // Show recipient + //$widthrecbox = 100; + //if ($this->page_largeur < 210) { + // $widthrecbox = 84; // To work with US executive format + //} + //$posy = 42 + $top_shift; + //$posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + //if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + // $posx = $this->marge_gauche; + //} + // + //// Show recipient frame + //$pdf->SetTextColor(0, 0, 0); + //$pdf->SetFont('', '', $default_font_size - 2); + //$pdf->SetXY($posx + 2, $posy - 5); + //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); + //$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + // + //// Show recipient name + //$pdf->SetXY($posx + 2, $posy + 3); + //$pdf->SetFont('', 'B', $default_font_size); + //$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection); + // + //$posy = $pdf->getY(); + // + //// Show recipient information + //$pdf->SetFont('', '', $default_font_size - 1); + //$pdf->SetXY($posx + 2, $posy); + //$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); + } + + return $top_shift; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param CommandeFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } + + + + /** + * Define Array Column Field + * + * @param object $object common object + * @param Translate $outputlangs langs + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return null + */ + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + global $conf, $hookmanager; + + // Default field style for content + $this->defaultContentsFieldsStyle = array( + 'align' => 'R', // R,C,L + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + // Default field style for content + $this->defaultTitlesFieldsStyle = array( + 'align' => 'C', // R,C,L + 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + /* + * For exemple + $this->cols['theColKey'] = array( + 'rank' => $rank, // int : use for ordering columns + 'width' => 20, // the column width in mm + 'title' => array( + 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + 'label' => ' ', // the final label : used fore final generated text + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + */ + $rank = 0; + $this->cols['code'] = array( + 'rank' => $rank, + 'status' => false, + 'width' => 35, // in mm + 'title' => array( + 'textkey' => 'Ref' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['code']['status'] = true; + + $rank = 1; // do not use negative rank + $this->cols['desc'] = array( + 'rank' => $rank, + 'width' => false, // only for desc + 'status' => true, + 'title' => array( + 'textkey' => 'Designation', // use lang key is usefull in somme case with module + 'align' => 'L', + // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + // 'label' => ' ', // the final label + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'border-left' => true, + 'content' => array( + 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + + $rank = $rank + 10; + $this->cols['photo'] = array( + 'rank' => $rank, + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'Photo', + 'label' => ' ' + ), + 'content' => array( + 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'border-left' => false, // remove left line separator + ); + + if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { + $this->cols['photo']['status'] = true; + } + + $rank = $rank + 10; + $this->cols['dim'] = array( + 'rank' => $rank, + 'status' => false, + 'width' => 25, // in mm + 'title' => array( + 'textkey' => 'Size' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['dim']['status'] = true; + + $rank = $rank + 10; + $this->cols['qty'] = array( + 'rank' => $rank, + 'width' => 16, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'Qty' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['qty']['status'] = true; + + $rank = $rank + 10; + $this->cols['qtytot'] = array( + 'rank' => $rank, + 'width' => 25, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'QtyTot' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['qtytot']['status'] = true; + + // Add extrafields cols + if (!empty($object->lines)) { + $line = reset($object->lines); + $this->defineColumnExtrafield($line, $outputlangs, $hidedetails); + } + + $parameters = array( + 'object' => $object, + 'outputlangs' => $outputlangs, + 'hidedetails' => $hidedetails, + 'hidedesc' => $hidedesc, + 'hideref' => $hideref + ); + + $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif (empty($reshook)) { + $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys + } else { + $this->cols = $hookmanager->resArray; + } + } +} From 35f3742d084f621a022b668782d2ebf79c718cb8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 4 Sep 2021 11:05:50 +0000 Subject: [PATCH 115/229] Fixing style errors. --- .../modules/mrp/doc/pdf_testD.modules.php | 3024 ++++++++--------- 1 file changed, 1512 insertions(+), 1512 deletions(-) diff --git a/htdocs/core/modules/mrp/doc/pdf_testD.modules.php b/htdocs/core/modules/mrp/doc/pdf_testD.modules.php index 59843be1a89..f370fe21b2b 100644 --- a/htdocs/core/modules/mrp/doc/pdf_testD.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_testD.modules.php @@ -1,1512 +1,1512 @@ - - * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2015 Marcos García - * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 Frédéric France - * Copyright (C) 2018 Frédéric France - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see https://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php - * \ingroup fournisseur - * \brief File of class to generate suppliers orders from cornas model - */ - -require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; - - -/** - * Class to generate the manufacturing orders with the cornas model - */ -class pdf_testD extends ModelePDFMo -{ - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var int Save the name of generated file as the main doc when generating a doc with this template - */ - public $update_main_doc_field; - - /** - * @var string document type - */ - public $type; - - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.6 = array(5, 6) - */ - public $phpmin = array(5, 6); - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ - public $marge_gauche; - - /** - * @var int marge_droite - */ - public $marge_droite; - - /** - * @var int marge_haute - */ - public $marge_haute; - - /** - * @var int marge_basse - */ - public $marge_basse; - - /** - * Issuer - * @var Societe object that emits - */ - public $emetteur; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $conf, $langs, $mysoc; - - // Load translation files required by the page - $langs->loadLangs(array("main", "bills")); - - $this->db = $db; - $this->name = "pdf_testD"; - $this->description = $langs->trans('DocumentModel'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template - - // Page size for A4 format - $this->type = 'pdf'; - $formatarray = pdf_getFormat(); - $this->page_largeur = $formatarray['width']; - $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur, $this->page_hauteur); - $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; - $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; - $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; - $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - - $this->option_logo = 1; // Display logo - $this->option_codeproduitservice = 1; // Display product-service code - $this->option_multilang = 1; //Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts - - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - - // Define position of columns - $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Function to build pdf onto disk - * - * @param CommandeFournisseur $object Id of object to generate - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return int 1=OK, 0=KO - */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { - // phpcs:enable - global $user, $langs, $conf, $hookmanager, $mysoc; - - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) { - $outputlangs->charset_output = 'ISO-8859-1'; - } - - // Load translation files required by the page - $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); - - global $outputlangsbis; - $outputlangsbis = null; - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - $outputlangsbis = new Translate('', $conf); - $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); - $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); - } - - $nblines = count($object->lines); - - //Change descriptionfield - $showsupplierSKU = False; - - $hidetop = 0; - if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { - $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; - } - - // Loop on each lines to detect if there is at least one image to show - $realpatharray = array(); - - if ($conf->mrp->dir_output) { - $object->fetch_thirdparty(); - - $deja_regle = 0; - $amount_credit_notes_included = 0; - $amount_deposits_included = 0; - //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); - //$amount_deposits_included = $object->getSumDepositsUsed(); - - // Definition of $dir and $file - if ($object->specimen) { - $dir = $conf->mrp->dir_output; - $file = $dir."/SPECIMEN.pdf"; - } else { - $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->mrp->dir_output.'/'.$objectref; - $file = $dir."/".$objectref.".pdf"; - } - - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { - $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); - return 0; - } - } - - if (file_exists($dir)) { - // Add pdfgeneration hook - if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($this->db); - } - $hookmanager->initHooks(array('pdfgeneration')); - $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); - global $action; - $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - - $nblines = count($object->lines); - - $pdf = pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) { - $heightforfooter += 6; - } - $pdf->SetAutoPageBreak(1, 0); - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); - $tplidx = $pdf->importPage(1); - } - - $pdf->Open(); - $pagenb = 0; - $pdf->SetDrawColor(128, 128, 128); - - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Order")); - $pdf->SetCreator("Dolibarr ".DOL_VERSION); - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { - $pdf->SetCompression(false); - } - - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - - // Does we have at least one line with discount $this->atleastonediscount - - // New page - $pdf->AddPage(); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - $pagenb++; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0, 0, 0); - - $tab_top = 90 + $top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); - - - // Affiche notes - $notetoshow = empty($object->note_public) ? '' : $object->note_public; - - // Extrafields in note - $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); - if (!empty($extranote)) { - $notetoshow = dol_concatdesc($notetoshow, $extranote); - } - - $pagenb = $pdf->getPage(); - if ($notetoshow) { - $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; - $pageposbeforenote = $pagenb; - - $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); - $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - - $tab_top -= 2; - - $pdf->startTransaction(); - - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - // Description - $pageposafternote = $pdf->getPage(); - $posyafter = $pdf->GetY(); - - if ($pageposafternote > $pageposbeforenote) { - $pdf->rollbackTransaction(true); - - // prepar pages to receive notes - while ($pagenb < $pageposafternote) { - $pdf->AddPage(); - $pagenb++; - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - // $this->_pagefoot($pdf,$object,$outputlangs,1); - $pdf->setTopMargin($tab_top_newpage); - // The only function to edit the bottom margin of current page to set it. - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); - } - - // back to start - $pdf->setPage($pageposbeforenote); - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - $pageposafternote = $pdf->getPage(); - - $posyafter = $pdf->GetY(); - - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text - $pdf->AddPage('', '', true); - $pagenb++; - $pageposafternote++; - $pdf->setPage($pageposafternote); - $pdf->setTopMargin($tab_top_newpage); - // The only function to edit the bottom margin of current page to set it. - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); - //$posyafter = $tab_top_newpage; - } - - - // apply note frame to previus pages - $i = $pageposbeforenote; - while ($i < $pageposafternote) { - $pdf->setPage($i); - - - $pdf->SetDrawColor(128, 128, 128); - // Draw note frame - if ($i > $pageposbeforenote) { - $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else { - $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - } - - // Add footer - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - $this->_pagefoot($pdf, $object, $outputlangs, 1); - - $i++; - } - - // apply note frame to last page - $pdf->setPage($pageposafternote); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { - $pdf->commitTransaction(); - $posyafter = $pdf->GetY(); - $height_note = $posyafter - $tab_top; - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - - - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { - // not enough space, need to add page - $pdf->AddPage('', '', true); - $pagenb++; - $pageposafternote++; - $pdf->setPage($pageposafternote); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - - $posyafter = $tab_top_newpage; - } - } - - $tab_height = $tab_height - $height_note; - $tab_top = $posyafter + 6; - } else { - $height_note = 0; - } - - $nexY = $tab_top + 5; - - // Use new auto collum system - $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - - // Loop on each lines - $pageposbeforeprintlines = $pdf->getPage(); - $pagenb = $pageposbeforeprintlines; - - $bom = new BOM($this->db); - $bom -> fetch($object->fk_bom); - - $nblines = count($bom->lines); - - for ($i = 0; $i < $nblines; $i++) { - $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage - $pdf->SetTextColor(0, 0, 0); - - $prod = new Product($this->db); - $prod->fetch($bom->lines[$i]->fk_product); - - // Define size of image if we need it - $imglinesize = array(); - if (!empty($realpatharray[$i])) { - $imglinesize = pdf_getSizeForImage($realpatharray[$i]); - } - - $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore = $pdf->getPage(); - - $showpricebeforepagebreak = 1; - $posYAfterImage = 0; - $posYAfterDescription = 0; - - // We start with Photo of product line - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $pdf->setPage($pageposbefore + 1); - - $curY = $tab_top_newpage; - - // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { - $showpricebeforepagebreak = 1; - } else { - $showpricebeforepagebreak = 0; - } - } - - if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { - $curX = $this->posxpicture - 1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi - // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage = $curY + $imglinesize['height']; - } - // Description of product line - $curX = $this->posxdesc - 1; - $showpricebeforepagebreak = 1; - - if ($this->getColumnStatus('code')) { - $pdf->startTransaction(); //description - //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU); - $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref); - - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - if ($pageposafter > $pageposbefore) { // There is a pagebreak - $pdf->rollbackTransaction(true); - - //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU); - $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref); - - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter + 1); - } else { - // We found a page break - // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { - $showpricebeforepagebreak = 1; - } else { - $showpricebeforepagebreak = 0; - } - } - } else // No pagebreak - { - $pdf->commitTransaction(); - } - $posYAfterDescription = $pdf->GetY(); - } - - $nexY = $pdf->GetY(); - $pageposafter = $pdf->getPage(); - $pdf->setPage($pageposbefore); - $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - - // We suppose that a too long description is moved completely on next page - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; - } - - if ($this->getColumnStatus('desc')) { - $pdf->startTransaction(); //description - $des = $prod -> description; - $descr = $des;//implode("
", $des); - - $this->printStdColumnContent($pdf, $curY, 'desc', $descr); - - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - if ($pageposafter > $pageposbefore) { // There is a pagebreak - $pdf->rollbackTransaction(true); - - $this->printStdColumnContent($pdf, $curY, 'desc', $descr); - - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter + 1); - } else { - // We found a page break - // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { - $showpricebeforepagebreak = 1; - } else { - $showpricebeforepagebreak = 0; - } - } - } else // No pagebreak - { - $pdf->commitTransaction(); - } - $posYAfterDescription = max($posYAfterDescription,$pdf->GetY()); - } - - $nexY = max($nexY,$pdf->GetY()); - $pageposafter = $pdf->getPage(); - $pdf->setPage($pageposbefore); - $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - - // We suppose that a too long description is moved completely on next page - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; - } - - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut - - // Quantity - // Enough for 6 chars - if ($this->getColumnStatus('qty')) { - $qty = $bom->lines[$i]->qty; - $this->printStdColumnContent($pdf, $curY, 'qty', $qty); - $nexY = max($pdf->GetY(), $nexY); - } - - // Quantity - // Enough for 6 chars - if ($this->getColumnStatus('qtytot')) { - $qtytot = $object->qty * $bom->lines[$i]->qty; - $this->printStdColumnContent($pdf, $curY, 'qtytot', $qtytot); - $nexY = max($pdf->GetY(), $nexY); - } - - // Dimensions - if ($this->getColumnStatus('dim')) { - $array = array_filter(array($prod->length, $prod->width, $prod->height)); - $dim = implode("x", $array); - $this->printStdColumnContent($pdf, $curY, 'dim', $dim); - $nexY = max($pdf->GetY(), $nexY); - } - } - - - - - // Show square - if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } - - // Affiche zone infos - $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - - // Affiche zone totaux - //$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - - // Affiche zone versements - if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { - $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); - } - - // Pied de page - $this->_pagefoot($pdf, $object, $outputlangs); - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } - - $pdf->Close(); - - $pdf->Output($file, 'F'); - - // Add pdfgeneration hook - $hookmanager->initHooks(array('pdfgeneration')); - $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); - global $action; - $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; - } - - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - - $this->result = array('fullpath'=>$file); - - return 1; // No error - } else { - $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); - return 0; - } - } else { - $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); - return 0; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Show payments table - * - * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object order - * @param int $posy Position y in PDF - * @param Translate $outputlangs Object langs for output - * @return int <0 if KO, >0 if OK - */ - protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs) - { - // phpcs:enable - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Show miscellaneous information (payment mode, payment term, ...) - * - * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object to show - * @param int $posy Y - * @param Translate $outputlangs Langs object - * @return integer - */ - protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) - { - // phpcs:enable - global $conf, $mysoc; - $default_font_size = pdf_getPDFFontSize($outputlangs); - - // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - - $posy = $pdf->GetY() + 4; - } - - $posxval = 52; - - // Show payments conditions - if (!empty($object->cond_reglement_code) || $object->cond_reglement) { - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentConditions").':'; - $pdf->MultiCell(80, 4, $titre, 0, 'L'); - - $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); - $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); - $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); - - $posy = $pdf->GetY() + 3; - } - - // Show payment mode - if (!empty($object->mode_reglement_code)) { - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentMode").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); - - $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); - $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); - - $posy = $pdf->GetY() + 2; - } - - - return $posy; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Show total to pay - * - * @param TCPDF $pdf Object PDF - * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart - * @param Translate $outputlangs Objet langs - * @return int Position pour suite - */ - protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) - { - // phpcs:enable - global $conf, $mysoc; - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $tab2_top = $posy; - $tab2_hl = 4; - $pdf->SetFont('', '', $default_font_size - 1); - - // Tableau total - $col1x = 120; - $col2x = 170; - if ($this->page_largeur < 210) { // To work with US executive format - $col2x -= 20; - } - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - - $useborder = 0; - $index = 0; - - // Total HT - $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - - $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); - $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); - - // Show VAT by rates and total - $pdf->SetFillColor(248, 248, 248); - - $this->atleastoneratenotnull = 0; - foreach ($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) { // On affiche pas taux 0 - $this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl = ''; - - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - - $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); - } - } - if (!$this->atleastoneratenotnull) { // If no vat at all - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); - - // Total LocalTax1 - if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); - } - - // Total LocalTax2 - if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); - } - } else { - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') - //{ - //Local tax 1 - foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2', '4', '6'))) { - continue; - } - - foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey != 0) { // On affiche pas taux 0 - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - } - - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - //{ - //Local tax 2 - foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2', '4', '6'))) { - continue; - } - - foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey != 0) { // On affiche pas taux 0 - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); - } - } - } - } - - // Total TTC - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0, 0, 60); - $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - - $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetTextColor(0, 0, 0); - - $creditnoteamount = 0; - $depositsamount = 0; - //$creditnoteamount=$object->getSumCreditNotesUsed(); - //$depositsamount=$object->getSumDepositsUsed(); - //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if (!empty($object->paye)) { - $resteapayer = 0; - } - - if ($deja_regle > 0) { - // Already paid + Deposits - $index++; - - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); - - $index++; - $pdf->SetTextColor(0, 0, 60); - $pdf->SetFillColor(224, 224, 224); - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); - - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetTextColor(0, 0, 0); - } - - $index++; - return ($tab2_top + ($tab2_hl * $index)); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Show table for lines - * - * @param TCPDF $pdf Object PDF - * @param string $tab_top Top position of table - * @param string $tab_height Height of table (rectangle) - * @param int $nexY Y (not used) - * @param Translate $outputlangs Langs object - * @param int $hidetop Hide top bar of array - * @param int $hidebottom Hide bottom bar of array - * @param string $currency Currency code - * @return void - */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') - { - global $conf; - - // Force to disable hidetop and hidebottom - $hidebottom = 0; - if ($hidetop) { - $hidetop = -1; - } - - $currency = !empty($currency) ? $currency : $conf->currency; - $default_font_size = pdf_getPDFFontSize($outputlangs); - - // Amount in (at tab_top - 1) - $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); - - if (empty($hidetop)) { - //$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); - } - } - - $pdf->SetDrawColor(128, 128, 128); - $pdf->SetFont('', '', $default_font_size - 1); - - // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter - - foreach ($this->cols as $colKey => $colDef) { - if (!$this->getColumnStatus($colKey)) { - continue; - } - - // get title label - $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']); - - // Add column separator - if (!empty($colDef['border-left'])) { - $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); - } - - if (empty($hidetop)) { - $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); - - $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; - $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); - } - } - - if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Show top header of page. - * - * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void - */ - protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) - { - global $langs, $conf, $mysoc; - - $ltrdirection = 'L'; - if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; - - // Load translation files required by the page - $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - // Do not add the BACKGROUND as this is for suppliers - //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); - - //Affiche le filigrane brouillon - Print Draft Watermark - /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) - { - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); - }*/ - //Print content - - $pdf->SetTextColor(0, 0, 60); - $pdf->SetFont('', 'B', $default_font_size + 3); - - $posx = $this->page_largeur - $this->marge_droite - 100; - $posy = $this->marge_haute; - - $pdf->SetXY($this->marge_gauche, $posy); - - // Logo - $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) { - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); - } - - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); - $pdf->MultiCell(100, 3, $title, '', 'R'); - $posy += 1; - - if ($object->ref_supplier) { - $posy += 4; - $pdf->SetFont('', 'B', $default_font_size); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); - $posy += 1; - } - - $pdf->SetFont('', '', $default_font_size - 1); - if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { - $object->fetch_projet(); - if (!empty($object->project->ref)) { - $posy += 3; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); - } - } - - if (!empty($conf->global->PDF_SHOW_PROJECT)) { - $object->fetch_projet(); - if (!empty($object->project->ref)) { - $outputlangs->load("projects"); - $posy += 4; - $pdf->SetXY($posx, $posy); - $langs->load("projects"); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); - } - } - - if (!empty($object->date_commande)) { - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); - } else { - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(255, 0, 0); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); - } - -// product info - $posy += 7; - $prodToMake = new Product($this->db); - $prodToMake->fetch($object->fk_product); - $pdf->SetFont('', 'B', $default_font_size + 1); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $prodToMake->ref, '', 'R'); - - $posy += 5; - $prodToMake = new Product($this->db); - $prodToMake->fetch($object->fk_product); - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $prodToMake->description, '', 'R'); - - $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height)); - $dim = implode("x", $array); - if (!empty($dim)){ - $posy += 5; - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $dim, '', 'R'); - } - - $posy += 5; - $prodToMake = new Product($this->db); - $prodToMake->fetch($object->fk_product); - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("QtyToProduce").": " .$object->qty, '', 'R'); - - - $pdf->SetTextColor(0, 0, 60); - $usehourmin = 'day'; - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { - $usehourmin = 'dayhour'; - } - if (!empty($object->delivery_date)) { - $posy += 4; - $pdf->SetXY($posx - 90, $posy); - $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R'); - } - - if ($object->thirdparty->code_fournisseur) { - $posy += 4; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); - } - - // Get contact - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); - if (count($arrayidcontact) > 0) { - $usertmp = new User($this->db); - $usertmp->fetch($arrayidcontact[0]); - $posy += 4; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); - } - } - - $posy += 1; - $pdf->SetTextColor(0, 0, 60); - - $top_shift = 0; - // Show list of linked objects - $current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - if ($current_y < $pdf->getY()) { - $top_shift = $pdf->getY() - $current_y; - } - - if ($showaddress) { - // Sender properties - $carac_emetteur = ''; - // Add internal contact of proposal if defined - $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); - if (count($arrayidcontact) > 0) { - $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; - } - - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); - - // Show sender - $posy = 42 + $top_shift; - $posx = $this->marge_gauche; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { - $posx = $this->page_largeur - $this->marge_droite - 80; - } - $hautcadre = 40; - - // Show sender frame - $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy - 5); - $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); - $pdf->SetXY($posx, $posy); - $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); - $pdf->SetTextColor(0, 0, 60); - - // Show sender name - $pdf->SetXY($posx + 2, $posy + 3); - $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection); - $posy = $pdf->getY(); - - // Show sender information - $pdf->SetXY($posx + 2, $posy); - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection); - - - - // If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER' - $usecontact = false; - $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); - if (count($arrayidcontact) > 0) { - $usecontact = true; - $result = $object->fetch_contact($arrayidcontact[0]); - } - - // Recipient name - if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { - $thirdparty = $object->contact; - } else { - $thirdparty = $object->thirdparty; - } - - //$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - - //$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); - - // Show recipient - //$widthrecbox = 100; - //if ($this->page_largeur < 210) { - // $widthrecbox = 84; // To work with US executive format - //} - //$posy = 42 + $top_shift; - //$posx = $this->page_largeur - $this->marge_droite - $widthrecbox; - //if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { - // $posx = $this->marge_gauche; - //} - // - //// Show recipient frame - //$pdf->SetTextColor(0, 0, 0); - //$pdf->SetFont('', '', $default_font_size - 2); - //$pdf->SetXY($posx + 2, $posy - 5); - //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); - //$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); - // - //// Show recipient name - //$pdf->SetXY($posx + 2, $posy + 3); - //$pdf->SetFont('', 'B', $default_font_size); - //$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection); - // - //$posy = $pdf->getY(); - // - //// Show recipient information - //$pdf->SetFont('', '', $default_font_size - 1); - //$pdf->SetXY($posx + 2, $posy); - //$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); - } - - return $top_shift; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Show footer of page. Need this->emetteur object - * - * @param TCPDF $pdf PDF - * @param CommandeFournisseur $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } - - - - /** - * Define Array Column Field - * - * @param object $object common object - * @param Translate $outputlangs langs - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return null - */ - public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { - global $conf, $hookmanager; - - // Default field style for content - $this->defaultContentsFieldsStyle = array( - 'align' => 'R', // R,C,L - 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ); - - // Default field style for content - $this->defaultTitlesFieldsStyle = array( - 'align' => 'C', // R,C,L - 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ); - - /* - * For exemple - $this->cols['theColKey'] = array( - 'rank' => $rank, // int : use for ordering columns - 'width' => 20, // the column width in mm - 'title' => array( - 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label - 'label' => ' ', // the final label : used fore final generated text - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'content' => array( - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - ); - */ - $rank = 0; - $this->cols['code'] = array( - 'rank' => $rank, - 'status' => false, - 'width' => 35, // in mm - 'title' => array( - 'textkey' => 'Ref' - ), - 'border-left' => true, // add left line separator - ); - $this->cols['code']['status'] = true; - - $rank = 1; // do not use negative rank - $this->cols['desc'] = array( - 'rank' => $rank, - 'width' => false, // only for desc - 'status' => true, - 'title' => array( - 'textkey' => 'Designation', // use lang key is usefull in somme case with module - 'align' => 'L', - // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label - // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'border-left' => true, - 'content' => array( - 'align' => 'L', - 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - ); - - $rank = $rank + 10; - $this->cols['photo'] = array( - 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm - 'status' => false, - 'title' => array( - 'textkey' => 'Photo', - 'label' => ' ' - ), - 'content' => array( - 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'border-left' => false, // remove left line separator - ); - - if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { - $this->cols['photo']['status'] = true; - } - - $rank = $rank + 10; - $this->cols['dim'] = array( - 'rank' => $rank, - 'status' => false, - 'width' => 25, // in mm - 'title' => array( - 'textkey' => 'Size' - ), - 'border-left' => true, // add left line separator - ); - $this->cols['dim']['status'] = true; - - $rank = $rank + 10; - $this->cols['qty'] = array( - 'rank' => $rank, - 'width' => 16, // in mm - 'status' => true, - 'title' => array( - 'textkey' => 'Qty' - ), - 'border-left' => true, // add left line separator - ); - $this->cols['qty']['status'] = true; - - $rank = $rank + 10; - $this->cols['qtytot'] = array( - 'rank' => $rank, - 'width' => 25, // in mm - 'status' => true, - 'title' => array( - 'textkey' => 'QtyTot' - ), - 'border-left' => true, // add left line separator - ); - $this->cols['qtytot']['status'] = true; - - // Add extrafields cols - if (!empty($object->lines)) { - $line = reset($object->lines); - $this->defineColumnExtrafield($line, $outputlangs, $hidedetails); - } - - $parameters = array( - 'object' => $object, - 'outputlangs' => $outputlangs, - 'hidedetails' => $hidedetails, - 'hidedesc' => $hidedesc, - 'hideref' => $hideref - ); - - $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } elseif (empty($reshook)) { - $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys - } else { - $this->cols = $hookmanager->resArray; - } - } -} + + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2015 Marcos García + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php + * \ingroup fournisseur + * \brief File of class to generate suppliers orders from cornas model + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to generate the manufacturing orders with the cornas model + */ +class pdf_testD extends ModelePDFMo +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.6 = array(5, 6) + */ + public $phpmin = array(5, 6); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe object that emits + */ + public $emetteur; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main", "bills")); + + $this->db = $db; + $this->name = "pdf_testD"; + $this->description = $langs->trans('DocumentModel'); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + + // Page size for A4 format + $this->type = 'pdf'; + $formatarray = pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; + + $this->option_logo = 1; // Display logo + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; //Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } + + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build pdf onto disk + * + * @param CommandeFournisseur $object Id of object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO + */ + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user, $langs, $conf, $hookmanager, $mysoc; + + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (!empty($conf->global->MAIN_USE_FPDF)) { + $outputlangs->charset_output = 'ISO-8859-1'; + } + + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); + + global $outputlangsbis; + $outputlangsbis = null; + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); + } + + $nblines = count($object->lines); + + //Change descriptionfield + $showsupplierSKU = false; + + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + } + + // Loop on each lines to detect if there is at least one image to show + $realpatharray = array(); + + if ($conf->mrp->dir_output) { + $object->fetch_thirdparty(); + + $deja_regle = 0; + $amount_credit_notes_included = 0; + $amount_deposits_included = 0; + //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); + //$amount_deposits_included = $object->getSumDepositsUsed(); + + // Definition of $dir and $file + if ($object->specimen) { + $dir = $conf->mrp->dir_output; + $file = $dir."/SPECIMEN.pdf"; + } else { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->mrp->dir_output.'/'.$objectref; + $file = $dir."/".$objectref.".pdf"; + } + + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); + return 0; + } + } + + if (file_exists($dir)) { + // Add pdfgeneration hook + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + global $action; + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + + $nblines = count($object->lines); + + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) { + $heightforfooter += 6; + } + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb = 0; + $pdf->SetDrawColor(128, 128, 128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { + $pdf->SetCompression(false); + } + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // Does we have at least one line with discount $this->atleastonediscount + + // New page + $pdf->AddPage(); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + $pagenb++; + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0, 0, 0); + + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + + + // Affiche notes + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + + // Extrafields in note + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + + $pagenb = $pdf->getPage(); + if ($notetoshow) { + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; + $pageposbeforenote = $pagenb; + + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); + + $tab_top -= 2; + + $pdf->startTransaction(); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + // Description + $pageposafternote = $pdf->getPage(); + $posyafter = $pdf->GetY(); + + if ($pageposafternote > $pageposbeforenote) { + $pdf->rollbackTransaction(true); + + // prepar pages to receive notes + while ($pagenb < $pageposafternote) { + $pdf->AddPage(); + $pagenb++; + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + // $this->_pagefoot($pdf,$object,$outputlangs,1); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + } + + // back to start + $pdf->setPage($pageposbeforenote); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); + + $posyafter = $pdf->GetY(); + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + //$posyafter = $tab_top_newpage; + } + + + // apply note frame to previus pages + $i = $pageposbeforenote; + while ($i < $pageposafternote) { + $pdf->setPage($i); + + + $pdf->SetDrawColor(128, 128, 128); + // Draw note frame + if ($i > $pageposbeforenote) { + $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else { + $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + } + + // Add footer + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $this->_pagefoot($pdf, $object, $outputlangs, 1); + + $i++; + } + + // apply note frame to last page + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else // No pagebreak + { + $pdf->commitTransaction(); + $posyafter = $pdf->GetY(); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { + // not enough space, need to add page + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + + $posyafter = $tab_top_newpage; + } + } + + $tab_height = $tab_height - $height_note; + $tab_top = $posyafter + 6; + } else { + $height_note = 0; + } + + $nexY = $tab_top + 5; + + // Use new auto collum system + $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); + + // Loop on each lines + $pageposbeforeprintlines = $pdf->getPage(); + $pagenb = $pageposbeforeprintlines; + + $bom = new BOM($this->db); + $bom -> fetch($object->fk_bom); + + $nblines = count($bom->lines); + + for ($i = 0; $i < $nblines; $i++) { + $curY = $nexY; + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0, 0, 0); + + $prod = new Product($this->db); + $prod->fetch($bom->lines[$i]->fk_product); + + // Define size of image if we need it + $imglinesize = array(); + if (!empty($realpatharray[$i])) { + $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + } + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); + + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; + + // We start with Photo of product line + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } + $pdf->setPage($pageposbefore + 1); + + $curY = $tab_top_newpage; + + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + + if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage = $curY + $imglinesize['height']; + } + // Description of product line + $curX = $this->posxdesc - 1; + $showpricebeforepagebreak = 1; + + if ($this->getColumnStatus('code')) { + $pdf->startTransaction(); //description + //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU); + $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak + $pdf->rollbackTransaction(true); + + //$this->printColDescContent($pdf, $curY, 'code', $object, $i, $outputlangs, $hideref, $hidedesc, $showsupplierSKU); + $this->printStdColumnContent($pdf, $curY, 'code', $prod->ref); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } else { + // We found a page break + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + } else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = $pdf->GetY(); + } + + $nexY = $pdf->GetY(); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; + } + + if ($this->getColumnStatus('desc')) { + $pdf->startTransaction(); //description + $des = $prod -> description; + $descr = $des;//implode("
", $des); + + $this->printStdColumnContent($pdf, $curY, 'desc', $descr); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak + $pdf->rollbackTransaction(true); + + $this->printStdColumnContent($pdf, $curY, 'desc', $descr); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + } elseif ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } else { + // We found a page break + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } + } + } else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = max($posYAfterDescription, $pdf->GetY()); + } + + $nexY = max($nexY, $pdf->GetY()); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; + } + + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + + // Quantity + // Enough for 6 chars + if ($this->getColumnStatus('qty')) { + $qty = $bom->lines[$i]->qty; + $this->printStdColumnContent($pdf, $curY, 'qty', $qty); + $nexY = max($pdf->GetY(), $nexY); + } + + // Quantity + // Enough for 6 chars + if ($this->getColumnStatus('qtytot')) { + $qtytot = $object->qty * $bom->lines[$i]->qty; + $this->printStdColumnContent($pdf, $curY, 'qtytot', $qtytot); + $nexY = max($pdf->GetY(), $nexY); + } + + // Dimensions + if ($this->getColumnStatus('dim')) { + $array = array_filter(array($prod->length, $prod->width, $prod->height)); + $dim = implode("x", $array); + $this->printStdColumnContent($pdf, $curY, 'dim', $dim); + $nexY = max($pdf->GetY(), $nexY); + } + } + + + + + // Show square + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + // Affiche zone infos + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + //$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Affiche zone versements + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); + } + + // Pied de page + $this->_pagefoot($pdf, $object, $outputlangs); + if (method_exists($pdf, 'AliasNbPages')) { + $pdf->AliasNbPages(); + } + + $pdf->Close(); + + $pdf->Output($file, 'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + global $action; + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } + + $this->result = array('fullpath'=>$file); + + return 1; // No error + } else { + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); + return 0; + } + } else { + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + return 0; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show payments table + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object order + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK + */ + protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + { + // phpcs:enable + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show miscellaneous information (payment mode, payment term, ...) + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object to show + * @param int $posy Y + * @param Translate $outputlangs Langs object + * @return integer + */ + protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + // phpcs:enable + global $conf, $mysoc; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // If France, show VAT mention if not applicable + if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + + $posy = $pdf->GetY() + 4; + } + + $posxval = 52; + + // Show payments conditions + if (!empty($object->cond_reglement_code) || $object->cond_reglement) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentConditions").':'; + $pdf->MultiCell(80, 4, $titre, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); + $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); + + $posy = $pdf->GetY() + 3; + } + + // Show payment mode + if (!empty($object->mode_reglement_code)) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); + + $posy = $pdf->GetY() + 2; + } + + + return $posy; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show total to pay + * + * @param TCPDF $pdf Object PDF + * @param Facture $object Object invoice + * @param int $deja_regle Montant deja regle + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position pour suite + */ + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + { + // phpcs:enable + global $conf, $mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $tab2_top = $posy; + $tab2_hl = 4; + $pdf->SetFont('', '', $default_font_size - 1); + + // Tableau total + $col1x = 120; + $col2x = 170; + if ($this->page_largeur < 210) { // To work with US executive format + $col2x -= 20; + } + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); + + $useborder = 0; + $index = 0; + + // Total HT + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); + $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); + + // Show VAT by rates and total + $pdf->SetFillColor(248, 248, 248); + + $this->atleastoneratenotnull = 0; + foreach ($this->tva as $tvakey => $tvaval) { + if ($tvakey > 0) { // On affiche pas taux 0 + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($tvakey, 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + if (!$this->atleastoneratenotnull) { // If no vat at all + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + + // Total LocalTax1 + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + } + + // Total LocalTax2 + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + } + } else { + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + //{ + //Local tax 1 + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2', '4', '6'))) { + continue; + } + + foreach ($localtax_rate as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + } + + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //{ + //Local tax 2 + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2', '4', '6'))) { + continue; + } + + foreach ($localtax_rate as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + } + } + + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + + $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetTextColor(0, 0, 0); + + $creditnoteamount = 0; + $depositsamount = 0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (!empty($object->paye)) { + $resteapayer = 0; + } + + if ($deja_regle > 0) { + // Already paid + Deposits + $index++; + + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); + + $index++; + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetTextColor(0, 0, 0); + } + + $index++; + return ($tab2_top + ($tab2_hl * $index)); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop Hide top bar of array + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom = 0; + if ($hidetop) { + $hidetop = -1; + } + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + + if (empty($hidetop)) { + //$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + } + + $pdf->SetDrawColor(128, 128, 128); + $pdf->SetFont('', '', $default_font_size - 1); + + // Output Rect + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + + foreach ($this->cols as $colKey => $colDef) { + if (!$this->getColumnStatus($colKey)) { + continue; + } + + // get title label + $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']); + + // Add column separator + if (!empty($colDef['border-left'])) { + $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); + } + + if (empty($hidetop)) { + $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); + + $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; + $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); + } + } + + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param CommandeFournisseur $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $langs, $conf, $mysoc; + + $ltrdirection = 'L'; + if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; + + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Do not add the BACKGROUND as this is for suppliers + //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + //Affiche le filigrane brouillon - Print Draft Watermark + /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + }*/ + //Print content + + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFont('', 'B', $default_font_size + 3); + + $posx = $this->page_largeur - $this->marge_droite - 100; + $posy = $this->marge_haute; + + $pdf->SetXY($this->marge_gauche, $posy); + + // Logo + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) { + if (is_readable($logo)) { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } else { + $pdf->SetTextColor(200, 0, 0); + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); + } + } else { + $text = $this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); + } + + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); + $pdf->MultiCell(100, 3, $title, '', 'R'); + $posy += 1; + + if ($object->ref_supplier) { + $posy += 4; + $pdf->SetFont('', 'B', $default_font_size); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); + $posy += 1; + } + + $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + + if (!empty($conf->global->PDF_SHOW_PROJECT)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $outputlangs->load("projects"); + $posy += 4; + $pdf->SetXY($posx, $posy); + $langs->load("projects"); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); + } + } + + if (!empty($object->date_commande)) { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); + } else { + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(255, 0, 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); + } + + // product info + $posy += 7; + $prodToMake = new Product($this->db); + $prodToMake->fetch($object->fk_product); + $pdf->SetFont('', 'B', $default_font_size + 1); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $prodToMake->ref, '', 'R'); + + $posy += 5; + $prodToMake = new Product($this->db); + $prodToMake->fetch($object->fk_product); + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $prodToMake->description, '', 'R'); + + $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height)); + $dim = implode("x", $array); + if (!empty($dim)) { + $posy += 5; + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $dim, '', 'R'); + } + + $posy += 5; + $prodToMake = new Product($this->db); + $prodToMake->fetch($object->fk_product); + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("QtyToProduce").": " .$object->qty, '', 'R'); + + + $pdf->SetTextColor(0, 0, 60); + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) { + $usehourmin = 'dayhour'; + } + if (!empty($object->delivery_date)) { + $posy += 4; + $pdf->SetXY($posx - 90, $posy); + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->delivery_date, $usehourmin, false, $outputlangs, true), '', 'R'); + } + + if ($object->thirdparty->code_fournisseur) { + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + } + + // Get contact + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); + if (count($arrayidcontact) > 0) { + $usertmp = new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy += 4; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); + } + } + + $posy += 1; + $pdf->SetTextColor(0, 0, 60); + + $top_shift = 0; + // Show list of linked objects + $current_y = $pdf->getY(); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + if ($current_y < $pdf->getY()) { + $top_shift = $pdf->getY() - $current_y; + } + + if ($showaddress) { + // Sender properties + $carac_emetteur = ''; + // Add internal contact of proposal if defined + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); + if (count($arrayidcontact) > 0) { + $object->fetch_user($arrayidcontact[0]); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + + // Show sender + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->page_largeur - $this->marge_droite - 80; + } + $hautcadre = 40; + + // Show sender frame + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posx, $posy - 5); + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection); + $pdf->SetXY($posx, $posy); + $pdf->SetFillColor(230, 230, 230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0, 0, 60); + + // Show sender name + $pdf->SetXY($posx + 2, $posy + 3); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection); + $posy = $pdf->getY(); + + // Show sender information + $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection); + + + + // If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER' + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) { + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->thirdparty; + } + + //$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + + //$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + + // Show recipient + //$widthrecbox = 100; + //if ($this->page_largeur < 210) { + // $widthrecbox = 84; // To work with US executive format + //} + //$posy = 42 + $top_shift; + //$posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + //if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + // $posx = $this->marge_gauche; + //} + // + //// Show recipient frame + //$pdf->SetTextColor(0, 0, 0); + //$pdf->SetFont('', '', $default_font_size - 2); + //$pdf->SetXY($posx + 2, $posy - 5); + //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); + //$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + // + //// Show recipient name + //$pdf->SetXY($posx + 2, $posy + 3); + //$pdf->SetFont('', 'B', $default_font_size); + //$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection); + // + //$posy = $pdf->getY(); + // + //// Show recipient information + //$pdf->SetFont('', '', $default_font_size - 1); + //$pdf->SetXY($posx + 2, $posy); + //$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); + } + + return $top_shift; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param CommandeFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } + + + + /** + * Define Array Column Field + * + * @param object $object common object + * @param Translate $outputlangs langs + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return null + */ + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + global $conf, $hookmanager; + + // Default field style for content + $this->defaultContentsFieldsStyle = array( + 'align' => 'R', // R,C,L + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + // Default field style for content + $this->defaultTitlesFieldsStyle = array( + 'align' => 'C', // R,C,L + 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + /* + * For exemple + $this->cols['theColKey'] = array( + 'rank' => $rank, // int : use for ordering columns + 'width' => 20, // the column width in mm + 'title' => array( + 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + 'label' => ' ', // the final label : used fore final generated text + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + */ + $rank = 0; + $this->cols['code'] = array( + 'rank' => $rank, + 'status' => false, + 'width' => 35, // in mm + 'title' => array( + 'textkey' => 'Ref' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['code']['status'] = true; + + $rank = 1; // do not use negative rank + $this->cols['desc'] = array( + 'rank' => $rank, + 'width' => false, // only for desc + 'status' => true, + 'title' => array( + 'textkey' => 'Designation', // use lang key is usefull in somme case with module + 'align' => 'L', + // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + // 'label' => ' ', // the final label + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'border-left' => true, + 'content' => array( + 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + + $rank = $rank + 10; + $this->cols['photo'] = array( + 'rank' => $rank, + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'Photo', + 'label' => ' ' + ), + 'content' => array( + 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'border-left' => false, // remove left line separator + ); + + if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { + $this->cols['photo']['status'] = true; + } + + $rank = $rank + 10; + $this->cols['dim'] = array( + 'rank' => $rank, + 'status' => false, + 'width' => 25, // in mm + 'title' => array( + 'textkey' => 'Size' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['dim']['status'] = true; + + $rank = $rank + 10; + $this->cols['qty'] = array( + 'rank' => $rank, + 'width' => 16, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'Qty' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['qty']['status'] = true; + + $rank = $rank + 10; + $this->cols['qtytot'] = array( + 'rank' => $rank, + 'width' => 25, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'QtyTot' + ), + 'border-left' => true, // add left line separator + ); + $this->cols['qtytot']['status'] = true; + + // Add extrafields cols + if (!empty($object->lines)) { + $line = reset($object->lines); + $this->defineColumnExtrafield($line, $outputlangs, $hidedetails); + } + + $parameters = array( + 'object' => $object, + 'outputlangs' => $outputlangs, + 'hidedetails' => $hidedetails, + 'hidedesc' => $hidedesc, + 'hideref' => $hideref + ); + + $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif (empty($reshook)) { + $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys + } else { + $this->cols = $hookmanager->resArray; + } + } +} From 4e7549ab7d4be8ef14b1970e0f540192be714731 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 4 Sep 2021 13:53:31 +0200 Subject: [PATCH 116/229] css --- htdocs/core/tpl/login.tpl.php | 4 ++-- htdocs/core/tpl/passwordforgotten.tpl.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 1d25249da75..7b20e7209f7 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -196,7 +196,7 @@ if ($disablenofollow) {
-
+
diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 6c6e2ca9dc3..6fe5ddad2d6 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -146,7 +146,7 @@ if (!empty($captcha)) { ?>
-
+
@@ -186,7 +186,7 @@ if (!empty($morelogincontent)) {
-
class="button" name="button_password" value="trans('SendNewPassword'); ?>" tabindex="4" /> +
class="button small" name="button_password" value="trans('SendNewPassword'); ?>" tabindex="4" />
From 885237f3ac0166b61313e01c5b7fe1574a7970cb Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 4 Sep 2021 19:32:15 +0200 Subject: [PATCH 117/229] Update llx_knowledgemanagement_knowledgerecord.sql --- .../mysql/tables/llx_knowledgemanagement_knowledgerecord.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql index 5bb4a0ea648..384725056ab 100644 --- a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql +++ b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql @@ -16,7 +16,8 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id ref varchar(128) NOT NULL, date_creation datetime NOT NULL, tms timestamp, From c276882442e19464d2c1c4a35c981064c7bf4041 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 4 Sep 2021 19:36:57 +0200 Subject: [PATCH 118/229] Update 14.0.0-15.0.0.sql --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 5584ccc40f6..59c488f5a73 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -70,3 +70,4 @@ DELETE FROM llx_menu WHERE type = 'top' AND module = 'cashdesk' AND mainmenu = ' INSERT INTO llx_c_action_trigger (code, label, description, elementtype, rang) values ('MEMBER_EXCLUDE', 'Member excluded', 'Executed when a member is excluded', 'member', 27); +ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN entity integer DEFAULT 1; From 8850bd774c557244a5f15b929a94e3f96007182b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 4 Sep 2021 19:37:36 +0200 Subject: [PATCH 119/229] Update 14.0.0-15.0.0.sql --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 59c488f5a73..1ab2b9d828e 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -41,6 +41,7 @@ ALTER TABLE llx_emailcollector_emailcollectoraction MODIFY COLUMN actionparam TEXT; ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD lang varchar(6); +ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN entity integer DEFAULT 1; CREATE TABLE llx_categorie_ticket ( @@ -69,5 +70,3 @@ DELETE FROM llx_menu WHERE type = 'top' AND module = 'cashdesk' AND mainmenu = ' INSERT INTO llx_c_action_trigger (code, label, description, elementtype, rang) values ('MEMBER_EXCLUDE', 'Member excluded', 'Executed when a member is excluded', 'member', 27); - -ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN entity integer DEFAULT 1; From f3cf4f77b983c5e70803dda813804981b36d7280 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 4 Sep 2021 21:30:56 +0200 Subject: [PATCH 120/229] Update knowledgerecord.class.php --- htdocs/knowledgemanagement/class/knowledgerecord.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 8182a962b50..6b192c4a83e 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -50,7 +50,7 @@ class KnowledgeRecord extends CommonObject * @var int Does this object support multicompany module ? * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table */ - public $ismultientitymanaged = 0; + public $ismultientitymanaged = 1; /** * @var int Does object support extrafields ? 0=No, 1=Yes From 4d314d557d06937311df7d99b1443a73234c182f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 01:14:42 +0200 Subject: [PATCH 121/229] Doc --- htdocs/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 0f457b0f40b..ea0efebc720 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -185,8 +185,9 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed"); } - // Number of commercial proposals open (expired) + // Number of supplier proposals open (expired) if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $langs->load("supplier_proposal"); include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; $board = new SupplierProposal($db); $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened"); From de8db34f435c74e3514308dc6b048f952afea36d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 01:42:15 +0200 Subject: [PATCH 122/229] Fix filter on status of order --- htdocs/commande/list.php | 15 +++------------ htdocs/filefunc.inc.php | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5f3568701e5..e8b76a94e42 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -33,7 +33,6 @@ * \brief Page to list orders */ - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -501,16 +500,13 @@ if ($search_billed != '' && $search_billed >= 0) { $sql .= ' AND c.facture = '.((int) $search_billed); } if ($search_status <> '') { - if ($search_status < 4 && $search_status > -4) { + if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) if ($search_status == 1 && empty($conf->expedition->enabled)) { $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' } else { $sql .= ' AND c.fk_statut = '.((int) $search_status); // brouillon, validee, en cours, annulee } } - if ($search_status == 4) { - $sql .= ' AND c.facture = 1'; // invoice created - } if ($search_status == -2) { // To process //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected @@ -520,8 +516,6 @@ if ($search_status <> '') { //$sql.= ' AND c.facture = 0'; // invoice not created $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed } - - if ($search_status == -4) { // "validate and in progress" $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process } @@ -675,9 +669,6 @@ if ($resql) { if ($search_status == 3) { $title .= ' - '.$langs->trans('StatusOrderToBillShort'); } - if ($search_status == 4) { - $title .= ' - '.$langs->trans('StatusOrderProcessedShort'); - } if ($search_status == -1) { $title .= ' - '.$langs->trans('StatusOrderCanceledShort'); } @@ -1254,10 +1245,10 @@ if ($resql) { Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), - -4=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), + -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); print '
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):'.$form->textwithpicto('', $tooltip, 1, 1).' 
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
".$extrafields->attributes[$elementtype]['pos'][$key]."".$extrafields->attributes[$elementtype]['label'][$key]."".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])."".dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key])."".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."".$key."".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."'.$extrafields->attributes[$elementtype]['size'][$key]."'.dol_trunc($extrafields->attributes[$elementtype]['computed'][$key], 20)."".dol_escape_htmltag($key)."".dol_escape_htmltag($type2label[$extrafields->attributes[$elementtype]['type'][$key]])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['size'][$key])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key])."'.yn($extrafields->attributes[$elementtype]['unique'][$key])."'.yn($extrafields->attributes[$elementtype]['required'][$key])."'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."'.$extrafields->attributes[$elementtype]['list'][$key]."'.$extrafields->attributes[$elementtype]['printable'][$key]."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key])."'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."'; @@ -116,8 +129,8 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel print ''; - print ''.img_edit().''; - print '  '.img_delete().''; + print ''.img_edit().''; + print '  '.img_delete().''; print '
".dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key])."".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."'.dol_escape_htmltag($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]))."".dol_escape_htmltag($key)."
"; // Bouton Save payment - print '
'.$langs->trans("ClosePaidSalaryAutomatically"); - print '
'; + print '
'; + print '
'; + print '
'; + print '
'; + print ''; print '     '; print ''; print '
'; From e4767e91eaccf5f3b3e8ddccdd06092069229e1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 03:26:43 +0200 Subject: [PATCH 133/229] Fix css --- htdocs/salaries/paiement_salary.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index 749ce8f9575..86a0e787e84 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -317,8 +317,7 @@ if ($action == 'create') { // Bouton Save payment print '
'; print '
'; - print '
'; - print '
'; + print '
'; print ''; print '     '; print ''; From b782e5986a27317cad94e7e3cc114f07b823dfa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 03:29:46 +0200 Subject: [PATCH 134/229] Fix css --- htdocs/compta/tva/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index daf5afb025e..2f3f4edf83c 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -437,7 +437,7 @@ if ($action == 'create') { print '
'; // Auto create payment - print ''.$langs->trans('AutomaticCreationPayment').''; + print ''; print ''."\n"; print ''; From c3f1ecb981bf85c990f40d503052dfe98f0384e4 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 6 Sep 2021 09:14:19 +0200 Subject: [PATCH 135/229] fix GET parameter on redirect --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 12668bdd55c..2efae8b1454 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -156,7 +156,7 @@ if ($reshook < 0) { } if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/fourn/commande/list.php'.($socid > 0 ? '&socid='.((int) $socid) : ''); + $backurlforlist = DOL_URL_ROOT.'/fourn/commande/list.php'.($socid > 0 ? '?socid='.((int) $socid) : ''); if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { From b9150c2441c2706ef2bc2cb0908f92c359d0459f Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 6 Sep 2021 11:20:36 +0200 Subject: [PATCH 136/229] add produce line if no produce objects --- htdocs/mrp/mo_production.php | 67 +++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 678865805d7..70eb96c5fe1 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -149,14 +149,19 @@ if (empty($reshook)) { $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN'); } - if ($action == 'confirm_addconsumeline' && GETPOST('addconsumelinebutton') && $permissiontoadd) { + if (($action == 'confirm_addconsumeline' && GETPOST('addconsumelinebutton') && $permissiontoadd) + || $action == 'confirm_addproduceline' && GETPOST('addproducelinebutton') && $permissiontoadd) { $moline = new MoLine($db); // Line to produce $moline->fk_mo = $object->id; $moline->qty = GETPOST('qtytoadd', 'int'); ; $moline->fk_product = GETPOST('productidtoadd', 'int'); - $moline->role = 'toconsume'; + if (GETPOST('addconsumelinebutton')) { + $moline->role = 'toconsume'; + } else { + $moline->role = 'toproduce'; + } $moline->origin_type = 'free'; // free consume line $moline->position = 0; @@ -642,7 +647,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; } - if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline', 'addproduceline'))) { print '
'; print ''; print ''; @@ -962,8 +967,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; - print load_fiche_titre($langs->trans('Production'), '', ''); + $nblinetoproduce = 0; + foreach ($object->lines as $line) { + if ($line->role == 'toproduce') { + $nblinetoproduce++; + } + } + if (empty($nblinetoproduce)) { + if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { + $newlinetext = ''.$langs->trans("AddNewProduceLines").''; + } + print load_fiche_titre($langs->trans('Production'), '', '', 0, '', '', $newlinetext); + } else { + print load_fiche_titre($langs->trans('Production'), '', '', 0); + } print '
'; print ''; @@ -993,6 +1011,34 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; + if ($action == 'addproduceline') { + print ''."\n"; + print ''; + print ''; + // Qty + print ''; + // Cost price + print ''; + + // Qty already produced + print ''; + // Warehouse + print ''; + // Lot - serial + if ($conf->productbatch->enabled) { + print ''; + } + // Action + if ($permissiontodelete) { + print ''; + } + print ''; + } + if (!empty($object->lines)) { $nblinetoproduce = 0; foreach ($object->lines as $line) { @@ -1065,7 +1111,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($conf->productbatch->enabled) { print ''; // Lot - print ''; + } + + if ($permissiontodelete && $line->origin_type == 'free') { + $href = $_SERVER["PHP_SELF"]; + $href .= '?id='.$object->id; + $href .= '&action=deleteline'; + $href .= '&lineid='.$line->id; + print ''; } print ''; From be1c08ddfe322c8f44a5e4a7474bd39f6f630bec Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 6 Sep 2021 12:30:39 +0200 Subject: [PATCH 137/229] FIX : salary extrafields don't work and table is not well named --- htdocs/core/tpl/extrafields_view.tpl.php | 3 +++ .../install/mysql/migration/13.0.0-14.0.0.sql | 2 ++ ...key.sql => llx_salary_extrafields.key.sql} | 2 +- ...afields.sql => llx_salary_extrafields.sql} | 4 ++-- .../salaries/admin/salaries_extrafields.php | 2 +- htdocs/salaries/card.php | 24 +++++++++++++++++++ 6 files changed, 33 insertions(+), 4 deletions(-) rename htdocs/install/mysql/tables/{llx_payment_salary_extrafields.key.sql => llx_salary_extrafields.key.sql} (89%) rename htdocs/install/mysql/tables/{llx_payment_salary_extrafields.sql => llx_salary_extrafields.sql} (91%) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 3f2ab773b06..0a2348f5858 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -194,6 +194,9 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l if ($object->element == 'contact') { $permok = $user->rights->societe->contact->creer; } + if($object->element == 'salary') { + $permok = $user->rights->salaries->read; + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index d50b6991261..7c1815377be 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -349,6 +349,8 @@ UPDATE llx_payment_salary SET ref = rowid WHERE ref IS NULL; ALTER TABLE llx_salary ALTER COLUMN paye set default 0; +ALTER TABLE llx_payment_salary_extrafields RENAME TO llx_salary_extrafields; + DELETE FROM llx_boxes WHERE box_id IN (SELECT rowid FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php')); DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php'); diff --git a/htdocs/install/mysql/tables/llx_payment_salary_extrafields.key.sql b/htdocs/install/mysql/tables/llx_salary_extrafields.key.sql similarity index 89% rename from htdocs/install/mysql/tables/llx_payment_salary_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_salary_extrafields.key.sql index 9231351a749..9c6e047d9ee 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary_extrafields.key.sql +++ b/htdocs/install/mysql/tables/llx_salary_extrafields.key.sql @@ -17,4 +17,4 @@ -- =================================================================== -ALTER TABLE llx_payment_salary_extrafields ADD INDEX idx_payment_salary_extrafields (fk_object); +ALTER TABLE llx_salary_extrafields ADD INDEX idx_salary_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_payment_salary_extrafields.sql b/htdocs/install/mysql/tables/llx_salary_extrafields.sql similarity index 91% rename from htdocs/install/mysql/tables/llx_payment_salary_extrafields.sql rename to htdocs/install/mysql/tables/llx_salary_extrafields.sql index 5f15918ef18..bedab6757b4 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_salary_extrafields.sql @@ -16,10 +16,10 @@ -- -- =================================================================== -create table llx_payment_salary_extrafields +create table llx_salary_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - fk_object integer NOT NULL, -- salary payment id + fk_object integer NOT NULL, -- salary id import_key varchar(14) -- import key )ENGINE=innodb; diff --git a/htdocs/salaries/admin/salaries_extrafields.php b/htdocs/salaries/admin/salaries_extrafields.php index 38303518ac4..2354da8048a 100644 --- a/htdocs/salaries/admin/salaries_extrafields.php +++ b/htdocs/salaries/admin/salaries_extrafields.php @@ -42,7 +42,7 @@ foreach ($tmptype2label as $key => $val) { $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'payment_salary'; //Must be the $table_element of the class that manage extrafield +$elementtype = 'salary'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) { accessforbidden(); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index d3c7ba504cb..d3cbc5d3904 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -354,6 +354,30 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- } } +// Action to update one extrafield +if ($action == "update_extras" && !empty($user->rights->salaries->read)) { + $object->fetch(GETPOST('id', 'int')); + + $attributekey = GETPOST('attribute', 'alpha'); + $attributekeylong = 'options_'.$attributekey; + + if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) { + // This is properties of a date + $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int')); + //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; + } else { + $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha'); + } + + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } +} /* * View From 38bd5e0902dd718eec765d6c7c5ba69b880f6143 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 12:51:40 +0200 Subject: [PATCH 138/229] Fix trans --- htdocs/contact/class/contact.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 83bc4202b9d..a45e28f6be1 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -90,21 +90,19 @@ class Contact extends CommonObject */ public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>15), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), - 'fk_soc' =>array('type'=>'integer', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>1, 'position'=>25, 'searchall'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>3, 'notnull'=>1, 'position'=>30, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>3, 'position'=>35), 'civility' =>array('type'=>'varchar(6)', 'label'=>'Civility', 'enabled'=>1, 'visible'=>3, 'position'=>40), 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'showoncombobox'=>1, 'searchall'=>1), 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'position'=>50, 'showoncombobox'=>1, 'searchall'=>1), + 'poste' =>array('type'=>'varchar(80)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>-1, 'position'=>52), '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), 'fk_departement' =>array('type'=>'integer', 'label'=>'Fk departement', 'enabled'=>1, 'visible'=>3, 'position'=>70), 'fk_pays' =>array('type'=>'integer', 'label'=>'Fk pays', 'enabled'=>1, 'visible'=>3, 'position'=>75), + 'fk_soc' =>array('type'=>'integer', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>1, 'position'=>77, 'searchall'=>1), 'birthday' =>array('type'=>'date', 'label'=>'Birthday', 'enabled'=>1, 'visible'=>3, 'position'=>80), - 'poste' =>array('type'=>'varchar(80)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>-1, 'position'=>85), 'phone' =>array('type'=>'varchar(30)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>1, 'position'=>90, 'searchall'=>1), 'phone_perso' =>array('type'=>'varchar(30)', 'label'=>'PhonePerso', 'enabled'=>1, 'visible'=>-1, 'position'=>95, 'searchall'=>1), 'phone_mobile' =>array('type'=>'varchar(30)', 'label'=>'PhoneMobile', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'searchall'=>1), @@ -113,15 +111,17 @@ class Contact extends CommonObject 'socialnetworks' =>array('type'=>'text', 'label'=>'SocialNetworks', 'enabled'=>1, 'visible'=>3, 'position'=>115), 'photo' =>array('type'=>'varchar(255)', 'label'=>'Photo', 'enabled'=>1, 'visible'=>3, 'position'=>170), 'priv' =>array('type'=>'smallint(6)', 'label'=>'ContactVisibility', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>175), - 'fk_stcommcontact' =>array('type'=>'integer', 'label'=>'Fk stcommcontact', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220), + 'fk_stcommcontact' =>array('type'=>'integer', 'label'=>'ProspectStatus', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220), 'fk_prospectlevel' =>array('type'=>'varchar(12)', 'label'=>'ProspectLevel', 'enabled'=>1, 'visible'=>-1, 'position'=>255), 'no_email' =>array('type'=>'smallint(6)', 'label'=>'No_Email', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>180), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>3, 'position'=>185), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>3, 'position'=>190), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>3, 'position'=>195, 'searchall'=>1), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>3, 'position'=>200, 'searchall'=>1), 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>3, 'position'=>205), 'canvas' =>array('type'=>'varchar(32)', 'label'=>'Canvas', 'enabled'=>1, 'visible'=>3, 'position'=>210), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>300), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>305), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>3, 'position'=>310), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>3, 'position'=>315), 'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'position'=>1000), ); From a57e8a14b88392cca1f56531a3c7285d448bb328 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 12:56:33 +0200 Subject: [PATCH 139/229] Fix look and feel v14 --- htdocs/contact/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 2f6b717a2dc..efb8f03736e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1164,25 +1164,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($conf->commande->enabled)) { print ''; } if (!empty($conf->propal->enabled)) { print ''; } if (!empty($conf->contrat->enabled)) { print ''; } if (!empty($conf->facture->enabled)) { print ''; } @@ -1193,7 +1193,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else { - print $langs->trans("NoDolibarrAccess"); + print ''.$langs->trans("NoDolibarrAccess").''; } print ''; From 383c92f6c62c32d9d7fd846f9b1f50ed49da7b65 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 6 Sep 2021 14:52:11 +0200 Subject: [PATCH 140/229] FIX : migration script --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 7c1815377be..a562f00c295 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -349,6 +349,7 @@ UPDATE llx_payment_salary SET ref = rowid WHERE ref IS NULL; ALTER TABLE llx_salary ALTER COLUMN paye set default 0; +UPDATE llx_extrafields SET elementtype = 'salary' WHERE elementtype = 'payment_salary'; ALTER TABLE llx_payment_salary_extrafields RENAME TO llx_salary_extrafields; DELETE FROM llx_boxes WHERE box_id IN (SELECT rowid FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php')); From 765f0c4d1919faa8f08f47159f756a04dc75c829 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 6 Sep 2021 14:56:30 +0200 Subject: [PATCH 141/229] Close #18584 : Code enhancement of MO --- htdocs/langs/en_US/mrp.lang | 1 + htdocs/langs/fr_FR/mrp.lang | 1 + htdocs/mrp/class/mo.class.php | 6 ++++++ htdocs/mrp/mo_production.php | 13 +++++-------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 0b779d55fbd..47d1fbe889f 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -74,6 +74,7 @@ NoStockChangeOnServices=No stock change on services ProductQtyToConsumeByMO=Product quantity still to consume by open MO ProductQtyToProduceByMO=Product quantity still to produce by open MO AddNewConsumeLines=Add new line to consume +AddNewProduceLines=Add new line to produce ProductsToConsume=Products to consume ProductsToProduce=Products to produce UnitCost=Unit cost diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index cdff650c34b..a0ab429a70c 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -72,6 +72,7 @@ NoStockChangeOnServices=Aucune variation de stock sur les services ProductQtyToConsumeByMO=Quantité de produit restant à consommer par OF ouvert ProductQtyToProduceByMO=Quantités restant à produire avec les OF ouverts AddNewConsumeLines=Ajouter une nouvelle ligne à consommer +AddNewProduceLines=Ajouter une nouvelle ligne à produire ProductsToConsume=Produits à consommer ProductsToProduce=Produits à produire UnitCost=Coût unitaire diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f4069bfc518..2fc2a01a802 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -659,6 +659,12 @@ class Mo extends CommonObject $role = 'toconsume'; $moline->role = 'toproduce'; } + } else { + if ($this->mrptype == 1) { + $moline->role = 'toconsume'; + } else { + $moline->role = 'toproduce'; + } } $resultline = $moline->create($user, false); // Never use triggers here diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 70eb96c5fe1..0558e7e74a4 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -973,15 +973,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $nblinetoproduce++; } } - - if (empty($nblinetoproduce)) { - if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { - $newlinetext = ''.$langs->trans("AddNewProduceLines").''; - } - print load_fiche_titre($langs->trans('Production'), '', '', 0, '', '', $newlinetext); - } else { - print load_fiche_titre($langs->trans('Production'), '', '', 0); + $newlinetext = ''; + if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { + $newlinetext = ''.$langs->trans("AddNewProduceLines").''; } + print load_fiche_titre($langs->trans('Production'), '', '', 0, '', '', $newlinetext); + print '
'; print '
'; + print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); + print ''; + print ''; + print '
'; + print ''; + print img_picto('', "delete"); + print ''; + print '
'.$langs->trans("ContactForOrders").''; - print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); + print $object->ref_commande ? $object->ref_commande : (''.$langs->trans("NoContactForAnyOrder").''); print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : (''.$langs->trans("NoContactForAnyProposal").''); print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : (''.$langs->trans("NoContactForAnyContract").''); print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : (''.$langs->trans("NoContactForAnyInvoice").''); print '
'; From 1043bc964ddb714483791efbdb9bad6049c1cbbe Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 6 Sep 2021 12:58:06 +0000 Subject: [PATCH 142/229] Fixing style errors. --- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0a2348f5858..f50276821b1 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -194,7 +194,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l if ($object->element == 'contact') { $permok = $user->rights->societe->contact->creer; } - if($object->element == 'salary') { + if ($object->element == 'salary') { $permok = $user->rights->salaries->read; } From 5c9100986d0b88445613475a109a09a21216a3b5 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Mon, 6 Sep 2021 15:19:35 +0200 Subject: [PATCH 143/229] Update row.php right write doesn't exist for supplier_proposal ->line order dont works --- htdocs/core/ajax/row.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 95518cbbf66..ce6bd3d4d60 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -89,7 +89,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } elseif ($table_element_line == 'mrp_production' && $user->rights->mrp->write) { $perm = 1; - } elseif ($table_element_line == 'supplier_proposaldet' && $user->rights->supplier_proposal->write) { + } elseif ($table_element_line == 'supplier_proposaldet' && $user->rights->supplier_proposal->creer) { $perm = 1; } elseif ($table_element_line == 'commande_fournisseurdet' && $user->rights->fournisseur->commande->creer) { $perm = 1; From 18da6e6d6f940c9ba3dbda75648af5186482c0ea Mon Sep 17 00:00:00 2001 From: jyhere Date: Mon, 6 Sep 2021 15:20:47 +0200 Subject: [PATCH 144/229] Update create.php Fix : unable to create a direct debit if ics and ics_transfer are empty even though ics_transfer is only used for bank transfer. --- htdocs/compta/prelevement/create.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 6f045f3ca74..9a3202540b4 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -95,7 +95,9 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $bank = new Account($db); $bank->fetch($conf->global->{$default_account}); - if (empty($bank->ics) || empty($bank->ics_transfer)) { + if ((empty($bank->ics) && $type !== 'bank-transfer') + || (empty($bank->ics_transfer) && $type === 'bank-transfer') + ) { $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}')); setEventMessages($errormessage, null, 'errors'); header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php'); From 3537f68c7e16a09aea83453022b262d580231e52 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 6 Sep 2021 13:24:22 +0000 Subject: [PATCH 145/229] Fixing style errors. --- htdocs/compta/prelevement/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 9a3202540b4..172cf020e34 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -96,8 +96,8 @@ if (empty($reshook)) { $bank = new Account($db); $bank->fetch($conf->global->{$default_account}); if ((empty($bank->ics) && $type !== 'bank-transfer') - || (empty($bank->ics_transfer) && $type === 'bank-transfer') - ) { + || (empty($bank->ics_transfer) && $type === 'bank-transfer') + ) { $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}')); setEventMessages($errormessage, null, 'errors'); header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php'); From 7d8023fea74862012ab35d1e5e0486d1b3743f1e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 6 Sep 2021 16:21:30 +0200 Subject: [PATCH 146/229] FIX wrong table_element_line --- htdocs/core/ajax/row.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 95518cbbf66..c55d80ee521 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2021 Regis Houssin * Copyright (C) 2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -79,7 +79,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } elseif ($table_element_line == 'facturedet' && $user->rights->facture->creer) { $perm = 1; - } elseif ($table_element_line == 'facturerecdet' && $user->rights->facture->creer) { + } elseif ($table_element_line == 'facturedet_rec' && $user->rights->facture->creer) { $perm = 1; } elseif ($table_element_line == 'ecm_files' && $user->rights->ecm->creer) { $perm = 1; From 70d52aca1d539c79a9fe27f416ffc471417c36c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 17:42:17 +0200 Subject: [PATCH 147/229] Trans --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 78cbff5cafe..af83083e308 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -496,7 +496,7 @@ WarningPHPMail=WARNING: The setup to send emails from the application is using t WarningPHPMailA=- Using the server of the Email Service Provider increases the trustability of your email, so it increases the deliverablity without being flagged as SPAM WarningPHPMailB=- Some Email Service Providers (like Yahoo) do not allow you to send an email from another server than their own server. Your current setup uses the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not theirs, so few of your sent Emails may not be accepted for delivery (be careful also of your email provider's sending quota). WarningPHPMailC=- Using the SMTP server of your own Email Service Provider to send emails is also interesting so all emails sent from application will also be saved into your "Sent" directory of your mailbox. -WarningPHPMailD=If the method 'PHP Mail' is really the method you would like to use, you can remove this warning by adding the constant MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP to 1 in Home - Setup - Other. +WarningPHPMailD=Also, it is therefore recommended to change the sending method of e-mails to the value "SMTP". If you really want to keep the default "PHP" method to send emails, just ignore this warning, or remove it by setting the MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP constant to 1 in Home - Setup - Other. WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of the mail user agent (MUA) for your ERP CRM application: %s. WarningPHPMailSPF=If the domain name in your sender email address is protected by a SPF record (ask you domain name registar), you must add the following IPs in the SPF record of the DNS of your domain: %s. ClickToShowDescription=Click to show description diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index b7a10c62ba2..31866672e17 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -495,7 +495,7 @@ WarningPHPMail=AVERTISSEMENT: la configuration pour envoyer des e-mails à parti WarningPHPMailA= - L'utilisation des serveurs de prestataires de messagerie augmente le niveau confiance des e-mails, cela augmente donc les chances de délivrabilité en n'étant pas considéré comme spam. WarningPHPMailB=- Certains fournisseurs de services de messagerie (comme Yahoo) ne vous permettent pas d'envoyer un e-mail à partir d'un autre serveur que leur propre serveur. Votre configuration actuelle utilise le serveur de l'application pour envoyer des e-mails et non le serveur de votre fournisseur de messagerie, donc certains destinataires (ceux compatibles avec le protocole DMARC restrictif), demanderont à votre fournisseur de messagerie si ils peuvent accepter votre message et ce fournisseur de messagerie (comme Yahoo) peut répondre «non» parce que le serveur d'envoi n'est pas le leur, aussi une partie de vos e-mails envoyés peuvent ne pas être acceptés pour la livraison (faites également attention au quota d'envoi de votre fournisseur de messagerie). WarningPHPMailC=- Utiliser le serveur SMTP de votre propre fournisseur de services de messagerie pour envoyer des e-mails est également intéressant afin que tous les e-mails envoyés depuis l'application soient également enregistrés dans votre répertoire "Envoyés" de votre boîte aux lettres. -WarningPHPMailD=Si PHP est vraiment la méthode d'envoi des e-mails que vous avez choisi d'utiliser, supprimer cette alerte en activant à 1 la constante MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP dans Accueil - Configuration - Divers +WarningPHPMailD=Aussi, il est donc recommandé de modifier la méthode d'envoi des e-mails sur la valeur "SMTP". Si vous voulez vraiment conserver la méthode par défaut "PHP", alors vous pouvez ignorer cette alerte ou la supprimer en activant à 1 la constante MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP dans Accueil - Configuration - Divers WarningPHPMail2=Si votre fournisseur de messagerie SMTP a besoin de restreindre le client de messagerie à certaines adresses IP (très rare), voici l'adresse IP du mail user agent (MUA) de votre application CRM ERP : %s . WarningPHPMailSPF=Si le nom de domaine de votre adresse e-mail d'expéditeur est protégé par un enregistrement SPF (demandez à votre fournisseur de nom de domaine), vous devez inclure les adresses IP suivantes dans l'enregistrement SPF du DNS de votre domaine: %s . ClickToShowDescription=Cliquer pour afficher la description From e77d7d22a87e2d7af4f61e8f2794a0a5e663015b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 18:34:18 +0200 Subject: [PATCH 148/229] Trans --- htdocs/langs/en_US/admin.lang | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af83083e308..5bda447f368 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2150,4 +2150,6 @@ DatabasePasswordObfuscated=Database password is obfuscated in conf file DatabasePasswordNotObfuscated=Database password is NOT obfuscated in conf file APIsAreNotEnabled=APIs modules are not enabled YouShouldSetThisToOff=You should set this to 0 or off -InstallAndUpgradeLockedBy=Install and upgrades are locked by the file %s \ No newline at end of file +InstallAndUpgradeLockedBy=Install and upgrades are locked by the file %s +IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sale tax +IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sale tax From f5f0b9debc083a17b942d57ab5a9411226282bb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 18:41:04 +0200 Subject: [PATCH 149/229] Fix label for selection --- htdocs/admin/company.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 0ca1ae7d98e..85d168ac8b3 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -696,7 +696,7 @@ $tooltiphelp = ''; if ($mysoc->country_code == 'FR') { $tooltiphelp = ''.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR").""; } -print ""; +print '"; print "\n"; @@ -706,7 +706,7 @@ $tooltiphelp = ''; if ($mysoc->country_code == 'FR') { $tooltiphelp = "".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."\n"; } -print ""; +print '"; print "\n"; print "
"; @@ -721,12 +721,12 @@ print "\n"; if ($mysoc->useLocalTax(1)) { // Note: When option is not set, it must not appears as set on on, because there is no default value for this option - print 'global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).""; + print 'global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "").'> "; print ''; print '
'; $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code); $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."\n" : ""); - print '"; + print $form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp); if (!isOnlyOneLocalTax(1)) { print '
: '; $formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1"); @@ -739,11 +739,11 @@ if ($mysoc->useLocalTax(1)) { print "
"; print "\n"; - print 'global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code).""; + print 'global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off") ? " checked" : "").'> "; print ''; $tooltiphelp = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code); $tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."\n" : ""); - print ""; + print $form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp); print "\n"; } else { if (empty($mysoc->country_code)) { @@ -765,7 +765,7 @@ print "\n"; if ($mysoc->useLocalTax(2)) { // Note: When option is not set, it must not appears as set on on, because there is no default value for this option - print 'global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).""; + print 'global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "").'> "; print ''; print '
'; print '"; @@ -780,7 +780,7 @@ if ($mysoc->useLocalTax(2)) { print "
"; print "\n"; - print 'global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code).""; + print 'global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off") ? " checked" : "").'> "; print ''; print "
"; $tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code); @@ -803,7 +803,7 @@ print ""; print '
'; print ''; print ''; -print ''; +print ''; print ''; print "\n"; if ($mysoc->useRevenueStamp()) { From 51a751f088eee25b3ef48fa32b6f3ca6a410f575 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 19:00:01 +0200 Subject: [PATCH 150/229] Fix option MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 10 +++++++++- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index b172cb3b5cf..839f7afa56a 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1195,6 +1195,14 @@ class pdf_crabe extends ModelePDFFactures $default_font_size = pdf_getPDFFontSize($outputlangs); + $outputlangsbis = null; + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); + $default_font_size--; + } + $tab2_top = $posy; $tab2_hl = 4; $pdf->SetFont('', '', $default_font_size - 1); @@ -1213,7 +1221,7 @@ class pdf_crabe extends ModelePDFFactures // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total") : ''), 0, 'L', 1); $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index bc4c536a2e6..db3609101a0 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1353,7 +1353,7 @@ class pdf_sponge extends ModelePDFFactures $posy = $pdf->GetY(); } - // cumul TVA précédent + // Cumulate preceding VAT $index++; $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $posy); @@ -1427,7 +1427,7 @@ class pdf_sponge extends ModelePDFFactures // Total remise $total_line_remise = 0; foreach ($object->lines as $i => $line) { - $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib + $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this method to core/lib/pdf.lib // Gestion remise sous forme de ligne négative if ($line->total_ht < 0) { $total_line_remise += -$line->total_ht; @@ -1458,7 +1458,7 @@ class pdf_sponge extends ModelePDFFactures // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) ? "TotalHT" : "Total") : ''), 0, 'L', 1); $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); From 02f21d478a0167b25ddc305aa14a243e7dc8bc98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Sep 2021 19:06:46 +0200 Subject: [PATCH 151/229] Fix trans --- htdocs/admin/translation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 3fa2e5d0af9..8d77e009cb3 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -541,7 +541,7 @@ if ($mode == 'searchkey') { print $form->textwithpicto('', $htmltext, 1, 'info'); } elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { //print $key.'-'.$val; - print ''.img_edit_add($langs->trans("Overwrite")).''; + print ''.img_edit_add($langs->trans("TranslationOverwriteKey")).''; } if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { From 0d9280f94535352f146b7033a99c19f5a91a9a64 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 7 Sep 2021 10:39:41 +0200 Subject: [PATCH 152/229] Close #18607 : Implementation of salary button --- htdocs/langs/en_US/salaries.lang | 3 +- htdocs/langs/fr_FR/salaries.lang | 1 + htdocs/salaries/ajax/ajaxsalaries.php | 73 +++++++++++++++++++++++++++ htdocs/salaries/card.php | 42 ++++++++++++++- 4 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 htdocs/salaries/ajax/ajaxsalaries.php diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 504f0fbcc16..d4dc53f42ed 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -21,4 +21,5 @@ LastSalaries=Latest %s salaries AllSalaries=All salaries SalariesStatistics=Salary statistics SalariesAndPayments=Salaries and payments -ConfirmDeleteSalaryPayment=Do you want to delete this salary payment ? \ No newline at end of file +ConfirmDeleteSalaryPayment=Do you want to delete this salary payment ? +FillFieldFirst=Fill employee field first diff --git a/htdocs/langs/fr_FR/salaries.lang b/htdocs/langs/fr_FR/salaries.lang index cdabb1c9f35..0dcf1a6d869 100644 --- a/htdocs/langs/fr_FR/salaries.lang +++ b/htdocs/langs/fr_FR/salaries.lang @@ -22,3 +22,4 @@ AllSalaries=Tous les salaires SalariesStatistics=Statistiques SalariesAndPayments=Salaires et paiements ConfirmDeleteSalaryPayment=Voulez-vous supprimer ce paiement de salaire ? +FillFieldFirst=Remplisez d'abord le champ salarié diff --git a/htdocs/salaries/ajax/ajaxsalaries.php b/htdocs/salaries/ajax/ajaxsalaries.php new file mode 100644 index 00000000000..28605ea5d83 --- /dev/null +++ b/htdocs/salaries/ajax/ajaxsalaries.php @@ -0,0 +1,73 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/salaries/ajax/ajaxsalaries.php + * \brief File to return Ajax response on salary request + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; + +restrictedArea($user, 'salaries'); + +$fk_user = GETPOST('fk_user', 'int'); +$return_arr = array(); +if (!empty(GETPOST('fk_user', 'int'))) { + $sql = "SELECT s.amount, s.rowid FROM ".MAIN_DB_PREFIX."salary as s"; + $sql .= " WHERE s.fk_user = ".$fk_user; + $sql .= " AND s.paye = 1"; + $sql .= $db->order("s.dateep", "DESC"); + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $label = "Salary amount"; + $row_array['label'] = $label; + $row_array['value'] = $obj->amount; + $row_array['key'] = "Amount"; + + array_push($return_arr, $row_array); + echo json_encode($return_arr); + } else { + echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); + } +} else { + echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); +} diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index ca111adf4d1..a404a7e9da1 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -466,8 +466,10 @@ if ($action == 'create') { // Amount print ''; + print ' '; + print '
'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).''.$langs->trans("Description").''.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).''.$langs->trans("Description").' 
'; print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).''; - print ''; - print '
'; print ''; print ''; print ''; From f2df3aa1516fe889c8f1c752773bc4cdf0ef77c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 17:27:29 +0200 Subject: [PATCH 170/229] css --- htdocs/knowledgemanagement/class/knowledgerecord.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 0325e804abd..310bdf2959b 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -102,9 +102,9 @@ class KnowledgeRecord extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'visible'=>5, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", "showoncombobox"=>1), - 'question' => array('type'=>'text', 'label'=>'Question', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflow300', 'copytoclipboard'=>1), + 'question' => array('type'=>'text', 'label'=>'Question', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax300', 'copytoclipboard'=>1), 'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>1), - 'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>3, 'csslist'=>'tdoverflow300', 'copytoclipboard'=>1), + 'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>3, 'csslist'=>'tdoverflowmax300', 'copytoclipboard'=>1), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>2,), 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), From 0edf2f344b430a57b3358b706dcfdb6f5b80ecb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 17:38:46 +0200 Subject: [PATCH 171/229] Fix sql --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index d50b6991261..ee1ad6b9f2e 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -392,7 +392,8 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) NOT NULL, fk_soc integer, - fk_actioncomm integer NOT NULL, + fk_actioncomm integer, + fk_project integer NOT NULL, email varchar(100), date_subscription datetime, amount double DEFAULT NULL, @@ -408,6 +409,11 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( status smallint NOT NULL ) ENGINE=innodb; +-- VMYSQL4.3 ALTER TABLE llx_eventorganization_conferenceorboothattendee MODIFY COLUMN fk_actioncomm integer NULL; +-- VPGSQL8.2 ALTER TABLE llx_eventorganization_conferenceorboothattendee ALTER COLUMN fk_actioncomm DROP NOT NULL; + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_project integer NOT NULL; + ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); From 83ec43a2ee265a1bee433511400cd3444735a948 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 17:44:57 +0200 Subject: [PATCH 172/229] css --- htdocs/install/default.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index 88967664ad8..c9ebc47d317 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -411,7 +411,7 @@ a.button:hover { /* background-color: rgba(70, 3, 62, 0.3); */ padding: 2px 4px; border-radius: 4px; - white-space: nowrap; + /* white-space: nowrap; */ } .choiceselected { background-color: #f4f6f4; From 1fda7d43ef303a6674973e57e61884c23d0aea78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 17:45:22 +0200 Subject: [PATCH 173/229] Fix sql --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index efbb129e2a1..c76be4edbde 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -35,6 +35,11 @@ -- VMYSQL4.3 ALTER TABLE llx_partnership MODIFY COLUMN date_partnership_end date NULL; -- VPGSQL8.2 ALTER TABLE llx_partnership ALTER COLUMN date_partnership_end DROP NOT NULL; +-- VMYSQL4.3 ALTER TABLE llx_eventorganization_conferenceorboothattendee MODIFY COLUMN fk_actioncomm integer NULL; +-- VPGSQL8.2 ALTER TABLE llx_eventorganization_conferenceorboothattendee ALTER COLUMN fk_actioncomm DROP NOT NULL; + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_project integer NOT NULL; + -- v15 From f54e4690e6c2f7731a237ca1aabb53dbbb81713c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 18:13:55 +0200 Subject: [PATCH 174/229] Debug event organization module --- .../conferenceorbooth_list.php | 8 +++--- htdocs/langs/en_US/eventorganization.lang | 7 +++-- .../attendee_subscription.php | 28 +++++++++++++++---- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index f0bb4d25074..e94a3139862 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -398,15 +398,15 @@ if ($projectid > 0) { print ""; print '"; print '"; print '
'; - print $langs->trans('Properties'); + print $langs->trans('TicketProperties'); print ''; if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d4058ccdb47..5d941d0564b 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2599,7 +2599,7 @@ if (!GETPOST('hide_websitemenu')) { print ''; if ($action != 'file_manager') { print ''; - print $langs->trans("Website").' : '; + print $langs->trans("Website").': '; print ''; $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite'; @@ -2668,7 +2668,7 @@ if (!GETPOST('hide_websitemenu')) { print '   '; //print ''; - print ''.dol_escape_htmltag($langs->trans("EditCss")).''; + print ''.dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ? "Properties" : "EditCss")).''; $importlabel = $langs->trans("ImportSite"); $exportlabel = $langs->trans("ExportSite"); @@ -2693,13 +2693,9 @@ if (!GETPOST('hide_websitemenu')) { // Regenerate all pages print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'">'; - print '   '; - // Generate site map print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">'; - print '   '; - print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">'; } @@ -2722,7 +2718,7 @@ if (!GETPOST('hide_websitemenu')) { } - print ''; + print ''; if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { $urlext = $virtualurl; @@ -2968,10 +2964,10 @@ if (!GETPOST('hide_websitemenu')) { print '   '; //print ''; - print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; + print ''.dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ? "Properties" : "EditPageMeta")).''; //print ''; - print ''.dol_escape_htmltag($langs->trans("EditHTMLSource")).''; + print ''.dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ? "HTML" : "EditHTMLSource")).''; print ''."\n"; print '
'; @@ -4360,7 +4356,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = } print ''.img_picto($langs->trans("EditHTMLSource"), 'edit').''; - print ''.ajax_object_onoff($answerrecord, 'status', 'status', 'Enabled', 'Disabled'); + print ''.ajax_object_onoff($answerrecord, 'status', 'status', 'Enabled', 'Disabled', array(), 'valignmiddle'); print '
'; - print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; - print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 4d8039dafca..d6b2b1177cb 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -29,6 +29,7 @@ EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth # # Admin page # +NewRegistration=Registration EventOrganizationSetup = Event Organization setup Settings = Settings EventOrganizationSetupPage = Event Organization setup page @@ -76,7 +77,7 @@ AllowUnknownPeopleSuggestConfHelp=Allow unknown people to suggest conferences AllowUnknownPeopleSuggestBooth=Allow unknown people to suggest booth AllowUnknownPeopleSuggestBoothHelp=Allow unknown people to suggest booth PriceOfRegistration=Price of registration -PriceOfRegistrationHelp=Price of registration +PriceOfRegistrationHelp=Price to pay to register or participate in the event PriceOfBooth=Subscription price to stand a booth PriceOfBoothHelp=Subscription price to stand a booth EventOrganizationICSLink=Link ICS for events @@ -101,7 +102,7 @@ EvntOrgCancelled = Cancelled # SuggestForm = Suggestion page SuggestOrVoteForConfOrBooth = Page for suggestion or vote -EvntOrgRegistrationHelpMessage = Here, you can vote for an event, or suggest a new conference or booth for the project +EvntOrgRegistrationHelpMessage = Here, you can vote for a conference or booth or suggest a new one for the event EvntOrgRegistrationConfHelpMessage = Here, you can suggest a new conference for the project EvntOrgRegistrationBoothHelpMessage = Here, you can suggest a new booth for the project ListOfSuggestedConferences = List of suggested conferences @@ -113,7 +114,7 @@ ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionGlobalPage = Public link for registration to the event PublicAttendeeSubscriptionPage = Public link for registration to this event only MissingOrBadSecureKey = The security key is invalid or missing -EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference : '%s' +EvntOrgWelcomeMessage = This form allows you to register as a new participant to the event : %s EvntOrgDuration = This conference starts on %s and ends on %s. ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s. BoothLocationFee = Booth location for the event : '%s' occurring from %s to %s diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 79688bffcf6..fd216e49c34 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -483,10 +483,10 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $form = new Form($db); $formcompany = new FormCompany($db); -llxHeaderVierge($langs->trans("NewSubscription")); +llxHeaderVierge($langs->trans("NewRegistration")); print '
'; -print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); +print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, 0, 'center'); print '
'; @@ -498,9 +498,19 @@ print '
'; print $langs->trans("EvntOrgWelcomeMessage", $project->title . ' '. $conference->label); print '
'; if ($conference->id) { - print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); + print $langs->trans("Date").': '; + print dol_print_date($conference->datep); + if ($conference->date_end) { + print ' - '; + print dol_print_date($conference->datef); + } } else { - print $langs->trans("EvntOrgDuration", dol_print_date($project->date_start), dol_print_date($project->date_end)); + print $langs->trans("Date").': '; + print dol_print_date($project->date_start); + if ($project->date_end) { + print ' - '; + print dol_print_date($project->date_end); + } } print '
'; @@ -540,13 +550,13 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO print '' . "\n"; // Email - print '' . "\n"; + print '' . "\n"; // Company print '' . "\n"; + print ' ' . "\n"; // Address print '' . "\n"; @@ -587,6 +597,12 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO print ''; } + if ($project->price_registration) { + print ''; + } + print "
' . $langs->trans("Email") . '*
' . $langs->trans("Email") . '*
' . $langs->trans("Company"); if (!empty(floatval($project->price_registration))) { print '*'; } - print '
' . $langs->trans("Address") . '' . "\n"; print '
' . $langs->trans('Price') . ''; + print price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency); + print '
\n"; print dol_get_fiche_end(); From 3df005778ce0e085e2c4efe631ce2edb6929cc17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 19:48:32 +0200 Subject: [PATCH 175/229] Debug event module --- htdocs/core/class/commonobject.class.php | 6 +-- .../class/conferenceorbooth.class.php | 8 +-- .../conferenceorbooth_list.php | 11 ++-- .../conferenceorboothattendee_card.php | 19 +++++-- .../conferenceorboothattendee_list.php | 50 +++++++++---------- htdocs/langs/en_US/eventorganization.lang | 5 +- 6 files changed, 57 insertions(+), 42 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6d9622ede17..d0682320788 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6721,9 +6721,9 @@ abstract class CommonObject foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow = dol_trunc($translabel).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; + $labeltoshow = dol_trunc($obj->$field_toshow).' '; } } $out .= ''; @@ -6733,7 +6733,7 @@ abstract class CommonObject if ($translabel != $obj->{$InfoFieldList[1]}) { $labeltoshow = dol_trunc($translabel, 18); } else { - $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}); } } if (empty($labeltoshow)) { diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index fec27a91bee..b826809b348 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -73,7 +73,7 @@ class ConferenceOrBooth extends ActionComm /** - * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms @@ -106,10 +106,10 @@ class ConferenceOrBooth extends ActionComm 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width300'), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'2',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'3',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index e94a3139862..64749e96113 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -293,7 +294,7 @@ if ($projectid > 0) { print '
'; print '
'; - print ''; + print '
'; // Usage print '
'; @@ -355,7 +356,7 @@ if ($projectid > 0) { // Other attributes $cols = 2; - $objectconf=$object; + $objectconf = $object; $object = $project; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; $object = $objectconf; @@ -367,7 +368,7 @@ if ($projectid > 0) { print '
'; print '
'; - print ''; + print '
'; // Description print '
'.$langs->trans("Description").''; @@ -415,7 +416,7 @@ if ($projectid > 0) { $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // Show message - $message = 'entity > 1 ? "&entity=".$conf->entity : ""); $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); $message .= "&project=".$projectid.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; @@ -638,6 +639,8 @@ print ''; print ''; print ''; +$title = $langs->trans("ListOfConferencesOrBooths"); + $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&withproject=1&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 4813ce5e968..a2dd7b50ea9 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -111,22 +111,33 @@ if (empty($reshook)) { $error = 0; if (!empty($withproject)) { - $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php?withproject=1', 1); + $backurlforlist = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php?withproject=1'; } else { - $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php'; } - if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + $backtopage = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?id='.($id > 0 ? $id : '__ID__'); } } } + if ($cancel) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } + + $triggermodname = 'EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 311b41a8810..7b49b8725b8 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -27,16 +27,15 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } -// load eventorganization libraries -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); @@ -209,8 +208,18 @@ if (empty($reshook)) { */ $form = new Form($db); - $now = dol_now(); + +//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; +$help_url = ''; +if ($confOrBooth->id > 0) { + $title = $langs->trans('ListOfAttendeesPerConference'); +} else { + $title = $langs->trans('ListOfAttendeesOfEvent'); +} +$morejs = array(); +$morecss = array(); + $confOrBooth = new ConferenceOrBooth($db); if ($conf_or_booth_id > 0) { $result = $confOrBooth->fetch($conf_or_booth_id); @@ -345,11 +354,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; -$help_url = ''; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")); -$morejs = array(); -$morecss = array(); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); @@ -473,7 +477,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print '
'; print '
'; - print ''; + print '
'; // Description print '"; } - print '"; print '"; print '"; print '"; print '"; print '"; print '
'.$langs->trans("Description").''; @@ -487,7 +491,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print "
'; + print '
'; $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); @@ -504,15 +508,15 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print "
'; - print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; - print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; @@ -521,7 +525,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // Show message - $message = 'entity > 1 ? "&entity=".$conf->entity : ""); $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; @@ -582,10 +586,6 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { $head = conferenceorboothPrepareHead($confOrBooth, $withproject); print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - //$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; - $title = $langs->trans("ConferenceOrBooth") . ' - ' . $langs->trans("Attendees") . ' - ' . $confOrBooth->id; - $object_evt = $object; $object = $confOrBooth; @@ -674,7 +674,7 @@ print ''; $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendConferenceOrBoothAttendeeRef"; @@ -728,7 +728,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { @@ -776,7 +776,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { @@ -829,12 +829,12 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap left'; } elseif ($key == 'ref') { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref', 'status'))) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index d6b2b1177cb..0494eeb05e8 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -82,7 +82,8 @@ PriceOfBooth=Subscription price to stand a booth PriceOfBoothHelp=Subscription price to stand a booth EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations -Attendees = Attendees +Attendees=Attendees +ListOfAttendeesOfEvent=List of attendees of the event project DownloadICSLink = Download ICS link EVENTORGANIZATION_SECUREKEY = Secure Key of the public registration link to a conference SERVICE_BOOTH_LOCATION = Service used for the invoice row about a booth location @@ -107,7 +108,7 @@ EvntOrgRegistrationConfHelpMessage = Here, you can suggest a new conference for EvntOrgRegistrationBoothHelpMessage = Here, you can suggest a new booth for the project ListOfSuggestedConferences = List of suggested conferences ListOfSuggestedBooths = List of suggested booths -ListOfConferencesOrBooths=List of conferences or booths +ListOfConferencesOrBooths=List of conferences or booths of event project SuggestConference = Suggest a new conference SuggestBooth = Suggest a booth ViewAndVote = View and vote for suggested events From 6089de568e88cc59900593a2203b271bac7b3f5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 23:15:06 +0200 Subject: [PATCH 176/229] Fix sort order --- htdocs/compta/sociales/list.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 388d0f5a7bf..71d788d6de6 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -192,7 +192,7 @@ if (!empty($conf->projet->enabled)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)"; $sql .= " WHERE cs.fk_type = c.id"; -$sql .= " AND cs.entity = ".$conf->entity; +$sql .= " AND cs.entity = ".((int) $conf->entity); // Search criteria if ($search_ref) { $sql .= " AND cs.ref = '".$db->escape($search_ref)."'"; @@ -452,13 +452,13 @@ if (!empty($arrayfields['cs.rowid']['checked'])) { print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.libelle']['checked'])) { - print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle", '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_type']['checked'])) { - print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type", '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.date_ech']['checked'])) { - print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech", '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['cs.periode']['checked'])) { print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center '); @@ -467,19 +467,19 @@ if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_user']['checked'])) { - print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, 'class="left"', $sortfield, $sortorder); + print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { - print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement", '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_account']['checked'])) { - print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account", '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.amount']['checked'])) { - print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount", '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder); } if (!empty($arrayfields['cs.paye']['checked'])) { - print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye", '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder); } // Hook fields From 07d48e627e58d120dc6d89ca0f7f44b005d962a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 18:13:55 +0200 Subject: [PATCH 177/229] Debug event organization module --- .../conferenceorbooth_list.php | 8 +++--- htdocs/langs/en_US/eventorganization.lang | 7 +++-- .../attendee_subscription.php | 28 +++++++++++++++---- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 5376acb3289..25537d2962d 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -398,15 +398,15 @@ if ($projectid > 0) { print "
'; - print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; - print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 7c07b853a6b..0910feef219 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -29,6 +29,7 @@ EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth # # Admin page # +NewRegistration=Registration EventOrganizationSetup = Event Organization setup Settings = Settings EventOrganizationSetupPage = Event Organization setup page @@ -76,7 +77,7 @@ AllowUnknownPeopleSuggestConfHelp=Allow unknown people to suggest conferences AllowUnknownPeopleSuggestBooth=Allow unknown people to suggest booth AllowUnknownPeopleSuggestBoothHelp=Allow unknown people to suggest booth PriceOfRegistration=Price of registration -PriceOfRegistrationHelp=Price of registration +PriceOfRegistrationHelp=Price to pay to register or participate in the event PriceOfBooth=Subscription price to stand a booth PriceOfBoothHelp=Subscription price to stand a booth EventOrganizationICSLink=Link ICS for events @@ -101,7 +102,7 @@ EvntOrgCancelled = Cancelled # SuggestForm = Suggestion page SuggestOrVoteForConfOrBooth = Page for suggestion or vote -EvntOrgRegistrationHelpMessage = Here, you can vote for an event, or suggest a new conference or booth for the project +EvntOrgRegistrationHelpMessage = Here, you can vote for a conference or booth or suggest a new one for the event EvntOrgRegistrationConfHelpMessage = Here, you can suggest a new conference for the project EvntOrgRegistrationBoothHelpMessage = Here, you can suggest a new booth for the project ListOfSuggestedConferences = List of suggested conferences @@ -113,7 +114,7 @@ ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionGlobalPage = Public link for registration to the event PublicAttendeeSubscriptionPage = Public link for registration to this event only MissingOrBadSecureKey = The security key is invalid or missing -EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference : '%s' +EvntOrgWelcomeMessage = This form allows you to register as a new participant to the event : %s EvntOrgDuration = This conference starts on %s and ends on %s. ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s. BoothLocationFee = Booth location for the event : '%s' occurring from %s to %s diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 79688bffcf6..fd216e49c34 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -483,10 +483,10 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $form = new Form($db); $formcompany = new FormCompany($db); -llxHeaderVierge($langs->trans("NewSubscription")); +llxHeaderVierge($langs->trans("NewRegistration")); print '
'; -print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); +print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, 0, 'center'); print '
'; @@ -498,9 +498,19 @@ print '
'; print $langs->trans("EvntOrgWelcomeMessage", $project->title . ' '. $conference->label); print '
'; if ($conference->id) { - print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); + print $langs->trans("Date").': '; + print dol_print_date($conference->datep); + if ($conference->date_end) { + print ' - '; + print dol_print_date($conference->datef); + } } else { - print $langs->trans("EvntOrgDuration", dol_print_date($project->date_start), dol_print_date($project->date_end)); + print $langs->trans("Date").': '; + print dol_print_date($project->date_start); + if ($project->date_end) { + print ' - '; + print dol_print_date($project->date_end); + } } print '
'; @@ -540,13 +550,13 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO print '' . "\n"; // Email - print '' . "\n"; + print '' . "\n"; // Company print '' . "\n"; + print ' ' . "\n"; // Address print '' . "\n"; @@ -587,6 +597,12 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO print ''; } + if ($project->price_registration) { + print ''; + } + print "
' . $langs->trans("Email") . '*
' . $langs->trans("Email") . '*
' . $langs->trans("Company"); if (!empty(floatval($project->price_registration))) { print '*'; } - print '
' . $langs->trans("Address") . '' . "\n"; print '
' . $langs->trans('Price') . ''; + print price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency); + print '
\n"; print dol_get_fiche_end(); From 3cc888f4dfbafd7b846524a70854a677f2d129e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 19:48:32 +0200 Subject: [PATCH 178/229] Debug event module --- htdocs/core/class/commonobject.class.php | 6 +-- .../class/conferenceorbooth.class.php | 8 +-- .../conferenceorbooth_list.php | 11 ++-- .../conferenceorboothattendee_card.php | 19 +++++-- .../conferenceorboothattendee_list.php | 50 +++++++++---------- htdocs/langs/en_US/eventorganization.lang | 5 +- 6 files changed, 57 insertions(+), 42 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cd7ea1af73c..6b741f59f20 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6688,9 +6688,9 @@ abstract class CommonObject foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow = dol_trunc($translabel).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; + $labeltoshow = dol_trunc($obj->$field_toshow).' '; } } $out .= ''; @@ -6700,7 +6700,7 @@ abstract class CommonObject if ($translabel != $obj->{$InfoFieldList[1]}) { $labeltoshow = dol_trunc($translabel, 18); } else { - $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}); } } if (empty($labeltoshow)) { diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 100c5559ca1..49b7112ac5b 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -73,7 +73,7 @@ class ConferenceOrBooth extends ActionComm /** - * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms @@ -106,10 +106,10 @@ class ConferenceOrBooth extends ActionComm 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width300'), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'2',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'3',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 25537d2962d..89a8e1c77ef 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -293,7 +294,7 @@ if ($projectid > 0) { print '
'; print '
'; - print ''; + print '
'; // Usage print '
'; @@ -355,7 +356,7 @@ if ($projectid > 0) { // Other attributes $cols = 2; - $objectconf=$object; + $objectconf = $object; $object = $project; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; $object = $objectconf; @@ -367,7 +368,7 @@ if ($projectid > 0) { print '
'; print '
'; - print ''; + print '
'; // Description print ''."\n"; + if (! is_object($attendee->project)) { + $text = 'ErrorProjectotFound'; + } else { + $text = $langs->trans("PaymentEvent").' - '.$attendee->project->title; + } + // Object - $text = ''.$langs->trans("PaymentConferenceAttendee").''; print ''."\n"; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 3952e5f0565..80783ab6216 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -23,9 +23,10 @@ /** * \file htdocs/public/payment/paymentok.php * \ingroup core - * \brief File to show page after a successful payment + * \brief File to show page after a successful payment on a payment line system. + * The payment was already really recorded. So an error here must send warning to admin but must still infor user that payment is ok. * This page is called by payment system with url provided to it completed with parameter TOKEN=xxx - * This token can be used to get more informations. + * This token and session can be used to get more informations. */ if (!defined('NOLOGIN')) { @@ -804,7 +805,7 @@ if ($ispaymentok) { $ispostactionok = 1; } } else { - $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.'; $ispostactionok = -1; $error++; } @@ -910,7 +911,7 @@ if ($ispaymentok) { $ispostactionok = 1; } } else { - $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.'; $ispostactionok = -1; $error++; } @@ -933,7 +934,7 @@ if ($ispaymentok) { // TODO send email with acknowledgment for the donation // (need that the donation module can gen a pdf document for the cerfa with pre filled content) } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) { - // Record payment for attendee + // Record payment for registration to an event for an attendee include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -985,7 +986,7 @@ if ($ispaymentok) { } $paiement->paiementid = $paymentTypeId; $paiement->num_payment = ''; - $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; + $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress.' for event registration'; $paiement->ext_payment_id = $TRANSACTIONID; $paiement->ext_payment_site = $service; @@ -1026,77 +1027,86 @@ if ($ispaymentok) { $ispostactionok = 1; } } else { - $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.'; $ispostactionok = -1; $error++; } } if (!$error) { - $db->commit(); - // Validating the attendee $attendeetovalidate = new ConferenceOrBoothAttendee($db); $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']); if ($resultattendee < 0) { + $error++; setEventMessages(null, $attendeetovalidate->errors, "errors"); } else { - $attendeetovalidate->amount=$FinalPaymentAmt; - $attendeetovalidate->update($user); $attendeetovalidate->validate($user); - // Sending mail - $thirdparty = new Societe($db); - $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc); - if ($resultthirdparty < 0) { - setEventMessages(null, $attendeetovalidate->errors, "errors"); + $attendeetovalidate->amount = $FinalPaymentAmt; + $attendeetovalidate->date_subscription = dol_now(); + $attendeetovalidate->update($user); + } + } + + if (!$error) { + $db->commit(); + } else { + setEventMessages(null, $postactionmessages, 'warnings'); + + $db->rollback(); + } + + if (! $error) { + // Sending mail + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc); + if ($resultthirdparty < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } else { + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + + $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; + + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + } + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + + $sendto = $attendeetovalidate->email; + $from = $conf->global->MAILING_EMAIL_FROM; + $urlback = $_SERVER["REQUEST_URI"]; + + $ishtml = dol_textishtml($texttosend); // May contain urls + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + + $result = $mailfile->sendfile(); + if ($result) { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); } else { - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; - - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); - } - - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); - - $sendto = $attendeetovalidate->email; - $from = $conf->global->MAILING_EMAIL_FROM; - $urlback = $_SERVER["REQUEST_URI"]; - - $ishtml = dol_textishtml($texttosend); // May contain urls - - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); - - $result = $mailfile->sendfile(); - if ($result) { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); - } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); - } + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); } } - } else { - $db->rollback(); } } } else { @@ -1201,7 +1211,7 @@ if ($ispaymentok) { $ispostactionok = 1; } } else { - $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.'; $ispostactionok = -1; $error++; } From f5903c9b02d7e5eb00b5e3683e901f9626de9838 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 01:45:17 +0200 Subject: [PATCH 181/229] Debug organizedeventregistration module --- .../class/conferenceorbooth.class.php | 4 +-- .../class/conferenceorboothattendee.class.php | 31 ++++++++++++------- .../conferenceorbooth_card.php | 2 +- .../conferenceorbooth_contact.php | 6 ++-- .../conferenceorboothattendee_card.php | 3 +- .../conferenceorboothattendee_list.php | 9 +++--- ...ventorganization_conferenceorbooth.lib.php | 8 ++--- htdocs/langs/en_US/eventorganization.lang | 4 +-- ...cription.php => attendee_registration.php} | 0 9 files changed, 39 insertions(+), 28 deletions(-) rename htdocs/public/eventorganization/{attendee_subscription.php => attendee_registration.php} (100%) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 9e07fd446d5..a8b1dddda3a 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -106,7 +106,7 @@ class ConferenceOrBooth extends ActionComm 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company', 'css'=>'maxwidth500'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width300'), @@ -565,7 +565,7 @@ class ConferenceOrBooth extends ActionComm $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->id; - $url = dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.$this->id; + $url = DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 3e402877b4d..9185ab5992f 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -63,6 +63,7 @@ class ConferenceOrBoothAttendee extends CommonObject */ public $picto = 'contact'; + public $paid = 0; const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; @@ -102,12 +103,12 @@ class ConferenceOrBoothAttendee extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>0, 'index'=>1,), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>0, 'index'=>1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company', 'css'=>'maxwidth500'), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'picto'=>'project'), 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'index'=>1,), - 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), - 'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), + 'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'amount' => array('type'=>'price', 'label'=>'AmountPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -730,6 +731,8 @@ class ConferenceOrBoothAttendee extends CommonObject } $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label .= '
'.$langs->trans('DateOfRegistration').': '.dol_print_date($this->date_subscription, 'dayhour'); + $label .= '
'.$langs->trans('AmountPaid').': '.$this->amount; $url = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$this->id; @@ -744,15 +747,15 @@ class ConferenceOrBoothAttendee extends CommonObject } if ($option == 'conforboothid') { - $url .= '&conforboothid='.$this->fk_actioncomm; + $url .= '&conforboothid='.((int) $this->fk_actioncomm); } if ($option == 'projectid') { - $url .= '&fk_project='.$this->fk_project.'&withproject=1'; + $url .= '&fk_project='.((int) $this->fk_project).'&withproject=1'; } if ($option == 'conforboothidproject') { - $url .= '&conforboothid='.$this->fk_actioncomm.'&withproject=1' ; + $url .= '&conforboothid='.((int) $this->fk_actioncomm).'&withproject=1' ; } } @@ -853,14 +856,15 @@ class ConferenceOrBoothAttendee extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable + global $langs; + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - global $langs; //$langs->load("eventorganization@eventorganization"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated'); $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Validated'); $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); } @@ -870,6 +874,11 @@ class ConferenceOrBoothAttendee extends CommonObject $statusType = 'status6'; } + if ($status == self::STATUS_VALIDATED && $this->date_subscription && $this->amount) { + $statusType = 'status4'; + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' - '.$langs->trans("Paid"); + } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 6ae9ab9664b..ea54d1e3d2f 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -182,7 +182,7 @@ $object->project = clone $projectstatic; if (!empty($withproject)) { // Tabs for project $tab = 'eventorganisation'; - $withProjectUrl="&withproject=1"; + $withProjectUrl = "&withproject=1"; $head = project_prepare_head($projectstatic); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php index 8595da92652..9fc26503c44 100644 --- a/htdocs/eventorganization/conferenceorbooth_contact.php +++ b/htdocs/eventorganization/conferenceorbooth_contact.php @@ -101,7 +101,7 @@ if ($action == 'addcontact' && $permission) { // Add a new contact $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.(!empty($withproject)?'&withproject=1':'')); + header("Location: ".$_SERVER['PHP_SELF']."?id=".((int) $object->id).(!empty($withproject)?'&withproject=1':'')); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -119,7 +119,7 @@ if ($action == 'addcontact' && $permission) { // Add a new contact $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.(!empty($withproject)?'&withproject=1':'')); + header("Location: ".$_SERVER['PHP_SELF']."?id=".((int) $object->id).(!empty($withproject)?'&withproject=1':'')); exit; } else { dol_print_error($db); @@ -161,7 +161,7 @@ $object->project = clone $projectstatic; if (!empty($withproject)) { // Tabs for project $tab = 'eventorganisation'; - $withProjectUrl="&withproject=1"; + $withProjectUrl = "&withproject=1"; $head = project_prepare_head($projectstatic); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 54131275ee8..329b54d5eda 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -200,7 +200,7 @@ $object->project = clone $projectstatic; if (!empty($withproject)) { // Tabs for project $tab = 'eventorganisation'; - $withProjectUrl="&withproject=1"; + $withProjectUrl = "&withproject=1"; $head = project_prepare_head($projectstatic); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); @@ -418,6 +418,7 @@ if ($action == 'create') { } if ($projectstatic->id > 0) { print ''; + print ''; } diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index da2ed2ed957..57ff9d23bd1 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -57,8 +57,7 @@ $id = GETPOST('id', 'int'); $conf_or_booth_id = GETPOST('conforboothid', 'int'); $withproject = GETPOST('withproject', 'int'); -$project_ref = GETPOST('project_ref', 'alpha'); -$fk_project = GETPOST('fk_project', 'int'); +$fk_project = GETPOST('fk_project', 'int') ? GETPOST('fk_project', 'int') : GETPOST('projectid', 'int') ; $withProjectUrl=''; @@ -372,8 +371,9 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { if (!empty($withproject)) { // Tabs for project $tab = 'eventorganisation'; - $withProjectUrl="&withproject=1"; + $withProjectUrl = "&withproject=1"; $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -587,6 +587,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { if ($confOrBooth->id > 0) { $head = conferenceorboothPrepareHead($confOrBooth, $withproject); + print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); $object_evt = $object; @@ -675,7 +676,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.(empty($confOrBooth->id) ? '' : '&conforboothid='.$confOrBooth->id).$withProjectUrl), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index fcdd3c296e1..f49bd5e49a0 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -39,20 +39,20 @@ function conferenceorboothPrepareHead($object, $with_project = 0) $withProjectUrl=''; if ($with_project>0) { - $withProjectUrl="&withproject=1"; + $withProjectUrl = "&withproject=1"; } - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id.$withProjectUrl; + $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.ph?id='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_contact.php", 1).'?id='.$object->id.$withProjectUrl; + $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorbooth_contact.php?id='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("ContactsAddresses"); $head[$h][2] = 'contact'; $h++; - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?conforboothid='.$object->id.$withProjectUrl; + $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php?conforboothid='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("Attendees"); $head[$h][2] = 'attendees'; // Enable caching of conf or booth count attendees diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 0133176a9ea..8f67c4290e5 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -55,8 +55,8 @@ EventOrganizationConfOrBooth= Conference Or Booth ManageOrganizeEvent = Manage event organisation ConferenceOrBooth = Conference Or Booth ConferenceOrBoothTab = Conference Or Booth -AmountOfSubscriptionPaid = Amount of subscription paid -DateSubscription = Date of subscription +AmountPaid = Amount paid +DateOfRegistration = Date of subscription ConferenceOrBoothAttendee = Conference Or Booth Attendee # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_registration.php similarity index 100% rename from htdocs/public/eventorganization/attendee_subscription.php rename to htdocs/public/eventorganization/attendee_registration.php From 0b68da4e9e1931a7dd7e6ee36fd336edea06169d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 02:27:52 +0200 Subject: [PATCH 182/229] Debug organizedeventregistration module --- htdocs/core/lib/project.lib.php | 2 +- htdocs/langs/en_US/eventorganization.lang | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 5432ff18095..d3285869752 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -207,7 +207,7 @@ function project_prepare_head(Project $project) if ($conf->eventorganization->enabled && !empty($project->usage_organize_event)) { $langs->load('eventorganization'); $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id; - $head[$h][1] = $langs->trans("ConferenceOrBoothTab"); + $head[$h][1] = $langs->trans("EventOrganization"); // Enable caching of conf or booth count $nbConfOrBooth = 0; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 8f67c4290e5..d4110dd184f 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -19,7 +19,7 @@ # ModuleEventOrganizationName = Event Organization EventOrganizationDescription = Event Organization through Module Project -EventOrganizationDescriptionLong= Manage Event organization for conference, attendees, speaker, and attendees, with public subcription page +EventOrganizationDescriptionLong= Manage the organization of an event (conferences, attendees, speakers, with public suggestion, vote or registration pages) # # Menu # @@ -32,8 +32,9 @@ PaymentEvent=Payment of event # Admin page # NewRegistration=Registration -EventOrganizationSetup = Event Organization setup -Settings = Settings +EventOrganizationSetup=Event Organization setup +EventOrganization=Event organization +Settings=Settings EventOrganizationSetupPage = Event Organization setup page EVENTORGANIZATION_TASK_LABEL = Label of tasks to create automatically when project is validated EVENTORGANIZATION_TASK_LABELTooltip = When you validate an organized event, some tasks can be automatically created in the project

For example:
Send Call for Conference
Send Call for Booth
Receive call for conferences
Receive call for Booth
Open subscriptions to events for attendees
Send remind of event to speakers
Send remind of event to Booth hoster
Send remind of event to attendees @@ -52,7 +53,7 @@ EVENTORGANIZATION_FILTERATTENDEES_TYPE = Filter thirdpartie's select list in att # Object # EventOrganizationConfOrBooth= Conference Or Booth -ManageOrganizeEvent = Manage event organisation +ManageOrganizeEvent = Manage the organization of an event ConferenceOrBooth = Conference Or Booth ConferenceOrBoothTab = Conference Or Booth AmountPaid = Amount paid From 6c118b4dfbe2cc7a312486cdcbedd086adf28459 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 8 Sep 2021 04:31:38 +0200 Subject: [PATCH 183/229] css --- htdocs/accountancy/journal/expensereportsjournal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 9633157b5b7..96ab150dd24 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -610,7 +610,7 @@ if (empty($action) || $action == 'view') { $userstatic->id = $tabuser[$key]['id']; $userstatic->name = $tabuser[$key]['name']; print "
"; - print '"; + print '"; print '"; print ""; } From 8c95ada9fddefd98c5713d5b61c93ddc7cd77823 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 8 Sep 2021 10:25:27 +0200 Subject: [PATCH 184/229] FIX wrong users count in multicompany transverse mode --- htdocs/user/class/user.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index df60c0f2fc9..05710ec2f88 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3298,14 +3298,21 @@ class User extends CommonObject public function load_state_board() { // phpcs:enable + global $conf; $this->nb = array(); - $sql = "SELECT count(u.rowid) as nb"; + $sql = "SELECT DISTINCT count(u.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.statut > 0"; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE ug.entity IN (".getEntity('usergroup').")"; + $sql .= " AND ug.fk_user = u.rowid "; + } else { + $sql .= " WHERE u.entity IN (".getEntity('user').")"; + } + $sql .= " AND u.statut > 0"; //$sql.= " AND employee != 0"; - $sql .= " AND u.entity IN (".getEntity('user').")"; $resql = $this->db->query($sql); if ($resql) { From a5e670291e8cedb47d0cb10e3c81841f41236b89 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 8 Sep 2021 15:36:51 +0200 Subject: [PATCH 185/229] Fix permission for salaries module --- htdocs/core/lib/security.lib.php | 2 +- htdocs/salaries/card.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b297c81035e..4c36244a5bf 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -611,7 +611,7 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $feature = 'projet_task'; } - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salary', 'website'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index d3c7ba504cb..f83f879cf8e 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -67,9 +67,27 @@ $fk_user = GETPOSTINT('userid'); $object = new Salary($db); $extrafields = new ExtraFields($db); +$childids = $user->getAllChildIds(1); + // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); +if (($id > 0) || $ref) { + $object->fetch($id, $ref); + + // Check current user can read this leave request + $canread = 0; + if (!empty($user->rights->salaries->readall)) { + $canread = 1; + } + if (!empty($user->rights->salaries->read) && in_array($object->fk_user, $childids)) { + $canread = 1; + } + if (!$canread) { + accessforbidden(); + } +} + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salarycard', 'globalcard')); From e9505c1109934e62b34f52e404528056ce0cd9e7 Mon Sep 17 00:00:00 2001 From: MOREAU FRANCK Date: Wed, 8 Sep 2021 18:23:44 +0200 Subject: [PATCH 186/229] Update V14 --- htdocs/core/menus/standard/eldy.lib.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 75055329add..95af5973587 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -384,10 +384,16 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Tickets and knwoledge base $tmpentry = array( - 'enabled'=>(!empty($conf->ticket->enabled) || !empty($conf->knwoledgemanagement->enabled)), - 'perms'=>(!empty($user->rights->ticket->read) || !empty($user->rights->knwoledgemanagement->read)), - 'module'=>'ticket|knwoledgemanagement' + 'enabled'=>(!empty($conf->ticket->enabled) || !empty($conf->knowledgemanagement->enabled)), + 'perms'=>(!empty($user->rights->ticket->read) || !empty($user->rights->knowledgemanagement->knowledgerecord->read)), + 'module'=>'ticket|knowledgemanagement' ); + $link = ''; + if(!empty($conf->ticket->enabled)){ + $link = '/ticket/index.php?mainmenu=ticket&leftmenu='; + }else{ + $link = '/knowledgemanagement/knowledgerecord_list.php?mainmenu=ticket&leftmenu='; + } $menu_arr[] = array( 'name' => 'Ticket', 'link' => '/ticket/index.php?mainmenu=ticket&leftmenu=', From 405beb77f5986679ad7f0e58f2f80d4d0a4b5a53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 19:45:55 +0200 Subject: [PATCH 187/229] Fix sql error --- htdocs/compta/facture/card-rec.php | 2 ++ htdocs/core/class/commonobject.class.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 94a884bf1bf..9443cab1d83 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1226,6 +1226,8 @@ if ($action == 'create') { } $morehtmlref .= ''; + $morehtmlright = ''; + dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright); print '
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d0682320788..ad4ad76a0f2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2010,6 +2010,11 @@ abstract class CommonObject return 1; } + // For backward compatibility + if ($this->table_element == 'facture_rec' && $fieldid == 'title') { + $fieldid = 'titre'; + } + // Security on socid $socid = 0; if ($user->socid > 0) { From 57a2ea3a5357af89088829ed74e296892eb47a12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 19:45:55 +0200 Subject: [PATCH 188/229] Fix sql error --- htdocs/compta/facture/card-rec.php | 2 ++ htdocs/core/class/commonobject.class.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index affdd2e8991..d122c00ac07 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1228,6 +1228,8 @@ if ($action == 'create') { } $morehtmlref .= '
'; + $morehtmlright = ''; + dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright); print '
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6b741f59f20..eb6ac7e882b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2001,6 +2001,11 @@ abstract class CommonObject return 1; } + // For backward compatibility + if ($this->table_element == 'facture_rec' && $fieldid == 'title') { + $fieldid = 'titre'; + } + // Security on socid $socid = 0; if ($user->socid > 0) { From 04026dd0b06f330a903a76e45d86109b7d23bc99 Mon Sep 17 00:00:00 2001 From: MOREAU FRANCK Date: Wed, 8 Sep 2021 19:51:34 +0200 Subject: [PATCH 189/229] fix Stickler CI review --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 95af5973587..7c93cd94163 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -389,9 +389,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'module'=>'ticket|knowledgemanagement' ); $link = ''; - if(!empty($conf->ticket->enabled)){ + if (!empty($conf->ticket->enabled)) { $link = '/ticket/index.php?mainmenu=ticket&leftmenu='; - }else{ + } else { $link = '/knowledgemanagement/knowledgerecord_list.php?mainmenu=ticket&leftmenu='; } $menu_arr[] = array( From bfa75e91e2b9f5de94f06f5086682fa2d78cb816 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 20:59:56 +0200 Subject: [PATCH 190/229] Code comment --- htdocs/product/class/product.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 818ee620821..e0a8ccb78a5 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -175,6 +175,9 @@ class Product extends CommonObject public $prices_by_qty_id = array(); public $prices_by_qty_list = array(); + //! Array for multilangs + public $multilangs = array(); + //! Default VAT code for product (link to code into llx_c_tva but without foreign keys) public $default_vat_code; @@ -350,8 +353,6 @@ class Product extends CommonObject public $stats_mrptoconsume = array(); public $stats_mrptoproduce = array(); - public $multilangs = array(); - //! Size of image public $imgWidth; public $imgHeight; @@ -2229,8 +2230,8 @@ class Product extends CommonObject * @param string $ref_ext Ref ext of product/service to load * @param string $barcode Barcode of product/service to load * @param int $ignore_expression When module dynamicprices is on, ignores the math expression for calculating price and uses the db value instead - * @param int $ignore_price_load Load product without loading prices arrays (when we are sure we don't need them) - * @param int $ignore_lang_load Load product without loading language arrays (when we are sure we don't need them) + * @param int $ignore_price_load Load product without loading $this->multiprices... array (when we are sure we don't need them) + * @param int $ignore_lang_load Load product without loading $this->multilangs language arrays (when we are sure we don't need them) * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore_expression = 0, $ignore_price_load = 0, $ignore_lang_load = 0) From e0fa4e4b5c6dc5c14e26a4fff12e7616bb699915 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 21:19:01 +0200 Subject: [PATCH 191/229] Fix phpcs --- htdocs/core/class/html.formcompany.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index db7df18e210..3e2c3588405 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -718,7 +718,7 @@ class FormCompany extends Form } print '>'; print ''; - + $num = $this->db->num_rows($resql); $i = 0; if ($num) { From 8326ecee786104edbd9cec778b811a1cd69018d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 21:19:40 +0200 Subject: [PATCH 192/229] Fix phpcs --- htdocs/eventorganization/conferenceorboothattendee_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 57ff9d23bd1..a6ea42da346 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -57,7 +57,7 @@ $id = GETPOST('id', 'int'); $conf_or_booth_id = GETPOST('conforboothid', 'int'); $withproject = GETPOST('withproject', 'int'); -$fk_project = GETPOST('fk_project', 'int') ? GETPOST('fk_project', 'int') : GETPOST('projectid', 'int') ; +$fk_project = GETPOST('fk_project', 'int') ? GETPOST('fk_project', 'int') : GETPOST('projectid', 'int'); $withProjectUrl=''; From 4705d41ed2b1b6f71d5cc781149da0373287ac68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 22:00:16 +0200 Subject: [PATCH 193/229] FIX Relative discount with high nb of decimals --- htdocs/comm/propal/card.php | 20 +++++++++++--------- htdocs/commande/card.php | 8 +++++--- htdocs/compta/facture/card-rec.php | 12 +++++++----- htdocs/compta/facture/card.php | 28 +++++++++++++++------------- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3c0d8dd9a28..95a1418b644 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -384,8 +384,8 @@ if (empty($reshook)) { $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); - $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU', 2); $object->socid = GETPOST('socid', 'int'); $object->contact_id = GETPOST('contactid', 'int'); $object->fk_project = GETPOST('projectid', 'int'); @@ -826,8 +826,8 @@ if (empty($reshook)) { $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2); if (empty($remise_percent)) { $remise_percent = 0; } @@ -1214,6 +1214,8 @@ if (empty($reshook)) { $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); @@ -1226,7 +1228,7 @@ if (empty($reshook)) { } // Define special_code for special lines - $special_code = GETPOST('special_code'); + $special_code = GETPOST('special_code', 'int'); if (!GETPOST('qty')) { $special_code = 3; } @@ -1245,7 +1247,7 @@ if (empty($reshook)) { } $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -1275,7 +1277,7 @@ if (empty($reshook)) { $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise); + $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise); if ($result >= 0) { $db->commit(); @@ -1343,9 +1345,9 @@ if (empty($reshook)) { // Terms of payment $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'))); + $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), '', 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { - $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'))); + $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); } elseif ($action == 'setmode' && $usercancreate) { // Payment choice $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 7363ceace5c..bbc6bdbafb9 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -629,7 +629,7 @@ if (empty($reshook)) { $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha')) : 0); + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { $remise_percent = 0; } @@ -1019,6 +1019,8 @@ if (empty($reshook)) { $special_code = 3; } + $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Check minimum price $productid = GETPOST('productid', 'int'); if (!empty($productid)) { @@ -1034,7 +1036,7 @@ if (empty($reshook)) { $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -1059,7 +1061,7 @@ if (empty($reshook)) { } } } - $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, price2num(GETPOST('qty'), 'MS'), price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); + $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, price2num(GETPOST('qty'), 'MS'), $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index d122c00ac07..ced6ea152e4 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -433,8 +433,8 @@ if (empty($reshook)) { $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -781,6 +781,8 @@ if (empty($reshook)) { $result = -1; }*/ + $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Check minimum price $productid = GETPOST('productid', 'int'); if (!empty($productid)) { @@ -797,7 +799,7 @@ if (empty($reshook)) { $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent', 2)) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -830,8 +832,8 @@ if (empty($reshook)) { $vat_rate, $localtax1_rate, $localtax1_rate, - GETPOST('productid'), - price2num(GETPOST('remise_percent'), 2), + GETPOST('productid', 'int'), + $remise_percent, 'HT', $info_bits, 0, diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a09bc6853d0..d019b2dcf9a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -506,7 +506,7 @@ if (empty($reshook)) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { $object->fetch($id); - $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), 2)); + $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), '', 2)); } elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] @@ -1022,8 +1022,8 @@ if (empty($reshook)) { $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU', 2); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1079,7 +1079,7 @@ if (empty($reshook)) { $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1294,7 +1294,7 @@ if (empty($reshook)) { $object->fk_account = GETPOST('fk_account', 'int'); $object->amount = price2num(GETPOST('amount')); $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1375,7 +1375,7 @@ if (empty($reshook)) { $object->fk_account = GETPOST('fk_account', 'int'); $object->amount = price2num(GETPOST('amount')); $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -1798,7 +1798,7 @@ if (empty($reshook)) { $product->fetch(GETPOST('idprod'.$i, 'int')); $startday = dol_mktime(12, 0, 0, GETPOST('date_start'.$i.'month'), GETPOST('date_start'.$i.'day'), GETPOST('date_start'.$i.'year')); $endday = dol_mktime(12, 0, 0, GETPOST('date_end'.$i.'month'), GETPOST('date_end'.$i.'day'), GETPOST('date_end'.$i.'year')); - $result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i)), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); + $result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); } } } @@ -1899,8 +1899,8 @@ if (empty($reshook)) { $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); - $object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU', 2); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); // Proprietes particulieres a facture de remplacement @@ -1986,8 +1986,8 @@ if (empty($reshook)) { $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef), 'MS'); - $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); + $qty = price2num(GETPOST('qty'.$predef), 'MS', 2); + $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -2389,6 +2389,8 @@ if (empty($reshook)) { } } + $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Check minimum price $productid = GETPOST('productid', 'int'); if (!empty($productid)) { @@ -2405,7 +2407,7 @@ if (empty($reshook)) { $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) { + if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -2458,7 +2460,7 @@ if (empty($reshook)) { $description, $pu_ht, $qty, - price2num(GETPOST('remise_percent'), 2), + $remise_percent, $date_start, $date_end, $vat_rate, From 30856d5b183d9b4d2c81cc2e90e15b937920b38c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 22:09:02 +0200 Subject: [PATCH 194/229] FIX Relative discount with high nb of decimals --- htdocs/commande/card.php | 4 ++-- htdocs/contrat/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 4 ++-- htdocs/product/card.php | 14 +++++++------- htdocs/product/fournisseurs.php | 2 +- htdocs/product/price.php | 6 +++--- htdocs/supplier_proposal/card.php | 12 ++++++------ 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index bbc6bdbafb9..224c443754a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -597,9 +597,9 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setremisepercent' && $usercancreate) { - $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), 2)); + $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), '', 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { - $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU')); + $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d5187c6a040..1466f595b3d 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -204,7 +204,7 @@ if (empty($reshook)) { $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); $object->fk_project = GETPOST('projectid', 'int'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); $object->ref = GETPOST('ref', 'alpha'); $object->ref_customer = GETPOST('ref_customer', 'alpha'); $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 625ecca522f..f02ffb99d77 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -748,7 +748,7 @@ if (empty($reshook)) { GETPOST('product_desc', 'restricthtml'), $ht, price2num(GETPOST('qty'), 'MS'), - price2num(GETPOST('remise_percent'), 2), + price2num(GETPOST('remise_percent'), '', 2), $vat_rate, $localtax1_rate, $localtax2_rate, diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 04d99240f6b..42e2f528bc6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1272,8 +1272,8 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - $remise_percent = price2num(GETPOST('remise_percent'), 2); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'MU'); + $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'MU', 2); // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3a85eaaf47b..d0675ed465c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -820,7 +820,7 @@ if (empty($reshook)) { if (GETPOST('propalid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), 2), $object->id)) < 0) { + if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); } else { @@ -835,7 +835,7 @@ if (empty($reshook)) { $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 $object->id, - price2num(GETPOST('remise_percent'), 2), + price2num(GETPOST('remise_percent'), '', 2), $price_base_type, $pu_ttc, 0, @@ -860,7 +860,7 @@ if (empty($reshook)) { } elseif (GETPOST('commandeid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) { + if (($result = $commande->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); } else { @@ -875,7 +875,7 @@ if (empty($reshook)) { $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 $object->id, - price2num(GETPOST('remise_percent'), 2), + price2num(GETPOST('remise_percent'), '', 2), '', '', $price_base_type, @@ -894,13 +894,13 @@ if (empty($reshook)) { ); if ($result > 0) { - header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".$commande->id); + header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".urlencode($commande->id)); exit; } } elseif (GETPOST('factureid') > 0) { // Define cost price for margin calculation $buyprice = 0; - if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0) { + if (($result = $facture->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) { dol_syslog($langs->trans('FailedToGetCostPrice')); setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors'); } else { @@ -915,7 +915,7 @@ if (empty($reshook)) { $localtax1_tx, $localtax2_tx, $object->id, - price2num(GETPOST('remise_percent'), 2), + price2num(GETPOST('remise_percent'), '', 2), '', '', '', diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 97f29de72f6..01a09a21335 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -715,7 +715,7 @@ END; // Discount qty min print '
'; - print ''; print ''; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 4188ca9719b..cef401bcc45 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -412,10 +412,10 @@ if (empty($reshook)) { // Récupération des variables $rowid = GETPOST('rowid', 'int'); $priceid = GETPOST('priceid', 'int'); - $newprice = price2num(GETPOST("price"), 'MU'); + $newprice = price2num(GETPOST("price"), 'MU', 2); // $newminprice=price2num(GETPOST("price_min"),'MU'); // TODO : Add min price management - $quantity = price2num(GETPOST('quantity'), 'MS'); - $remise_percent = price2num(GETPOST('remise_percent'), 2); + $quantity = price2num(GETPOST('quantity'), 'MS', 2); + $remise_percent = price2num(GETPOST('remise_percent'), '', 2); $remise = 0; // TODO : allow discount by amount when available on documents if (empty($quantity)) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 5d22ea05684..6f1d0824b0b 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -258,8 +258,8 @@ if (empty($reshook)) { $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->remise_percent = price2num(GETPOST('remise_percent'), 2); - $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU'); + $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU', 2); $object->socid = GETPOST('socid'); $object->fk_project = GETPOST('projectid', 'int'); $object->model_pdf = GETPOST('model'); @@ -915,8 +915,8 @@ if (empty($reshook)) { $result = $object->updateline( GETPOST('lineid', 'int'), $ht, - price2num(GETPOST('qty'), 'MS'), - price2num(GETPOST('remise_percent'), 2), + price2num(GETPOST('qty'), 'MS', 2), + price2num(GETPOST('remise_percent'), '', 2), $vat_rate, $localtax1_rate, $localtax2_rate, @@ -996,9 +996,9 @@ if (empty($reshook)) { // Terms of payments $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), 2)); + $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), '', 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { - $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU')); + $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); } elseif ($action == 'setmode' && $usercancreate) { // Payment mode $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); From 39dd1e2dd1e3e967ab5e02b8b274564fa0e4a0b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Sep 2021 02:00:07 +0200 Subject: [PATCH 195/229] Code comment --- htdocs/societe/class/societe.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fa19b23e6cd..5f1e4cd132a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4345,10 +4345,10 @@ class Societe extends CommonObject } /** - * Return amount of order not paid and total + * Return amount of proposal not yet paid and total an dlist of all proposals * * @param string $mode 'customer' or 'supplier' - * @return array array('opened'=>Amount, 'total'=>Total amount) + * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amunt including tax of all object paid or not) */ public function getOutstandingProposals($mode = 'customer') { @@ -4389,10 +4389,10 @@ class Societe extends CommonObject } /** - * Return amount of order not paid and total + * Return amount of order not yet paid and total and list of all orders * * @param string $mode 'customer' or 'supplier' - * @return array array('opened'=>Amount, 'total'=>Total amount) + * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amunt including tax of all object paid or not) */ public function getOutstandingOrders($mode = 'customer') { @@ -4432,11 +4432,11 @@ class Societe extends CommonObject } /** - * Return amount of bill not paid and total + * Return amount of bill not yet paid and total of all invoices * - * @param string $mode 'customer' or 'supplier' + * @param string $mode 'customer' or 'supplier' * @param int $late 0 => all invoice, 1=> only late - * @return array array('opened'=>Amount, 'total'=>Total amount) + * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amunt including tax of all object paid or not) */ public function getOutstandingBills($mode = 'customer', $late = 0) { @@ -4496,7 +4496,7 @@ class Societe extends CommonObject $creditnotes = $tmpobject->getSumCreditNotesUsed(); $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened += $obj->total_ttc - $paiement - $creditnotes - $deposits; + $outstandingOpened += ($obj->total_ttc - $paiement - $creditnotes - $deposits); } //if credit note is converted but not used From 89ed156d7ee45756a5e5eac6d41e93fe41269e53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Sep 2021 02:18:50 +0200 Subject: [PATCH 196/229] Complete getOutstandingBills() --- htdocs/societe/class/societe.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5f1e4cd132a..69aecc885c7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4470,6 +4470,7 @@ class Societe extends CommonObject $outstandingTotal = 0; $outstandingTotalIncTax = 0; $arrayofref = array(); + $arrayofrefopened = array(); if ($mode == 'supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $tmpobject = new FactureFournisseur($this->db); @@ -4487,6 +4488,9 @@ class Societe extends CommonObject $outstandingTotal += $obj->total_ht; $outstandingTotalIncTax += $obj->total_ttc; } + + $remaintopay = 0; + if ($obj->paye == 0 && $obj->status != $tmpobject::STATUS_DRAFT // Not a draft && $obj->status != $tmpobject::STATUS_ABANDONED // Not abandonned @@ -4496,16 +4500,23 @@ class Societe extends CommonObject $creditnotes = $tmpobject->getSumCreditNotesUsed(); $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened += ($obj->total_ttc - $paiement - $creditnotes - $deposits); + $remaintopay = ($obj->total_ttc - $paiement - $creditnotes - $deposits); + $outstandingOpened += $remaintopay; } //if credit note is converted but not used // TODO Do this also for customer ? if ($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) { - $outstandingOpened -= $tmpobject->getSumFromThisCreditNotesNotUsed(); + $remainingcreditnote = $tmpobject->getSumFromThisCreditNotesNotUsed(); + $remaintopay -= $remainingcreditnote; + $outstandingOpened -= $remainingcreditnote; + } + + if ($remaintopay) { + $arrayofrefopened[$obj->rowid] = $obj->ref; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax, 'refs'=>$arrayofref); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax, 'refs'=>$arrayofref, 'refsopened'=>$arrayofrefopened); // 'opened' is 'incl taxes' } else { dol_syslog("Sql error ".$this->db->lasterror, LOG_ERR); return array(); From ad9bf27beab7f60617a4ca061d52660531ffc727 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Sep 2021 02:26:49 +0200 Subject: [PATCH 197/229] Clean code --- htdocs/core/boxes/box_customers_outstanding_bill_reached.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php index b61fe66f064..87be4a10c2d 100644 --- a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -133,7 +133,8 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes $thirdpartystatic->entity = $objp->entity; $thirdpartystatic->outstanding_limit = $objp->outstanding_limit; - $outstandingtotal = $thirdpartystatic->getOutstandingBills()['opened']; + $tmp = $thirdpartystatic->getOutstandingBills(); + $outstandingtotal = $tmp['opened']; $outstandinglimit = $thirdpartystatic->outstanding_limit; if ($outstandingtotal >= $outstandinglimit) { From b87ac639fd4ed060e73653f9123420cfa3354c8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Sep 2021 03:02:18 +0200 Subject: [PATCH 198/229] Update card.php --- htdocs/salaries/card.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index f83f879cf8e..6d30ae73e3d 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -72,28 +72,24 @@ $childids = $user->getAllChildIds(1); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if (($id > 0) || $ref) { - $object->fetch($id, $ref); - - // Check current user can read this leave request - $canread = 0; - if (!empty($user->rights->salaries->readall)) { - $canread = 1; - } - if (!empty($user->rights->salaries->read) && in_array($object->fk_user, $childids)) { - $canread = 1; - } - if (!$canread) { - accessforbidden(); - } -} - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salarycard', 'globalcard')); $object = new Salary($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); + + // Check current user can read this salary + $canread = 0; + if (!empty($user->rights->salaries->readall)) { + $canread = 1; + } + if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) { + $canread = 1; + } + if (!$canread) { + accessforbidden(); + } } // Security check From 8b58de50d52a22a397cab3ecbcd622b90992228a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Sep 2021 03:21:41 +0200 Subject: [PATCH 199/229] Clean code --- htdocs/holiday/card.php | 26 +++++++++++--------------- htdocs/holiday/class/holiday.class.php | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index fd0fb2eb91e..ac38a130bfa 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -467,22 +467,24 @@ if (empty($reshook)) { $message .= $langs->transnoentities("HolidaysToValidateBody")."\n"; - $delayForRequest = $object->getConfCP('delayForRequest'); - //$delayForRequest = $delayForRequest * (60*60*24); - - $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); // option to warn the validator in case of too short delay - if ($object->getConfCP('AlertValidatorDelay')) { - if ($object->date_debut < $nextMonth) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; + if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_TOO_LOW_DELAY)) { + $delayForRequest = 0; // TODO Set delay depending of holiday leave type + if ($delayForRequest) { + $nowplusdelay = dol_time_plus_duree($now, $delayForRequest, 'd'); + + if ($object->date_debut < $nowplusdelay) { + $message .= "\n"; + $message .= $langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."\n"; + } } } // option to notify the validator if the balance is less than the request - if ($object->getConfCP('AlertValidatorSolde')) { + if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE)) { $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { $message .= "\n"; $message .= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; @@ -925,12 +927,6 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } - $delayForRequest = $object->getConfCP('delayForRequest', 1); - //$delayForRequest = $delayForRequest * (60*60*24); - - $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); - - print '
'.$langs->trans("Description").''; @@ -415,7 +416,7 @@ if ($projectid > 0) { $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // Show message - $message = 'entity > 1 ? "&entity=".$conf->entity : ""); $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); $message .= "&project=".$projectid.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; @@ -638,6 +639,8 @@ print ''; print ''; print ''; +$title = $langs->trans("ListOfConferencesOrBooths"); + $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&withproject=1&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index ff46f7b4a7b..fd762c03568 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -111,22 +111,33 @@ if (empty($reshook)) { $error = 0; if (!empty($withproject)) { - $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php?withproject=1', 1); + $backurlforlist = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php?withproject=1'; } else { - $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php'; } - if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + $backtopage = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?id='.($id > 0 ? $id : '__ID__'); } } } + if ($cancel) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } + + $triggermodname = 'EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 401f3367044..6f4d2a34565 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -27,16 +27,15 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } -// load eventorganization libraries -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); @@ -209,8 +208,18 @@ if (empty($reshook)) { */ $form = new Form($db); - $now = dol_now(); + +//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; +$help_url = ''; +if ($confOrBooth->id > 0) { + $title = $langs->trans('ListOfAttendeesPerConference'); +} else { + $title = $langs->trans('ListOfAttendeesOfEvent'); +} +$morejs = array(); +$morecss = array(); + $confOrBooth = new ConferenceOrBooth($db); if ($conf_or_booth_id > 0) { $result = $confOrBooth->fetch($conf_or_booth_id); @@ -345,11 +354,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; -$help_url = ''; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")); -$morejs = array(); -$morecss = array(); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); @@ -473,7 +477,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print '
'; print '
'; - print ''; + print '
'; // Description print '"; } - print '"; print '"; print '"; print '
'.$langs->trans("Description").''; @@ -487,7 +491,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print "
'; + print '
'; $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); @@ -504,15 +508,15 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print "
'; - print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; - print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); print ''; - print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; @@ -521,7 +525,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // Show message - $message = 'entity > 1 ? "&entity=".$conf->entity : ""); $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; @@ -582,10 +586,6 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { $head = conferenceorboothPrepareHead($confOrBooth, $withproject); print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - //$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; - $title = $langs->trans("ConferenceOrBooth") . ' - ' . $langs->trans("Attendees") . ' - ' . $confOrBooth->id; - $object_evt = $object; $object = $confOrBooth; @@ -674,7 +674,7 @@ print ''; $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendConferenceOrBoothAttendeeRef"; @@ -728,7 +728,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { @@ -776,7 +776,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { @@ -829,12 +829,12 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap left'; } elseif ($key == 'ref') { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref', 'status'))) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 0910feef219..659677d5452 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -82,7 +82,8 @@ PriceOfBooth=Subscription price to stand a booth PriceOfBoothHelp=Subscription price to stand a booth EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations -Attendees = Attendees +Attendees=Attendees +ListOfAttendeesOfEvent=List of attendees of the event project DownloadICSLink = Download ICS link EVENTORGANIZATION_SECUREKEY = Secure Key of the public registration link to a conference SERVICE_BOOTH_LOCATION = Service used for the invoice row about a booth location @@ -107,7 +108,7 @@ EvntOrgRegistrationConfHelpMessage = Here, you can suggest a new conference for EvntOrgRegistrationBoothHelpMessage = Here, you can suggest a new booth for the project ListOfSuggestedConferences = List of suggested conferences ListOfSuggestedBooths = List of suggested booths -ListOfConferencesOrBooths=List of conferences or booths +ListOfConferencesOrBooths=List of conferences or booths of event project SuggestConference = Suggest a new conference SuggestBooth = Suggest a booth ViewAndVote = View and vote for suggested events From b92784c04bacd7767493f354b7d5b3f96e33f4e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Sep 2021 23:38:33 +0200 Subject: [PATCH 179/229] Fix autoselect of thirdparty --- htdocs/core/class/html.formcompany.class.php | 2 ++ htdocs/core/tpl/contacts.tpl.php | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index bb99b2a32e9..db7df18e210 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -717,6 +717,8 @@ class FormCompany extends Form print ' onChange="'.$javaScript.'"'; } print '>'; + print ''; + $num = $this->db->num_rows($resql); $i = 0; if ($num) { diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 00a38fde351..1257d473ced 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -89,7 +89,7 @@ if ($permission) { ?>
-
trans("ThirdParty"); ?>
+
trans("ThirdParty"); ?>
trans("Users"), 'user', 'class="optiongrey paddingright"').$langs->trans("Users").' | '.img_picto($langs->trans("Contacts"), 'contact', 'class="optiongrey paddingright"').$langs->trans("Contacts"); ?>
trans("ContactType"); ?>
 
@@ -140,11 +140,8 @@ if ($permission) { } ?>
- socid) ? 0 : $object->socid); - // add company icon before select list - if ($selectedCompany) { - echo img_object('', 'company', 'class="hideonsmartphone"'); - } + socid) ? 0 : $object->socid); $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?>
From 880ac076616dd16e265568429d81b6053d114a86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Sep 2021 01:41:59 +0200 Subject: [PATCH 180/229] Debug organizedeventregistration module --- .../class/conferenceorbooth.class.php | 2 +- .../class/conferenceorboothattendee.class.php | 2 +- .../conferenceorbooth_list.php | 8 +- .../conferenceorboothattendee_card.php | 2 +- .../conferenceorboothattendee_list.php | 7 +- htdocs/langs/en_US/eventorganization.lang | 2 + .../attendee_subscription.php | 145 +++++++++++------- htdocs/public/payment/newpayment.php | 22 ++- htdocs/public/payment/paymentok.php | 132 ++++++++-------- 9 files changed, 192 insertions(+), 130 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 49b7112ac5b..9e07fd446d5 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -246,7 +246,7 @@ class ConferenceOrBooth extends ActionComm $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.urlencode($id).'&type=conf'; + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.urlencode($id).'&type=conf'; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 61d8e7c32b2..3e402877b4d 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -404,7 +404,7 @@ class ConferenceOrBoothAttendee extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; } else { diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 89a8e1c77ef..0a01a3f5996 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -147,9 +147,11 @@ if ($user->socid > 0) { // Protection if external user $result = restrictedArea($user, 'eventorganization'); if (!$permissiontoread) accessforbidden(); + /* * Actions */ + if (preg_match('/^set/', $action) && $projectid > 0) { $project = new Project($db); //If "set" fields keys is in projects fields @@ -429,7 +431,7 @@ if ($projectid > 0) { //print ''; print '
'; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$project->id; - $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2); + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); //print ''; - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$project->id.'&type=global'; - $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2); + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.$project->id.'&type=global'; + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); //print ''; - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$projectstatic->id.'&type=global'; + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.$projectstatic->id.'&type=global'; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); //print '
'; @@ -554,7 +557,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); //print ''; print '
'; - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$projectstatic->id.'&type=global'; + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.$projectstatic->id.'&type=global'; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); //print '
'.$langs->trans("Designation"); - print ''.$text; + print ''.$text.''; print ''; print ''; print '
".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label."'.($mt >= 0 ? price($mt) : '')."'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
'.$langs->trans("DiscountQtyMin").' %'; + print ' %'; print '