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';
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_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha");
$search_status = GETPOST("search_status", "int");
$mode = GETPOST('mode', 'alpha');
if (isModEnabled('categorie')) {
$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();
$param = '';
if (!empty($mode)) {
$param .= '&mode='.urlencode($mode);
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$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="sortorder" value="'.$sortorder.'">';
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);
@ -619,158 +629,172 @@ while ($i < min($num, $limit)) {
$warehouse->setVarsFromFetchObj($obj);
$warehouse->label = $warehouse->ref;
$warehouse->sellvalue = $obj->sellvalue;
// Show here line of result
print '<tr class="oddeven">';
if ($mode =='kanban') {
if ($i == 0) {
print '<tr><td colspan="12">';
print '<div class="box-flex-container">';
}
// Output Kanban
print $warehouse->getKanbanView('');
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
}
} else {
// Show here line of result
print '<tr class="oddeven">';
// Action column
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
print '</td>';
}
print '</td>';
}
foreach ($warehouse->fields as $key => $val) {
if ($key == 'statut') {
continue;
}
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) {
$cssforfield = 'tdoverflowmax100';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
foreach ($warehouse->fields as $key => $val) {
if ($key == 'statut') {
print $warehouse->getLibStatut(5);
continue;
}
if ($key == 'phone') {
print dol_print_phone($obj->phone, '', 0, $obj->rowid, 'AC_TEL');
} elseif ($key == 'fax') {
print dol_print_phone($obj->fax, '', 0, $obj->rowid, 'AC_FAX');
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) {
$cssforfield = 'tdoverflowmax100';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'statut') {
print $warehouse->getLibStatut(5);
}
if ($key == 'phone') {
print dol_print_phone($obj->phone, '', 0, $obj->rowid, 'AC_TEL');
} elseif ($key == 'fax') {
print dol_print_phone($obj->fax, '', 0, $obj->rowid, 'AC_FAX');
} else {
print $warehouse->showOutputField($val, $key, $warehouse->$key, '');
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $warehouse->$key;
}
}
}
// Stock qty
if (!empty($arrayfields["stockqty"]['checked'])) {
print '<td class="right">'.price2num($obj->stockqty, 5).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'stockqty';
}
}
// PMP value
if (!empty($arrayfields["estimatedvalue"]['checked'])) {
print '<td class="right">';
if (price2num($obj->estimatedvalue, 'MT')) {
print '<span class="amount">'.price(price2num($obj->estimatedvalue, 'MT'), 1).'</span>';
} else {
print $warehouse->showOutputField($val, $key, $warehouse->$key, '');
print '';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $warehouse->$key;
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue';
}
}
}
// Stock qty
if (!empty($arrayfields["stockqty"]['checked'])) {
print '<td class="right">'.price2num($obj->stockqty, 5).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'stockqty';
}
}
// PMP value
if (!empty($arrayfields["estimatedvalue"]['checked'])) {
print '<td class="right">';
if (price2num($obj->estimatedvalue, 'MT')) {
print '<span class="amount">'.price(price2num($obj->estimatedvalue, 'MT'), 1).'</span>';
} else {
print '';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue';
}
}
// Selling value
if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
if ($obj->sellvalue) {
print '<span class="amount">'.price(price2num($obj->sellvalue, 'MT'), 1).'</span>';
// Selling value
if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
if ($obj->sellvalue) {
print '<span class="amount">'.price(price2num($obj->sellvalue, 'MT'), 1).'</span>';
}
} else {
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
print $form->textwithtooltip('<span class="opacitymedium">'.$langs->trans("Variable").'</span>', $htmltext);
}
} else {
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
print $form->textwithtooltip('<span class="opacitymedium">'.$langs->trans("Variable").'</span>', $htmltext);
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell';
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status
if (!empty($arrayfields['t.statut']['checked'])) {
print '<td class="center">'.$warehouse->LibStatut($obj->statut, 5).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell';
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
}
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status
if (!empty($arrayfields['t.statut']['checked'])) {
print '<td class="center">'.$warehouse->LibStatut($obj->statut, 5).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action column
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
}
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
}
$i++;
}