From 0935094385db55f242302918f0964c6b735b5a33 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 11 Jan 2023 18:22:46 +0100 Subject: [PATCH 1/2] kanban mode for list of loan --- htdocs/loan/class/loan.class.php | 35 ++++++++++++++++++ htdocs/loan/list.php | 62 +++++++++++++++++++++++--------- 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 1c6913035e8..6dd0f5fe92b 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -721,4 +721,39 @@ class Loan extends CommonObject return -1; } } + + /** + * 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; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'capital')) { + $return .= ' | '.$langs->trans("Amount").' : '.price($this->capital).''; + } + if (property_exists($this, 'datestart')) { + $return .= '
'.$langs->trans("DateStart").' : '.dol_print_date($this->db->jdate($this->datestart), 'day').''; + } + if (property_exists($this, 'dateend')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->db->jdate($this->dateend), 'day').''; + } + + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->totalpaid, 5, $this->alreadypaid).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 1324876a98c..5acd2532bef 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -66,6 +66,8 @@ $search_amount = GETPOST('search_amount', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'loanlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); // mode view result + /* @@ -171,6 +173,9 @@ if ($resql) { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -194,7 +199,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write); + $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('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write); print '
'."\n"; if ($optioncss != '') { @@ -206,6 +214,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'money-bill-alt', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -256,31 +266,49 @@ if ($resql) { $loan_static->label = $obj->label; $loan_static->paid = $obj->paid; - print ''; - // Ref - print ''.$loan_static->getNomUrl(1).''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + $loan_static->datestart= $obj->datestart; + $loan_static->dateend = $obj->dateend; + $loan_static->capital = $obj->capital; + $loan_static->totalpaid = $obj->paid; - // Label - print ''.dol_trunc($obj->label, 42).''; + print $loan_static->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + print ''; - // Capital - print ''.price($obj->capital).''; + // Ref + print ''.$loan_static->getNomUrl(1).''; - // Date start - print ''.dol_print_date($db->jdate($obj->datestart), 'day').''; + // Label + print ''.dol_trunc($obj->label, 42).''; - // Date end - print ''.dol_print_date($db->jdate($obj->dateend), 'day').''; + // Capital + print ''.price($obj->capital).''; - print ''; - print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid); - print ''; + // Date start + print ''.dol_print_date($db->jdate($obj->datestart), 'day').''; - print ''; + // Date end + print ''.dol_print_date($db->jdate($obj->dateend), 'day').''; - print "\n"; + print ''; + print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid); + print ''; + print ''; + + print "\n"; + } $i++; } From 6f93cac359f875dd97cead8973135ad1f4548e5d Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 16 Jan 2023 17:10:26 +0100 Subject: [PATCH 2/2] fix style error --- htdocs/loan/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 5acd2532bef..1225f5304be 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -66,8 +66,7 @@ $search_amount = GETPOST('search_amount', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'loanlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); -$mode = GETPOST('mode', 'alpha'); // mode view result - +$mode = GETPOST('mode', 'alpha'); // mode view result /*