Merge pull request #23489 from lamrani002/kanbanDonList

NEW kanban for list of Donnation
This commit is contained in:
Laurent Destailleur 2023-01-11 20:22:41 +01:00 committed by GitHub
commit 2873886611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 101 additions and 31 deletions

View File

@ -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 = '<div class="box-flex-item box-flex-grow-zero">';
$return .= '<div class="info-box info-box-sm">';
$return .= '<span class="info-box-icon bg-infobox-action">';
$return .= img_picto('', $this->picto);
$return .= '</span>';
$return .= '<div class="info-box-content">';
$return .= '<span class="info-box-ref">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
if (property_exists($this, 'date')) {
$return .= ' | <span class="opacitymedium" >'.$langs->trans("Date").'</span> : <span class="info-box-label">'.dol_print_date($this->date).'</span>';
}
if (property_exists($this, 'societe') && !empty($this->societe)) {
$return .= '<br><span class="opacitymedium">'.$langs->trans("Company").'</span> : <span class="info-box-label">'.$this->societe.'</span>';
}
if (property_exists($this, 'amount')) {
$return .= '<br><span class="opacitymedium" >'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
}
if (method_exists($this, 'LibStatut')) {
$return .= '<br><div class="info-box-status margintoponly">'.$this->LibStatut($this->labelStatus, 5).'</div>';
}
$return .= '</div>';
$return .= '</div>';
$return .= '</div>';
return $return;
}
}

View File

@ -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 '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
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 '<tr><td colspan="12">';
print '<div class="box-flex-container">';
}
// Output Kanban
$donationstatic->amount = $objp->amount;
$donationstatic->date = $objp->datedon;
$donationstatic->labelStatus = $objp->status;
$donationstatic->id = $objp->rowid;
$donationstatic->ref = $objp->rowid;
print '<tr class="oddeven">';
$donationstatic->id = $objp->rowid;
$donationstatic->ref = $objp->rowid;
$donationstatic->lastname = $objp->lastname;
$donationstatic->firstname = $objp->firstname;
print "<td>".$donationstatic->getNomUrl(1)."</td>";
if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
$company = new Societe($db);
$result = $company->fetch($objp->socid);
if (!empty($objp->socid) && $company->id > 0) {
print "<td>".$company->getNomUrl(1)."</td>";
$donationstatic->societe = $company->getNomUrl(1);
} else {
$donationstatic->societe = $objp->societe;
}
print $donationstatic->getKanbanView('');
if ($i == (min($num, $limit) - 1)) {
print '</div>';
print '</td></tr>';
}
} else {
print '<tr class="oddeven">';
$donationstatic->id = $objp->rowid;
$donationstatic->ref = $objp->rowid;
$donationstatic->lastname = $objp->lastname;
$donationstatic->firstname = $objp->firstname;
print "<td>".$donationstatic->getNomUrl(1)."</td>";
if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
if (!empty($objp->socid) && $company->id > 0) {
print "<td>".$company->getNomUrl(1)."</td>";
} else {
print "<td>".$objp->societe."</td>";
}
} else {
print "<td>".$objp->societe."</td>";
}
} else {
print "<td>".$objp->societe."</td>";
}
print "<td>".$donationstatic->getFullName($langs)."</td>";
print '<td class="center">'.dol_print_date($db->jdate($objp->datedon), 'day').'</td>';
if (isModEnabled('project')) {
print "<td>";
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 '&nbsp;';
print "<td>".$donationstatic->getFullName($langs)."</td>";
print '<td class="center">'.dol_print_date($db->jdate($objp->datedon), 'day').'</td>';
if (isModEnabled('project')) {
print "<td>";
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 '&nbsp;';
}
print "</td>\n";
}
print "</td>\n";
print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
print '<td class="right">'.$donationstatic->LibStatut($objp->status, 5).'</td>';
print '<td></td>';
print "</tr>";
}
print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
print '<td class="right">'.$donationstatic->LibStatut($objp->status, 5).'</td>';
print '<td></td>';
print "</tr>";
$i++;
}
print "</table>";