Merge pull request #23157 from lamrani002/KanbaModeForListOfStock

NEW Mode View for list of Stocks
This commit is contained in:
Laurent Destailleur 2022-12-17 01:46:57 +01:00 committed by GitHub
commit 3f17d6df03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 188 additions and 133 deletions

View File

@ -903,4 +903,35 @@ class Entrepot extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
return parent::setCategoriesCommon($categories, Categorie::TYPE_WAREHOUSE); return parent::setCategoriesCommon($categories, Categorie::TYPE_WAREHOUSE);
} }
/**
* 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 = '')
{
$return = '<div class="box-flex-item box-flex-grow-zero">';
$return .= '<div class="info-box info-box-sm">';
$return .= '<div class="info-box-icon bg-infobox-action" >';
$return .= img_picto('', $this->picto);
$return .= '</div>';
$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, 'lieu') && (!empty($this->lieu))) {
$return .= '<br><span class="info-box-label opacitymedium">'.$this->lieu.'</span>';
}
if (property_exists($this, 'sellvalue') && $this->sellvalue != 0) {
$return .= '<br><span class="info-box-label amount">'.price($this->sellvalue).'</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

@ -53,6 +53,8 @@ $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search
$search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha");
$search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); $search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha");
$search_status = GETPOST("search_status", "int"); $search_status = GETPOST("search_status", "int");
$mode = GETPOST('mode', 'alpha');
if (isModEnabled('categorie')) { if (isModEnabled('categorie')) {
$search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array"); $search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array");
@ -376,6 +378,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);
} }
@ -421,8 +426,13 @@ 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.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->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('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->creer);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit, 0, 0, 1);
@ -619,7 +629,21 @@ while ($i < min($num, $limit)) {
$warehouse->setVarsFromFetchObj($obj); $warehouse->setVarsFromFetchObj($obj);
$warehouse->label = $warehouse->ref; $warehouse->label = $warehouse->ref;
$warehouse->sellvalue = $obj->sellvalue;
if ($mode =='kanban') {
if ($i == 0) {
print '<tr><td colspan="12">';
print '<div class="box-flex-container">';
}
// Output Kanban
print $warehouse->getKanbanView('');
if ($i == ($imaxinloop - 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">';
@ -770,7 +794,7 @@ while ($i < min($num, $limit)) {
} }
print '</tr>'."\n"; print '</tr>'."\n";
}
$i++; $i++;
} }