diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 158c96cb441..c1d09a6cdd0 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -1141,4 +1141,39 @@ class Don extends CommonObject return (float) $this->amount - $sum_amount; } } + + /** + * 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, 'date')) { + $return .= ' | '.$langs->trans("Date").' : '.dol_print_date($this->date).''; + } + if (property_exists($this, 'societe') && !empty($this->societe)) { + $return .= '
'.$langs->trans("Company").' : '.$this->societe.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->labelStatus, 5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 386a4bc2f6b..1e96277025d 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -42,6 +42,7 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $type = GETPOST('type', 'aZ'); +$mode = GETPOST('mode', 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -153,6 +154,9 @@ if ($resql) { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -179,6 +183,8 @@ if ($resql) { } $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->don->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); } @@ -193,6 +199,9 @@ if ($resql) { print ''; print ''; print ''; + print ''; + + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -267,44 +276,70 @@ if ($resql) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); + $donationstatic->setVarsFromFetchObj($objp); + $company = new Societe($db); + $result = $company->fetch($objp->socid); + + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + $donationstatic->amount = $objp->amount; + $donationstatic->date = $objp->datedon; + $donationstatic->labelStatus = $objp->status; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; - print ''; - $donationstatic->id = $objp->rowid; - $donationstatic->ref = $objp->rowid; - $donationstatic->lastname = $objp->lastname; - $donationstatic->firstname = $objp->firstname; - print "".$donationstatic->getNomUrl(1).""; - if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { - $company = new Societe($db); - $result = $company->fetch($objp->socid); if (!empty($objp->socid) && $company->id > 0) { - print "".$company->getNomUrl(1).""; + $donationstatic->societe = $company->getNomUrl(1); + } else { + $donationstatic->societe = $objp->societe; + } + + print $donationstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + print ''; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; + print "".$donationstatic->getNomUrl(1).""; + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($objp->socid) && $company->id > 0) { + print "".$company->getNomUrl(1).""; + } else { + print "".$objp->societe.""; + } } else { print "".$objp->societe.""; } - } else { - print "".$objp->societe.""; - } - print "".$donationstatic->getFullName($langs).""; - print ''.dol_print_date($db->jdate($objp->datedon), 'day').''; - if (isModEnabled('project')) { - print ""; - if ($objp->pid) { - $projectstatic->id = $objp->pid; - $projectstatic->ref = $objp->ref; - $projectstatic->id = $objp->pid; - $projectstatic->public = $objp->public; - $projectstatic->title = $objp->title; - print $projectstatic->getNomUrl(1); - } else { - print ' '; + print "".$donationstatic->getFullName($langs).""; + print ''.dol_print_date($db->jdate($objp->datedon), 'day').''; + if (isModEnabled('project')) { + print ""; + if ($objp->pid) { + $projectstatic->id = $objp->pid; + $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->pid; + $projectstatic->public = $objp->public; + $projectstatic->title = $objp->title; + print $projectstatic->getNomUrl(1); + } else { + print ' '; + } + print "\n"; } - print "\n"; + print ''.price($objp->amount).''; + print ''.$donationstatic->LibStatut($objp->status, 5).''; + print ''; + print ""; } - print ''.price($objp->amount).''; - print ''.$donationstatic->LibStatut($objp->status, 5).''; - print ''; - print ""; $i++; } print "";