mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 19:18:22 +01:00
Merge pull request #23305 from lamrani002/kanbanBomList
New mode view "Kanban" for BOM list
This commit is contained in:
@@ -42,6 +42,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
|
|||||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search
|
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search
|
||||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||||
|
$mode = GETPOST('mode', 'alpha'); // mode view (kanban or common)
|
||||||
|
|
||||||
|
|
||||||
// Load variable for pagination
|
// Load variable for pagination
|
||||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
@@ -433,6 +435,9 @@ llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
|
|||||||
$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);
|
||||||
}
|
}
|
||||||
@@ -483,7 +488,11 @@ 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="page" value="'.$page.'">';
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
|
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||||
|
|
||||||
|
$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('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write);
|
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write);
|
||||||
|
|
||||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||||
@@ -648,6 +657,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
|||||||
// Store properties in $object
|
// Store properties in $object
|
||||||
$object->setVarsFromFetchObj($obj);
|
$object->setVarsFromFetchObj($obj);
|
||||||
|
|
||||||
|
// mode view kanban
|
||||||
|
if ($mode == 'kanban') {
|
||||||
|
if ($i == 0) {
|
||||||
|
print '<tr><td colspan="12">';
|
||||||
|
print '<div class="box-flex-container">';
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
@@ -732,6 +756,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
|||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show total line
|
// Show total line
|
||||||
|
|||||||
@@ -1515,6 +1515,46 @@ class BOM extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 $db,$langs;
|
||||||
|
$prod = new Product($db);
|
||||||
|
$prod->fetch($this->fk_product);
|
||||||
|
|
||||||
|
$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() : '').'</span>';
|
||||||
|
if (property_exists($this, 'fields') && !empty($this->fields['bomtype']['arrayofkeyval'])) {
|
||||||
|
$return .= '<br><span class="info-box-label opacitymedium">'.$langs->trans("Type").' : </span>';
|
||||||
|
if ($this->bomtype == 0) {
|
||||||
|
$return .= '<span class="info-box-label">'.$this->fields['bomtype']['arrayofkeyval'][0].'</span>';
|
||||||
|
} else {
|
||||||
|
$return .= '<span class="info-box-label">'.$this->fields['bomtype']['arrayofkeyval'][1].'</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (property_exists($this, 'fk_product') && !is_null($this->fk_product)) {
|
||||||
|
$return .= '<br><span class="info-box-label">'.$prod->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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1064,6 +1064,239 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output a task line into a pertime intput mode
|
||||||
|
*
|
||||||
|
* @param string $inc Line number (start to 0, then increased by recursive call)
|
||||||
|
* @param string $parent Id of parent task to show (0 to show all)
|
||||||
|
* @param User|null $fuser Restrict list to user if defined
|
||||||
|
* @param Task[] $lines Array of lines
|
||||||
|
* @param int $level Level (start to 0, then increased/decrease by recursive call)
|
||||||
|
* @param string $projectsrole Array of roles user has on project
|
||||||
|
* @param string $tasksrole Array of roles user has on task
|
||||||
|
* @param string $mine Show only task lines I am assigned to <<<<<<<<< Temporary merge branch 1
|
||||||
|
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
|
||||||
|
* @param int $preselectedday Preselected day
|
||||||
|
* @param array $isavailable Array with data that say if user is available for several days for morning and afternoon
|
||||||
|
* @param int $oldprojectforbreak Old project id of last project break
|
||||||
|
* @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks
|
||||||
|
*/
|
||||||
|
function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0)
|
||||||
|
{
|
||||||
|
global $conf, $db, $user, $langs;
|
||||||
|
global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
|
||||||
|
|
||||||
|
$lastprojectid = 0;
|
||||||
|
$totalforeachline = array();
|
||||||
|
$workloadforid = array();
|
||||||
|
$lineswithoutlevel0 = array();
|
||||||
|
|
||||||
|
$numlines = count($lines);
|
||||||
|
|
||||||
|
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
|
||||||
|
if ($parent == 0) { // Always and only if at first level
|
||||||
|
for ($i = 0; $i < $numlines; $i++) {
|
||||||
|
if ($lines[$i]->fk_task_parent) {
|
||||||
|
$lineswithoutlevel0[] = $lines[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($oldprojectforbreak)) {
|
||||||
|
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
|
||||||
|
}
|
||||||
|
|
||||||
|
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
|
||||||
|
for ($i = 0; $i < $numlines; $i++) {
|
||||||
|
if ($parent == 0) {
|
||||||
|
$level = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if ($lines[$i]->fk_task_parent == $parent)
|
||||||
|
//{
|
||||||
|
// If we want all or we have a role on task, we show it
|
||||||
|
if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
|
||||||
|
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
|
||||||
|
|
||||||
|
// Break on a new project
|
||||||
|
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
|
||||||
|
$lastprojectid = $lines[$i]->fk_project;
|
||||||
|
if ($preselectedday) {
|
||||||
|
$projectstatic->id = $lines[$i]->fk_project;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($workloadforid[$projectstatic->id])) {
|
||||||
|
if ($preselectedday) {
|
||||||
|
$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
|
||||||
|
$workloadforid[$projectstatic->id] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectstatic->id = $lines[$i]->fk_project;
|
||||||
|
$projectstatic->ref = $lines[$i]->project_ref;
|
||||||
|
$projectstatic->title = $lines[$i]->project_label;
|
||||||
|
$projectstatic->public = $lines[$i]->public;
|
||||||
|
$projectstatic->status = $lines[$i]->project->status;
|
||||||
|
|
||||||
|
$taskstatic->id = $lines[$i]->fk_statut;
|
||||||
|
$taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id);
|
||||||
|
$taskstatic->label = $lines[$i]->task_label;
|
||||||
|
$taskstatic->date_start = $lines[$i]->date_start;
|
||||||
|
$taskstatic->date_end = $lines[$i]->date_end;
|
||||||
|
|
||||||
|
$thirdpartystatic->id = $lines[$i]->socid;
|
||||||
|
$thirdpartystatic->name = $lines[$i]->thirdparty_name;
|
||||||
|
$thirdpartystatic->email = $lines[$i]->thirdparty_email;
|
||||||
|
|
||||||
|
if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
|
||||||
|
print '<tr class="oddeven trforbreak nobold">'."\n";
|
||||||
|
print '<td colspan="11">';
|
||||||
|
print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
|
||||||
|
if ($projectstatic->title) {
|
||||||
|
print ' - ';
|
||||||
|
print $projectstatic->title;
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($oldprojectforbreak != -1) {
|
||||||
|
$oldprojectforbreak = $projectstatic->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<tr class="oddeven">'."\n";
|
||||||
|
|
||||||
|
// User
|
||||||
|
/*
|
||||||
|
print '<td class="nowrap">';
|
||||||
|
print $fuser->getNomUrl(1, 'withproject', 'time');
|
||||||
|
print '</td>';
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Project
|
||||||
|
print "<td>";
|
||||||
|
if ($oldprojectforbreak == -1) {
|
||||||
|
print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
|
||||||
|
print '<br>'.$projectstatic->title;
|
||||||
|
}
|
||||||
|
print "</td>";
|
||||||
|
|
||||||
|
// Thirdparty
|
||||||
|
print '<td class="tdoverflowmax100">';
|
||||||
|
if ($thirdpartystatic->id > 0) {
|
||||||
|
print $thirdpartystatic->getNomUrl(1, 'project', 10);
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Ref
|
||||||
|
print '<td>';
|
||||||
|
print '<!-- Task id = '.$lines[$i]->id.' -->';
|
||||||
|
for ($k = 0; $k < $level; $k++) {
|
||||||
|
print " ";
|
||||||
|
}
|
||||||
|
print $taskstatic->getNomUrl(1, 'withproject', 'time');
|
||||||
|
// Label task
|
||||||
|
print '<br>';
|
||||||
|
for ($k = 0; $k < $level; $k++) {
|
||||||
|
print " ";
|
||||||
|
}
|
||||||
|
print $taskstatic->label;
|
||||||
|
//print "<br>";
|
||||||
|
//for ($k = 0 ; $k < $level ; $k++) print " ";
|
||||||
|
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
|
||||||
|
print "</td>\n";
|
||||||
|
|
||||||
|
// Date
|
||||||
|
print '<td class="center">';
|
||||||
|
print dol_print_date($lines[$i]->timespent_datehour, 'day');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$disabledproject = 1;
|
||||||
|
$disabledtask = 1;
|
||||||
|
//print "x".$lines[$i]->fk_project;
|
||||||
|
//var_dump($lines[$i]);
|
||||||
|
//var_dump($projectsrole[$lines[$i]->fk_project]);
|
||||||
|
// If at least one role for project
|
||||||
|
if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
|
||||||
|
$disabledproject = 0;
|
||||||
|
$disabledtask = 0;
|
||||||
|
}
|
||||||
|
// If $restricteditformytask is on and I have no role on task, i disable edit
|
||||||
|
if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
|
||||||
|
$disabledtask = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hour
|
||||||
|
print '<td class="nowrap center">';
|
||||||
|
print dol_print_date($lines[$i]->timespent_datehour, 'hour');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$cssonholiday = '';
|
||||||
|
if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
|
||||||
|
$cssonholiday .= 'onholidayallday ';
|
||||||
|
} elseif (!$isavailable[$preselectedday]['morning']) {
|
||||||
|
$cssonholiday .= 'onholidaymorning ';
|
||||||
|
} elseif (!$isavailable[$preselectedday]['afternoon']) {
|
||||||
|
$cssonholiday .= 'onholidayafternoon ';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Duration
|
||||||
|
print '<td class="duration'.($cssonholiday ? ' '.$cssonholiday : '').' center">';
|
||||||
|
|
||||||
|
$dayWorkLoad = $lines[$i]->timespent_duration;
|
||||||
|
$totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
|
||||||
|
|
||||||
|
$alreadyspent = '';
|
||||||
|
if ($dayWorkLoad > 0) {
|
||||||
|
$alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
|
||||||
|
}
|
||||||
|
|
||||||
|
print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
|
||||||
|
|
||||||
|
// Comment for avoid unnecessary multiple calculation
|
||||||
|
/*$modeinput = 'hours';
|
||||||
|
|
||||||
|
print '<script type="text/javascript">';
|
||||||
|
print "jQuery(document).ready(function () {\n";
|
||||||
|
print " jQuery('.inputhour, .inputminute').bind('keyup', function(e) { updateTotal(0, '".$modeinput."') });";
|
||||||
|
print "})\n";
|
||||||
|
print '</script>';*/
|
||||||
|
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Note
|
||||||
|
print '<td class="center">';
|
||||||
|
print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
|
||||||
|
print $lines[$i]->timespent_note;
|
||||||
|
print '</textarea>';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Warning
|
||||||
|
print '<td class="right">';
|
||||||
|
/*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
|
||||||
|
elseif ($disabledtask)
|
||||||
|
{
|
||||||
|
$titleassigntask = $langs->trans("AssignTaskToMe");
|
||||||
|
if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
|
||||||
|
|
||||||
|
print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
|
||||||
|
}*/
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print "</tr>\n";
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
//$level--;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $totalforeachline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output a task line into a pertime intput mode
|
* Output a task line into a pertime intput mode
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user