From 91837dd2efc979721ed300807e827eb6d1c58da3 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 11 Jan 2023 15:03:55 +0100 Subject: [PATCH 1/2] kanban mode for list of salaries --- htdocs/salaries/class/salary.class.php | 34 ++++ htdocs/salaries/list.php | 217 ++++++++++++++----------- 2 files changed, 155 insertions(+), 96 deletions(-) diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 25adb60382c..72a228658d8 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -707,4 +707,38 @@ class Salary extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + /** + * 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 $langs, $db; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_user')) { + $return .= ' | '.$this->fk_user.''; + } + if (property_exists($this, 'type_payment')) { + $return .= '
'.$langs->trans("PaymentMode").' : '.$this->type_payment.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->paye, 5, $this->alreadypaid).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 361107005a6..edeafa94c6a 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -44,6 +44,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'alpha'); //for mode view + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -315,6 +317,9 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -379,11 +384,16 @@ print ''; print ''; print ''; print ''; +print ''; + $url = DOL_URL_ROOT.'/salaries/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.$socid; } +$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('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'salary', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -534,121 +544,136 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $salstatic->ref = $obj->rowid; $salstatic->label = $obj->label; $salstatic->paye = $obj->paye; - $salstatic->datesp = $db->jdate($obj->datesp); - $salstatic->dateep = $db->jdate($obj->dateep); + $salstatic->datesp = $obj->datesp; + $salstatic->dateep = $obj->dateep; + $salstatic->amount = $obj->amount; + $salstatic->fk_user = $userstatic->getNomUrl(1); + $salstatic->type_payment = $obj->payment_code; - // Show here line of result - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + print $salstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + // Show here line of result + print ''; - // Ref - print "".$salstatic->getNomUrl(1)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } + // Ref + print "".$salstatic->getNomUrl(1)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } - // Label payment - print ''.dol_escape_htmltag($obj->label)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } + // Label payment + print ''.dol_escape_htmltag($obj->label)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } - // Date Start - print ''.dol_print_date($db->jdate($obj->datesp), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; - } + // Date Start + print ''.dol_print_date($db->jdate($obj->datesp), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } - // Date End - print ''.dol_print_date($db->jdate($obj->dateep), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; - } + // Date End + print ''.dol_print_date($db->jdate($obj->dateep), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } - // Employee - print ''.$userstatic->getNomUrl(1)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } + // Employee + print ''.$userstatic->getNomUrl(1)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } - // Type - print ''; - if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - // Account - if (isModEnabled("banque")) { + // Type print ''; - if ($obj->fk_account > 0) { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->label = $obj->blabel; - $accountstatic->number = $obj->bnumber; - $accountstatic->iban = $obj->iban; - $accountstatic->bic = $obj->bic; - $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code); - $accountstatic->account_number = $obj->account_number; - $accountstatic->clos = $obj->clos; + if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } - if (isModEnabled('accounting')) { + // Account + if (isModEnabled("banque")) { + print ''; + if ($obj->fk_account > 0) { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->label = $obj->blabel; + $accountstatic->number = $obj->bnumber; + $accountstatic->iban = $obj->iban; + $accountstatic->bic = $obj->bic; + $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code); $accountstatic->account_number = $obj->account_number; + $accountstatic->clos = $obj->clos; - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($obj->fk_accountancy_journal); + if (isModEnabled('accounting')) { + $accountstatic->account_number = $obj->account_number; - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($obj->fk_accountancy_journal); + + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + //$accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else { + print ' '; } - //$accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else { - print ' '; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + + // Amount + print ''.price($obj->amount).''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + } + $totalarray['val']['totalttcfield'] += $obj->amount; + + print ''.$salstatic->LibStatut($obj->paye, 5, $obj->alreadypayed).''; + if (!$i) $totalarray['nbfield']++; + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + 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 ''; } print ''; if (!$i) { $totalarray['nbfield']++; } + + print ''."\n"; } - - // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; - - // Amount - print ''.price($obj->amount).''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; - } - $totalarray['val']['totalttcfield'] += $obj->amount; - - print ''.$salstatic->LibStatut($obj->paye, 5, $obj->alreadypayed).''; - if (!$i) $totalarray['nbfield']++; - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; - 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 ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - $i++; } From 7213595cef946f1c29b4516e2768586c710fe078 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 11 Jan 2023 15:19:21 +0100 Subject: [PATCH 2/2] modify kanban mode for list of salaries --- htdocs/salaries/class/salary.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 72a228658d8..7f9ea31cdc9 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -716,7 +716,7 @@ class Salary extends CommonObject */ public function getKanbanView($option = '') { - global $langs, $db; + global $langs; $return = '
'; $return .= '
'; $return .= '';