From face07ece1577311119b2df0bf2243003a62f9ba Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 1 May 2019 15:15:20 +0200 Subject: [PATCH] new constant PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC --- htdocs/product/class/product.class.php | 87 +++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3796f5b022e..6afd42e3aae 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2410,6 +2410,28 @@ class Product extends CommonObject $this->stats_propale['nb']=$obj->nb; $this->stats_propale['rows']=$obj->nb_rows; $this->stats_propale['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in proposal 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_propale($socid); + + $this->stats_propale['customers']+=$pFather->stats_propale['customers']; + $this->stats_propale['nb']+=$pFather->stats_propale['nb']; + $this->stats_propale['rows']+=$pFather->stats_propale['rows']; + $this->stats_propale['qty']+=$pFather->stats_propale['qty'] * $qtyCoef; + } + } + } + } + return 1; } else @@ -2512,7 +2534,7 @@ class Product extends CommonObject $this->stats_commande['qty']=$obj->qty?$obj->qty:0; // if it's a virtual product, maybe it is in order by extension - if (! empty($conf->global->ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC)) { + if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { foreach($TFather as &$fatherData) { @@ -2665,6 +2687,27 @@ class Product extends CommonObject $this->stats_expedition['nb']=$obj->nb; $this->stats_expedition['rows']=$obj->nb_rows; $this->stats_expedition['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in sending 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_sending($socid, $filtrestatut, $forVirtualStock); + + $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; + } + } + } + } return 1; } else @@ -2762,6 +2805,27 @@ class Product extends CommonObject $this->stats_contrat['nb']=$obj->nb; $this->stats_contrat['rows']=$obj->nb_rows; $this->stats_contrat['qty']=$obj->qty?$obj->qty:0; + + // if it's a virtual product, maybe it is in contract 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_contrat($socid); + + $this->stats_contrat['customers']+=$pFather->stats_contrat['customers']; + $this->stats_contrat['nb']+=$pFather->stats_contrat['nb']; + $this->stats_contrat['rows']+=$pFather->stats_contrat['rows']; + $this->stats_contrat['qty']+=$pFather->stats_contrat['qty'] * $qtyCoef; + } + } + } + } return 1; } else @@ -2811,6 +2875,27 @@ class Product extends CommonObject $this->stats_facture['nb']=$obj->nb; $this->stats_facture['rows']=$obj->nb_rows; $this->stats_facture['qty']=$obj->qty?$obj->qty:0; + + // 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_facture($socid); + + $this->stats_facture['customers']+=$pFather->stats_facture['customers']; + $this->stats_facture['nb']+=$pFather->stats_facture['nb']; + $this->stats_facture['rows']+=$pFather->stats_facture['rows']; + $this->stats_facture['qty']+=$pFather->stats_facture['qty'] * $qtyCoef; + } + } + } + } return 1; } else