From 6e6a62d167d4ac9d48b937c0b6e98c3dbca7438e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 7 Sep 2022 14:58:07 +0200 Subject: [PATCH 01/22] NEW set payment default values when supplier order created from reception --- htdocs/fourn/facture/card.php | 95 +++++++++++++++++++++++++++++--- htdocs/reception/list.php | 100 ++++++++++++++++++++++++++++++++-- 2 files changed, 181 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 2f8f3f2adae..d096d02d92c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1954,15 +1954,93 @@ if ($action == 'create') { $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); - $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_supplier_id) ? $soc->cond_reglement_supplier_id : 0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_supplier_id) ? $soc->mode_reglement_supplier_id : 0)); - $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); - $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); - $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0)); + + $cond_reglement_id = 0; + $mode_reglement_id = 0; + $fk_account = 0; + $remise_percent = 0; + $remise_absolue = 0; + $transport_mode_id = 0; + + // set from object source + if (!empty($objectsrc->cond_reglement_id)) { + $cond_reglement_id = $objectsrc->cond_reglement_id; + } + if (!empty($objectsrc->mode_reglement_id)) { + $mode_reglement_id = $objectsrc->mode_reglement_id; + } + if (!empty($objectsrc->fk_account)) { + $fk_account = $objectsrc->fk_account; + } + if (!empty($objectsrc->remise_percent)) { + $remise_percent = $objectsrc->remise_percent; + } + if (!empty($objectsrc->remise_absolue)) { + $remise_absolue = $objectsrc->remise_absolue; + } + if (!empty($objectsrc->transport_mode_id)) { + $transport_mode_id = $objectsrc->transport_mode_id; + } + + if (empty($cond_reglement_id) + || empty($mode_reglement_id) + || empty($fk_account) + || empty($remise_percent) + || empty($remise_absolue) + || empty($transport_mode_id) + ) { + if ($origin == 'reception') { + // try to get from source of reception (supplier order) + if (!isset($objectsrc->supplier_order)) { + $objectsrc->fetch_origin(); + } + + if (!empty($objectsrc->commandeFournisseur)) { + $supplierOrder = $objectsrc->commandeFournisseur; + if (empty($cond_reglement_id) && !empty($supplierOrder->cond_reglement_id)) { + $cond_reglement_id = $supplierOrder->cond_reglement_id; + } + if (empty($mode_reglement_id) && !empty($supplierOrder->mode_reglement_id)) { + $mode_reglement_id = $supplierOrder->mode_reglement_id; + } + if (empty($fk_account) && !empty($supplierOrder->fk_account)) { + $fk_account = $supplierOrder->fk_account; + } + if (empty($remise_percent) && !empty($supplierOrder->remise_percent)) { + $remise_percent = $supplierOrder->remise_percent; + } + if (empty($remise_absolue) && !empty($supplierOrder->remise_absolue)) { + $remise_absolue = $supplierOrder->remise_absolue; + } + if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) { + $transport_mode_id = $supplierOrder->transport_mode_id; + } + } + } + + // try to get from third-party of source object + if (!empty($soc)) { + if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) { + $cond_reglement_id = $soc->cond_reglement_supplier_id; + } + if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) { + $mode_reglement_id = $soc->mode_reglement_supplier_id; + } + if (empty($fk_account) && !empty($soc->fk_account)) { + $fk_account = $soc->fk_account; + } + if (empty($remise_percent) && !empty($soc->remise_supplier_percent)) { + $remise_percent = $soc->remise_supplier_percent; + } + if (empty($remise_absolue) && !empty($soc->remise_absolue)) { + $remise_absolue = $soc->remise_absolue; + } + if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) { + $transport_mode_id = $soc->transport_mode_id; + } + } + } if (isModEnabled("multicurrency")) { if (!empty($objectsrc->multicurrency_code)) { @@ -1973,6 +2051,7 @@ if ($action == 'create') { } } + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); $datetmp = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 88c86168678..a6ed1ad935e 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -219,15 +219,98 @@ if (empty($reshook)) { } } } else { + $cond_reglement_id = 0; + $mode_reglement_id = 0; + $fk_account = 0; + $remise_percent = 0; + $remise_absolue = 0; + $transport_mode_id = 0; + if (!empty($rcp->cond_reglement_id)) { + $cond_reglement_id = $rcp->cond_reglement_id; + } + if (!empty($rcp->mode_reglement_id)) { + $mode_reglement_id = $rcp->mode_reglement_id; + } + if (!empty($rcp->fk_account)) { + $fk_account = $rcp->fk_account; + } + if (!empty($rcp->remise_percent)) { + $remise_percent = $rcp->remise_percent; + } + if (!empty($rcp->remise_absolue)) { + $remise_absolue = $rcp->remise_absolue; + } + if (!empty($rcp->transport_mode_id)) { + $transport_mode_id = $rcp->transport_mode_id; + } + + if (empty($cond_reglement_id) + || empty($mode_reglement_id) + || empty($fk_account) + || empty($remise_percent) + || empty($remise_absolue) + || empty($transport_mode_id) + ) { + if (!isset($rcp->supplier_order)) { + $rcp->fetch_origin(); + } + + // try to get from source of reception (supplier order) + if (!empty($rcp->commandeFournisseur)) { + $supplierOrder = $rcp->commandeFournisseur; + if (empty($cond_reglement_id) && !empty($supplierOrder->cond_reglement_id)) { + $cond_reglement_id = $supplierOrder->cond_reglement_id; + } + if (empty($mode_reglement_id) && !empty($supplierOrder->mode_reglement_id)) { + $mode_reglement_id = $supplierOrder->mode_reglement_id; + } + if (empty($fk_account) && !empty($supplierOrder->fk_account)) { + $fk_account = $supplierOrder->fk_account; + } + if (empty($remise_percent) && !empty($supplierOrder->remise_percent)) { + $remise_percent = $supplierOrder->remise_percent; + } + if (empty($remise_absolue) && !empty($supplierOrder->remise_absolue)) { + $remise_absolue = $supplierOrder->remise_absolue; + } + if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) { + $transport_mode_id = $supplierOrder->transport_mode_id; + } + } + + // try get from third-party of reception + if (!empty($rcp->thirdparty)) { + $soc = $rcp->thirdparty; + if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) { + $cond_reglement_id = $soc->cond_reglement_supplier_id; + } + if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) { + $mode_reglement_id = $soc->mode_reglement_supplier_id; + } + if (empty($fk_account) && !empty($soc->fk_account)) { + $fk_account = $soc->fk_account; + } + if (empty($remise_percent) && !empty($soc->remise_supplier_percent)) { + $remise_percent = $soc->remise_supplier_percent; + } + if (empty($remise_absolue) && !empty($soc->remise_absolue)) { + $remise_absolue = $soc->remise_absolue; + } + if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) { + $transport_mode_id = $soc->transport_mode_id; + } + } + } + // If we want one invoice per reception or if there is no first invoice yet for this thirdparty. $objecttmp->socid = $rcp->socid; $objecttmp->type = $objecttmp::TYPE_STANDARD; - $objecttmp->cond_reglement_id = $rcp->cond_reglement_id || $rcp->thirdparty->cond_reglement_supplier_id; - $objecttmp->mode_reglement_id = $rcp->mode_reglement_id || $rcp->thirdparty->mode_reglement_supplier_id; - - $objecttmp->fk_account = !empty($rcp->thirdparty->fk_account) ? $rcp->thirdparty->fk_account : 0; - $objecttmp->remise_percent = !empty($rcp->thirdparty->remise_percent) ? $rcp->thirdparty->remise_percent : 0; - $objecttmp->remise_absolue = !empty($rcp->thirdparty->remise_absolue) ? $rcp->thirdparty->remise_absolue : 0; + $objecttmp->cond_reglement_id = $cond_reglement_id; + $objecttmp->mode_reglement_id = $mode_reglement_id; + $objecttmp->fk_account = $fk_account; + $objecttmp->remise_percent = $remise_percent; + $objecttmp->remise_absolue = $remise_absolue; + $objecttmp->transport_mode_id = $transport_mode_id; $objecttmp->fk_project = $rcp->fk_project; //$objecttmp->multicurrency_code = $rcp->multicurrency_code; @@ -247,6 +330,11 @@ if (empty($reshook)) { $objecttmp->origin = 'reception'; $objecttmp->origin_id = $id_reception; + // Auto calculation of date due if not filled by user + if (empty($objecttmp->date_echeance)) { + $objecttmp->date_echeance = $objecttmp->calculate_date_lim_reglement(); + } + $objecttmp->array_options = $rcp->array_options; // Copy extrafields // Set $objecttmp->linked_objects with all links order_supplier existing on reception, so same links will be added to the generated supplier invoice From dc3d0c5c2e78bbe9c9fa1156b96c19422abeeaa3 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 28 Sep 2022 11:04:09 +0200 Subject: [PATCH 02/22] FIX duplicate invoice date --- htdocs/fourn/facture/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d096d02d92c..e6c16d03eed 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2050,10 +2050,9 @@ if ($action == 'create') { $currency_tx = $objectsrc->multicurrency_tx; } } - - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; + $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); + $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : '') : $datetmp); $datetmp = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); $datedue = ($datetmp == '' ?-1 : $datetmp); From 4bcd9220e64d6784453ef324c59b7c6a9bc836c5 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 28 Sep 2022 11:13:21 +0200 Subject: [PATCH 03/22] FIX stickler-ci --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e6c16d03eed..d342ddc79d6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2050,7 +2050,7 @@ if ($action == 'create') { $currency_tx = $objectsrc->multicurrency_tx; } } - + $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : '') : $datetmp); $datetmp = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); From 1c108f3583c76c00fd243f918d2fc84643b251fb Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 6 Dec 2022 16:11:14 +0100 Subject: [PATCH 04/22] New mode kaban for products list --- htdocs/product/class/product.class.php | 55 ++ htdocs/product/list.php | 1128 ++++++++++++------------ htdocs/theme/eldy/info-box.inc.php | 25 + 3 files changed, 655 insertions(+), 553 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ffb72bfca78..b0b55cab66c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6238,6 +6238,61 @@ 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 = '
'; + $return .= '
'; + $return .= '
'; + $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 .= '
'; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= '
'.$this->label.''; + } + if (property_exists($this, 'price') && property_exists($this, 'price_ttc')) { + if ($this->price_base_type == 'TTC') { + $return .= '
'.price($this->price_ttc).' '.$langs->trans("TTC").''; + } else { + if ($this->status) { + $return .= '
'.price($this->price).' '.$langs->trans("HT").''; + } + } + } + if (property_exists($this, 'stock_reel')) { + $return .= '
'.$langs->trans('PhysicalStock').' : '.$this->stock_reel.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .='
'.$this->getLibStatut(5, 1).' '.$this->getLibStatut(5, 0).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } /** diff --git a/htdocs/product/list.php b/htdocs/product/list.php index df9acd10cf7..f45f33c9de1 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -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)) { @@ -642,6 +644,9 @@ if ($resql) { } $param = ''; + if (!empty($mode)) { + $param = "&mode=".urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -751,6 +756,8 @@ if ($resql) { $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) { @@ -784,6 +791,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; //print ''; print ''; if (empty($arrayfields['p.fk_product_type']['checked'])) { @@ -1297,7 +1305,8 @@ if ($resql) { $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 @@ -1366,592 +1375,605 @@ if ($resql) { 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 ''; + print '
'; + } + $product_static->price = $obj->price; + // Output Kanban + print $product_static->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print ''; + } + } else { + print ''; - 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; + // 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 ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Ref - if (!empty($arrayfields['p.rowid']['checked'])) { - print ''; - print $product_static->id; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - print $product_static->getNomUrl(1); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref supplier - if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { - print ''; - print $product_static->getNomUrl(1); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thumbnail - if (!empty($arrayfields['thumbnail']['checked'])) { - $product_thumbnail_html = ''; - if (!empty($product_static->entity)) { - $product_thumbnail = $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); - if ($product_static->nbphoto > 0) { - $product_thumbnail_html = $product_thumbnail; + // Ref + if (!empty($arrayfields['p.rowid']['checked'])) { + print ''; + print $product_static->id; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print '' . $product_thumbnail_html . ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['p.label']['checked'])) { - print ''.$obj->label.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['p.fk_product_type']['checked'])) { - print ''; - $s = ''; - 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"'); - } - print $s; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Barcode - if (!empty($arrayfields['p.barcode']['checked'])) { - print ''.$obj->barcode.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Duration - if (!empty($arrayfields['p.duration']['checked'])) { - print ''; - - if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { - $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); - $duration_unit = substr($obj->duration, -1); - - if ((float) $duration_value > 1) { - $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ((float) $duration_value > 0) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + // Ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + print $product_static->getNomUrl(1); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; } - print $duration_value; - print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); - } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) { // If duration is a simple char (like 's' of 'm'), we do not show value - print $obj->duration; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Ref supplier + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { + print ''; + print $product_static->getNomUrl(1); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Finished - if (!empty($arrayfields['p.finished']['checked'])) { - print ''; - print $product_static->getLibFinished(); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + // Thumbnail + if (!empty($arrayfields['thumbnail']['checked'])) { + $product_thumbnail_html = ''; + if (!empty($product_static->entity)) { + $product_thumbnail = $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); + if ($product_static->nbphoto > 0) { + $product_thumbnail_html = $product_thumbnail; + } + } - // Weight - if (!empty($arrayfields['p.weight']['checked'])) { - print ''; - print $obj->weight; - print ''; - if (!$i) { - $totalarray['nbfield']++; + print '' . $product_thumbnail_html . ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Weight units - if (!empty($arrayfields['p.weight_units']['checked'])) { - print ''; - if ($product_static->weight != '') { - print measuringUnitString(0, 'weight', $product_static->weight_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Length - if (!empty($arrayfields['p.length']['checked'])) { - print ''; - print $obj->length; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Length units - if (!empty($arrayfields['p.length_units']['checked'])) { - print ''; - if ($product_static->length != '') { - print measuringUnitString(0, 'size', $product_static->length_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Width - if (!empty($arrayfields['p.width']['checked'])) { - print ''; - print $obj->width; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Width units - if (!empty($arrayfields['p.width_units']['checked'])) { - print ''; - if ($product_static->width != '') { - print measuringUnitString(0, 'size', $product_static->width_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Height - if (!empty($arrayfields['p.height']['checked'])) { - print ''; - print $obj->height; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Height units - if (!empty($arrayfields['p.height_units']['checked'])) { - print ''; - if ($product_static->height != '') { - print measuringUnitString(0, 'size', $product_static->height_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Surface - if (!empty($arrayfields['p.surface']['checked'])) { - print ''; - print $obj->surface; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Surface units - if (!empty($arrayfields['p.surface_units']['checked'])) { - print ''; - if ($product_static->surface != '') { - print measuringUnitString(0, 'surface', $product_static->surface_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Volume - if (!empty($arrayfields['p.volume']['checked'])) { - print ''; - print $obj->volume; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Volume units - if (!empty($arrayfields['p.volume_units']['checked'])) { - print ''; - if ($product_static->volume != '') { - print measuringUnitString(0, 'volume', $product_static->volume_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Unit - if (!empty($arrayfields['cu.label']['checked'])) { - print ''; - if (!empty($obj->cu_label)) { - print $langs->trans($obj->cu_label); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Sell price - if (!empty($arrayfields['p.sellprice']['checked'])) { - print ''; - if ($obj->tosell && $usercancreadprice) { - if ($obj->price_base_type == 'TTC') { - print ''.price($obj->price_ttc).' '.$langs->trans("TTC").''; + // Label + if (!empty($arrayfields['p.label']['checked'])) { + print ''.$obj->label.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if (!empty($arrayfields['p.fk_product_type']['checked'])) { + print ''; + $s = ''; + if ($obj->fk_product_type == 0) { + $s .= img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"'); } else { - print ''.price($obj->price).' '.$langs->trans("HT").''; + $s .= img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"'); + } + print $s; + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Multiprices - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - if (! isset($productpricescache)) { - $productpricescache=array(); - } - if (! isset($productpricescache[$obj->rowid])) { - $productpricescache[$obj->rowid] = array(); + // Barcode + if (!empty($arrayfields['p.barcode']['checked'])) { + print ''.$obj->barcode.''; + if (!$i) { + $totalarray['nbfield']++; + } } - 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"; - $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; - $sqlp .= " WHERE fk_product = ".((int) $obj->rowid); - $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; - $resultp = $db->query($sqlp); - if ($resultp) { - $nump = $db->num_rows($resultp); - $j = 0; - while ($j < $nump) { - $objp = $db->fetch_object($resultp); + // Duration + if (!empty($arrayfields['p.duration']['checked'])) { + print ''; - if (empty($productpricescache[$obj->rowid][$objp->price_level])) { - $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; - $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; - $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; + if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { + $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $duration_unit = substr($obj->duration, -1); + + if ((float) $duration_value > 1) { + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } elseif ((float) $duration_value > 0) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + print $duration_value; + print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); + } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) { // If duration is a simple char (like 's' of 'm'), we do not show value + print $obj->duration; + } + + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Finished + if (!empty($arrayfields['p.finished']['checked'])) { + print ''; + print $product_static->getLibFinished(); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Weight + if (!empty($arrayfields['p.weight']['checked'])) { + print ''; + print $obj->weight; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Weight units + if (!empty($arrayfields['p.weight_units']['checked'])) { + print ''; + if ($product_static->weight != '') { + print measuringUnitString(0, 'weight', $product_static->weight_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Length + if (!empty($arrayfields['p.length']['checked'])) { + print ''; + print $obj->length; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Length units + if (!empty($arrayfields['p.length_units']['checked'])) { + print ''; + if ($product_static->length != '') { + print measuringUnitString(0, 'size', $product_static->length_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Width + if (!empty($arrayfields['p.width']['checked'])) { + print ''; + print $obj->width; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Width units + if (!empty($arrayfields['p.width_units']['checked'])) { + print ''; + if ($product_static->width != '') { + print measuringUnitString(0, 'size', $product_static->width_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Height + if (!empty($arrayfields['p.height']['checked'])) { + print ''; + print $obj->height; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Height units + if (!empty($arrayfields['p.height_units']['checked'])) { + print ''; + if ($product_static->height != '') { + print measuringUnitString(0, 'size', $product_static->height_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Surface + if (!empty($arrayfields['p.surface']['checked'])) { + print ''; + print $obj->surface; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Surface units + if (!empty($arrayfields['p.surface_units']['checked'])) { + print ''; + if ($product_static->surface != '') { + print measuringUnitString(0, 'surface', $product_static->surface_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Volume + if (!empty($arrayfields['p.volume']['checked'])) { + print ''; + print $obj->volume; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Volume units + if (!empty($arrayfields['p.volume_units']['checked'])) { + print ''; + if ($product_static->volume != '') { + print measuringUnitString(0, 'volume', $product_static->volume_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Unit + if (!empty($arrayfields['cu.label']['checked'])) { + print ''; + if (!empty($obj->cu_label)) { + print $langs->trans($obj->cu_label); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Sell price + if (!empty($arrayfields['p.sellprice']['checked'])) { + print ''; + if ($obj->tosell && $usercancreadprice) { + if ($obj->price_base_type == 'TTC') { + print ''.price($obj->price_ttc).' '.$langs->trans("TTC").''; + } else { + print ''.price($obj->price).' '.$langs->trans("HT").''; + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + + // Multiprices + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + if (! isset($productpricescache)) { + $productpricescache=array(); + } + if (! isset($productpricescache[$obj->rowid])) { + $productpricescache[$obj->rowid] = array(); + } + + 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"; + $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; + $sqlp .= " WHERE fk_product = ".((int) $obj->rowid); + $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; + $resultp = $db->query($sqlp); + if ($resultp) { + $nump = $db->num_rows($resultp); + $j = 0; + while ($j < $nump) { + $objp = $db->fetch_object($resultp); + + if (empty($productpricescache[$obj->rowid][$objp->price_level])) { + $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; + $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; + $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; + } + + $j++; } - $j++; + $db->free($resultp); + } else { + dol_print_error($db); } + } - $db->free($resultp); + foreach ($arraypricelevel as $key => $value) { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { + print ''; + if (!empty($productpricescache[$obj->rowid])) { + if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { + print ''.price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC").''; + } else { + print ''.price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT").''; + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + } + } + + // Better buy price + if (!empty($arrayfields['p.minbuyprice']['checked'])) { + print ''; + if ($obj->tobuy && $obj->minsellprice != '' && $usercancreadprice) { + //print price($obj->minsellprice).' '.$langs->trans("HT"); + if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { + if ($product_fourn->product_fourn_price_id > 0) { + if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print ''.$form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext).''; + } else { + print ''.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").''; + } + } + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Number of buy prices + if (!empty($arrayfields['p.numbuyprice']['checked'])) { + print ''; + if ($obj->tobuy && $usercancreadprice) { + if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList), $htmltext); + } + } + print ''; + } + + // VAT or Sell Tax Rate + if (!empty($arrayfields['p.tva_tx']['checked'])) { + print ''; + print vatrate($obj->tva_tx, true); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // WAP + if (!empty($arrayfields['p.pmp']['checked'])) { + print ''; + if ($usercancreadprice) { + print ''.price($product_static->pmp, 1, $langs).""; + } + print ''; + } + // Cost price + if (!empty($arrayfields['p.cost_price']['checked'])) { + print ''; + //print $obj->cost_price; + if ($usercancreadprice) { + print ''.price($obj->cost_price).' '.$langs->trans("HT").''; + } + print ''; + } + + // Limit alert + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { + print ''; + if ($obj->fk_product_type != 1) { + print $obj->seuil_stock_alerte; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Desired stock + if (!empty($arrayfields['p.desiredstock']['checked'])) { + print ''; + if ($obj->fk_product_type != 1) { + print $obj->desiredstock; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Stock real + if (!empty($arrayfields['p.stock']['checked'])) { + print ''; + if ($obj->fk_product_type != 1) { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + } + if ($usercancreadprice) { + print price(price2num($product_static->stock_reel, 'MS')); + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Stock virtual + if (!empty($arrayfields['stock_virtual']['checked'])) { + print ''; + if ($obj->fk_product_type != 1) { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + } + if ($usercancreadprice) { + print price(price2num($product_static->stock_theorique, 'MS')); + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Lot/Serial + if (!empty($arrayfields['p.tobatch']['checked'])) { + print ''; + print $product_static->getLibStatut(1, 2); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['p.fk_country']['checked'])) { + print ''.getCountry($obj->fk_country, 0, $db).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['p.fk_state']['checked'])) { + print ''; + if (!empty($obj->fk_state)) { + print getState($obj->fk_state, 0, $db); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Accountancy code sell + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { + print ''.$obj->accountancy_code_sell.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { + print ''.$obj->accountancy_code_sell_intra.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { + print ''.$obj->accountancy_code_sell_export.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Accountancy code buy + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { + print ''.$obj->accountancy_code_buy.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { + print ''.$obj->accountancy_code_buy_intra.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { + print ''.$obj->accountancy_code_buy_export.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Status (to sell) + if (!empty($arrayfields['p.tosell']['checked'])) { + print ''; + if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { - dol_print_error($db); + print $product_static->LibStatut($obj->tosell, 5, 0); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status (to buy) + if (!empty($arrayfields['p.tobuy']['checked'])) { + print ''; + if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + print $product_static->LibStatut($obj->tobuy, 5, 1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - foreach ($arraypricelevel as $key => $value) { - if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { - print ''; - if (!empty($productpricescache[$obj->rowid])) { - if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { - print ''.price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC").''; - } else { - print ''.price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT").''; - } - } - print ''; - 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']++; } } - } - // Better buy price - if (!empty($arrayfields['p.minbuyprice']['checked'])) { - print ''; - if ($obj->tobuy && $obj->minsellprice != '' && $usercancreadprice) { - //print price($obj->minsellprice).' '.$langs->trans("HT"); - if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { - if ($product_fourn->product_fourn_price_id > 0) { - if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { - $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print ''.$form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext).''; - } else { - print ''.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").''; - } - } - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + print "\n"; } - - // Number of buy prices - if (!empty($arrayfields['p.numbuyprice']['checked'])) { - print ''; - if ($obj->tobuy && $usercancreadprice) { - if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { - $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList), $htmltext); - } - } - print ''; - } - - // VAT or Sell Tax Rate - if (!empty($arrayfields['p.tva_tx']['checked'])) { - print ''; - print vatrate($obj->tva_tx, true); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // WAP - if (!empty($arrayfields['p.pmp']['checked'])) { - print ''; - if ($usercancreadprice) { - print ''.price($product_static->pmp, 1, $langs).""; - } - print ''; - } - // Cost price - if (!empty($arrayfields['p.cost_price']['checked'])) { - print ''; - //print $obj->cost_price; - if ($usercancreadprice) { - print ''.price($obj->cost_price).' '.$langs->trans("HT").''; - } - print ''; - } - - // Limit alert - if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { - print ''; - if ($obj->fk_product_type != 1) { - print $obj->seuil_stock_alerte; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Desired stock - if (!empty($arrayfields['p.desiredstock']['checked'])) { - print ''; - if ($obj->fk_product_type != 1) { - print $obj->desiredstock; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Stock real - if (!empty($arrayfields['p.stock']['checked'])) { - print ''; - if ($obj->fk_product_type != 1) { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { - print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - } - if ($usercancreadprice) { - print price(price2num($product_static->stock_reel, 'MS')); - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Stock virtual - if (!empty($arrayfields['stock_virtual']['checked'])) { - print ''; - if ($obj->fk_product_type != 1) { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { - print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - } - if ($usercancreadprice) { - print price(price2num($product_static->stock_theorique, 'MS')); - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Lot/Serial - if (!empty($arrayfields['p.tobatch']['checked'])) { - print ''; - print $product_static->getLibStatut(1, 2); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['p.fk_country']['checked'])) { - print ''.getCountry($obj->fk_country, 0, $db).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['p.fk_state']['checked'])) { - print ''; - if (!empty($obj->fk_state)) { - print getState($obj->fk_state, 0, $db); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Accountancy code sell - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { - print ''.$obj->accountancy_code_sell.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { - print ''.$obj->accountancy_code_sell_intra.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { - print ''.$obj->accountancy_code_sell_export.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Accountancy code buy - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { - print ''.$obj->accountancy_code_buy.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { - print ''.$obj->accountancy_code_buy_intra.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { - print ''.$obj->accountancy_code_buy_export.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status (to sell) - if (!empty($arrayfields['p.tosell']['checked'])) { - print ''; - if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product_static->LibStatut($obj->tosell, 5, 0); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status (to buy) - if (!empty($arrayfields['p.tobuy']['checked'])) { - print ''; - if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product_static->LibStatut($obj->tobuy, 5, 1); - } - print ''; - 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++; } diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 29f1a229054..b241d4d278b 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -173,6 +173,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%); +} + global->MAIN_DISABLE_GLOBAL_BOXSTATS) && !empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD)) { ?> .info-box-icon-text{ opacity: 1; From 20cd8348394af379df498ee23fa0391176745322 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 10:15:21 +0000 Subject: [PATCH 05/22] Fixing style errors. --- htdocs/product/list.php | 1339 +++++++++++++++++++-------------------- 1 file changed, 667 insertions(+), 672 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index c4473a9376a..f7634c7311b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -675,7 +675,7 @@ if (GETPOST('delprod')) { $param = ''; if (!empty($mode)) { - $param = "&mode=".urlencode($mode); + $param = "&mode=".urlencode($mode); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); @@ -788,26 +788,26 @@ $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) { - $perm = $user->rights->service->creer; - } elseif ($type == Product::TYPE_PRODUCT) { - $perm = $user->rights->produit->creer; - } +if ($type === "") { + $perm = ($user->rights->produit->creer || $user->rights->service->creer); +} elseif ($type == Product::TYPE_SERVICE) { + $perm = $user->rights->service->creer; +} elseif ($type == Product::TYPE_PRODUCT) { + $perm = $user->rights->produit->creer; +} $oldtype = $type; $params = array(); - if ($type === "") { - $params['forcenohideoftext'] = 1; - } - if ($type === "") { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params); - $type = Product::TYPE_SERVICE; - } +if ($type === "") { + $params['forcenohideoftext'] = 1; +} +if ($type === "") { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params); + $type = Product::TYPE_SERVICE; +} $label = 'NewProduct'; - if ($type == Product::TYPE_SERVICE) { - $label = 'NewService'; - } +if ($type == Product::TYPE_SERVICE) { + $label = 'NewService'; +} $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type, '', $perm, $params); @@ -1337,679 +1337,99 @@ print "\n"; $totalarray = array(); $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); +while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); - // Multilangs - if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product = ".((int) $obj->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; - $sql .= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) { - $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) { - $obj->label = $objtp->label; - } + // Multilangs + if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled + $sql = "SELECT label"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product = ".((int) $obj->rowid); + $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; + $sql .= " LIMIT 1"; + $result = $db->query($sql); + if ($result) { + $objtp = $db->fetch_object($result); + if (!empty($objtp->label)) { + $obj->label = $objtp->label; } } } +} $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 $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $product_static, $action); - if (empty($reshook)) { - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated - $product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->finished = $obj->finished; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; - $product_static->status_batch = $obj->tobatch; - $product_static->entity = $obj->entity; - $product_static->pmp = $obj->pmp; - $product_static->accountancy_code_sell = $obj->accountancy_code_sell; - $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $product_static->accountancy_code_buy = $obj->accountancy_code_buy; - $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; - $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export; - $product_static->length = $obj->length; - $product_static->length_units = $obj->length_units; - $product_static->width = $obj->width; - $product_static->width_units = $obj->width_units; - $product_static->height = $obj->height; - $product_static->height_units = $obj->height_units; - $product_static->weight = $obj->weight; - $product_static->weight_units = $obj->weight_units; - $product_static->volume = $obj->volume; - $product_static->volume_units = $obj->volume_units; - $product_static->surface = $obj->surface; - $product_static->surface_units = $obj->surface_units; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $product_static->fk_unit = $obj->fk_unit; - } +if (empty($reshook)) { + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated + $product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->finished = $obj->finished; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; + $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export; + $product_static->length = $obj->length; + $product_static->length_units = $obj->length_units; + $product_static->width = $obj->width; + $product_static->width_units = $obj->width_units; + $product_static->height = $obj->height; + $product_static->height_units = $obj->height_units; + $product_static->weight = $obj->weight; + $product_static->weight_units = $obj->weight_units; + $product_static->volume = $obj->volume; + $product_static->volume_units = $obj->volume_units; + $product_static->surface = $obj->surface; + $product_static->surface_units = $obj->surface_units; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $product_static->fk_unit = $obj->fk_unit; + } - // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. - if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock - if ($product_static->type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service - $option = 'nobatch'; - if (empty($arrayfields['stock_virtual']['checked'])) { - $option .= ',novirtual'; - } - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() + // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. + if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock + if ($product_static->type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service + $option = 'nobatch'; + if (empty($arrayfields['stock_virtual']['checked'])) { + $option .= ',novirtual'; } + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } } +} $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 ''; - print '
'; - } - $product_static->price = $obj->price; - // Output Kanban - print $product_static->getKanbanView(''); - if ($i == ($imaxinloop - 1)) { - print '
'; - print ''; - } - } else { - 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 ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Ref - if (!empty($arrayfields['p.rowid']['checked'])) { - print ''; - print $product_static->id; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - print $product_static->getNomUrl(1); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref supplier - if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { - print ''; - print $product_static->getNomUrl(1); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thumbnail - if (!empty($arrayfields['thumbnail']['checked'])) { - $product_thumbnail_html = ''; - if (!empty($product_static->entity)) { - $product_thumbnail = $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); - if ($product_static->nbphoto > 0) { - $product_thumbnail_html = $product_thumbnail; - } - } - - print '' . $product_thumbnail_html . ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['p.label']['checked'])) { - print ''.$obj->label.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['p.fk_product_type']['checked'])) { - print ''; - $s = ''; - 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"'); - } - print $s; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Barcode - if (!empty($arrayfields['p.barcode']['checked'])) { - print ''.$obj->barcode.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Duration - if (!empty($arrayfields['p.duration']['checked'])) { - print ''; - - if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { - $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); - $duration_unit = substr($obj->duration, -1); - - if ((float) $duration_value > 1) { - $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ((float) $duration_value > 0) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); - } - print $duration_value; - print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); - } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) { // If duration is a simple char (like 's' of 'm'), we do not show value - print $obj->duration; - } - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Finished - if (!empty($arrayfields['p.finished']['checked'])) { - print ''; - print $product_static->getLibFinished(); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Weight - if (!empty($arrayfields['p.weight']['checked'])) { - print ''; - print $obj->weight; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Weight units - if (!empty($arrayfields['p.weight_units']['checked'])) { - print ''; - if ($product_static->weight != '') { - print measuringUnitString(0, 'weight', $product_static->weight_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Length - if (!empty($arrayfields['p.length']['checked'])) { - print ''; - print $obj->length; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Length units - if (!empty($arrayfields['p.length_units']['checked'])) { - print ''; - if ($product_static->length != '') { - print measuringUnitString(0, 'size', $product_static->length_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Width - if (!empty($arrayfields['p.width']['checked'])) { - print ''; - print $obj->width; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Width units - if (!empty($arrayfields['p.width_units']['checked'])) { - print ''; - if ($product_static->width != '') { - print measuringUnitString(0, 'size', $product_static->width_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Height - if (!empty($arrayfields['p.height']['checked'])) { - print ''; - print $obj->height; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Height units - if (!empty($arrayfields['p.height_units']['checked'])) { - print ''; - if ($product_static->height != '') { - print measuringUnitString(0, 'size', $product_static->height_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Surface - if (!empty($arrayfields['p.surface']['checked'])) { - print ''; - print $obj->surface; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Surface units - if (!empty($arrayfields['p.surface_units']['checked'])) { - print ''; - if ($product_static->surface != '') { - print measuringUnitString(0, 'surface', $product_static->surface_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Volume - if (!empty($arrayfields['p.volume']['checked'])) { - print ''; - print $obj->volume; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Volume units - if (!empty($arrayfields['p.volume_units']['checked'])) { - print ''; - if ($product_static->volume != '') { - print measuringUnitString(0, 'volume', $product_static->volume_units); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Unit - if (!empty($arrayfields['cu.label']['checked'])) { - print ''; - if (!empty($obj->cu_label)) { - print $langs->trans($obj->cu_label); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Sell price - if (!empty($arrayfields['p.sellprice']['checked'])) { - print ''; - if ($obj->tosell && $usercancreadprice) { - if ($obj->price_base_type == 'TTC') { - print ''.price($obj->price_ttc).' '.$langs->trans("TTC").''; - } else { - print ''.price($obj->price).' '.$langs->trans("HT").''; - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - - // Multiprices - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - if (! isset($productpricescache)) { - $productpricescache=array(); - } - if (! isset($productpricescache[$obj->rowid])) { - $productpricescache[$obj->rowid] = array(); - } - - 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"; - $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; - $sqlp .= " WHERE fk_product = ".((int) $obj->rowid); - $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; - $resultp = $db->query($sqlp); - if ($resultp) { - $nump = $db->num_rows($resultp); - $j = 0; - while ($j < $nump) { - $objp = $db->fetch_object($resultp); - - if (empty($productpricescache[$obj->rowid][$objp->price_level])) { - $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; - $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; - $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; - } - - $j++; - } - - $db->free($resultp); - } else { - dol_print_error($db); - } - } - - foreach ($arraypricelevel as $key => $value) { - if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { - print ''; - if (!empty($productpricescache[$obj->rowid])) { - if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { - print ''.price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC").''; - } else { - print ''.price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT").''; - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - } +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 ''; + print '
'; } - - // Better buy price - if (!empty($arrayfields['p.minbuyprice']['checked'])) { - print ''; - if ($product_static->status_buy && $obj->bestpurchaseprice != '' && $usercancreadprice) { - if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { - if ($product_fourn->product_fourn_price_id > 0) { - if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { - $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print ''.$form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext).''; - } else { - print ''.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").''; - - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Number of buy prices - if (!empty($arrayfields['p.numbuyprice']['checked'])) { - print ''; - if ($product_static->status_buy && $usercancreadprice) { - if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { - $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList), $htmltext); - } - } - print ''; - } - - // VAT or Sell Tax Rate - if (!empty($arrayfields['p.tva_tx']['checked'])) { - print ''; - print vatrate($obj->tva_tx, true); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // WAP - if (!empty($arrayfields['p.pmp']['checked'])) { - print ''; - if ($usercancreadprice) { - print ''.price($product_static->pmp, 1, $langs).""; - } - print ''; - } - // Cost price - if (!empty($arrayfields['p.cost_price']['checked'])) { - print ''; - //print $obj->cost_price; - if ($usercancreadprice) { - print ''.price($obj->cost_price).' '.$langs->trans("HT").''; - } - print ''; - } - - // Limit alert - if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { - print ''; - if ($product_static->type != 1) { - print $obj->seuil_stock_alerte; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Desired stock - if (!empty($arrayfields['p.desiredstock']['checked'])) { - print ''; - if ($product_static->type != 1) { - print $obj->desiredstock; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Stock real - if (!empty($arrayfields['p.stock']['checked'])) { - print ''; - if ($product_static->type != 1) { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { - print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - } - if ($usercancreadprice) { - print price(price2num($product_static->stock_reel, 'MS')); - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Stock virtual - if (!empty($arrayfields['stock_virtual']['checked'])) { - print ''; - if ($product_static->type != 1) { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { - print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - } - if ($usercancreadprice) { - print price(price2num($product_static->stock_theorique, 'MS')); - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Lot/Serial - if (!empty($arrayfields['p.tobatch']['checked'])) { - print ''; - print $product_static->getLibStatut(1, 2); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['p.fk_country']['checked'])) { - print ''.getCountry($obj->fk_country, 0, $db).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['p.fk_state']['checked'])) { - print ''; - if (!empty($obj->fk_state)) { - print getState($obj->fk_state, 0, $db); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Accountancy code sell - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { - print ''.$product_static->accountancy_code_sell.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { - print ''.$product_static->accountancy_code_sell_intra.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { - print ''.$product_static->accountancy_code_sell_export.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Accountancy code buy - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { - print ''.$product_static->accountancy_code_buy.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { - print ''.$product_static->accountancy_code_buy_intra.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { - print ''.$product_static->accountancy_code_buy_export.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status (to sell) - if (!empty($arrayfields['p.tosell']['checked'])) { - print ''; - if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product_static->LibStatut($product_static->status, 5, 0); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status (to buy) - if (!empty($arrayfields['p.tobuy']['checked'])) { - print ''; - if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product_static->LibStatut($product_static->status_buy, 5, 1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + $product_static->price = $obj->price; + // Output Kanban + print $product_static->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print ''; } +} else { + print ''; // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_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; @@ -2023,9 +1443,584 @@ print "\n"; $totalarray['nbfield']++; } } + // Ref + if (!empty($arrayfields['p.rowid']['checked'])) { + print ''; + print $product_static->id; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + print $product_static->getNomUrl(1); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref supplier + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { + print ''; + print $product_static->getNomUrl(1); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thumbnail + if (!empty($arrayfields['thumbnail']['checked'])) { + $product_thumbnail_html = ''; + if (!empty($product_static->entity)) { + $product_thumbnail = $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); + if ($product_static->nbphoto > 0) { + $product_thumbnail_html = $product_thumbnail; + } + } + + print '' . $product_thumbnail_html . ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['p.label']['checked'])) { + print ''.$obj->label.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if (!empty($arrayfields['p.fk_product_type']['checked'])) { + print ''; + $s = ''; + 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"'); + } + print $s; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Barcode + if (!empty($arrayfields['p.barcode']['checked'])) { + print ''.$obj->barcode.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Duration + if (!empty($arrayfields['p.duration']['checked'])) { + print ''; + + if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { + $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $duration_unit = substr($obj->duration, -1); + + if ((float) $duration_value > 1) { + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } elseif ((float) $duration_value > 0) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + print $duration_value; + print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); + } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) { // If duration is a simple char (like 's' of 'm'), we do not show value + print $obj->duration; + } + + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Finished + if (!empty($arrayfields['p.finished']['checked'])) { + print ''; + print $product_static->getLibFinished(); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Weight + if (!empty($arrayfields['p.weight']['checked'])) { + print ''; + print $obj->weight; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Weight units + if (!empty($arrayfields['p.weight_units']['checked'])) { + print ''; + if ($product_static->weight != '') { + print measuringUnitString(0, 'weight', $product_static->weight_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Length + if (!empty($arrayfields['p.length']['checked'])) { + print ''; + print $obj->length; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Length units + if (!empty($arrayfields['p.length_units']['checked'])) { + print ''; + if ($product_static->length != '') { + print measuringUnitString(0, 'size', $product_static->length_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Width + if (!empty($arrayfields['p.width']['checked'])) { + print ''; + print $obj->width; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Width units + if (!empty($arrayfields['p.width_units']['checked'])) { + print ''; + if ($product_static->width != '') { + print measuringUnitString(0, 'size', $product_static->width_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Height + if (!empty($arrayfields['p.height']['checked'])) { + print ''; + print $obj->height; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Height units + if (!empty($arrayfields['p.height_units']['checked'])) { + print ''; + if ($product_static->height != '') { + print measuringUnitString(0, 'size', $product_static->height_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Surface + if (!empty($arrayfields['p.surface']['checked'])) { + print ''; + print $obj->surface; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Surface units + if (!empty($arrayfields['p.surface_units']['checked'])) { + print ''; + if ($product_static->surface != '') { + print measuringUnitString(0, 'surface', $product_static->surface_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Volume + if (!empty($arrayfields['p.volume']['checked'])) { + print ''; + print $obj->volume; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Volume units + if (!empty($arrayfields['p.volume_units']['checked'])) { + print ''; + if ($product_static->volume != '') { + print measuringUnitString(0, 'volume', $product_static->volume_units); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Unit + if (!empty($arrayfields['cu.label']['checked'])) { + print ''; + if (!empty($obj->cu_label)) { + print $langs->trans($obj->cu_label); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Sell price + if (!empty($arrayfields['p.sellprice']['checked'])) { + print ''; + if ($obj->tosell && $usercancreadprice) { + if ($obj->price_base_type == 'TTC') { + print ''.price($obj->price_ttc).' '.$langs->trans("TTC").''; + } else { + print ''.price($obj->price).' '.$langs->trans("HT").''; + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + + // Multiprices + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + if (! isset($productpricescache)) { + $productpricescache=array(); + } + if (! isset($productpricescache[$obj->rowid])) { + $productpricescache[$obj->rowid] = array(); + } + + 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"; + $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; + $sqlp .= " WHERE fk_product = ".((int) $obj->rowid); + $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; + $resultp = $db->query($sqlp); + if ($resultp) { + $nump = $db->num_rows($resultp); + $j = 0; + while ($j < $nump) { + $objp = $db->fetch_object($resultp); + + if (empty($productpricescache[$obj->rowid][$objp->price_level])) { + $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; + $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; + $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; + } + + $j++; + } + + $db->free($resultp); + } else { + dol_print_error($db); + } + } + + foreach ($arraypricelevel as $key => $value) { + if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { + print ''; + if (!empty($productpricescache[$obj->rowid])) { + if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { + print ''.price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC").''; + } else { + print ''.price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT").''; + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } +} + } + + // Better buy price +if (!empty($arrayfields['p.minbuyprice']['checked'])) { + print ''; + if ($product_static->status_buy && $obj->bestpurchaseprice != '' && $usercancreadprice) { + if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { + if ($product_fourn->product_fourn_price_id > 0) { + if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print ''.$form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext).''; + } else { + print ''.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").''; + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + + // Number of buy prices +if (!empty($arrayfields['p.numbuyprice']['checked'])) { + print ''; + if ($product_static->status_buy && $usercancreadprice) { + if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList), $htmltext); + } + } + print ''; +} + + // VAT or Sell Tax Rate +if (!empty($arrayfields['p.tva_tx']['checked'])) { + print ''; + print vatrate($obj->tva_tx, true); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + + // WAP +if (!empty($arrayfields['p.pmp']['checked'])) { + print ''; + if ($usercancreadprice) { + print ''.price($product_static->pmp, 1, $langs).""; + } + print ''; +} + // Cost price +if (!empty($arrayfields['p.cost_price']['checked'])) { + print ''; + //print $obj->cost_price; + if ($usercancreadprice) { + print ''.price($obj->cost_price).' '.$langs->trans("HT").''; + } + print ''; +} + + // Limit alert +if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { + print ''; + if ($product_static->type != 1) { + print $obj->seuil_stock_alerte; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Desired stock +if (!empty($arrayfields['p.desiredstock']['checked'])) { + print ''; + if ($product_static->type != 1) { + print $obj->desiredstock; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Stock real +if (!empty($arrayfields['p.stock']['checked'])) { + print ''; + if ($product_static->type != 1) { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + } + if ($usercancreadprice) { + print price(price2num($product_static->stock_reel, 'MS')); + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Stock virtual +if (!empty($arrayfields['stock_virtual']['checked'])) { + print ''; + if ($product_static->type != 1) { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + } + if ($usercancreadprice) { + print price(price2num($product_static->stock_theorique, 'MS')); + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Lot/Serial +if (!empty($arrayfields['p.tobatch']['checked'])) { + print ''; + print $product_static->getLibStatut(1, 2); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Country +if (!empty($arrayfields['p.fk_country']['checked'])) { + print ''.getCountry($obj->fk_country, 0, $db).''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // State +if (!empty($arrayfields['p.fk_state']['checked'])) { + print ''; + if (!empty($obj->fk_state)) { + print getState($obj->fk_state, 0, $db); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Accountancy code sell +if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { + print ''.$product_static->accountancy_code_sell.''; + if (!$i) { + $totalarray['nbfield']++; + } +} +if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { + print ''.$product_static->accountancy_code_sell_intra.''; + if (!$i) { + $totalarray['nbfield']++; + } +} +if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { + print ''.$product_static->accountancy_code_sell_export.''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Accountancy code buy +if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { + print ''.$product_static->accountancy_code_buy.''; + if (!$i) { + $totalarray['nbfield']++; + } +} +if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { + print ''.$product_static->accountancy_code_buy_intra.''; + if (!$i) { + $totalarray['nbfield']++; + } +} +if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { + print ''.$product_static->accountancy_code_buy_export.''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation +if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Date modification +if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + + // Status (to sell) +if (!empty($arrayfields['p.tosell']['checked'])) { + print ''; + if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + } else { + print $product_static->LibStatut($product_static->status, 5, 0); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } +} + // Status (to buy) +if (!empty($arrayfields['p.tobuy']['checked'])) { + print ''; + if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + print $product_static->LibStatut($product_static->status_buy, 5, 1); + } + print ''; + 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++; } From 6983ef95846949955b5591ca918de5b353cab546 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Mon, 16 Jan 2023 15:53:57 +0100 Subject: [PATCH 06/22] Update product.class.php fix style error --- htdocs/product/class/product.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 96e3ac7c7f5..b0882e95632 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6291,7 +6291,6 @@ class Product extends CommonObject $return .= '
'; $return .= '
'; $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; @@ -6303,7 +6302,6 @@ class Product extends CommonObject } $return .= $label; } - $return .= '
'; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; From 84436e1217327fac1e27c395613d41c8abf75ce7 Mon Sep 17 00:00:00 2001 From: hystepik Date: Thu, 19 Jan 2023 15:31:47 +0100 Subject: [PATCH 07/22] Fix : php 8.1 warnings and dolibarr log --- htdocs/barcode/printsheet.php | 2 +- htdocs/comm/action/index.php | 2 +- htdocs/comm/mailing/cibles.php | 2 +- htdocs/comm/mailing/index.php | 4 ++-- htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php | 4 ++-- htdocs/hrm/class/position.class.php | 4 ++-- htdocs/modulebuilder/index.php | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 373effecbe8..56361b948f0 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -226,7 +226,7 @@ if ($action == 'builddoc') { 'code'=>$code, 'encoding'=>$encoding, 'is2d'=>$is2d, - 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF + 'photo'=>!empty($barcodeimage) ? $barcodeimage : '' // Photo must be a file that exists with format supported by TCPDF ); } } else { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e730243bfbf..9d84e205f2b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -2048,7 +2048,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } } if (!empty($contact_id) && $contact_id > 0) { - if (!is_object($cachecontacts[$contact_id])) { + if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) { $contact = new Contact($db); $contact->fetch($contact_id); $cachecontacts[$contact_id] = $contact; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index dde6e3204d6..c39e4fbf834 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -675,7 +675,7 @@ if ($object->fetch($id) >= 0) { // Date last update print ''; - print dol_print_date($obj->tms, 'dayhour'); + print dol_print_date(dol_stringtotime($obj->tms), 'dayhour'); print ''; // Status of recipient sending email (Warning != status of emailing) diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index d3ebc379b55..cf3d18adbac 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -101,7 +101,7 @@ if (is_resource($handle)) { $qualified = 1; foreach ($mailmodule->require_module as $key) { - if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) { + if (empty($conf->$key->enabled) || (!$user->admin && $mailmodule->require_admin)) { $qualified = 0; //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; break; @@ -176,7 +176,7 @@ if ($result) { print ''; print ''.$mailstatic->getNomUrl(1).''; - print ''.dol_trunc($obj->title, 38).''; + print ''.(!empty($obj->title) ? dol_trunc($obj->title, 38) : '').''; print ''.dol_print_date($db->jdate($obj->date_creat), 'day').''; print ''.($obj->nbemail ? $obj->nbemail : "0").''; print ''.$mailstatic->LibStatut($obj->statut, 5).''; diff --git a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php index b75d0752334..5a6dbbedd37 100644 --- a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php +++ b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php @@ -120,7 +120,7 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes while ($i < $num) { $objp = $this->db->fetch_object($resql); while ($minimumdatecformated < $objp->datec) { - $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); + $dataseries[] = array('label' => dol_print_date($minimumdatec, 'day'), 'data' => 0); $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); } @@ -130,7 +130,7 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes $i++; } while (count($dataseries) < $days) { - $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); + $dataseries[] = array('label' => dol_print_date($minimumdatec, 'day'), 'data' => 0); $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); $i++; diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index b685147a9b9..caf2ff00b03 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -395,10 +395,10 @@ class Position extends CommonObject foreach ($filter as $key => $value) { if ($key == 't.rowid') { $sqlwhere[] = $key . '=' . $value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key . ' = \'' . $this->db->idate($value) . '\''; } elseif ($key == 'customsql') { $sqlwhere[] = $value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key . ' = \'' . $this->db->idate($value) . '\''; } elseif (strpos($value, '%') === false) { $sqlwhere[] = $key . ' IN (' . $this->db->sanitize($this->db->escape($value)) . ')'; } else { diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b8810a2696d..0d2137928ac 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3739,7 +3739,7 @@ if ($module == 'initmodule') { print ''; print ''; - print dol_escape_htmltag($menu['leftmenu']); + print !empty($menu['leftmenu']) ? dol_escape_htmltag($menu['leftmenu']) : ''; print ''; print ''; From 62d0b7b97299964cf85c5cd44c78eded7f92787a Mon Sep 17 00:00:00 2001 From: "T. Mulzer" Date: Thu, 19 Jan 2023 17:10:50 +0100 Subject: [PATCH 08/22] Update get_attribute_values.php --- htdocs/variants/ajax/get_attribute_values.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index 1867eb368de..3950a262500 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -83,4 +83,4 @@ if ($res == -1) { exit(); } -print json_encode($res); +print json_encode($res, JSON_PARTIAL_OUTPUT_ON_ERROR); From d8dcb0d1012278aea36f05f29cd4dde52a1714db Mon Sep 17 00:00:00 2001 From: "T. Mulzer" Date: Thu, 19 Jan 2023 17:13:25 +0100 Subject: [PATCH 09/22] Solves issue #17181 --- htdocs/variants/combinations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 5128f31d0c5..e5043dcd7fa 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -511,7 +511,7 @@ if (!empty($id) || !empty($ref)) {