From 1c7b30819131a0517e90db78236b963342c9ce84 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 8 Dec 2022 16:38:53 +0100 Subject: [PATCH] NEW Mode View for list of Stocks Kanban --- htdocs/product/stock/class/entrepot.class.php | 31 ++ htdocs/product/stock/list.php | 290 ++++++++++-------- 2 files changed, 188 insertions(+), 133 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index b47430bffc2..6e09a81eb7f 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -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 = '
'; + $return .= '
'; + $return .= '
'; + $return .= img_picto('', $this->picto); + $return .= '
'; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'lieu') && (!empty($this->lieu))) { + $return .= '
'.$this->lieu.''; + } + if (property_exists($this, 'sellvalue') && $this->sellvalue != 0) { + $return .= '
'.price($this->sellvalue).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index b0c33e61484..86a5a7fdeb3 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -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 ''; print ''; print ''; print ''; +print ''; -$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 ''; + if ($mode =='kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + print $warehouse->getKanbanView(''); - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - 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 '
'; + print ''; + } + } else { + // Show here line of result + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; } - print ''; + print ''; } - print ''; - } - 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 ''; + 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 ''; + 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 ''; + 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 ''.price2num($obj->stockqty, 5).''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'stockqty'; + } + } + + // PMP value + if (!empty($arrayfields["estimatedvalue"]['checked'])) { + print ''; + if (price2num($obj->estimatedvalue, 'MT')) { + print ''.price(price2num($obj->estimatedvalue, 'MT'), 1).''; } else { - print $warehouse->showOutputField($val, $key, $warehouse->$key, ''); + print ''; } print ''; 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 ''.price2num($obj->stockqty, 5).''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'stockqty'; - } - } - - // PMP value - if (!empty($arrayfields["estimatedvalue"]['checked'])) { - print ''; - if (price2num($obj->estimatedvalue, 'MT')) { - print ''.price(price2num($obj->estimatedvalue, 'MT'), 1).''; - } else { - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue'; - } - } - - // Selling value - if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) { - if ($obj->sellvalue) { - print ''.price(price2num($obj->sellvalue, 'MT'), 1).''; + // Selling value + if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + if ($obj->sellvalue) { + print ''.price(price2num($obj->sellvalue, 'MT'), 1).''; + } + } else { + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip(''.$langs->trans("Variable").'', $htmltext); } - } else { - $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip(''.$langs->trans("Variable").'', $htmltext); - } - print ''; - 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 ''.$warehouse->LibStatut($obj->statut, 5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - 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 ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell'; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\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 ''.$warehouse->LibStatut($obj->statut, 5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + } $i++; }