From 6e6a62d167d4ac9d48b937c0b6e98c3dbca7438e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 7 Sep 2022 14:58:07 +0200 Subject: [PATCH 001/111] 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 002/111] 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 003/111] 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 638b7bc6534d9eb1eedc9eb827a99defbb5b3a1b Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 22 Nov 2022 17:02:12 +0100 Subject: [PATCH 004/111] fix(scrutinizer) https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/core/boxes/box_services_contracts.php?selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=10&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/core/boxes/box_services_contracts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 3d1e640f34b..acc1d40eed5 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -124,7 +124,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->label = $objp->label; $contractlinestatic->description = $objp->description; $contractlinestatic->type = $objp->type; - $contractlinestatic->product_id = $objp->product_id; + $contractlinestatic->fk_productyy = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; $contractlinestatic->product_type = $objp->product_type; $contractlinestatic->statut = $objp->contractline_status; From 8426e955c8f221817653f9cc498db8eb60a7c713 Mon Sep 17 00:00:00 2001 From: Jesse Rovira Date: Fri, 2 Dec 2022 12:34:13 -0300 Subject: [PATCH 005/111] Showing Due date into last customer invoice at comm card --- htdocs/comm/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index f578aa75cf5..0df573b7f9b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1418,7 +1418,7 @@ if ($object->id > 0) { $sql .= ', f.total_tva'; $sql .= ', f.total_ttc'; $sql .= ', f.entity'; - $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status'; + $sql .= ', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status'; $sql .= ', s.nom, s.rowid as socid'; $sql .= ', SUM(pf.amount) as am'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; @@ -1496,6 +1496,11 @@ if ($object->id > 0) { } else { print '!!!'; } + if ($objp->dl > 0) { + print ''.dol_print_date($db->jdate($objp->dl), 'day').''; + } else { + print '!!!'; + } print ''; print price($objp->total_ht); print ''; From f98381de8a45047a182d10df72c1509575f2a915 Mon Sep 17 00:00:00 2001 From: Jesse Rovira Date: Fri, 2 Dec 2022 13:36:17 -0300 Subject: [PATCH 006/111] Showing label for Due date into last customer invoice at comm card --- htdocs/comm/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 0df573b7f9b..345a97e9e19 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1492,12 +1492,12 @@ if ($object->id > 0) { //print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print ''; if ($objp->df > 0) { - print ''.dol_print_date($db->jdate($objp->df), 'day').''; + print ''.$langs->trans('DateInvoice').": ".dol_print_date($db->jdate($objp->df), 'day').''; } else { print '!!!'; } if ($objp->dl > 0) { - print ''.dol_print_date($db->jdate($objp->dl), 'day').''; + print ''.$langs->trans('DateMaxPayment').": ".dol_print_date($db->jdate($objp->dl), 'day').''; } else { print '!!!'; } From 19e3a8949a0476647849c18e4aeae45785ce6e73 Mon Sep 17 00:00:00 2001 From: FLIO Date: Mon, 5 Dec 2022 10:51:09 +0100 Subject: [PATCH 007/111] Fix(scrutinizer) --- htdocs/core/boxes/box_services_contracts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index acc1d40eed5..433db55a515 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -124,7 +124,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->label = $objp->label; $contractlinestatic->description = $objp->description; $contractlinestatic->type = $objp->type; - $contractlinestatic->fk_productyy = $objp->product_id; + $contractlinestatic->fk_product = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; $contractlinestatic->product_type = $objp->product_type; $contractlinestatic->statut = $objp->contractline_status; From 1c108f3583c76c00fd243f918d2fc84643b251fb Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 6 Dec 2022 16:11:14 +0100 Subject: [PATCH 008/111] 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 471260738ab41260459150b7ad3ccefbb9af4574 Mon Sep 17 00:00:00 2001 From: IC-Florian <71641704+IC-Florian@users.noreply.github.com> Date: Wed, 21 Dec 2022 12:03:32 +0100 Subject: [PATCH 009/111] FIX : Product list in setup.php in new Module --- htdocs/modulebuilder/template/admin/setup.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 1c46028b142..37fa410f1e7 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -55,6 +55,7 @@ global $langs, $user; // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; //require_once "../class/myclass.class.php"; // Translations From 20cd8348394af379df498ee23fa0391176745322 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 10:15:21 +0000 Subject: [PATCH 010/111] 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 2a68836375fd0cdb9f1b03068fcfdfac0f61711b Mon Sep 17 00:00:00 2001 From: IC-Florian <71641704+IC-Florian@users.noreply.github.com> Date: Thu, 22 Dec 2022 14:52:03 +0100 Subject: [PATCH 011/111] New require for product in generateOutputField --- htdocs/core/class/html.formsetup.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 1cfddb588fd..4f88c597178 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1103,6 +1103,9 @@ class FormSetupItem $out.= $this->langs->trans("NorProspectNorCustomer"); } } elseif ($this->type == 'product') { + if (!class_exists("Product")){ + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + } $product = new Product($this->db); $resprod = $product->fetch($this->fieldValue); if ($resprod > 0) { From 56d05c09b2fd02450831083af0ec5ca560478378 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 13:52:39 +0000 Subject: [PATCH 012/111] Fixing style errors. --- htdocs/core/class/html.formsetup.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 4f88c597178..611455f003f 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1103,9 +1103,9 @@ class FormSetupItem $out.= $this->langs->trans("NorProspectNorCustomer"); } } elseif ($this->type == 'product') { - if (!class_exists("Product")){ - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - } + if (!class_exists("Product")) { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + } $product = new Product($this->db); $resprod = $product->fetch($this->fieldValue); if ($resprod > 0) { From ffae98085bcaa3b54e9d3439bff7e4ab71506fab Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 26 Dec 2022 22:36:05 +0100 Subject: [PATCH 013/111] New box box_members_by_tags.php --- htdocs/adherents/class/adherent.class.php | 2 +- .../adherents/class/adherentstats.class.php | 78 +++++ htdocs/core/boxes/box_members_by_tags.php | 279 ++++++++++++++++++ htdocs/core/boxes/modules_boxes.php | 1 + htdocs/langs/en_US/boxes.lang | 1 + 5 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 htdocs/core/boxes/box_members_by_tags.php diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6aaac503060..15df4f7225d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -3203,4 +3203,4 @@ class Adherent extends CommonObject return $nbko; } -} +} \ No newline at end of file diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9aa2fe2e8ad..ed86cae8704 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -181,4 +181,82 @@ class AdherentStats extends Stats return $this->_getAllByYear($sql); } + + + + /** + * Return count of member by status group by adh type, total and average + * + * @param int $numberYears Years to scan + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + */ + public function countMembersByTagAndStatus($tag_id, $numberYears = 2) + { + global $user; + + $now = dol_now(); + $endYear = date('Y'); + $startYear = $endYear - $numberYears; + + $sql = "SELECT c.rowid as fk_categorie, c.label as label"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')", "'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)", "'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)", "'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED, "'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as ct ON c.rowid = ct.fk_categorie"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON d.rowid = ct.fk_member"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as t ON t.rowid = d.fk_adherent_type"; + $sql .= " WHERE c.entity IN (".getEntity('member_type').")"; + $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND t.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.datefin > '".$this->db->idate(dol_get_first_day($startYear))."'"; + $sql .= " AND c.fk_parent = 0"; + $sql .= " GROUP BY c.rowid"; + + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $MembersCountArray = []; + $totalstatus = array( + 'label' => 'Total', + 'members_draft' => 0, + 'members_pending' => 0, + 'members_uptodate' => 0, + 'members_expired' => 0, + 'members_excluded' => 0, + 'members_resiliated' => 0 + ); + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $MembersCountArray[$objp->fk_categorie] = array( + 'label' => $objp->label, + 'members_draft' => (int) $objp->members_draft, + 'members_pending' => (int) $objp->members_pending, + 'members_uptodate' => (int) $objp->members_uptodate, + 'members_expired' => (int) $objp->members_expired, + 'members_excluded' => (int) $objp->members_excluded, + 'members_resiliated' => (int) $objp->members_resiliated + ); + $totalrow = 0; + foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) { + if ($key!='label') { + $totalrow += $nb; + $totalstatus[$key] += $nb; + } + } + $MembersCountArray[$objp->fk_categorie]['total_adhtype'] = $totalrow; + $i++; + } + $this->db->free($result); + $MembersCountArray['total'] = $totalstatus; + $MembersCountArray['total']['all'] = array_sum($totalstatus); + } + return $MembersCountArray; + } } diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php new file mode 100644 index 00000000000..cd7a499c867 --- /dev/null +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -0,0 +1,279 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2021-2022 Waël Almoman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_members_by_tags.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_members_by_tags extends ModeleBoxes +{ + public $boxcode = "box_members_by_tags"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMembersByTags"; + public $depends = array("adherent", "categorie"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + $staticmember = new Adherent($this->db); + + $year = date('Y'); + $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByTags").' ('.$year-$numberyears.' - '.$year.')'); + + if ($user->rights->adherent->lire) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $stats = new AdherentStats($this->db, $user->socid, $user->id); + + // Show array + $sumMembers= $stats->countMembersByTagAndStatus($tag_id, $numberyears); + echo "
";print_r($sumMembers);echo "
"; + if ($sumMembers) { + $line = 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class=""', + 'text' => '', + ); + // Members Status To Valid + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Waiting for subscription + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus, + ); + // Up to date + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus, + ); + // Expired + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Excluded + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Resiliated + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Total row + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($langs->trans("Total")).'"', + 'text' => $langs->trans("Total") + ); + $line++; + foreach ($sumMembers as $key => $data) { + $adhtype = new AdherentType($this->db); + $adhtype->id = $key; + + if ($key=='total') { + break; + } + $adhtype->label = $data['label']; + $AdherentType[$key] = $adhtype; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $adhtype->getNomUrl(1, dol_size(32)), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_draft']) && $data['members_draft'] > 0 ? $data['members_draft'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_uptodate']) && $data['members_uptodate'] > 0 ? $data['members_uptodate'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_expired']) && $data['members_expired'] > 0 ? $data['members_expired'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_excluded']) && $data['members_excluded'] > 0 ? $data['members_excluded'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_resiliated']) && $data['members_resiliated'] > 0 ? $data['members_resiliated'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['total_adhtype']) && $data['total_adhtype'] > 0 ? $data['total_adhtype'] : ''), + 'asis' => 1, + ); + $line++; + } + + if (count($sumMembers) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center" colspan="6"', + 'text' => $langs->trans("NoRecordedMembersByType") + ); + } else { + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total"', + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total") + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_draft'].' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_uptodate'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_expired'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_excluded'].' '.$staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_resiliated'].' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['all'], + 'asis' => 1 + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error() . ' sql=' . $sql) + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 1a29c8e1389..54ad02c0f3b 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -464,6 +464,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box closedir($handle); } } + echo "
";print_r($modules);echo "
"; asort($orders); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 0ac1ecce545..9e80e36b119 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -24,6 +24,7 @@ BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleMemberNextBirthdays=Birthdays of this month (members) BoxTitleMembersByType=Members by type and status +BoxTitleMembersByTags=Members by tags and status BoxTitleMembersSubscriptionsByYear=Members Subscriptions by year BoxTitleLastRssInfos=Latest %s news from %s BoxTitleLastProducts=Products/Services: last %s modified From 5b40a4a21097b2550063c228e0d020b7ffd63752 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 26 Dec 2022 21:37:33 +0000 Subject: [PATCH 014/111] Fixing style errors. --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 15df4f7225d..6aaac503060 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -3203,4 +3203,4 @@ class Adherent extends CommonObject return $nbko; } -} \ No newline at end of file +} From 5d09076a8faad01b77446ceb03d7ddcfd9f6bbe0 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 26 Dec 2022 22:56:26 +0100 Subject: [PATCH 015/111] Doc --- htdocs/adherents/class/adherentstats.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index ed86cae8704..20d66130362 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -187,10 +187,10 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Years to scan - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @param int $numberYears Years to scan + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag */ - public function countMembersByTagAndStatus($tag_id, $numberYears = 2) + public function countMembersByTagAndStatus($numberYears = 2) { global $user; From 7a15e61849fd66edb0b1a33de6f34b2d1b5f201a Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 26 Dec 2022 22:59:39 +0100 Subject: [PATCH 016/111] Clean code --- htdocs/core/boxes/box_members_by_tags.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index cd7a499c867..196cec30738 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -98,8 +98,7 @@ class box_members_by_tags extends ModeleBoxes $stats = new AdherentStats($this->db, $user->socid, $user->id); // Show array - $sumMembers= $stats->countMembersByTagAndStatus($tag_id, $numberyears); - echo "
";print_r($sumMembers);echo "
"; + $sumMembers= $stats->countMembersByTagAndStatus($numberyears); if ($sumMembers) { $line = 0; $this->info_box_contents[$line][] = array( From 39cf086ace24ffd79ef4072dc2022caa28df7d54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Dec 2022 18:20:52 +0100 Subject: [PATCH 017/111] Update modules_boxes.php --- htdocs/core/boxes/modules_boxes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 54ad02c0f3b..96928adfdff 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -464,7 +464,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box closedir($handle); } } - echo "
";print_r($modules);echo "
"; + //echo "
";print_r($modules);echo "
"; asort($orders); From 596cb4caa6e987fe6642c2623a3ea340d44d345a Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 30 Dec 2022 18:16:42 +0100 Subject: [PATCH 018/111] Add box_members_by_tags.php in modAdherent.class.php --- htdocs/core/modules/modAdherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 2422cead7bb..0df5284eaed 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -198,6 +198,7 @@ class modAdherent extends DolibarrModules 4 => array('file'=>'box_members_last_subscriptions.php', 'enabledbydefaulton'=>'membersindex'), 5 => array('file'=>'box_members_subscriptions_by_year.php', 'enabledbydefaulton'=>'membersindex'), 6 => array('file'=>'box_members_by_type.php', 'enabledbydefaulton'=>'membersindex'), + 7 => array('file'=>'box_members_by_tags.php', 'enabledbydefaulton'=>'membersindex'), ); // Permissions From 303220a88f90501ae466a88fda10938315e67cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Wed, 11 Jan 2023 22:51:17 +0100 Subject: [PATCH 019/111] ajout d'un hook pour ajouter des landingpage dans la liste de user_ihm --- htdocs/user/param_ihm.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 3d2e3240ce3..1bd806849b6 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -215,6 +215,14 @@ if (isModEnabled('ticket')) { $tmparray['ticket/list.php?mainmenu=ticket&leftmenu='] = 'Tickets'; } +// Hook for insertion new items in the List of possible landing pages +$reshook = $hookmanager->executeHooks('addToLandingPageList',$tmparray,$object); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} else if ($reshook == 0) { + $tmparray=$hookmanager->resArray; +} + $head = user_prepare_head($object); $title = $langs->trans("User"); From 74a5c91a48238b505dac86fbfe204ce6dc8bdc38 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 11 Jan 2023 21:59:55 +0000 Subject: [PATCH 020/111] Fixing style errors. --- htdocs/user/param_ihm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 1bd806849b6..81ecdca8e73 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -216,10 +216,10 @@ if (isModEnabled('ticket')) { } // Hook for insertion new items in the List of possible landing pages -$reshook = $hookmanager->executeHooks('addToLandingPageList',$tmparray,$object); +$reshook = $hookmanager->executeHooks('addToLandingPageList', $tmparray, $object); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} else if ($reshook == 0) { +} elseif ($reshook == 0) { $tmparray=$hookmanager->resArray; } From 468b8bcab38e0b0ec6bc5f8226bc0758c776c405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Thu, 12 Jan 2023 19:26:55 +0100 Subject: [PATCH 021/111] correction bug si pas reponse sur le hook --- htdocs/user/param_ihm.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 81ecdca8e73..2f8f4ae24ad 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -216,11 +216,13 @@ if (isModEnabled('ticket')) { } // Hook for insertion new items in the List of possible landing pages -$reshook = $hookmanager->executeHooks('addToLandingPageList', $tmparray, $object); -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} elseif ($reshook == 0) { - $tmparray=$hookmanager->resArray; +$reshook = $hookmanager->executeHooks('addToLandingPageList',$tmparray,$object); +if (!empty($reshook)) { + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } else if ($reshook == 0) { + $tmparray=$hookmanager->resArray; + } } $head = user_prepare_head($object); From c8055715447465066a6a2855fb0958d08d0b8277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Thu, 12 Jan 2023 19:35:49 +0100 Subject: [PATCH 022/111] correction bug si pas reponse sur le hook --- htdocs/user/param_ihm.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 2f8f4ae24ad..4ee2c318f5e 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -217,14 +217,15 @@ if (isModEnabled('ticket')) { // Hook for insertion new items in the List of possible landing pages $reshook = $hookmanager->executeHooks('addToLandingPageList',$tmparray,$object); -if (!empty($reshook)) { - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } else if ($reshook == 0) { +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} else if ($reshook === 0) { + if (count($hookmanager->resArray)!==0) { $tmparray=$hookmanager->resArray; } } + $head = user_prepare_head($object); $title = $langs->trans("User"); From 2f80f873eae389a27dd9851b02b1fdeebf8ae624 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 12 Jan 2023 18:36:33 +0000 Subject: [PATCH 023/111] Fixing style errors. --- htdocs/user/param_ihm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 4ee2c318f5e..da8eebacaac 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -216,10 +216,10 @@ if (isModEnabled('ticket')) { } // Hook for insertion new items in the List of possible landing pages -$reshook = $hookmanager->executeHooks('addToLandingPageList',$tmparray,$object); +$reshook = $hookmanager->executeHooks('addToLandingPageList', $tmparray, $object); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} else if ($reshook === 0) { +} elseif ($reshook === 0) { if (count($hookmanager->resArray)!==0) { $tmparray=$hookmanager->resArray; } From a5fba0fd09db765f91d11f00e07a01a2dbb70f94 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 12:10:22 +0100 Subject: [PATCH 024/111] kanban for position list --- htdocs/hrm/class/position.class.php | 35 +++++++++++++++++++++++++++++ htdocs/hrm/position_list.php | 18 +++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 98b5fd89be9..9d4f71d24fd 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1118,6 +1118,41 @@ class Position extends CommonObject return $error; } + + /** + * 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 $selected, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; + if (property_exists($this, 'fk_user') && !(empty($this->fk_user))) { + $return .= '
'.$langs->trans("Employee").' : '; + $return .= ''.$this->fk_user.''; + } + if (property_exists($this, 'fk_job') && !(empty($this->fk_job))) { + $return .= '
'.$langs->trans("Job").' : '; + $return .= ''.$this->fk_job.''; + } + if (property_exists($this, 'date_start') && property_exists($this, 'date_end')) { + $return .= '
'.dol_print_date($this->db->jdate($this->date_start), 'day').''; + $return .= ' - '.dol_print_date($this->db->jdate($this->date_end), 'day').'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 40cb706b5df..5dc33859219 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -426,7 +426,10 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1).'?action=create', '', $permissiontoadd); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1).'?action=create', '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -602,12 +605,23 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + if ($mode == 'kanban') { if ($i == 0) { print ''; print '
'; } - // Output Kanban + // get info needed + + $object->date_start = $obj->date_start; + $object->date_end = $obj->date_end; + $job = new job($db); + $job->fetch($obj->fk_job); + $object->fk_job = $job->getNomUrl(); + $userstatic = new User($db); + $userstatic->fetch($obj->fk_user); + $object->fk_user = $userstatic->getNomUrl(1); + // output kanban print $object->getKanbanView(''); if ($i == ($imaxinloop - 1)) { print '
'; From a42c879ac5589381ab83bcfcb14a54c67d9d4282 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 12:25:44 +0100 Subject: [PATCH 025/111] modify colspan --- htdocs/hrm/position_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 5dc33859219..201be040d20 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -608,7 +608,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { - print ''; + print ''; print '
'; } // get info needed From 19b77e3dcda2e862afe82cc2a7b13eac97bf9b58 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 12:33:25 +0100 Subject: [PATCH 026/111] modify checkbox action --- htdocs/hrm/position_list.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 201be040d20..7a6f7fcc417 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -622,7 +622,13 @@ while ($i < $imaxinloop) { $userstatic->fetch($obj->fk_user); $object->fk_user = $userstatic->getNomUrl(1); // output kanban - print $object->getKanbanView(''); + 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($object->id, $arrayofselected)) { + $selected = 1; + } + print $object->getKanbanView(''); + } if ($i == ($imaxinloop - 1)) { print '
'; print ''; From 0ee90877aa0f20caeefe92614d474f6fc34d4f2e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 14:17:49 +0100 Subject: [PATCH 027/111] modify style for checkbox --- htdocs/hrm/class/position.class.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 9d4f71d24fd..2f4a127999a 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1135,7 +1135,7 @@ class Position extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'fk_user') && !(empty($this->fk_user))) { $return .= '
'.$langs->trans("Employee").' : '; $return .= ''.$this->fk_user.''; diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index f35516ad58e..9c1f3b443ef 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -491,7 +491,10 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { min-width: 350px; max-width: 350px; } - +/**for make a checkbox in the right of the box in mode kanban */ +.fright { + float:right; +} @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; From 313608b6273d4e4134c2561a05f147f791e9f110 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 14:19:14 +0100 Subject: [PATCH 028/111] modify style for checkbox --- htdocs/hrm/class/job.class.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index a013bb57a36..85845e557ab 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -1071,7 +1071,7 @@ class Job extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'deplacement')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['deplacement']['arrayofkeyval'][$this->deplacement].''; diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index f35516ad58e..f13bd8c6c26 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -492,6 +492,10 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { max-width: 350px; } +/**for make a checkbox in the right of the box in mode kanban */ +.fright { + float:right; +} @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; From 317b49917aa7192abc9ae375f807e96731f95292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Fri, 13 Jan 2023 23:06:44 +0100 Subject: [PATCH 029/111] correctif hook --- htdocs/user/param_ihm.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index da8eebacaac..136da34e1bd 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -219,13 +219,12 @@ if (isModEnabled('ticket')) { $reshook = $hookmanager->executeHooks('addToLandingPageList', $tmparray, $object); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} elseif ($reshook === 0) { - if (count($hookmanager->resArray)!==0) { - $tmparray=$hookmanager->resArray; - } +} elseif ($reshook > 0) { + $tmparray=$hookmanager->resArray; +} elseif ($reshook == 0) { + $tmparray=array_merge($tmparray, $hookmanager->resArray); } - $head = user_prepare_head($object); $title = $langs->trans("User"); From 20633aa7747bfb38aa508839515585e19c9b3025 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 16 Jan 2023 15:03:01 +0100 Subject: [PATCH 030/111] fix checkbox by mergin two class --- htdocs/hrm/class/job.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 85845e557ab..fdeebe484eb 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -1071,7 +1071,7 @@ class Job extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'deplacement')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['deplacement']['arrayofkeyval'][$this->deplacement].''; From 6983ef95846949955b5591ca918de5b353cab546 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Mon, 16 Jan 2023 15:53:57 +0100 Subject: [PATCH 031/111] 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 690646b7da0d151a1662f7333a9b462cfb915e3c Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 16 Jan 2023 16:12:27 +0100 Subject: [PATCH 032/111] fix errors in info-box.css --- htdocs/theme/eldy/info-box.inc.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 5c010e21e26..99e8e5e2ca1 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -491,12 +491,9 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { min-width: 350px; max-width: 350px; } - -/**for make a checkbox in the right of the box in mode kanban */ .fright { float:right; } - @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; From 957e8538a4b7768a60d7495331eaad3d33d31b49 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Tue, 17 Jan 2023 11:36:03 +0100 Subject: [PATCH 033/111] FIX - Order list det sortfield default --- htdocs/commande/list_det.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index fd36f229e5c..c05ff36e9d2 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -137,10 +137,10 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) { - $sortfield = 'c.ref'; + $sortfield = 'pr.ref'; } if (!$sortorder) { - $sortorder = 'DESC'; + $sortorder = 'ASSC'; } $show_shippable_command = GETPOST('show_shippable_command', 'aZ09'); From 947365fabfabd96a198952de5acfa24dfe5bf99d Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+BB2A-Anthony@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:48:37 +0100 Subject: [PATCH 034/111] Update list_det.php --- htdocs/commande/list_det.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index c05ff36e9d2..48d21abf4a3 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -140,7 +140,7 @@ if (!$sortfield) { $sortfield = 'pr.ref'; } if (!$sortorder) { - $sortorder = 'ASSC'; + $sortorder = 'ASC'; } $show_shippable_command = GETPOST('show_shippable_command', 'aZ09'); From 1d50acb3cfdc083bc142d00d65c3f21808881143 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 18 Jan 2023 12:10:58 +0100 Subject: [PATCH 035/111] Fix fieldvalue emailtemplate --- htdocs/core/class/html.formsetup.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 1cfddb588fd..0c9adf0be59 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1069,16 +1069,18 @@ class FormSetupItem } elseif ($this->type == 'yesno') { $out.= ajax_constantonoff($this->confKey); } elseif (preg_match('/emailtemplate:/', $this->type)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($this->db); + if ($this->fieldValue > 0){ + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); - $tmp = explode(':', $this->type); + $tmp = explode(':', $this->type); - $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); - if ($template<0) { - $this->setErrors($formmail->errors); + $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); + if ($template<0) { + $this->setErrors($formmail->errors); + } + $out.= $this->langs->trans($template->label); } - $out.= $this->langs->trans($template->label); } elseif (preg_match('/category:/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); From c8d0226613ef1f09e2e17a69d3406178d5f6ebae Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 19 Jan 2023 11:24:53 +0100 Subject: [PATCH 036/111] Harmonize CSS for tables in fichehalfleft/fichehalfright --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 43dfbf67869..1592fed7493 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3549,7 +3549,7 @@ td.border, div.tagtable div div.border { } -.fichehalfright table.noborder { +.fichehalfright table.noborder , .fichehalfleft table.noborder{ margin: 0px 0px 0px 0px; } table.liste, table.noborder, table.formdoc, div.noborder { From 84436e1217327fac1e27c395613d41c8abf75ce7 Mon Sep 17 00:00:00 2001 From: hystepik Date: Thu, 19 Jan 2023 15:31:47 +0100 Subject: [PATCH 037/111] 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 9a40c966bd7d4cb67b8f16fbbb97b01d345034b0 Mon Sep 17 00:00:00 2001 From: piernov Date: Thu, 19 Jan 2023 16:25:59 +0100 Subject: [PATCH 038/111] Fix: don setPaid sets paid field When donation is classified as paid, paid field also needs to be set to 1 so that accounting reports show the correct information. --- htdocs/don/class/don.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 181b3fc0ca3..3b09e8cc178 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -758,7 +758,7 @@ class Don extends CommonObject */ public function setPaid($id, $modepayment = 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2, paid = 1"; if ($modepayment) { $sql .= ", fk_payment = ".((int) $modepayment); } @@ -768,6 +768,7 @@ class Don extends CommonObject if ($resql) { if ($this->db->affected_rows($resql)) { $this->statut = 2; + $this->paid = 1; return 1; } else { return 0; From 62d0b7b97299964cf85c5cd44c78eded7f92787a Mon Sep 17 00:00:00 2001 From: "T. Mulzer" Date: Thu, 19 Jan 2023 17:10:50 +0100 Subject: [PATCH 039/111] 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 040/111] 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)) {