2
0
forked from Wavyzz/dolibarr

Merge pull request #23125 from lamrani002/kanbanForProducts

New mode kaban for products list
This commit is contained in:
Laurent Destailleur
2023-01-23 01:15:13 +01:00
committed by GitHub
3 changed files with 367 additions and 253 deletions

View File

@@ -6303,6 +6303,59 @@ class Product extends CommonObject
return $prodDurationHours;
}
/**
* 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,$conf;
$return = '<div class="box-flex-item box-flex-grow-zero">';
$return .= '<div class="info-box info-box-sm">';
$return .= '<div class="info-box-img">';
$label = '';
if ($this->is_photo_available($conf->product->multidir_output[$this->entity])) {
$label .= $this->show_photos('product', $conf->product->multidir_output[$this->entity]);
$return .= $label;
} else {
if ($this->type == Product::TYPE_PRODUCT) {
$label .= img_picto('', 'product');
} elseif ($this->type == Product::TYPE_SERVICE) {
$label .= img_picto('', 'service');
}
$return .= $label;
}
$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, 'label')) {
$return .= '<br><span class="info-box-label opacitymedium">'.$this->label.'</span>';
}
if (property_exists($this, 'price') && property_exists($this, 'price_ttc')) {
if ($this->price_base_type == 'TTC') {
$return .= '<br><span class="info-box-status amount">'.price($this->price_ttc).' '.$langs->trans("TTC").'</span>';
} else {
if ($this->status) {
$return .= '<br><span class="info-box-status amount">'.price($this->price).' '.$langs->trans("HT").'</span>';
}
}
}
if (property_exists($this, 'stock_reel')) {
$return .= '<br><span class="info-box-status opacitymedium">'.$langs->trans('PhysicalStock').' : <span class="bold">'.$this->stock_reel.'</span></span>';
}
if (method_exists($this, 'getLibStatut')) {
$return .='<br><span class="info-box-status margintoponly">'.$this->getLibStatut(5, 1).' '.$this->getLibStatut(5, 0).'</span>';
}
$return .= '</div>';
$return .= '</div>';
$return .= '</div>';
return $return;
}
}
/**

View File

@@ -97,6 +97,8 @@ $search_accountancy_code_buy_export = GETPOST("search_accountancy_code_buy_expor
$search_finished = GETPOST("search_finished", 'int');
$optioncss = GETPOST('optioncss', 'alpha');
$type = GETPOST("type", "int");
$mode = GETPOST('mode', 'alpha');
//Show/hide child products
if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
@@ -672,6 +674,9 @@ if (GETPOST('delprod')) {
}
$param = '';
if (!empty($mode)) {
$param = "&mode=".urlencode($mode);
}
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
@@ -781,6 +786,8 @@ if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_ext
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$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'));
if ($type === "") {
$perm = ($user->rights->produit->creer || $user->rights->service->creer);
} elseif ($type == Product::TYPE_SERVICE) {
@@ -803,7 +810,6 @@ if ($type == Product::TYPE_SERVICE) {
}
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type, '', $perm, $params);
$type = $oldtype;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
if ($optioncss != '') {
@@ -816,6 +822,8 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
//print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
if (empty($arrayfields['p.fk_product_type']['checked'])) {
print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
}
@@ -1321,13 +1329,15 @@ if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print "</tr>\n";
$product_static = new Product($db);
$product_fourn = new ProductFournisseur($db);
$i = 0;
$totalarray = array();
$totalarray['nbfield'] = 0;
while ($i < min($num, $limit)) {
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
// Multilangs
@@ -1346,6 +1356,7 @@ while ($i < min($num, $limit)) {
}
}
}
}
$parameters = array('staticdata' => $obj);
// Note that $action and $object may have been modified by hook
// do product_static fetch in hook if wanted or anything else
@@ -1397,11 +1408,24 @@ while ($i < min($num, $limit)) {
}
}
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'lire');
if ($product_static->isService()) {
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('service', 'service_advance', 'read_prices'):$user->hasRight('service', 'lire');
}
if ($mode == 'Kanban') {
if ($i == 0) {
print '<tr><td colspan="12">';
print '<div class="box-flex-container">';
}
$product_static->price = $obj->price;
// Output Kanban
print $product_static->getKanbanView('');
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
}
} else {
print '<tr class="oddeven">';
// Action column
@@ -1467,7 +1491,7 @@ while ($i < min($num, $limit)) {
// Label
if (!empty($arrayfields['p.label']['checked'])) {
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($product_static->label).'">'.$product_static->label.'</td>';
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.$obj->label.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@@ -1477,7 +1501,7 @@ while ($i < min($num, $limit)) {
if (!empty($arrayfields['p.fk_product_type']['checked'])) {
print '<td class="center">';
$s = '';
if ($product_static->type == 0) {
if ($obj->fk_product_type == 0) {
$s .= img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"');
} else {
$s .= img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"');
@@ -1491,7 +1515,7 @@ while ($i < min($num, $limit)) {
// Barcode
if (!empty($arrayfields['p.barcode']['checked'])) {
print '<td>'.$product_static->barcode.'</td>';
print '<td>'.$obj->barcode.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
@@ -1535,7 +1559,7 @@ while ($i < min($num, $limit)) {
// Weight
if (!empty($arrayfields['p.weight']['checked'])) {
print '<td class="center">';
print $product_static->weight;
print $obj->weight;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@@ -1555,7 +1579,7 @@ while ($i < min($num, $limit)) {
// Length
if (!empty($arrayfields['p.length']['checked'])) {
print '<td class="center">';
print $product_static->length;
print $obj->length;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@@ -1575,7 +1599,7 @@ while ($i < min($num, $limit)) {
// Width
if (!empty($arrayfields['p.width']['checked'])) {
print '<td align="center">';
print $product_static->width;
print $obj->width;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@@ -1595,7 +1619,7 @@ while ($i < min($num, $limit)) {
// Height
if (!empty($arrayfields['p.height']['checked'])) {
print '<td align="center">';
print $product_static->height;
print $obj->height;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@@ -1615,7 +1639,7 @@ while ($i < min($num, $limit)) {
// Surface
if (!empty($arrayfields['p.surface']['checked'])) {
print '<td class="center">';
print $product_static->surface;
print $obj->surface;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@@ -1635,7 +1659,7 @@ while ($i < min($num, $limit)) {
// Volume
if (!empty($arrayfields['p.volume']['checked'])) {
print '<td class="center">';
print $product_static->volume;
print $obj->volume;
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@@ -1667,7 +1691,7 @@ while ($i < min($num, $limit)) {
// Sell price
if (!empty($arrayfields['p.sellprice']['checked'])) {
print '<td class="right nowraponall">';
if ($product_static->status && $usercancreadprice) {
if ($obj->tosell && $usercancreadprice) {
if ($obj->price_base_type == 'TTC') {
print '<span class="amount">'.price($obj->price_ttc).' '.$langs->trans("TTC").'</span>';
} else {
@@ -1690,7 +1714,7 @@ while ($i < min($num, $limit)) {
$productpricescache[$obj->rowid] = array();
}
if ($product_static->status && $usercancreadprice) {
if ($obj->tosell && $usercancreadprice) {
// Make 1 request for all price levels (without filter on price_level) and saved result into an cache array
// then reuse the cache array if we need prices for other price levels
$sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type";
@@ -1734,6 +1758,12 @@ while ($i < min($num, $limit)) {
$totalarray['nbfield']++;
}
}
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
}
}
@@ -1750,6 +1780,10 @@ while ($i < min($num, $limit)) {
print '<span class="amount">'.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").'</span>';
}
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
}
print '</td>';
@@ -1986,6 +2020,8 @@ while ($i < min($num, $limit)) {
}
print "</tr>\n";
}
$i++;
}

View File

@@ -189,6 +189,31 @@ a.info-box-text-a i.fa.fa-exclamation-triangle {
bottom: 0;
}
/* customize section img box on list of products */
.info-box-img {
height: 105px !important;
width: 88px;
border-top-left-radius: 2px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 2px;
display: block;
overflow: hidden;
float: left;
text-align: center;
font-size: 2.8em;
line-height: 90px;
margin-right: 5px;
background: var(--colorbacktitle1) !important;
}
.info-box-img > img {
width: 90%;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<?php if (empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS) && !empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD)) { ?>
.info-box-icon-text{
opacity: 1;