From 6c373c9381357bdafcc08997bcdf8ca5db9872d0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 9 Jan 2023 15:50:55 +0100 Subject: [PATCH 01/10] fix: reminder type label --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 0b169d846e9..545088e47e9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2213,7 +2213,7 @@ if ($id > 0) { $tmpuserstatic = new User($db); foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]; + print $TRemindTypes[$actioncommreminder->typeremind]['label']; if ($actioncommreminder->fk_user > 0) { $tmpuserstatic->fetch($actioncommreminder->fk_user); print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; From 4a40039f565c67d5baa7e1df9776f2aa03a54143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Wed, 11 Jan 2023 21:06:55 +0100 Subject: [PATCH 02/10] correction bug selection contact dans emailing --- .../core/modules/mailings/contacts1.modules.php | 17 ++++++++++------- .../modules/mailings/thirdparties.modules.php | 13 +++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 38a82907124..09595b61376 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -122,7 +122,7 @@ class mailing_contacts1 extends MailingTargets */ public function formFilter() { - global $langs; + global $langs,$conf; // Load translation files required by the page $langs->loadLangs(array("commercial", "companies", "suppliers", "categories")); @@ -307,11 +307,14 @@ class mailing_contacts1 extends MailingTargets $s .= ajax_combobox("filter_category_supplier_contact"); - // Choose language - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($this->db); - $s .= ''.$langs->trans("DefaultLang").': '; - $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + // Choose language if multilangue active + + if (@$conf->global->MAIN_MULTILANGS==1) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($this->db); + $s .= ''.$langs->trans("DefaultLang").': '; + $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + } return $s; } @@ -409,7 +412,7 @@ class mailing_contacts1 extends MailingTargets // Filter on language if (!empty($filter_lang)) { - $sql .= " AND sp.default_lang = '".$this->db->escape($filter_lang)."'"; + $sql .= " AND sp.default_lang LIKE '".$this->db->escape($filter_lang)."%'"; } // Filter on nature diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 89bc2cf2b5e..81a9bfaea51 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -316,12 +316,13 @@ class mailing_thirdparties extends MailingTargets $s .= ''; $s .= ajax_combobox("filter_status_thirdparties"); - // Choose language - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($this->db); - $s .= ''.$langs->trans("DefaultLang").': '; - $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang_thirdparties', 0, null, 1, 0, 0, '', 0, 0, 0, null, 1); - + // Choose language if multilangue active + if (@$conf->global->MAIN_MULTILANGS==1) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($this->db); + $s .= ''.$langs->trans("DefaultLang").': '; + $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang_thirdparties', 0, null, 1, 0, 0, '', 0, 0, 0, null, 1); + } return $s; } From 534cb8f0a045552448006d957238565de7bc06c2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 13 Jan 2023 09:55:57 +0100 Subject: [PATCH 03/10] fix: token for scan inventory --- htdocs/product/inventory/inventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 3d0dea9e3b7..cd27c09aaa0 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -609,7 +609,7 @@ if ($object->id > 0) { if ($permissiontoadd) { // Link to launch scan tool if (!empty($conf->barcode->enabled) || !empty($conf->productbatch->enabled)) { - print ''.img_picto('', 'barcode', 'class="paddingrightonly"').$langs->trans("UpdateByScaning").''; + print ''.img_picto('', 'barcode', 'class="paddingrightonly"').$langs->trans("UpdateByScaning").''; } // Link to autofill From a4c06a2188edad3fd08e609bff92a5368e50f4ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Jan 2023 23:19:09 +0100 Subject: [PATCH 04/10] css --- .../class/conferenceorbooth.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 76b1941fe69..b3232f079f6 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -112,13 +112,13 @@ class ConferenceOrBooth extends ActionComm 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width100'), '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,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), - 'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax100'), + 'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax100'), + 'num_vote' => array('type'=>'smallint', 'label'=>'NbVotes', 'enabled'=>'1', 'position'=>800, 'notnull'=>-1, 'visible'=>5, 'default'=>'0', 'index'=>0), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'EvntOrgDraft', '1'=>'EvntOrgSuggested', '2'=> 'EvntOrgConfirmed', '3' =>'EvntOrgNotQualified', '4' =>'EvntOrgDone', '9'=>'EvntOrgCancelled'),), - 'num_vote' => array('type'=>'smallint', 'label'=>'NbVotes', 'enabled'=>'1', 'position'=>1001, 'notnull'=>-1, 'visible'=>5, 'default'=>'0', 'index'=>0), ); public $rowid; public $id; From ff7a666c2b2e53191198e4187466e98b854e3f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 18 Jan 2023 23:43:54 +0100 Subject: [PATCH 05/10] Update bonprelevement.class.php --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a1dcdba6f58..7d16bcd8136 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1690,7 +1690,7 @@ class BonPrelevement extends CommonObject fclose($this->file); if (!empty($conf->global->MAIN_UMASK)) { - @chmod($this->file, octdec($conf->global->MAIN_UMASK)); + @chmod($this->filename, octdec($conf->global->MAIN_UMASK)); } return $result; From 58645a1d4aadc575d5c965573d7dd56b3a1df0a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jan 2023 00:19:57 +0100 Subject: [PATCH 06/10] Debug v17 --- htdocs/admin/system/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index c2ad387d955..6ea79cf00eb 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -241,7 +241,7 @@ if ($arrayfields['version']['checked']) { } if ($arrayfields['id']['checked']) { print ''; - print ''; + print ''; print ''; } if ($arrayfields['permission']['checked']) { From d3c4255e0e12a16228a67ce135ab8ab34f9847c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jan 2023 01:28:48 +0100 Subject: [PATCH 07/10] Fix bad test --- htdocs/comm/action/peruser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 5c5ef948c30..c6c91228af0 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -628,7 +628,7 @@ if ($type) { if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1' || $status == 'na') { +if ($status == 'na') { // Not applicable $sql .= " AND a.percent = -1"; } From 28139689ff6fb74336f75dc6ad269dcfbaff9374 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jan 2023 02:26:24 +0100 Subject: [PATCH 08/10] Debug v17 --- htdocs/comm/action/list.php | 5 +- htdocs/comm/action/pertype.php | 88 ++++++++++++++++++---------------- htdocs/comm/action/peruser.php | 53 ++++++++++++-------- 3 files changed, 81 insertions(+), 65 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 5eb538d4e62..4ff5c864908 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -795,9 +795,8 @@ if (!empty($arrayfields['a.tms']['checked'])) { print ''; } if (!empty($arrayfields['a.percent']['checked'])) { - print ''; - $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); - print ajax_combobox('selectsearch_status'); + print ''; + $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'search_status width100 onrightofpage'); print ''; } // Action column diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 61092df5665..7fe8f8108ed 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -63,23 +63,19 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { // Sorting $sortfield = GETPOST('sortfield', 'aZ09comma'); -if (!$sortfield) { - $sortfield = "a.datec"; -} - $sortorder = GETPOST('sortorder', 'aZ09comma'); -if (!$sortorder) { - $sortorder = "ASC"; -} - -// Page $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; - +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "a.datec"; +} // Security check @@ -110,14 +106,14 @@ $month = GETPOST("month", "int") ? GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); +if (GETPOST('search_actioncode', 'array:aZ09')) { + $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3); if (!count($actioncode)) { $actioncode = '0'; } @@ -321,7 +317,7 @@ if ($pid) { if ($type) { $param .= "&search_type=".urlencode($type); } -if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month' || $mode != 'show_peruser') { +if ($mode != 'show_pertype') { $param .= '&mode='.urlencode($mode); } if ($begin_h != '') { @@ -356,12 +352,13 @@ $next_year = $year + 1; $next_month = $month; $next_day = $day; -// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) +// Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1 +// $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); //print $firstday.'-'.$first_month.'-'.$first_year; -//print dol_print_date($firstdaytoshow,'dayhour'); -//print dol_print_date($lastdaytoshow,'dayhour'); +//print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); +//print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); @@ -477,7 +474,7 @@ if (empty($reshook)) { $viewmode = $hookmanager->resPrint; } - +$newparam = ''; $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton = dol_getdate(dol_now(), true); @@ -592,12 +589,12 @@ if ($filtert > 0 || $usergroup > 0) { if ($mode == 'show_day') { $sql .= " AND ("; $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; $sql .= " OR "; $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; $sql .= ')'; } else { @@ -619,12 +616,14 @@ if ($type) { if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1') { +if ($status === 'na') { + // Not applicable $sql .= " AND a.percent = -1"; -} // Not applicable +} if ($status == '50') { + // Running already started $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} // Running already started +} if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } @@ -788,8 +787,9 @@ echo ''; //print "begin_d=".$begin_d." end_d=".$end_d; +echo '
'; -echo ''; +echo '
'; echo ''; echo ''; @@ -847,10 +847,11 @@ foreach ($typeofevents as $typeofevent) { // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime, 'fast'); - $tmpday = $tmparray['mday']; - $tmpmonth = $tmparray['mon']; - $tmpyear = $tmparray['year']; + // $curtime is a gmt time, but we want the day, month, year in user TZ + $tmpday = dol_print_date($curtime, "%d", "tzuserrel"); + $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel"); + $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel"); + //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear); $style = 'cal_current_month'; if ($iter_day == 6) { @@ -875,6 +876,8 @@ foreach ($typeofevents as $typeofevent) { echo "
\n"; echo "
"; +echo '
'; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { $langs->load("commercial"); print '
'.$langs->trans("Legend").':
'; @@ -984,14 +987,14 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { - $annee = dol_print_date($daykey, '%Y'); - $mois = dol_print_date($daykey, '%m'); - $jour = dol_print_date($daykey, '%d'); + $annee = dol_print_date($daykey, '%Y', 'tzuserrel'); + $mois = dol_print_date($daykey, '%m', 'tzuserrel'); + $jour = dol_print_date($daykey, '%d', 'tzuserrel'); - if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ? + if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ? // Scan all event for this date foreach ($eventarray[$daykey] as $index => $event) { - //print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n"; + //print 'daykey='.$daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n"; //var_dump($event); $keysofuserassigned = array_keys($event->userassigned); @@ -1173,7 +1176,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } } - // Now output $casesX + // Now output $casesX from start hour to end hour for ($h = $begin_h; $h < $end_h; $h++) { $color1 = ''; $color2 = ''; $style1 = ''; $style2 = ''; @@ -1214,11 +1217,12 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } } - $ids1 = ''; $ids2 = ''; - if (count($cases1[$h]) && array_keys($cases1[$h])) { + $ids1 = ''; + $ids2 = ''; + if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) { $ids1 = join(',', array_keys($cases1[$h])); } - if (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])); } @@ -1227,7 +1231,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } else { echo ''; } - if (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']) { @@ -1236,12 +1240,12 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s if ($output[0]['color']) { $color1 = $output[0]['color']; } - } elseif (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 (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']) { @@ -1250,7 +1254,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s if ($output[0]['color']) { $color2 = $output[0]['color']; } - } elseif (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'; } diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index c6c91228af0..993bc3a908a 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -349,14 +349,14 @@ $next_year = $next['year']; $next_month = $next['month']; $next_day = $next['day']; -// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); - +// Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1 +// $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel'); $nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); //print $firstday.'-'.$first_month.'-'.$first_year; -//print dol_print_date($firstdaytoshow,'dayhour'); -//print dol_print_date($lastdaytoshow,'dayhour'); +//print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); +//print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); @@ -655,6 +655,7 @@ if ($filtert > 0 || $usergroup > 0) { } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action +//print $sql; dol_syslog("comm/action/peruser.php", LOG_DEBUG); @@ -665,6 +666,7 @@ if ($resql) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + //print $obj->fk_user_action.' '.$obj->id."
"; // Discard auto action if option is on if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') { @@ -675,6 +677,7 @@ if ($resql) { $datep = $db->jdate($obj->datep); $datep2 = $db->jdate($obj->datep2); + // Create a new object action $event = new ActionComm($db); $event->id = $obj->id; @@ -717,13 +720,15 @@ if ($resql) { } } + //print '
'.$i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' '.dol_print_date($firstdaytoshow, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '.dol_print_date($lastdaytoshow, 'dayhour').'
'."\n"; + // Check values if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range unset($event); } else { - //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; + //print $i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').'
'."\n"; $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) { @@ -744,7 +749,7 @@ if ($resql) { $loop = true; $j = 0; $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + //print 'Add event into eventarray for daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$event->id.' '.$event->datep.' '.$event->datef.'
'; $eventarray[$daykey][] = $event; $j++; @@ -802,6 +807,7 @@ echo ''; $currentdaytoshow = $firstdaytoshow; echo '
'; +//print dol_print_date($currentdaytoshow, 'dayhour', 'gmt'); while ($currentdaytoshow < $lastdaytoshow) { echo ''; @@ -853,9 +859,9 @@ while ($currentdaytoshow < $lastdaytoshow) { echo ''.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).''; print "
"; if ($i) { - print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day'); + print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day', 'tzuserrel'); } else { - print dol_print_date($currentdaytoshow, 'day'); + print dol_print_date($currentdaytoshow, 'day', 'tzuserrel'); } echo "\n"; $i++; @@ -976,6 +982,8 @@ while ($currentdaytoshow < $lastdaytoshow) { $showheader = true; $var = false; foreach ($usernames as $username) { + //if ($username->login != 'admin') continue; + $var = !$var; echo ""; echo '
'; @@ -993,10 +1001,10 @@ while ($currentdaytoshow < $lastdaytoshow) { // Show days of the current week $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime, 'fast'); - $tmpday = $tmparray['mday']; - $tmpmonth = $tmparray['mon']; - $tmpyear = $tmparray['year']; + // $curtime is a gmt time, but we want the day, month, year in user TZ + $tmpday = dol_print_date($curtime, "%d", "tzuserrel"); + $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel"); + $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel"); //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear); $style = 'cal_current_month'; @@ -1134,17 +1142,22 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & //if ($username->id && $day==1) { //var_dump($eventarray); //} + //var_dump("------ username=".$username->login." for day=".$day); // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { - $annee = dol_print_date($daykey, '%Y'); - $mois = dol_print_date($daykey, '%m'); - $jour = dol_print_date($daykey, '%d'); + $annee = dol_print_date($daykey, '%Y', 'tzuserrel'); + $mois = dol_print_date($daykey, '%m', 'tzuserrel'); + $jour = dol_print_date($daykey, '%d', 'tzuserrel'); + //var_dump("daykey=$daykey day=$day jour=$jour, month=$month mois=$mois, year=$year annee=$annee"); + + + if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ? + //var_dump("day=$day jour=$jour month=$month mois=$mois year=$year annee=$annee"); - if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ? // Scan all event for this date foreach ($eventarray[$daykey] as $index => $event) { - //print $daykey.' '.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n"; + //print 'daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> This event: '.$event->id.' '.$index.' is open for this daykey '.$annee.'-'.$mois.'-'.$jour."
\n"; //var_dump($event); $keysofuserassigned = array_keys($event->userassigned); @@ -1353,7 +1366,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } } - // Now output $casesX + // Now output $casesX from start hour to end hour for ($h = $begin_h; $h < $end_h; $h++) { $color1 = ''; $color2 = ''; $style1 = ''; $style2 = ''; @@ -1435,7 +1448,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $color2 = '222222'; } - print ''; + print '
'; print '
Date: Thu, 19 Jan 2023 13:40:37 +0100 Subject: [PATCH 09/10] FIX Add bookmark with search fields that are arrays --- htdocs/bookmarks/bookmarks.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index c13b810a4bc..88cae3e4293 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -52,6 +52,7 @@ function printDropdownBookmarksList() } } } + $tmpurl = ''; // No urlencode, all param $url will be urlencoded later if ($sortfield) { @@ -65,7 +66,13 @@ function printDropdownBookmarksList() if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var)) && $val != '' && !array_key_exists($key, $url_param)) { - $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + if (is_array($val)) { + foreach ($val as $tmpsubval) { + $url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval))); + } + } elseif ($val != '') { + $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + } } } } From d426598ab59da022843d23166fe77dab1944990c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jan 2023 13:46:54 +0100 Subject: [PATCH 10/10] Fix search criteria on service lines --- htdocs/contrat/services_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index cfc888e229a..08989fdcad0 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -256,7 +256,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; if ($search_product_category > 0) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; } -$sql .= " WHERE c.entity = ".$conf->entity; +$sql .= " WHERE c.entity IN (".getEntity($object->element).")"; $sql .= " AND c.rowid = cd.fk_contrat"; if ($search_product_category > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_product_category); @@ -281,13 +281,13 @@ if ($filter == "notexpired") { $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; } if ($search_name) { - $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%'"; + $sql .= natural_search("c.ref", $search_name); } if ($search_contract) { - $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; + $sql .= natural_search("c.ref", $search_contract); } if ($search_service) { - $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; + $sql .= natural_search(array("p.ref", "p.description", "cd.description"), $search_service); } if ($socid > 0) { $sql .= " AND s.rowid = ".((int) $socid);