new mode kanban for projects

This commit is contained in:
Lamrani Abdel 2023-02-20 16:23:12 +01:00
commit 4d232af62b
2 changed files with 477 additions and 441 deletions

View File

@ -2373,4 +2373,37 @@ class Project extends CommonObject
return 1; 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,$db,$user;
$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 .= '<i class="fa fa-dol-action"></i>'; // Can be image
$return .= '</span>';
$return .= '<div class="info-box-content">';
$return .= '<span class="info-box-ref">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
if (property_exists($this, 'date_start_event')) {
$return .= '<br><span class="info-bo-label opacitymedium">'.$langs->trans("DateStart").'</span>';
$return .= '<span class="info-box-label "> : '.dol_print_date($db->jdate($this->date_start_event), 'day').'</>';
}
if (property_exists($this, 'user_author_id')) {
$return .= '<br><span class="info-box-label opacitymedium">'.$langs->trans("Author").'</span>';
$return .= '<span> : '.$user->getNomUrl(1).'</span>';
}
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

@ -56,6 +56,8 @@ $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
$mode = GETPOST('mode', 'alpha');
$title = $langs->trans("Projects"); $title = $langs->trans("Projects");
@ -730,6 +732,9 @@ llxHeader('', $title, $help_url);
$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);
} }
@ -919,7 +924,11 @@ if (!empty($socid)) {
if ($search_usage_event_organization == 1) { if ($search_usage_event_organization == 1) {
$url .= '&usage_organize_event=1'; $url .= '&usage_organize_event=1';
} }
$newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
$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('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') { if ($optioncss != '') {
@ -931,6 +940,8 @@ print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
// Show description of content // Show description of content
$texthelp = ''; $texthelp = '';
@ -1372,21 +1383,23 @@ while ($i < $imaxinloop) {
$companystatic->town = $obj->town; $companystatic->town = $obj->town;
$companystatic->country_code = $obj->country_code; $companystatic->country_code = $obj->country_code;
// Author if ($mode == 'kanban') {
$userstatic->id = $obj->fk_user_creat; if ($i == 0) {
$userstatic->login = $obj->login; print '<tr><td colspan="12">';
$userstatic->lastname = $obj->lastname; print '<div class="box-flex-container">';
$userstatic->firstname = $obj->firstname; }
$userstatic->email = $obj->user_email; $object->date_start_event = $obj->date_start;
$userstatic->statut = $obj->user_statut;
$userstatic->entity = $obj->entity;
$userstatic->photo = $obj->photo;
$userstatic->office_phone = $obj->office_phone;
$userstatic->office_fax = $obj->office_fax;
$userstatic->user_mobile = $obj->user_mobile;
$userstatic->job = $obj->job;
$userstatic->gender = $obj->gender;
$userstatic->id = $obj->fk_user_creat;
$object->user_author_id = $userstatic->id;
//var_dump($object->user_author_id);exit;
print $object->getKanbanView('');
if ($i == min($num, $limit)-1) {
print '</div>';
print '</td></tr>';
}
} else {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Action column // Action column
@ -1540,25 +1553,12 @@ while ($i < $imaxinloop) {
if (!empty($numcontact)) { if (!empty($numcontact)) {
foreach ($tab as $contactproject) { foreach ($tab as $contactproject) {
//var_dump($contacttask); //var_dump($contacttask);
$cid = $contactproject['id'];
if ($source == 'internal') { if ($source == 'internal') {
if (empty($conf->cache['user'][$cid])) {
$c = new User($db); $c = new User($db);
$c->fetch($cid);
$conf->cache['user'][$cid] = $c;
} else { } else {
$c = $conf->cache['user'][$cid];
}
} else {
if (empty($conf->cache['contact'][$cid])) {
$c = new Contact($db); $c = new Contact($db);
$c->fetch($cid);
$conf->cache['contact'][$cid] = $c;
} else {
$c = $conf->cache['contact'][$cid];
} }
} $c->fetch($contactproject['id']);
if (!empty($c->photo)) { if (!empty($c->photo)) {
if (get_class($c) == 'User') { if (get_class($c) == 'User') {
print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
@ -1598,12 +1598,8 @@ while ($i < $imaxinloop) {
//if ($obj->opp_status_code) //if ($obj->opp_status_code)
if (strcmp($obj->opp_amount, '')) { if (strcmp($obj->opp_amount, '')) {
print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>'; print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
if (empty($totalarray['val']['p.opp_amount'])) {
$totalarray['val']['p.opp_amount'] = $obj->opp_amount;
} else {
$totalarray['val']['p.opp_amount'] += $obj->opp_amount; $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
} }
}
print '</td>'; print '</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
@ -1631,12 +1627,8 @@ while ($i < $imaxinloop) {
print '<td align="right">'; print '<td align="right">';
if ($obj->opp_weighted_amount) { if ($obj->opp_weighted_amount) {
print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>'; print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
if (empty($totalarray['val']['opp_weighted_amount'])) {
$totalarray['val']['opp_weighted_amount'] = $obj->opp_weighted_amount;
} else {
$totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
} }
}
print '</td>'; print '</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
@ -1650,12 +1642,8 @@ while ($i < $imaxinloop) {
print '<td class="right">'; print '<td class="right">';
if ($obj->budget_amount != '') { if ($obj->budget_amount != '') {
print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>'; print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
if (empty($totalarray['val']['p.budget_amount'])) {
$totalarray['val']['p.budget_amount'] = $obj->budget_amount;
} else {
$totalarray['val']['p.budget_amount'] += $obj->budget_amount; $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
} }
}
print '</td>'; print '</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
@ -1760,6 +1748,20 @@ while ($i < $imaxinloop) {
$totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
} }
} }
// Author
$userstatic->id = $obj->fk_user_creat;
$userstatic->login = $obj->login;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->user_email;
$userstatic->statut = $obj->user_statut;
$userstatic->entity = $obj->entity;
$userstatic->photo = $obj->photo;
$userstatic->office_phone = $obj->office_phone;
$userstatic->office_fax = $obj->office_fax;
$userstatic->user_mobile = $obj->user_mobile;
$userstatic->job = $obj->job;
$userstatic->gender = $obj->gender;
if (!empty($arrayfields['u.login']['checked'])) { if (!empty($arrayfields['u.login']['checked'])) {
print '<td class="center tdoverflowmax150">'; print '<td class="center tdoverflowmax150">';
@ -1813,7 +1815,7 @@ while ($i < $imaxinloop) {
} }
// Status // Status
if (!empty($arrayfields['p.fk_statut']['checked'])) { if (!empty($arrayfields['p.fk_statut']['checked'])) {
print '<td class="center">'.$object->getLibStatut(5).'</td>'; print '<td class="right">'.$object->getLibStatut(5).'</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
@ -1836,6 +1838,7 @@ while ($i < $imaxinloop) {
print "</tr>\n"; print "</tr>\n";
} }
}
$i++; $i++;
} }