From a5fba0fd09db765f91d11f00e07a01a2dbb70f94 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 12:10:22 +0100 Subject: [PATCH 1/9] kanban for position list --- htdocs/hrm/class/position.class.php | 35 +++++++++++++++++++++++++++++ htdocs/hrm/position_list.php | 18 +++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 98b5fd89be9..9d4f71d24fd 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1118,6 +1118,41 @@ class Position extends CommonObject return $error; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $selected, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; + if (property_exists($this, 'fk_user') && !(empty($this->fk_user))) { + $return .= '
'.$langs->trans("Employee").' : '; + $return .= ''.$this->fk_user.''; + } + if (property_exists($this, 'fk_job') && !(empty($this->fk_job))) { + $return .= '
'.$langs->trans("Job").' : '; + $return .= ''.$this->fk_job.''; + } + if (property_exists($this, 'date_start') && property_exists($this, 'date_end')) { + $return .= '
'.dol_print_date($this->db->jdate($this->date_start), 'day').''; + $return .= ' - '.dol_print_date($this->db->jdate($this->date_end), 'day').'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 40cb706b5df..5dc33859219 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -426,7 +426,10 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1).'?action=create', '', $permissiontoadd); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1).'?action=create', '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -602,12 +605,23 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + if ($mode == 'kanban') { if ($i == 0) { print ''; print '
'; } - // Output Kanban + // get info needed + + $object->date_start = $obj->date_start; + $object->date_end = $obj->date_end; + $job = new job($db); + $job->fetch($obj->fk_job); + $object->fk_job = $job->getNomUrl(); + $userstatic = new User($db); + $userstatic->fetch($obj->fk_user); + $object->fk_user = $userstatic->getNomUrl(1); + // output kanban print $object->getKanbanView(''); if ($i == ($imaxinloop - 1)) { print '
'; From a42c879ac5589381ab83bcfcb14a54c67d9d4282 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 12:25:44 +0100 Subject: [PATCH 2/9] modify colspan --- htdocs/hrm/position_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 5dc33859219..201be040d20 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -608,7 +608,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { - print ''; + print ''; print '
'; } // get info needed From 19b77e3dcda2e862afe82cc2a7b13eac97bf9b58 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 12:33:25 +0100 Subject: [PATCH 3/9] modify checkbox action --- htdocs/hrm/position_list.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 201be040d20..7a6f7fcc417 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -622,7 +622,13 @@ while ($i < $imaxinloop) { $userstatic->fetch($obj->fk_user); $object->fk_user = $userstatic->getNomUrl(1); // output kanban - print $object->getKanbanView(''); + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print $object->getKanbanView(''); + } if ($i == ($imaxinloop - 1)) { print '
'; print ''; From 0ee90877aa0f20caeefe92614d474f6fc34d4f2e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 14:17:49 +0100 Subject: [PATCH 4/9] modify style for checkbox --- htdocs/hrm/class/position.class.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 9d4f71d24fd..2f4a127999a 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1135,7 +1135,7 @@ class Position extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'fk_user') && !(empty($this->fk_user))) { $return .= '
'.$langs->trans("Employee").' : '; $return .= ''.$this->fk_user.''; diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index f35516ad58e..9c1f3b443ef 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -491,7 +491,10 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { min-width: 350px; max-width: 350px; } - +/**for make a checkbox in the right of the box in mode kanban */ +.fright { + float:right; +} @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; From 392773968561c70c3d136536cfdc55ccf928b636 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 19 Jan 2023 17:27:53 +0100 Subject: [PATCH 5/9] add infos needed in the main sql --- htdocs/hrm/position_list.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 7a6f7fcc417..dc427fd3aa6 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -73,6 +73,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Position($db); $extrafields = new ExtraFields($db); +$userstatic = new User($db); $diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('positionlist')); // Note that conf->hooks_modules contains array @@ -218,6 +219,9 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); +$sql .= ', '.$userstatic->getFieldList('u'); +$sql .= ',u.email, u.statut'; +$sql .= ',j.rowid, j.label as job_label'; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -229,7 +233,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t, ".MAIN_DB_PREFIX.$userstatic->table_element." as u,".MAIN_DB_PREFIX."hrm_job as j"; if (isset($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 (t.rowid = ef.fk_object)"; } @@ -242,6 +246,8 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } +$sql .= " AND t.fk_user = u.rowid"; +$sql .= " AND t.fk_job = j.rowid"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -612,14 +618,18 @@ while ($i < $imaxinloop) { print '
'; } // get info needed - $object->date_start = $obj->date_start; $object->date_end = $obj->date_end; - $job = new job($db); - $job->fetch($obj->fk_job); - $object->fk_job = $job->getNomUrl(); - $userstatic = new User($db); - $userstatic->fetch($obj->fk_user); + + $object->fk_job = $obj->job_label; + + $userstatic->id = $obj->fk_user; + $userstatic->ref = $obj->fk_user; + $userstatic->firstname = $obj->firstname; + $userstatic->lastname = $obj->lastname; + $userstatic->email = $obj->email; + $userstatic->statut = $obj->statut; + $object->fk_user = $userstatic->getNomUrl(1); // output kanban if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined From c6fd20deef77fcb35fbea6dfde66dfead889c646 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 19 Jan 2023 17:43:20 +0100 Subject: [PATCH 6/9] add columns needed in the main sql --- htdocs/hrm/position_list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index dc427fd3aa6..4500d3d45ec 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -620,7 +620,6 @@ while ($i < $imaxinloop) { // get info needed $object->date_start = $obj->date_start; $object->date_end = $obj->date_end; - $object->fk_job = $obj->job_label; $userstatic->id = $obj->fk_user; From 2433248445abb5ddad889534c078a4b216ba5595 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 19 Jan 2023 18:07:18 +0100 Subject: [PATCH 7/9] fix problem in sql --- htdocs/hrm/position_list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 4500d3d45ec..308e48e153b 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -219,7 +219,8 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); -$sql .= ', '.$userstatic->getFieldList('u'); +$sql .= ','; +$sql .= $userstatic->getFieldList('u'); $sql .= ',u.email, u.statut'; $sql .= ',j.rowid, j.label as job_label'; // Add fields from extrafields From 229b06a33309c794d862a96cb2ed6f66d303b32b Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 23 Jan 2023 19:56:52 +0100 Subject: [PATCH 8/9] fix sql request by adding left join for user table --- htdocs/hrm/position_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 308e48e153b..de86b3d41c5 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -234,7 +234,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t, ".MAIN_DB_PREFIX.$userstatic->table_element." as u,".MAIN_DB_PREFIX."hrm_job as j"; +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t LEFT JOIN ".MAIN_DB_PREFIX.$userstatic->table_element." as u on t.fk_user = u.rowid, ".MAIN_DB_PREFIX."hrm_job as j"; if (isset($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 (t.rowid = ef.fk_object)"; } From 87d9b8075bb88d8a12fb2a82a45f96c7be42514e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 24 Jan 2023 20:40:16 +0100 Subject: [PATCH 9/9] fix error style --- htdocs/hrm/position_list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index de86b3d41c5..4518d28bf65 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -247,7 +247,6 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } -$sql .= " AND t.fk_user = u.rowid"; $sql .= " AND t.fk_job = j.rowid"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) {