Merge pull request #23603 from lamrani002/kanbanForTickets

NEW kanban mode for list of tickets
This commit is contained in:
Laurent Destailleur 2023-01-17 17:17:47 +01:00 committed by GitHub
commit 00a0e4e246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 217 additions and 152 deletions

View File

@ -2932,6 +2932,42 @@ class Ticket extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
} }
/**
* 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, $selected,$arrayofselected,$obj;
$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 (in_array($this->id, $arrayofselected)) {
$selected = 1;
}
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
if (property_exists($this, 'fk_user_assign') && !empty($this->fk_user_assign)) {
$return .= '<br><span class="opacitymedium">'.$langs->trans("AssignedTo").'</span> : <span class="info-box-label">'.$this->fk_user_assign.'</span>';
}
if (property_exists($this, 'type_code') && !empty($this->type_code)) {
$return .= '<br><span class="opacitymedium">'.$langs->trans("Type").'</span> : ';
$return .= $langs->getLabelFromKey($this->db, 'TicketTypeShort'.$this->type_code, 'c_ticket_type', 'code', 'label', $this->type_code);
}
if (method_exists($this, 'getLibStatut')) {
$return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).'</div>';
}
$return .= '</div>';
$return .= '</div>';
$return .= '</div>';
return $return;
}
} }

View File

@ -629,6 +629,9 @@ if ($projectid > 0 || $project_ref) {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($mode)) {
$param .= '&mode='.urlencode($mode);
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage); $param .= '&contextpage='.urlencode($contextpage);
} }
@ -740,7 +743,10 @@ $url = DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid
if (!empty($socid)) { if (!empty($socid)) {
$url .= '&socid='.$socid; $url .= '&socid='.$socid;
} }
$newcardbutton = dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->rights->ticket->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('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->rights->ticket->write);
$picto = 'ticket'; $picto = 'ticket';
if ($socid > 0) { if ($socid > 0) {
@ -999,6 +1005,28 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
$object->setVarsFromFetchObj($obj); $object->setVarsFromFetchObj($obj);
$object->status = $object->fk_statut; // fk_statut is deprecated $object->status = $object->fk_statut; // fk_statut is deprecated
if ($mode == 'kanban') {
if ($i == 0) {
print '<tr><td colspan="12">';
print '<div class="box-flex-container">';
}
// get infos needed from object
$userstatic = new User($db);
$userstatic->fetch($obj->fk_user_assign);
$object->fk_user_assign = $userstatic->getNomUrl(-1);
$object->type_code = $obj->type_code;
// Output Kanban
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
if ($massactionbutton || $massaction) {
$selected = 0;
}
print $object->getKanbanView('');
}
if ($i == (min($num, $limit) - 1)) {
print '</div>';
print '</td></tr>';
}
} else {
// Show here line of result // Show here line of result
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Action column // Action column
@ -1169,6 +1197,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
} }
print '</tr>'."\n"; print '</tr>'."\n";
}
$i++; $i++;
} }