From 024ba2ee422cc31764c789956dae681c0d97ccd4 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Tue, 6 Aug 2013 21:31:32 +0200 Subject: [PATCH 1/4] Update index.php Add quarter report of sell service/product --- htdocs/product/index.php | 111 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 247ddf7d5ff..b1d2209d94c 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -258,10 +258,121 @@ else dol_print_error($db); } +// ici le récap des ventes par trimestre de service et de produit +if (! empty($conf->product->enabled)) + activitytrim(0); + +if (! empty($conf->service->enabled)) + activitytrim(1); + //print ''; print ''; llxFooter(); $db->close(); + +function activitytrim($product_type) +{ + global $conf,$langs,$db; + + // on affiche les 3 dernières années + $begindate=date('Y',dol_time_plus_duree(time(), -3, "y")); + + // ventilation par trimestre + $sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, sum(fd.total_ht) as Mnttot"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sql.= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.rowid = fd.fk_facture"; + $sql.= " AND pf.fk_facture = f.rowid"; + $sql.= " AND pf.fk_paiement= p.rowid"; + $sql.= " AND fd.product_type=".$product_type; + $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND DATE_FORMAT(p.datep,'%Y') > ".date('Y',$begindate)." and paye=1"; + $sql.= " GROUP BY annee, mois "; + $sql.= " ORDER BY annee, mois "; + + $result = $db->query($sql); + if ($result) + { + $tmpyear=$beginyear; + $trim1=0; + $trim2=0; + $trim3=0; + $trim4=0; + $lgn = 0; + $num = $db->num_rows($result); + + if ($num > 0 ) + { + print '
'; + print ''; + + if ($product_type==1) + print ''; + else + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + $i = 0; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + if ($tmpyear != $objp->annee) + { + if ($trim1+$trim2+$trim3+$trim4 > 0) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $lgn++; + } + // on passe à l'année suivante + $tmpyear = $objp->annee; + $trim1=0; + $trim2=0; + $trim3=0; + $trim4=0; + } + + if ($objp->mois == "01" || $objp->mois == "02" || $objp->mois == "03") + $trim1 += $objp->Mnttot; + + if ($objp->mois == "04" || $objp->mois == "05" || $objp->mois == "06") + $trim2 += $objp->Mnttot; + + if ($objp->mois == "07" || $objp->mois == "08" || $objp->mois == "09") + $trim3 += $objp->Mnttot; + + if ($objp->mois == "10" || $objp->mois == "11" || $objp->mois == "12") + $trim4 += $objp->Mnttot; + + $i++; + } + if ($trim1+$trim2+$trim3+$trim4 > 0) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + if ($num > 0 ) + print '
'.$langs->trans("ProductSellByQuarterHT").'
'.$langs->trans("SerciceSellByQuarterHT").''.$langs->trans("Quarter1").''.$langs->trans("Quarter2").''.$langs->trans("Quarter3").''.$langs->trans("Quarter4").''.$langs->trans("Total").'
'.$tmpyear.''.price($trim1).''.price($trim2).''.price($trim3).''.price($trim4).''.price($trim1+$trim2+$trim3+$trim4).'
'.$tmpyear.''.price($trim1).''.price($trim2).''.price($trim3).''.price($trim4).''.price($trim1+$trim2+$trim3+$trim4).'
'; + } +} + ?> From 54d2f1161d1d84a95b03c15cf0c731bf87902d2f Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Wed, 7 Aug 2013 07:15:09 +0200 Subject: [PATCH 2/4] Update index.php change datep --- htdocs/product/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index b1d2209d94c..46c220e9503 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -277,7 +277,7 @@ function activitytrim($product_type) global $conf,$langs,$db; // on affiche les 3 dernières années - $begindate=date('Y',dol_time_plus_duree(time(), -3, "y")); + $yearofbegindate=date('Y',dol_time_plus_duree(time(), -3, "y")); // ventilation par trimestre $sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, sum(fd.total_ht) as Mnttot"; @@ -289,7 +289,7 @@ function activitytrim($product_type) $sql.= " AND pf.fk_paiement= p.rowid"; $sql.= " AND fd.product_type=".$product_type; $sql.= " AND s.entity = ".$conf->entity; - $sql.= " AND DATE_FORMAT(p.datep,'%Y') > ".date('Y',$begindate)." and paye=1"; + $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate),1)."'"; $sql.= " GROUP BY annee, mois "; $sql.= " ORDER BY annee, mois "; From 12479a946a7a2f151a212b16c7a8d101af2be484 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Wed, 7 Aug 2013 07:28:37 +0200 Subject: [PATCH 3/4] Update index.php Error on column titles --- htdocs/product/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 46c220e9503..f9eb16e23de 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -309,10 +309,10 @@ function activitytrim($product_type) print '
'; print ''; - if ($product_type==1) + if ($product_type==0) print ''; else - print ''; + print ''; print ''; print ''; print ''; From 2548274c10325524e557e2636b09825e4e2fe237 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Wed, 7 Aug 2013 07:32:27 +0200 Subject: [PATCH 4/4] Update products.lang add header translation --- htdocs/langs/fr_FR/products.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index bb444584721..916d4d9e6ff 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -199,3 +199,5 @@ CostPmpHT=Cout à l'achat HT ProductUsedForBuild=Consommé automatiquement par la fabrication ProductBuilded=Fabrication terminée ProductsMultiPrice=Produits multi-prix +ProductSellByQuarterHT=Chiffre d'affaire trimestrielle HT des produits +ServiceSellByQuarterHT=Chiffre d'affaire trimestrielle HT des services
'.$langs->trans("ProductSellByQuarterHT").'
'.$langs->trans("SerciceSellByQuarterHT").'
'.$langs->trans("ServiceSellByQuarterHT").''.$langs->trans("Quarter1").''.$langs->trans("Quarter2").''.$langs->trans("Quarter3").'