From 3b2d3dc6a6c67b50dfbd8f8481769aa113051d1f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 09:44:38 +0100 Subject: [PATCH 1/6] NEW : batch referential objets --- htdocs/core/lib/product.lib.php | 130 ++++++ htdocs/product/stats/mo.php | 28 ++ .../product/stock/class/productlot.class.php | 283 +++++++++++++ .../stock/stats/commande_fournisseur.php | 375 ++++++++++++++++++ htdocs/product/stock/stats/expedition.php | 369 +++++++++++++++++ htdocs/product/stock/stats/mo.php | 302 ++++++++++++++ htdocs/product/stock/stats/reception.php | 368 +++++++++++++++++ 7 files changed, 1855 insertions(+) create mode 100644 htdocs/product/stock/stats/commande_fournisseur.php create mode 100644 htdocs/product/stock/stats/expedition.php create mode 100644 htdocs/product/stock/stats/mo.php create mode 100644 htdocs/product/stock/stats/reception.php diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e919bf2c8b6..4898ff96cc2 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -253,6 +253,11 @@ function productlot_prepare_head($object) $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT."/product/stock/stats/expedition.php?showmessage=1&id=".$object->id; + $head[$h][1] = $langs->trans('Referers'); + $head[$h][2] = 'referers'; + $h++; + // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; @@ -648,6 +653,131 @@ function show_stats_for_company($product, $socid) return $nblines++; } +/** + * Show stats for company + * + * @param Product $product Product object + * @param int $socid Thirdparty id + * @return integer NB of lines shown into array + */ +function show_stats_for_batch($batch, $socid) +{ + global $conf, $langs, $user, $db, $hookmanager; + + $langs->LoadLangs(array('sendings', 'orders', 'receptions')); + + $form = new Form($db); + + $nblines = 0; + + print ''; + print ''.$langs->trans("Referers").''; + print ''.$langs->trans("NbOfThirdParties").''; + print ''.$langs->trans("NbOfObjectReferers").''; + print ''.$langs->trans("TotalQuantity").''; + print ''; + + // Expeditions + if (isModEnabled('expedition') && !empty($user->rights->expedition->lire)) { + $nblines++; + $ret = $batch->load_stats_expedition($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("bills"); + print ''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("Shipments").''; + print ''; + print $batch->stats_expedition['customers']; + print ''; + print $batch->stats_expedition['nb']; + print ''; + print $batch->stats_expedition['qty']; + print ''; + print ''; + } + + if(isModEnabled("reception") && !empty($user->rights->reception->lire)) { + + $nblines++; + $ret = $batch->load_stats_reception($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("bills"); + print ''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("Receptions").''; + print ''; + print $batch->stats_reception['customers']; + print ''; + print $batch->stats_reception['nb']; + print ''; + print $batch->stats_reception['qty']; + print ''; + print ''; + + } elseif(isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { + + $nblines++; + $ret = $batch->load_stats_supplier_order($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("bills"); + print ''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("SuppliersOrders").''; + print ''; + print $batch->stats_supplier_order['customers']; + print ''; + print $batch->stats_supplier_order['nb']; + print ''; + print $batch->stats_supplier_order['qty']; + print ''; + print ''; + + } + + if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { + $nblines++; + $ret = $batch->load_stats_mo($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("mrp"); + print ''; + print ''.img_object('', 'mrp', 'class="pictofixedwidth"').$langs->trans("MO").''; + print ''; +// print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); +// print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['customers_produced'], $langs->trans("QtyAlreadyProduced")); + print ''; +// print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed")); +// print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['nb_produced'], $langs->trans("QtyAlreadyProduced")); + print ''; +// print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed")); +// print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced")); + print ''; + print ''; + } + + $parameters = array('socid'=>$socid); + $reshook = $hookmanager->executeHooks('addMoreBatchProductStat', $parameters, $batch, $nblines); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + print $hookmanager->resPrint; + + + return $nblines++; + +} + /** * Return translation label of a unit key. * Function kept for backward compatibility. diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 085a6687f5c..3127f9e83a6 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('mrp', 'products', 'companies')); @@ -63,6 +64,14 @@ if (!$sortfield) { $sortfield = "c.date_valid"; } +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -74,6 +83,7 @@ $staticmo = new Mo($db); $staticmoligne = new MoLine($db); $form = new Form($db); +$formother = new FormOther($db); if ($id > 0 || !empty($ref)) { $product = new Product($db); @@ -139,6 +149,12 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE c.rowid = cd.fk_mo"; $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.fk_product = ".((int) $product->id); + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + } if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } @@ -190,6 +206,18 @@ if ($id > 0 || !empty($ref)) { $option .= '&page='.urlencode($page); } + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + $i = 0; print '
'; print ''; diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 6fe855543c9..c20f224a584 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -554,6 +554,289 @@ class Productlot extends CommonObject } } + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_expedition($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,"; + $sql .= " COUNT(ed.rowid) as nb_rows, SUM(edb.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; + $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; + $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; +// $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE exp.entity IN (".getEntity('expedition').")"; + $sql .= " AND edb.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND exp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND exp.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND exp.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_expedition['customers'] = $obj->nb_customers; + $this->stats_expedition['nb'] = $obj->nb; + $this->stats_expedition['rows'] = $obj->nb_rows; + $this->stats_expedition['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension +// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { +// $TFather = $this->getFather(); +// if (is_array($TFather) && !empty($TFather)) { +// foreach ($TFather as &$fatherData) { +// $pFather = new Product($this->db); +// $pFather->id = $fatherData['id']; +// $qtyCoef = $fatherData['qty']; +// +// if ($fatherData['incdec']) { +// $pFather->load_stats_expedition($socid); +// +// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; +// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; +// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; +// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; +// } +// } +// } +// } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats commande fournisseur pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_supplier_order($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; + $sql .= " COUNT(cfd.rowid) as nb_rows, SUM(cfdi.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; + $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; +// $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE cf.entity IN (".getEntity('expedition').")"; + $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND cf.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND cf.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_supplier_order['customers'] = $obj->nb_customers; + $this->stats_supplier_order['nb'] = $obj->nb; + $this->stats_supplier_order['rows'] = $obj->nb_rows; + $this->stats_supplier_order['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension +// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { +// $TFather = $this->getFather(); +// if (is_array($TFather) && !empty($TFather)) { +// foreach ($TFather as &$fatherData) { +// $pFather = new Product($this->db); +// $pFather->id = $fatherData['id']; +// $qtyCoef = $fatherData['qty']; +// +// if ($fatherData['incdec']) { +// $pFather->stats_supplier_order($socid); +// +// $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; +// $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; +// $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; +// $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; +// } +// } +// } +// } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_supplier_order = $hookmanager->resArray['stats_supplier_order']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_reception($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,"; + $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; +// $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE recep.entity IN (".getEntity('reception').")"; + $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND recep.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND exp.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND recep.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_reception['customers'] = $obj->nb_customers; + $this->stats_reception['nb'] = $obj->nb; + $this->stats_reception['rows'] = $obj->nb_rows; + $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension +// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { +// $TFather = $this->getFather(); +// if (is_array($TFather) && !empty($TFather)) { +// foreach ($TFather as &$fatherData) { +// $pFather = new Product($this->db); +// $pFather->id = $fatherData['id']; +// $qtyCoef = $fatherData['qty']; +// +// if ($fatherData['incdec']) { +// $pFather->load_stats_expedition($socid); +// +// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; +// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; +// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; +// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; +// } +// } +// } +// } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_mo($socid = 0) + { + // phpcs:enable + global $user, $hookmanager, $action; + + $error = 0; + + foreach (array('toconsume', 'consumed', 'toproduce', 'produced') as $role) { + $this->stats_mo['customers_'.$role] = 0; + $this->stats_mo['nb_'.$role] = 0; + $this->stats_mo['qty_'.$role] = 0; + + $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; + $sql .= " SUM(mp.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."mrp_mo as c"; + $sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= "INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id); + } + $sql .= " WHERE "; + $sql .= " c.entity IN (".getEntity('mo').")"; + + $sql .= " AND mp.batch = '".($this->db->escape($this->batch))."'"; + $sql .= " AND mp.role ='".$this->db->escape($role)."'"; + if ($socid > 0) { + $sql .= " AND c.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_mo['customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0; + $this->stats_mo['nb_'.$role] = $obj->nb ? $obj->nb : 0; + $this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() + } else { + $this->error = $this->db->error(); + $error++; + } + } + + if (!empty($error)) { + return -1; + } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_mo = $hookmanager->resArray['stats_mo']; + } + + return 1; + } + /** * Return label of status of object diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php new file mode 100644 index 00000000000..a8a5d529b53 --- /dev/null +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -0,0 +1,375 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * + * 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/product/stock/stats/commande_fournisseur.php + * \ingroup product service facture + * \brief Page of supplier order statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'orders')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatssupplierorder')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "cf.date_commande"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$commandefournisseurstatic = new CommandeFournisseur($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print '
'; + + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + +// // Sell by +// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// // Eat by +// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { +// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; +// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; +// // print ''; +// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// } +// +// // Quality control +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { +// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; +// print ''; +// } +// +// // Other attributes +// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->fournisseur->commande->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; + $sql .= " cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,"; + $sql .= " cfd.rowid, SUM(cfdi.qty) as qty"; +// $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur as cf ON (cf.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE cf.entity IN (".getEntity('product').")"; + $sql .= " AND cfdi.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND cf.fk_soc = ".((int) $socid); + } + $sql .= " GROUP BY cf.rowid"; + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht_pondere = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "cf.date_commande", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("DateDeliveryPlanned", $_SERVER["PHP_SELF"], "cf.date_livraison", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "cfdi.qty", "", $option, 'align="center"', $sortfield, $sortorder); +// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cf.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + +// $total_ht_pondere += $objp->total_ht_pondere; + $total_qty += $objp->qty; + + $commandefournisseurstatic->id = $objp->facid; + $commandefournisseurstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); +// $paiement = $commandefournisseurstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '"; + print '\n"; +// print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; +// print ''; + print ''; + print "
'; + print $commandefournisseurstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_fournisseur."'; + print dol_print_date($db->jdate($objp->date_commande), 'dayhour')."'; + print dol_print_date($db->jdate($objp->delivery_date), 'dayhour')."'.$objp->qty."'.price($objp->total_ht_pondere)."'.$commandefournisseurstatic->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.$total_ht_pondere.'
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php new file mode 100644 index 00000000000..f675f5745fb --- /dev/null +++ b/htdocs/product/stock/stats/expedition.php @@ -0,0 +1,369 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * + * 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/product/stock/stats/expedition.php + * \ingroup product service facture + * \brief Page of expedition statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsexpedition')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "exp.date_creation"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$expeditionstatic = new Expedition($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + +// // Sell by +// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// // Eat by +// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { +// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; +// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; +// // print ''; +// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// } +// +// // Quality control +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { +// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; +// print ''; +// } +// +// // Other attributes +// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->expedition->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; + $sql .= " exp.ref, exp.date_creation, exp.fk_statut as statut, exp.rowid as facid,"; + $sql .= " d.rowid, db.qty"; + // $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expedition as exp ON (exp.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet as d ON (d.fk_expedition = exp.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as db ON (db.fk_expeditiondet = d.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE exp.entity IN (".getEntity('product').")"; + $sql .= " AND db.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(exp.date_creation) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(exp.date_creation) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND exp.fk_soc = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("Shipments"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "exp.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); +// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "exp.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + + $expeditionstatic->id = $objp->facid; + $expeditionstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); +// $paiement = $expeditionstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '\n"; +// print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
'; + print $expeditionstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; + print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$expeditionstatic->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.'
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php new file mode 100644 index 00000000000..5a54ad9b75a --- /dev/null +++ b/htdocs/product/stock/stats/mo.php @@ -0,0 +1,302 @@ + + * Copyright (C) 2004-2021 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * + * 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/product/stats/mo.php + * \ingroup product mo + * \brief Page of MO referring product + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('mrp', 'products', 'companies', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsmo')); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "c.date_valid"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$staticmo = new Mo($db); +$staticmoligne = new MoLine($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + + $now = dol_now(); + + $sql = "SELECT"; +// $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; + $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; +// $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; + $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; + $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; + //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_production as cd"; + $sql .= " WHERE c.rowid = cd.fk_mo"; + $sql .= " AND c.entity IN (".getEntity('mo').")"; + $sql .= " AND cd.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + } + if ($socid) { + $sql .= " AND s.rowid = ".((int) $socid); + } + $sql .= " GROUP BY c.rowid, c.ref, c.date_valid, c.status"; + //$sql .= ", s.nom, s.rowid, s.code_client"; + $sql .= $db->order($sortfield, $sortorder); + + //Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option = '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("MOs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + + print ''; + + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "c.rowid", "", $option."&id=".$object->id, '', $sortfield, $sortorder); + //print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&id=".$object->id, '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "c.date_valid", "", $option."&id=".$object->id, 'align="center"', $sortfield, $sortorder); + //print_liste_field_titre("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$object->id,'align="right"',$sortfield,$sortorder); +// print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("QtyAlreadyConsumed", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); +// print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("QtyAlreadyProduced", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.status", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print "\n"; + + $motmp = new Mo($db); + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + $motmp->id = $objp->rowid; + $motmp->ref = $objp->ref; + $motmp->status = $objp->status; + + print ''; + print '\n"; + print ""; + //print "\n"; + //print ''; + print ''; +// print ''; + print ''; + //$mostatic->LibStatut($objp->statut,5).''; + print ''; + print "\n"; + $i++; + } + } + + print '
'; + print $motmp->getNomUrl(1, 'production'); + print ""; + print dol_print_date($db->jdate($objp->date_valid), 'dayhour')."".price($objp->total_ht)."'; +// print ''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_consumed > 0 ? $objp->nb_consumed : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_produced > 0 ? $objp->nb_produced : '').''.$motmp->getLibStatut(2).'
'; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php new file mode 100644 index 00000000000..f289c469a6d --- /dev/null +++ b/htdocs/product/stock/stats/reception.php @@ -0,0 +1,368 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * + * 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/product/stock/stats/reception.php + * \ingroup product service facture + * \brief Page of reception statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsreception')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "recep.date_creation"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$receptionstatic = new Reception($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + +// // Sell by +// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// // Eat by +// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { +// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; +// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; +// // print ''; +// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// } +// +// // Quality control +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { +// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; +// print ''; +// } +// +// // Other attributes +// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->reception->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; + $sql .= " recep.ref, recep.date_creation, recep.fk_statut as statut, recep.rowid as facid,"; + $sql .= " d.qty"; + // $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."reception as recep ON (recep.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as d ON (d.fk_reception = recep.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE recep.entity IN (".getEntity('product').")"; + $sql .= " AND d.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(recep.date_creation) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(recep.date_creation) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND recep.fk_soc = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("Receptions"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "recep.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); +// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "recep.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + + $receptionstatic->id = $objp->facid; + $receptionstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); +// $paiement = $receptionstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '\n"; +// print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
'; + print $receptionstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_fournisseur."'; + print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$receptionstatic->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.'
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); From 373388ca4a14808e2978117a8c3531c396c8dd5f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 09:58:48 +0100 Subject: [PATCH 2/6] FIX : total line on batch stats mo --- htdocs/product/stock/stats/mo.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 5a54ad9b75a..4133448aa63 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -258,6 +258,8 @@ if ($id > 0 || !empty($ref)) { $motmp = new Mo($db); + $total_consumed=$total_produced=0; + if ($num > 0) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); @@ -266,6 +268,9 @@ if ($id > 0 || !empty($ref)) { $motmp->ref = $objp->ref; $motmp->status = $objp->status; + $total_consumed+=$objp->nb_consumed; + $total_produced+=$objp->nb_produced; + print ''; print ''; print $motmp->getNomUrl(1, 'production'); @@ -284,6 +289,19 @@ if ($id > 0 || !empty($ref)) { $i++; } } + print ''; + if ($num < $limit) { + print ''.$langs->trans("Total").''; + } else { + print ''.$langs->trans("Totalforthispage").''; + } + print ''; + print ''.$total_consumed.''; + print ''.$total_produced.''; + print ''; + print ""; + print ''; + print ''; print ''; print ''; From 40f52afb9e16a85bc3e28575e2172464ebc12c03 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 17 Feb 2023 09:06:07 +0000 Subject: [PATCH 3/6] Fixing style errors. --- htdocs/core/lib/product.lib.php | 21 ++- .../product/stock/class/productlot.class.php | 120 +++++++++--------- .../stock/stats/commande_fournisseur.php | 100 +++++++-------- htdocs/product/stock/stats/expedition.php | 94 +++++++------- htdocs/product/stock/stats/mo.php | 12 +- htdocs/product/stock/stats/reception.php | 94 +++++++------- 6 files changed, 218 insertions(+), 223 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 7f2f626beee..fc2fa468533 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -697,8 +697,7 @@ function show_stats_for_batch($batch, $socid) print ''; } - if(isModEnabled("reception") && !empty($user->rights->reception->lire)) { - + if (isModEnabled("reception") && !empty($user->rights->reception->lire)) { $nblines++; $ret = $batch->load_stats_reception($socid); if ($ret < 0) { @@ -715,9 +714,7 @@ function show_stats_for_batch($batch, $socid) print $batch->stats_reception['qty']; print ''; print ''; - - } elseif(isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { - + } elseif (isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { $nblines++; $ret = $batch->load_stats_supplier_order($socid); if ($ret < 0) { @@ -734,7 +731,6 @@ function show_stats_for_batch($batch, $socid) print $batch->stats_supplier_order['qty']; print ''; print ''; - } if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { @@ -747,19 +743,19 @@ function show_stats_for_batch($batch, $socid) print ''; print ''.img_object('', 'mrp', 'class="pictofixedwidth"').$langs->trans("MO").''; print ''; -// print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); -// print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['customers_produced'], $langs->trans("QtyAlreadyProduced")); print ''; -// print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed")); -// print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['nb_produced'], $langs->trans("QtyAlreadyProduced")); print ''; -// print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed")); -// print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced")); print ''; print ''; @@ -775,7 +771,6 @@ function show_stats_for_batch($batch, $socid) return $nblines++; - } /** diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index c87a63c11e3..182f3ac1a76 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -570,7 +570,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -596,25 +596,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->load_stats_expedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); @@ -645,7 +645,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -671,25 +671,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->stats_supplier_order($socid); -// -// $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; -// $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; -// $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; -// $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->stats_supplier_order($socid); + // + // $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; + // $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; + // $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; + // $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); @@ -719,7 +719,7 @@ class Productlot extends CommonObject $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -745,25 +745,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->load_stats_expedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action); diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index a8a5d529b53..34fe3780c9f 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -152,50 +152,50 @@ if ($id > 0 || !empty($ref)) { echo '
'; -// // Sell by -// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// // Eat by -// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { -// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; -// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; -// // print ''; -// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// } -// -// // Quality control -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { -// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; -// print ''; -// } -// -// // Other attributes -// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -214,7 +214,7 @@ if ($id > 0 || !empty($ref)) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; $sql .= " cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,"; $sql .= " cfd.rowid, SUM(cfdi.qty) as qty"; -// $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; + // $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; } @@ -308,7 +308,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "cf.date_commande", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateDeliveryPlanned", $_SERVER["PHP_SELF"], "cf.date_livraison", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "cfdi.qty", "", $option, 'align="center"', $sortfield, $sortorder); -// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cf.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -320,13 +320,13 @@ if ($id > 0 || !empty($ref)) { $objp->qty = -($objp->qty); } -// $total_ht_pondere += $objp->total_ht_pondere; + // $total_ht_pondere += $objp->total_ht_pondere; $total_qty += $objp->qty; $commandefournisseurstatic->id = $objp->facid; $commandefournisseurstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); -// $paiement = $commandefournisseurstatic->getSommePaiement(); + // $paiement = $commandefournisseurstatic->getSommePaiement(); print ''; print '"; print '\n"; -// print '\n"; + // print '\n"; print ''; print "\n"; $i++; @@ -355,7 +355,7 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; print ''; -// print ''; + // print ''; print ''; print "
'; @@ -339,7 +339,7 @@ if ($id > 0 || !empty($ref)) { print ''; print dol_print_date($db->jdate($objp->delivery_date), 'dayhour')."'.$objp->qty."'.price($objp->total_ht_pondere)."'.price($objp->total_ht_pondere)."'.$commandefournisseurstatic->LibStatut($objp->statut, 5).'
'.$total_qty.''.$total_ht_pondere.''.$total_ht_pondere.'
"; print ''; diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index f675f5745fb..0db73a319b3 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -152,50 +152,50 @@ if ($id > 0 || !empty($ref)) { echo '
'; -// // Sell by -// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// // Eat by -// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { -// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; -// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; -// // print ''; -// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// } -// -// // Quality control -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { -// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; -// print ''; -// } -// -// // Other attributes -// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -306,7 +306,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "exp.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); -// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "exp.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -324,7 +324,7 @@ if ($id > 0 || !empty($ref)) { $expeditionstatic->id = $objp->facid; $expeditionstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); -// $paiement = $expeditionstatic->getSommePaiement(); + // $paiement = $expeditionstatic->getSommePaiement(); print ''; print '"; print '\n"; -// print '\n"; + // print '\n"; print ''; print "\n"; $i++; diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 4133448aa63..ff1e60e046a 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -159,9 +159,9 @@ if ($id > 0 || !empty($ref)) { $now = dol_now(); $sql = "SELECT"; -// $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; + // $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; -// $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; + // $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; @@ -249,9 +249,9 @@ if ($id > 0 || !empty($ref)) { //print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&id=".$object->id, '', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "c.date_valid", "", $option."&id=".$object->id, 'align="center"', $sortfield, $sortorder); //print_liste_field_titre("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$object->id,'align="right"',$sortfield,$sortorder); -// print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + // print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("QtyAlreadyConsumed", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); -// print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + // print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("QtyAlreadyProduced", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.status", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'right '); print "\n"; @@ -279,9 +279,9 @@ if ($id > 0 || !empty($ref)) { print dol_print_date($db->jdate($objp->date_valid), 'dayhour').""; //print "\n"; //print ''; + // print ''; print ''; -// print ''; + // print ''; print ''; //$mostatic->LibStatut($objp->statut,5).''; print ''; diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f289c469a6d..498a39c41d8 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -152,50 +152,50 @@ if ($id > 0 || !empty($ref)) { echo '
'; -// // Sell by -// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { -// print ''; -// print ''; -// } -// -// // Eat by -// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { -// print ''; -// print ''; -// } -// -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { -// print ''; -// print ''; -// print ''; -// // print ''; -// // print ''; -// // print ''; -// print ''; -// print ''; -// print ''; -// } -// -// // Quality control -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { -// print ''; -// print ''; -// print ''; -// print ''; -// print ''; -// print ''; -// } -// -// // Other attributes -// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''; + // print ''; + // print ''; + // // print ''; + // // print ''; + // // print ''; + // print ''; + // print ''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''; + // print ''; + // print ''; + // print ''; + // print ''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; @@ -335,7 +335,7 @@ if ($id > 0 || !empty($ref)) { print ''; print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.price($objp->total_ht)."'.$expeditionstatic->LibStatut($objp->statut, 5).'
".price($objp->total_ht)."'; -// print ''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_consumed > 0 ? $objp->nb_consumed : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_produced > 0 ? $objp->nb_produced : '').''.$motmp->getLibStatut(2).'
'; -// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print '
'; -// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').'
'; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print '
'; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').'
'; @@ -305,7 +305,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "recep.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); -// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "recep.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -323,7 +323,7 @@ if ($id > 0 || !empty($ref)) { $receptionstatic->id = $objp->facid; $receptionstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); -// $paiement = $receptionstatic->getSommePaiement(); + // $paiement = $receptionstatic->getSommePaiement(); print ''; print '"; print '\n"; -// print '\n"; + // print '\n"; print ''; print "\n"; $i++; From 8e2998a50482ee74a50ff46fd0d6a8ad23b43be7 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 10:12:19 +0100 Subject: [PATCH 4/6] NEW : dev name --- htdocs/core/lib/product.lib.php | 1 + htdocs/product/stats/mo.php | 1 + htdocs/product/stock/class/productlot.class.php | 1 + htdocs/product/stock/stats/commande_fournisseur.php | 1 + htdocs/product/stock/stats/expedition.php | 1 + htdocs/product/stock/stats/mo.php | 1 + htdocs/product/stock/stats/reception.php | 1 + 7 files changed, 7 insertions(+) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 4898ff96cc2..89bf0f2537d 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2010 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2015-2016 Marcos García + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 3127f9e83a6..b401b40bc9e 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index c20f224a584..a522f36ad47 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index a8a5d529b53..561f041e35c 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index f675f5745fb..6825cb989d4 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 4133448aa63..ae90127065a 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f289c469a6d..e2397e47438 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL * * 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 From 8534a9698127cc7c71ac63ff76d4b254c4f98c07 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 10:24:59 +0100 Subject: [PATCH 5/6] FIX : stickler feedbacks --- htdocs/core/lib/product.lib.php | 16 ++++++++-------- htdocs/product/stock/class/productlot.class.php | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 89bf0f2537d..0f12ba4f46f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -655,11 +655,11 @@ function show_stats_for_company($product, $socid) } /** - * Show stats for company + * Show stats for product batch * - * @param Product $product Product object - * @param int $socid Thirdparty id - * @return integer NB of lines shown into array + * @param Productlot $batch Product batch object + * @param int $socid Thirdparty id + * @return integer NB of lines shown into array */ function show_stats_for_batch($batch, $socid) { @@ -681,7 +681,7 @@ function show_stats_for_batch($batch, $socid) // Expeditions if (isModEnabled('expedition') && !empty($user->rights->expedition->lire)) { $nblines++; - $ret = $batch->load_stats_expedition($socid); + $ret = $batch->loadStatsExpedition($socid); if ($ret < 0) { dol_print_error($db); } @@ -701,7 +701,7 @@ function show_stats_for_batch($batch, $socid) if(isModEnabled("reception") && !empty($user->rights->reception->lire)) { $nblines++; - $ret = $batch->load_stats_reception($socid); + $ret = $batch->loadStatsReception($socid); if ($ret < 0) { dol_print_error($db); } @@ -720,7 +720,7 @@ function show_stats_for_batch($batch, $socid) } elseif(isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { $nblines++; - $ret = $batch->load_stats_supplier_order($socid); + $ret = $batch->loadStatsSupplierOrder($socid); if ($ret < 0) { dol_print_error($db); } @@ -740,7 +740,7 @@ function show_stats_for_batch($batch, $socid) if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { $nblines++; - $ret = $batch->load_stats_mo($socid); + $ret = $batch->loadStatsMo($socid); if ($ret < 0) { dol_print_error($db); } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index a522f36ad47..95c7240e2c3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -561,7 +561,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_expedition($socid = 0) + public function loadStatsExpedition($socid = 0) { // phpcs:enable global $db, $conf, $user, $hookmanager, $action; @@ -606,7 +606,7 @@ class Productlot extends CommonObject // $qtyCoef = $fatherData['qty']; // // if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); +// $pFather->loadStatsExpedition($socid); // // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; @@ -636,7 +636,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_supplier_order($socid = 0) + public function loadStatsSupplierOrder($socid = 0) { // phpcs:enable global $db, $conf, $user, $hookmanager, $action; @@ -711,7 +711,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_reception($socid = 0) + public function loadStatsReception($socid = 0) { // phpcs:enable global $db, $conf, $user, $hookmanager, $action; @@ -755,7 +755,7 @@ class Productlot extends CommonObject // $qtyCoef = $fatherData['qty']; // // if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); +// $pFather->loadStatsReception($socid); // // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; @@ -785,7 +785,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_mo($socid = 0) + public function loadStatsMo($socid = 0) { // phpcs:enable global $user, $hookmanager, $action; From bc954af404fc5e2d9c2e0cf481ba36867749c24c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 17 Feb 2023 09:32:05 +0000 Subject: [PATCH 6/6] Fixing style errors. --- .../product/stock/class/productlot.class.php | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 7f05796eeae..7d12acae368 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -571,7 +571,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -597,25 +597,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->loadStatsExpedition($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->loadStatsExpedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); @@ -646,7 +646,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -672,25 +672,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->stats_supplier_order($socid); -// -// $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; -// $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; -// $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; -// $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->stats_supplier_order($socid); + // + // $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; + // $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; + // $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; + // $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); @@ -720,7 +720,7 @@ class Productlot extends CommonObject $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -746,25 +746,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->loadStatsReception($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->loadStatsReception($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action);
'; @@ -334,7 +334,7 @@ if ($id > 0 || !empty($ref)) { print ''; print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.price($objp->total_ht)."'.$receptionstatic->LibStatut($objp->statut, 5).'