From abd5a86f348256fa6ab2eb09b93bed678f0ff9d2 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 19 Dec 2022 15:19:12 +0100 Subject: [PATCH] mode Kanban for subscription list --- htdocs/adherents/class/subscription.class.php | 32 ++ htdocs/adherents/subscription/list.php | 275 ++++++++++-------- 2 files changed, 187 insertions(+), 120 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index b3cfe027197..411fdb2181f 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -505,4 +505,36 @@ class Subscription extends CommonObject dol_print_error($this->db); } } + + /** + * 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 = '') + { + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + + $return .= '
'; + $return .= ''.(property_exists($this, 'fk_adherent')? $this->fk_adherent: $this->ref ).''; + if (property_exists($this, 'dateh') || property_exists($this, 'datef')) { + $return .= '
'.dol_print_date($this->dateh, 'day').' - '.dol_print_date($this->datef, 'day').''; + } + + if (property_exists($this, 'fk_bank')) { + $return .= '
'.$this->fk_bank.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.price($this->amount).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 1523bd4ee90..5aa19c6c6d0 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -37,6 +37,8 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'subscriptionlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); + $statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1); $search_ref = GETPOST('search_ref', 'alpha'); @@ -253,6 +255,9 @@ if (!empty($date_select)) { } $param = ''; +if (!empty($mode)) { + $param .='&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -298,6 +303,9 @@ if (in_array($massaction, array('presend', 'predelete'))) { $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $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')); + if ($user->rights->adherent->cotisation->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } @@ -313,6 +321,8 @@ print ''; print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -506,144 +516,169 @@ while ($i < min($num, $limit)) { $adht->fetch($typeid); $adherent->need_subscription = $adht->subscription; - - print ''; - - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print ''.$subscription->getNomUrl(1).''; - if (!$i) { - $totalarray['nbfield']++; + + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { - print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { - print ''.$adherent->firstname.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Login - if (!empty($arrayfields['d.login']['checked'])) { - print ''.$adherent->login.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['t.libelle']['checked'])) { - print ''; - print $obj->note; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Banque - if (!empty($arrayfields['d.bank']['checked'])) { - print ''; + + //fetch informations needs on this mode + $subscription->fk_adherent = $adherent->getNomUrl(1); + $subscription->fk_type = $adht->getNomUrl(1); + $subscription->amount = $obj->subscription; if ($obj->fk_account > 0) { $accountstatic->id = $obj->fk_account; $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print $accountstatic->getNomUrl(1); + $subscription->fk_bank = $accountstatic->getNomUrl(1); } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Output Kanban + print $subscription->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } } - // Date start - if (!empty($arrayfields['c.dateadh']['checked'])) { - print ''.dol_print_date($db->jdate($obj->dateadh), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; + else { + print ''; + + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ''.$subscription->getNomUrl(1).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end - if (!empty($arrayfields['c.datef']['checked'])) { - print ''.dol_print_date($db->jdate($obj->datef), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Price - if (!empty($arrayfields['d.amount']['checked'])) { - print ''.price($obj->subscription).''; - if (!$i) { - $totalarray['nbfield']++; + + // Lastname + if (!empty($arrayfields['d.lastname']['checked'])) { + print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + // Firstname + if (!empty($arrayfields['d.firstname']['checked'])) { + print ''.$adherent->firstname.''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (empty($totalarray['val']['d.amount'])) { - $totalarray['val']['d.amount'] = $obj->subscription; - } else { - $totalarray['val']['d.amount'] += $obj->subscription; + + // Login + if (!empty($arrayfields['d.login']['checked'])) { + print ''.$adherent->login.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['t.libelle']['checked'])) { + print ''; + print $obj->note; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Banque + if (!empty($arrayfields['d.bank']['checked'])) { + print ''; + if ($obj->fk_account > 0) { + $accountstatic->id = $obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print $accountstatic->getNomUrl(1); + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date start + if (!empty($arrayfields['c.dateadh']['checked'])) { + print ''.dol_print_date($db->jdate($obj->dateadh), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date end + if (!empty($arrayfields['c.datef']['checked'])) { + print ''.dol_print_date($db->jdate($obj->datef), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Price + if (!empty($arrayfields['d.amount']['checked'])) { + print ''.price($obj->subscription).''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + } + if (empty($totalarray['val']['d.amount'])) { + $totalarray['val']['d.amount'] = $obj->subscription; + } else { + $totalarray['val']['d.amount'] += $obj->subscription; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // 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($obj->crowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (!$i) { $totalarray['nbfield']++; } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // 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($obj->crowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + print "\n"; + } $i++; }