From 4f9a1768d52cffceaa3e7a8cc51ecac891f2de6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Aug 2013 14:36:35 +0200 Subject: [PATCH 01/15] Work on graphical box with product distribution --- .../comm/propal/class/propalestats.class.php | 28 ++++- htdocs/commande/class/commandestats.class.php | 29 ++++- .../boxes/box_graph_product_distribution.php | 119 +++++++++++++----- htdocs/langs/en_US/boxes.lang | 5 +- htdocs/langs/fr_FR/boxes.lang | 5 +- htdocs/theme/eldy/style.css.php | 4 + 6 files changed, 154 insertions(+), 36 deletions(-) diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 5b5b0dd7279..1b1b5d2e045 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -62,10 +62,11 @@ class PropaleStats extends Stats $object=new Propal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; - //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->field='total_ht'; - + $this->field_line='total_ht'; + $this->where.= " p.fk_statut > 0"; //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; $this->where.= " AND p.entity = ".$conf->entity; @@ -182,5 +183,28 @@ class PropaleStats extends Stats return $this->_getAllByYear($sql); } + + + /** + * Return nb, amount of predefined product for year + * + * @param int $year Year to scan + * @return array Array of values + */ + function getAllByProduct($year) + { + global $user; + + $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; + $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; + $sql.= " GROUP BY product.ref"; + $sql.= $this->db->order('nb','DESC'); + $sql.= $this->db->plimit(20); + + return $this->_getAllByProduct($sql); + } } ?> diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 9609a4e9440..a1c976db6a5 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -66,16 +66,18 @@ class CommandeStats extends Stats { $object=new Commande($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; - //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->field='total_ht'; + $this->field_line='total_ht'; $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled } if ($mode == 'supplier') { $object=new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; - //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->field='total_ht'; + $this->field_line='total_ht'; $this->where.= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; @@ -191,6 +193,29 @@ class CommandeStats extends Stats return $this->_getAllByYear($sql); } + + /** + * Return nb, amount of predefined product for year + * + * @param int $year Year to scan + * @return array Array of values + */ + function getAllByProduct($year) + { + global $user; + + $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; + $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; + $sql.= " GROUP BY product.ref"; + $sql.= $this->db->order('nb','DESC'); + $sql.= $this->db->plimit(20); + + return $this->_getAllByProduct($sql); + } + } ?> \ No newline at end of file diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 8fccc4fd8a0..c92b9100e1f 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -86,28 +86,34 @@ class box_graph_product_distribution extends ModeleBoxes $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; $param_showinvoicenb='DOLUSERCOOKIE_param'.$this->boxcode.'showinvoicenb'; $param_showpropalnb='DOLUSERCOOKIE_param'.$this->boxcode.'showpropalnb'; + $param_showordernb='DOLUSERCOOKIE_param'.$this->boxcode.'showordernb'; $showinvoicenb=GETPOST($param_showinvoicenb,'alpha',4); $showpropalnb=GETPOST($param_showpropalnb,'alpha',4); - if (empty($showinvoicenb) && empty($showpropalnb)) { $showpropalnb=1; $showinvoicenb=1; } + $showordernb=GETPOST($param_showordernb,'alpha',4); + if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } $nowarray=dol_getdate(dol_now(),true); $year=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + $paramtitle=$langs->trans("Products").'/'.$langs->trans("Services"); + if (empty($conf->produit->enabled)) $paramtitle=$langs->trans("Services"); + if (empty($conf->service->enabled)) $paramtitle=$langs->trans("Products"); + if ($user->rights->facture->lire) { - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; + $mode='customer'; $userid=0; - $WIDTH=(($showinvoicenb && $showpropalnb) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; + $WIDTH=(($showinvoicenb && $showpropalnb) || ! empty($conf->dol_optimize_smallscreen))?'160':'320'; $HEIGHT='192'; - - $stats = new FactureStats($this->db, 0, $mode, ($userid>0?$userid:0)); - + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showinvoicenb) { - $data1 = $stats->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; + + $stats_invoice = new FactureStats($this->db, 0, $mode, ($userid>0?$userid:0)); + $data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; @@ -136,22 +142,25 @@ class box_graph_product_distribution extends ModeleBoxes $px1->SetCssPrefix("cssboxes"); //$px1->mode='depth'; $px1->SetType(array('pie')); - $px1->SetTitle($langs->trans("BoxProductDistributionFor",$langs->trans("ProductsServices"),$langs->transnoentitiesnoconv("Invoices"))); + $px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices"))); $px1->draw($filenamenb,$fileurlnb); } } } -/* if ($user->rights->propal->lire) + if ($user->rights->propal->lire) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) { - $data2 = $stats->getAmountByMonthWithPrevYear($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; + + $stats_proposal = new PropaleStats($this->db, 0, $mode, ($userid>0?$userid:0)); + $data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); $filenamenb = $dir."/prodserforpropal-".$year.".png"; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=prodserforpropal-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=proposalstats&file=prodserforpropal-'.$year.'.png'; $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); @@ -175,14 +184,58 @@ class box_graph_product_distribution extends ModeleBoxes $px2->SetHorizTickIncrement(1); $px2->SetPrecisionY(0); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; - $px2->SetTitle($langs->trans("BoxProductDistributionFor",$langs->trans("ProductsServices"),$langs->transnoentitiesnoconv("Proposals"))); + //$px2->mode='depth'; + $px2->SetType(array('pie')); + $px2->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Proposals"))); $px2->draw($filenamenb,$fileurlnb); } } } - */ + + if ($user->rights->commande->lire) + { + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) + if ($showordernb) + { + include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; + + $stats_order = new CommandeStats($this->db, 0, $mode, ($userid>0?$userid:0)); + $data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); + + $filenamenb = $dir."/prodserfororder-".$year.".png"; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=prodserfororder-'.$year.'.png'; + + $px3 = new DolGraph(); + $mesg = $px3->isGraphKo(); + if (! $mesg) + { + $px3->SetData($data3); + unset($data3); + $px3->SetPrecisionY(0); + $i=0;$tot=count($data3);$legend=array(); + while ($i <= $tot) + { + $legend[]=$data3[$i][0]; + $i++; + } + $px3->SetLegend($legend); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + //$px3->SetYLabel($langs->trans("AmountOfBillsHT")); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->SetPrecisionY(0); + $px3->SetCssPrefix("cssboxes"); + //$px3->mode='depth'; + $px3->SetType(array('pie')); + $px3->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Orders"))); + $px3->draw($filenamenb,$fileurlnb); + } + } + } + if (! $mesg) { $stringtoshow=''; @@ -197,33 +250,39 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.='
'; $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("ForInvoice"); + $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("ForProposals"); $stringtoshow.=' '; - $stringtoshow.=' '.$langs->trans("ForOrders"); + $stringtoshow.=' '.$langs->trans("ForCustomersOrders"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; $stringtoshow.=''; $stringtoshow.='
'; $stringtoshow.=''; - if ($showinvoicenb && $showpropalnb) - { - $stringtoshow.='
'; - $stringtoshow.='
'; - } + //if ($showinvoicenb && $showpropalnb && $showordernb) + //{ + $stringtoshow.='
'; + $stringtoshow.='
'; + //} if ($showinvoicenb) $stringtoshow.=$px1->show(); - if ($showinvoicenb && $showpropalnb) - { + //if ($showinvoicenb && $showpropalnb) + //{ $stringtoshow.='
'; - $stringtoshow.='
'; - } -// if ($showpropalnb) $stringtoshow.=$px2->show(); - if ($showinvoicenb && $showpropalnb) - { + $stringtoshow.='
'; + //} + if ($showpropalnb) $stringtoshow.=$px2->show(); + //if ($showinvoicenb && $showpropalnb) + //{ $stringtoshow.='
'; + $stringtoshow.='
'; + //} + if ($showordernb) $stringtoshow.=$px3->show(); + //if ($showinvoicenb && $showpropalnb) + //{ + $stringtoshow.='
'; $stringtoshow.='
'; - } + //} $this->info_box_contents[0][0] = array('td' => 'align="center" class="nohover"','textnoformat'=>$stringtoshow); } else diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 7ac3a28102a..65fd3dec7cd 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -85,4 +85,7 @@ BoxSuppliersOrdersPerMonth=Supplier orders per month BoxProposalsPerMonth=Proposals per month NoTooLowStockProducts=No product under the low stock limit BoxProductDistribution=Products/Services distribution -BoxProductDistributionFor=Distribution of %s for %s \ No newline at end of file +BoxProductDistributionFor=Distribution of %s for %s +ForCustomersInvoices=Customers invoices +ForCustomersOrders=Customers orders +ForProposals=Proposals \ No newline at end of file diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 2a163ff382e..48f8459c1bc 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -85,4 +85,7 @@ BoxSuppliersOrdersPerMonth=Commandes fournisseurs par mois BoxProposalsPerMonth=Proposition par mois NoTooLowStockProducts=Pas de produits sous le seuil de stock minimal BoxProductDistribution=Répartition des produis/services -BoxProductDistributionFor=Répartition des %s pour les %s \ No newline at end of file +BoxProductDistributionFor=Répartition des %s pour les %s +ForCustomersInvoices=Factures clients +ForCustomersOrders=Commandes clients +ForProposals=Propositions \ No newline at end of file diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ba895840b87..ddafc390fde 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -478,6 +478,10 @@ div.ficheaddleft { dol_optimize_smallscreen)) { print "padding-left: 16px;\n"; } else print "margin-top: 10px;\n"; ?> } +.containercenter { +display : table; +margin : 0px auto; +} /* ============================================================================== */ From 3cf3dbeb51cc8f37ef29fb8fea31f4aafb1c0424 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Fri, 9 Aug 2013 13:48:44 +0200 Subject: [PATCH 02/15] Add pdf link into supplier invoice list and supplier order list --- ChangeLog | 1 + htdocs/core/class/html.formactions.class.php | 2 +- htdocs/core/lib/functions2.lib.php | 48 +++++++++++++------- htdocs/fourn/commande/fiche.php | 10 ++++ htdocs/fourn/commande/liste.php | 10 +++- htdocs/fourn/facture/list.php | 6 +++ 6 files changed, 59 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index d83555879b3..bf9ac07542f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,6 +46,7 @@ For users: - New: [ task #1016 ] Can define a specific numbering for deposits - New: [ task #918 ] Stock replenishment - Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count +- New : Add pdf link into supplier invoice list and supplier order list For translators: diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index ef8422a7dbc..43a06fead4e 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -144,7 +144,7 @@ class FormActions global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 38558c2e5fe..428cddcf0ca 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1451,47 +1451,63 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') // To work with non standard path if ($objecttype == 'facture' || $objecttype == 'invoice') { - $classpath = 'compta/facture/class'; $module='facture'; $subelement='facture'; + $classpath = 'compta/facture/class'; + $module='facture'; + $subelement='facture'; } if ($objecttype == 'commande' || $objecttype == 'order') { - $classpath = 'commande/class'; $module='commande'; $subelement='commande'; + $classpath = 'commande/class'; + $module='commande'; + $subelement='commande'; } if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } if ($objecttype == 'shipping') { - $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; + $classpath = 'expedition/class'; + $subelement = 'expedition'; + $module = 'expedition_bon'; } if ($objecttype == 'delivery') { - $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; - } - if ($objecttype == 'invoice_supplier') { - $classpath = 'fourn/class'; - } - if ($objecttype == 'order_supplier') { - $classpath = 'fourn/class'; + $classpath = 'livraison/class'; + $subelement = 'livraison'; + $module = 'livraison_bon'; } if ($objecttype == 'contract') { - $classpath = 'contrat/class'; $module='contrat'; $subelement='contrat'; + $classpath = 'contrat/class'; + $module='contrat'; + $subelement='contrat'; } if ($objecttype == 'member') { - $classpath = 'adherents/class'; $module='adherent'; $subelement='adherent'; + $classpath = 'adherents/class'; + $module='adherent'; + $subelement='adherent'; } if ($objecttype == 'cabinetmed_cons') { - $classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons'; + $classpath = 'cabinetmed/class'; + $module='cabinetmed'; + $subelement='cabinetmedcons'; } if ($objecttype == 'fichinter') { - $classpath = 'fichinter/class'; $module='ficheinter'; $subelement='fichinter'; + $classpath = 'fichinter/class'; + $module='ficheinter'; + $subelement='fichinter'; } //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; $classfile = strtolower($subelement); $classname = ucfirst($subelement); if ($objecttype == 'invoice_supplier') { - $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; + $classfile = 'fournisseur.facture'; + $classname='FactureFournisseur'; + $classpath = 'fourn/class'; + $module='fournisseur'; } if ($objecttype == 'order_supplier') { - $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; + $classfile = 'fournisseur.commande'; + $classname='CommandeFournisseur'; + $classpath = 'fourn/class'; + $module='fournisseur'; } if (! empty($conf->$module->enabled)) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 1e932d64827..1876d181339 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1812,6 +1812,16 @@ elseif (! empty($object->id)) * Linked object block */ $somethingshown=$object->showLinkedObjectBlock(); + + print '
'; + + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'order_supplier',$socid); + + print '
'; //print ''; print '
'; diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index 478bf76f86f..9715bb52ca7 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -23,9 +23,11 @@ * \brief List of suppliers orders */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->load("orders"); @@ -65,6 +67,7 @@ if ($socid > 0) llxHeader('',$title); $commandestatic=new CommandeFournisseur($db); +$formfile = new FormFile($db); if ($sortorder == "") $sortorder="DESC"; @@ -154,6 +157,7 @@ if ($resql) $var=true; $userstatic = new User($db); + $objectstatic=new CommandeFournisseur($db); while ($i < min($num,$conf->liste_limit)) { @@ -163,7 +167,11 @@ if ($resql) print ""; // Ref - print ''.img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.''."\n"; + print ''.img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->fournisseur->dir_output.'/commande' . '/' . dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print ''."\n"; // Company print ''.img_object($langs->trans("ShowCompany"),"company").' '; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 80c20a821ba..820aaadb573 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013 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 @@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; if (!$user->rights->fournisseur->facture->lire) accessforbidden(); @@ -99,6 +101,7 @@ if ($mode == 'search') $now=dol_now(); $form=new Form($db); $htmlother=new FormOther($db); +$formfile = new FormFile($db); llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); @@ -252,6 +255,9 @@ if ($resql) $facturestatic->ref=$obj->ref; $facturestatic->ref_supplier=$obj->ref_supplier; print $facturestatic->getNomUrl(1); + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->fournisseur->dir_output.'/facture' . '/' . dol_sanitizeFileName($obj->facid).'/0/'.dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print "\n"; print ''.dol_trunc($obj->ref_supplier,10).""; print ''.dol_print_date($db->jdate($obj->datef),'day').''; From 0a8c7f76392b99607a404fcd0c55919cb9b15ddd Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Fri, 9 Aug 2013 13:59:37 +0200 Subject: [PATCH 03/15] Generate auto supplier invoice --- ChangeLog | 1 + htdocs/fourn/facture/fiche.php | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf9ac07542f..965f70d316f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -47,6 +47,7 @@ For users: - New: [ task #918 ] Stock replenishment - Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count - New : Add pdf link into supplier invoice list and supplier order list +- New : Genrate auto the PDF for supplier invoice For translators: diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index aaf36409b81..ebcb324f557 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -28,6 +28,10 @@ * \brief Page for supplier invoice card (view, edit, validate) */ +error_reporting(E_ALL); +ini_set('display_errors', true); +ini_set('html_errors', false); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; @@ -456,6 +460,16 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) else { $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + } + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -608,7 +622,14 @@ elseif ($action == 'addline') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + } unset($_POST['qty']); unset($_POST['type']); @@ -659,7 +680,14 @@ elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + } $action=''; } From a2005ed603e3cebced01b7aeda6e03ca8eb84c1a Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:10:10 +0200 Subject: [PATCH 04/15] Trad: Update ca_ES mailmanspip.lang --- htdocs/langs/ca_ES/mailmanspip.lang | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/ca_ES/mailmanspip.lang b/htdocs/langs/ca_ES/mailmanspip.lang index 085916bbd73..d85c9a2ca5c 100644 --- a/htdocs/langs/ca_ES/mailmanspip.lang +++ b/htdocs/langs/ca_ES/mailmanspip.lang @@ -17,12 +17,12 @@ DescADHERENT_SPIP_SERVEUR=Servidor SPIP DescADHERENT_SPIP_DB=Nom de la base de dades d'SPIP DescADHERENT_SPIP_USER=Usuari de la base de dades d'SPIP DescADHERENT_SPIP_PASS=Contrasenya de la base de dades d'SPIP -# AddIntoSpip=Add into SPIP -# AddIntoSpipConfirmation=Are you sure you want to add this member into SPIP? -# AddIntoSpipError=Failed to add the user in SPIP -# DeleteIntoSpip=Remove from SPIP -# DeleteIntoSpipConfirmation=Are you sure you want to remove this member from SPIP? -# DeleteIntoSpipError=Failed to suppress the user from SPIP -# SPIPConnectionFailed=Failed to connect to SPIP +AddIntoSpip=Afegir a SPIP +AddIntoSpipConfirmation=Esteu segur de voler afegir aquest membre a SPIP? +AddIntoSpipError=S'ha produït un error en afegir el membre a SPIP +DeleteIntoSpip=Esborrar de SPIP +DeleteIntoSpipConfirmation=Esteu segur de voler esborrar aquest membre del SPIP? +DeleteIntoSpipError=S'ha produït un error en suprimir el membre d'SPIP +SPIPConnectionFailed=Error al connectar amb SPIP SuccessToAddToMailmanList=Addició de %s a la llista Mailman %s o base SPIP realitzada SuccessToRemoveToMailmanList=Eliminació de %s de la llista Mailman %s o base SPIP realitzada From e2cc4a9545658729e9d7dc54991a233453248ba2 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:12:44 +0200 Subject: [PATCH 05/15] Trad: Update ca_ES externalsite.lang --- htdocs/langs/ca_ES/externalsite.lang | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/ca_ES/externalsite.lang b/htdocs/langs/ca_ES/externalsite.lang index 3210701aec2..5b331a8b023 100644 --- a/htdocs/langs/ca_ES/externalsite.lang +++ b/htdocs/langs/ca_ES/externalsite.lang @@ -1,4 +1,5 @@ -# Dolibarr language file - ca_ES - externalsite +# Dolibarr language file - es_ES - externalsite CHARSET=UTF-8 ExternalSiteSetup=Configuració de l'enllaç al lloc web extern -ExternalSiteURL=URL del lloc extern \ No newline at end of file +ExternalSiteURL=URL del lloc extern +ExternalSiteModuleNotComplete=El mòdul Lloc web extern no ha estat configurat correctament. From 911b4965a2d4e69874fbd7acfba3ea565a67b7c6 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:16:04 +0200 Subject: [PATCH 06/15] Trad: Update ca_ES donations.lang --- htdocs/langs/ca_ES/donations.lang | 9 +++++++-- htdocs/langs/ca_ES/externalsite.lang | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/ca_ES/donations.lang b/htdocs/langs/ca_ES/donations.lang index 4e18a894944..ad368412004 100644 --- a/htdocs/langs/ca_ES/donations.lang +++ b/htdocs/langs/ca_ES/donations.lang @@ -7,6 +7,7 @@ Donor=Donant Donors=Donants AddDonation=Afegir donació NewDonation=Nova donació +ShowDonation=Mostrar donació DonationPromise=Promesa de donació PromisesNotValid=Promeses no validades PromisesValid=Promeses validades @@ -24,5 +25,9 @@ DonationStatusPaidShort=Pagada ValidPromess=Validar promesa BuildDonationReceipt=Crear rebut DonationsModels=Model de document de recepció de donació -LastModifiedDonations=Less %s últimes donacions modificades -SearchADonation=Cercar una donació \ No newline at end of file +LastModifiedDonations=Les %s últimes donacions modificades +SearchADonation=Cercar una donació +DonationReceipt=Rebut de donació +DonationRecipient=Beneficiari +IConfirmDonationReception=El beneficiari confirma la recepció, com a donació, de la següent quantitat +ThankYou=Moltes gràcies diff --git a/htdocs/langs/ca_ES/externalsite.lang b/htdocs/langs/ca_ES/externalsite.lang index 5b331a8b023..e0e8f487817 100644 --- a/htdocs/langs/ca_ES/externalsite.lang +++ b/htdocs/langs/ca_ES/externalsite.lang @@ -1,4 +1,4 @@ -# Dolibarr language file - es_ES - externalsite +# Dolibarr language file - ca_ES - externalsite CHARSET=UTF-8 ExternalSiteSetup=Configuració de l'enllaç al lloc web extern ExternalSiteURL=URL del lloc extern From 25e970757e853d270537049ca64a3e219eee1e8d Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:18:06 +0200 Subject: [PATCH 07/15] Trad: Update ca_ES paypal.lang --- htdocs/langs/ca_ES/paypal.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/ca_ES/paypal.lang b/htdocs/langs/ca_ES/paypal.lang index 041833621ca..88b659fb175 100644 --- a/htdocs/langs/ca_ES/paypal.lang +++ b/htdocs/langs/ca_ES/paypal.lang @@ -10,8 +10,8 @@ PAYPAL_API_USER=Nom usuari API PAYPAL_API_PASSWORD=Contrasenya usuari API PAYPAL_API_SIGNATURE=Signatura API PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Proposar pagament integral (Targeta+Paypal) o només Paypal -# PaypalModeIntegral=Integral -# PaypalModeOnlyPaypal=PayPal only +PaypalModeIntegral=Integral +PaypalModeOnlyPaypal=Només PayPal PAYPAL_CSS_URL=Url opcional del full d'estil CSS de la pàgina de pagament ThisIsTransactionId=Identificador de la transacció: %s PAYPAL_ADD_PAYMENT_URL=Afegir la url del pagament Paypal en enviar un document per e-mail From 7eecf88c8cee33da68298d4179a48cbc9f091168 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:21:22 +0200 Subject: [PATCH 08/15] Trad: Update ca_ES ftp.lang --- htdocs/langs/ca_ES/ftp.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/ca_ES/ftp.lang b/htdocs/langs/ca_ES/ftp.lang index 5057fb93b64..80f17c93a15 100644 --- a/htdocs/langs/ca_ES/ftp.lang +++ b/htdocs/langs/ca_ES/ftp.lang @@ -9,4 +9,5 @@ FTPFeatureNotSupportedByYourPHP=El seu PHP no suporta les funcions FTP FailedToConnectToFTPServer=No s'ha pogut connectar amb el servidor FTP (servidor: %s, port %s) FailedToConnectToFTPServerWithCredentials=No s'ha pogut connectar amb el login/contrasenya FTP configurats FTPFailedToRemoveFile=No s'ha pogut suprimir el fitxer %s. -FTPFailedToRemoveDir=No s'ha pogut suprimir la carpeta %s (Comproveu els permisos i que el directori està buit). \ No newline at end of file +FTPFailedToRemoveDir=No s'ha pogut suprimir la carpeta %s (Comproveu els permisos i que el directori està buit). +FTPPassiveMode=Mode passiu From f0445cd7a0d810b18a8970680d9e144d868b46e4 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:23:41 +0200 Subject: [PATCH 09/15] Trad: Update ca_ES languages.lang --- htdocs/langs/ca_ES/languages.lang | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/ca_ES/languages.lang b/htdocs/langs/ca_ES/languages.lang index 8a81803a2cf..0d06ed0d78a 100644 --- a/htdocs/langs/ca_ES/languages.lang +++ b/htdocs/langs/ca_ES/languages.lang @@ -2,6 +2,7 @@ CHARSET=UTF-8 Language_ar_AR=Àrab Language_ar_SA=Àrab +Language_bg_BG=Búlgar Language_ca_ES=Català Language_da_DA=Danès Language_da_DK=Danès @@ -27,6 +28,7 @@ Language_fr_BE=Francès (Bèlgica) Language_fr_CA=Francès (Canadà) Language_fr_CH=Francès (Suïssa) Language_fr_FR=Francès +Language_he_IL=Hebreu Language_hu_HU=Hongarès Language_is_IS=Islandès Language_it_IT=Italià @@ -45,4 +47,4 @@ Language_sl_SI=Eslovè Language_sv_SV=Suec Language_sv_SE=Suec Language_zh_CN=Xinès -Language_zh_TW=Xinès (Tradicional) \ No newline at end of file +Language_zh_TW=Xinès (Tradicional) From b54fc29a079c7fa8b1055bded01581251a115781 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:25:55 +0200 Subject: [PATCH 10/15] Trad: Update ca_ES suppliers.lang --- htdocs/langs/ca_ES/suppliers.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/ca_ES/suppliers.lang b/htdocs/langs/ca_ES/suppliers.lang index d7e2dd1fd28..541ae6200b1 100644 --- a/htdocs/langs/ca_ES/suppliers.lang +++ b/htdocs/langs/ca_ES/suppliers.lang @@ -26,7 +26,7 @@ RefSupplierShort=Ref. proveïdor Availability=Disponibilitat ExportDataset_fournisseur_1=Factures de proveïdors i línies de factura ExportDataset_fournisseur_2=Factures proveïdors i pagaments -# ExportDataset_fournisseur_3=Supplier orders and order lines +ExportDataset_fournisseur_3=Comandes de proveïdors i línies de comanda ApproveThisOrder=Aprovar aquesta comanda ConfirmApproveThisOrder=Esteu segur de voler aprovar la comanda a proveïdor %s? DenyingThisOrder=Denegar aquesta comanda From 1b1f44edbb7249fb604ba52fc15874fb560e2afc Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:27:48 +0200 Subject: [PATCH 11/15] Trad: Update ca_ES commercial.lang --- htdocs/langs/ca_ES/commercial.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/ca_ES/commercial.lang b/htdocs/langs/ca_ES/commercial.lang index dc796ad2bef..f40ef35e89d 100644 --- a/htdocs/langs/ca_ES/commercial.lang +++ b/htdocs/langs/ca_ES/commercial.lang @@ -81,7 +81,7 @@ ActionAC_SHIP=Enviament expedició per correu ActionAC_SUP_ORD=Enviament comanda a proveïdor per correu ActionAC_SUP_INV=Enviament factura de proveïdor per correu ActionAC_OTH=Altra -# ActionAC_OTH_AUTO=Other (automatically inserted events) +ActionAC_OTH_AUTO=Altra (esdeveniments inserits automàticament) ActionAC_MANUAL=Esdeveniments creats manualment ActionAC_AUTO=Esdeveniments creats automàticament Stats=Estadístiques de venda From 2ae3af7851e63ef221e22dc14ef900219a0541a7 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:29:30 +0200 Subject: [PATCH 12/15] Trad: Update ca_ES other.lang --- htdocs/langs/ca_ES/other.lang | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/ca_ES/other.lang b/htdocs/langs/ca_ES/other.lang index e749fd0ba2c..4c6902cdf78 100644 --- a/htdocs/langs/ca_ES/other.lang +++ b/htdocs/langs/ca_ES/other.lang @@ -8,8 +8,8 @@ ToolsDesc=Aquesta àrea està dedicada al reagrupament de diverses utilitats no Birthday=Aniversari BirthdayDate=Data aniversari DateToBirth=Data de naiximent -BirthdayAlertOn= alerta aniversari activada -BirthdayAlertOff= alerta aniversari desactivada +BirthdayAlertOn=alerta aniversari activada +BirthdayAlertOff=alerta aniversari desactivada Notify_FICHINTER_VALIDATE=Validació fitxa intervenció Notify_FICHINTER_SENTBYMAIL=Enviament fitxa intervenció per e-mail Notify_BILL_VALIDATE=Validació factura @@ -24,7 +24,6 @@ Notify_WITHDRAW_EMIT=Emissió domiciliació Notify_ORDER_SENTBYMAIL=Enviament comanda de client per e-mail Notify_COMPANY_CREATE=Creació tercer Notify_PROPAL_SENTBYMAIL=Enviament pressupost per e-mail -Notify_ORDER_SENTBYMAIL=Enviament comanda de client per e-mail Notify_BILL_PAYED=Cobrament factura a client Notify_BILL_CANCEL=Cancel·lació factura a client Notify_BILL_SENTBYMAIL=Enviament factura a client per e-mail @@ -152,7 +151,7 @@ EMailTextOrderApproved=Comanda %s aprovada EMailTextOrderApprovedBy=Comanda %s aprovada per %s EMailTextOrderRefused=Comanda %s rebutjada EMailTextOrderRefusedBy=Comanda %s rebutjada per %s -# EMailTextExpeditionValidated=The shipping %s has been validated. +EMailTextExpeditionValidated=L'enviament %s ha estat validat. ImportedWithSet=Lot d'importació (import key) DolibarrNotification=Notificació automàtica ResizeDesc=Introduïu l'ample O la nova alçada. La relació es conserva en canviar la mida... @@ -174,7 +173,6 @@ StartUpload=Transferir CancelUpload=Cancel·lar transferència FileIsTooBig=L'arxiu és massa gran PleaseBePatient=Preguem esperi uns instants... - ##### Calendar common ##### AddCalendarEntry=Afegir entrada al calendari NewCompanyToDolibarr=Empresa %s inserida en Dolibarr From 23be083637374a362528f1c1f0eb220d715c8c0f Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:31:40 +0200 Subject: [PATCH 13/15] Trad: Update ca_ES exports.lang --- htdocs/langs/ca_ES/exports.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/ca_ES/exports.lang b/htdocs/langs/ca_ES/exports.lang index 11f2499b342..23ed584b3aa 100644 --- a/htdocs/langs/ca_ES/exports.lang +++ b/htdocs/langs/ca_ES/exports.lang @@ -125,7 +125,7 @@ DeskCode=Codi oficina BankAccountNumber=Número compte BankAccountNumberKey=Dígit Control ## filters -# SelectFilterFields=If you want to filter on some values, just input values here. +SelectFilterFields=Si vol aplicar un filtre sobre alguns valors, introduïu-los aquí. FilterableFields=Camps filtrables FilteredFields=Campos filtrats FilteredFieldsValues=Valors de filtres From ee107a64b4226a634e3de5fc35586d1506859693 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 9 Aug 2013 15:33:31 +0200 Subject: [PATCH 14/15] Trad: Update ca_ES dict.lang --- htdocs/langs/ca_ES/dict.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/ca_ES/dict.lang b/htdocs/langs/ca_ES/dict.lang index 0ab12a2e38c..225dc9f6280 100644 --- a/htdocs/langs/ca_ES/dict.lang +++ b/htdocs/langs/ca_ES/dict.lang @@ -1,4 +1,4 @@ -# Dolibarr language file - ca_ES - dict +# Dolibarr language file - ca_ES - dict CHARSET=UTF-8 CountryFR=França CountryBE=Bèlgica @@ -246,13 +246,13 @@ CountryJE=Jersey CountryME=Monténégro CountryBL=Saint-Barthélemy CountryMF=Saint-Martin -##### Civilities ##### +##### Civilities #####=undefined CivilityMME=Senyora CivilityMR=Senyor CivilityMLE=Senyoreta CivilityMTRE=En CivilityDR=Doctor -##### Currencies ##### +##### Currencies #####=undefined Currencyeuros=Euros CurrencyAUD=Dòlars Aus. CurrencySingAUD=Dòlar Aus. @@ -294,7 +294,7 @@ CurrencyXPF=Francs CFP CurrencySingXPF=Franc CFP CurrencyCentSingEUR=cèntim CurrencyThousandthSingTND=mil·lèsim -#### Input reasons ####= +#### Input reasons #### DemandReasonTypeSRC_INTE=Internet DemandReasonTypeSRC_CAMP_MAIL=Campanya correu DemandReasonTypeSRC_CAMP_EMAIL=Campanya E-Mailing @@ -306,7 +306,7 @@ DemandReasonTypeSRC_WOM=Boca a boca DemandReasonTypeSRC_PARTNER=Soci DemandReasonTypeSRC_EMPLOYEE=Empleat DemandReasonTypeSRC_SPONSORING=Patrocinador -#### Paper formats ####= +#### Paper formats #### PaperFormatEU4A0=Format 4A0 PaperFormatEU2A0=Format 2A0 PaperFormatEUA0=Format A0 @@ -317,7 +317,7 @@ PaperFormatEUA4=Format A4 PaperFormatEUA5=Format A5 PaperFormatEUA6=Format A6 PaperFormatUSLETTER=Format carta EE. UU. -PaperFormatUSLEGAL= +PaperFormatUSLEGAL=Format legal EE. UU. PaperFormatUSEXECUTIVE=Format executiu EE. UU. PaperFormatUSLEDGER=Format tabloide PaperFormatCAP1=Format canadec P1 From 59c1f54d689cd3b57289dbfad47515498a940b00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Aug 2013 19:19:48 +0200 Subject: [PATCH 15/15] New: Enhance DolGraph class for pie charts. --- .../comm/propal/class/propalestats.class.php | 1 + htdocs/commande/class/commandestats.class.php | 1 + .../facture/class/facturestats.class.php | 1 + .../boxes/box_graph_product_distribution.php | 38 +++++++++-- htdocs/core/class/dolgraph.class.php | 67 ++++++++++++++++--- 5 files changed, 92 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 1b1b5d2e045..f8eecb486ad 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -200,6 +200,7 @@ class PropaleStats extends Stats //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; + $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,1,false))."' AND '".$this->db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb','DESC'); $sql.= $this->db->plimit(20); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index a1c976db6a5..930c6ca4587 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -209,6 +209,7 @@ class CommandeStats extends Stats //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; + $sql.= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year,1,false))."' AND '".$this->db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb','DESC'); $sql.= $this->db->plimit(20); diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 7f33f66fd8b..a402f2a70c4 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -209,6 +209,7 @@ class FactureStats extends Stats //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; + $sql.= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year,1,false))."' AND '".$this->db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb','DESC'); $sql.= $this->db->plimit(20); diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index c92b9100e1f..9311832d3be 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -112,9 +112,14 @@ class box_graph_product_distribution extends ModeleBoxes { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; + $showpointvalue = 1; $stats_invoice = new FactureStats($this->db, 0, $mode, ($userid>0?$userid:0)); $data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); - + if (empty($data1)) + { + $showpointvalue=0; + $data1=array(array(0=>$langs->trans("None"),1=>1)); + } $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; @@ -125,13 +130,16 @@ class box_graph_product_distribution extends ModeleBoxes $px1->SetData($data1); unset($data1); $px1->SetPrecisionY(0); - $i=0;$tot=count($data2);$legend=array(); + $i=0;$tot=count($data1);$legend=array(); while ($i <= $tot) { - $legend[]=$data2[$i][0]; + $legend[]=$data1[$i][0]; $i++; } $px1->SetLegend($legend); + $px1->setShowLegend(0); + $px1->setShowPointValue($showpointvalue); + $px1->setShowPercent(0); $px1->SetMaxValue($px1->GetCeilMaxValue()); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); @@ -143,7 +151,7 @@ class box_graph_product_distribution extends ModeleBoxes //$px1->mode='depth'; $px1->SetType(array('pie')); $px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices"))); - + $px1->draw($filenamenb,$fileurlnb); } } @@ -156,9 +164,15 @@ class box_graph_product_distribution extends ModeleBoxes { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; + $showpointvalue = 1; $stats_proposal = new PropaleStats($this->db, 0, $mode, ($userid>0?$userid:0)); $data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); - + if (empty($data2)) + { + $showpointvalue = 0; + $data2=array(array(0=>$langs->trans("None"),1=>1)); + } + $filenamenb = $dir."/prodserforpropal-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=proposalstats&file=prodserforpropal-'.$year.'.png'; @@ -176,6 +190,9 @@ class box_graph_product_distribution extends ModeleBoxes $i++; } $px2->SetLegend($legend); + $px2->setShowLegend(0); + $px2->setShowPointValue($showpointvalue); + $px2->setShowPercent(0); $px2->SetMaxValue($px2->GetCeilMaxValue()); $px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); @@ -200,9 +217,15 @@ class box_graph_product_distribution extends ModeleBoxes { include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; + $showpointvalue = 1; $stats_order = new CommandeStats($this->db, 0, $mode, ($userid>0?$userid:0)); $data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24))); - + if (empty($data3)) + { + $showpointvalue = 0; + $data3=array(array(0=>$langs->trans("None"),1=>1)); + } + $filenamenb = $dir."/prodserfororder-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=prodserfororder-'.$year.'.png'; @@ -220,6 +243,9 @@ class box_graph_product_distribution extends ModeleBoxes $i++; } $px3->SetLegend($legend); + $px3->setShowLegend(0); + $px3->setShowPointValue($showpointvalue); + $px3->setShowPercent(0); $px3->SetMaxValue($px3->GetCeilMaxValue()); $px3->SetWidth($WIDTH); $px3->SetHeight($HEIGHT); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 9c6cc5b424e..54ec78a8287 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -68,7 +68,10 @@ class DolGraph var $Legend=array(); var $LegendWidthMin=0; - + var $showlegend=1; + var $showpointvalue=1; + var $showpercent=0; + var $graph; // Objet Graph (Artichow, Phplot...) var $error; @@ -234,6 +237,7 @@ class DolGraph * * @param array $data Data * @return void + * @see draw_jflot for syntax of data array */ function SetData($data) { @@ -379,7 +383,41 @@ class DolGraph return $this->error; } + /** + * Show legend or not + * + * @param int $showlegend 1=Show legend (default), 0=Hide legend + * @return void + */ + function setShowLegend($showlegend) + { + $this->showlegend=$showlegend; + } + /** + * Show pointvalue or not + * + * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value + * @return void + */ + function setShowPointValue($showpointvalue) + { + $this->showpointvalue=$showpointvalue; + } + + /** + * Show percent or not + * + * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) + * @return void + */ + function setShowPercent($showpercent) + { + $this->showpercent=$showpercent; + } + + + /** * Define background color of complete image * @@ -766,14 +804,13 @@ class DolGraph // Works with line but not with bars //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x - $i=$firstlot; $serie=array(); while ($i < $nblot) // Loop on each serie { $values=array(); // Array with horizontal y values (specific values of a serie) for each abscisse x $serie[$i]="var d".$i." = [];\n"; - + // Fill array $values $x=0; foreach($this->data as $valarray) // Loop on each x @@ -816,7 +853,12 @@ class DolGraph { $datacolor=array(); foreach($this->datacolor as $val) $datacolor[]="#".sprintf("%02x%02x%02x",$val[0],$val[1],$val[2]); - + + $urltemp=''; // TODO Add support for url link into labels + $showlegend=$this->showlegend; + $showpointvalue=$this->showpointvalue; + $showpercent=$this->showpercent; + $this->_stringtoshow.= ' function plotWithOptions_'.$tag.'() { $.plot($("#placeholder_'.$tag.'"), d0, @@ -833,11 +875,13 @@ class DolGraph var number=series.data[0][1]; return \''; $this->_stringtoshow.='
'; - if ($url) $this->_stringtoshow.=''; - $this->_stringtoshow.='\'+'.($showlegend?'number':'label+\'
\'+number'); - if (! empty($showpercent)) $this->_stringtoshow.='+\'
\'+percent+\'%\''; - $this->_stringtoshow.='+\''; - if ($url) $this->_stringtoshow.='
'; + if ($urltemp) $this->_stringtoshow.=''; + $this->_stringtoshow.='\'+'; + $this->_stringtoshow.=($showlegend?'':'label+\'
\'+'); // Hide label if already shown in legend + $this->_stringtoshow.=($showpointvalue?'number+':''); + $this->_stringtoshow.=($showpercent?'\'
\'+percent+\'%\'+':''); + $this->_stringtoshow.='\''; + if ($urltemp) $this->_stringtoshow.='
'; $this->_stringtoshow.='
\'; }, background: { @@ -894,9 +938,12 @@ class DolGraph var x = item.datapoint[0].toFixed(2); var y = item.datapoint[1].toFixed(2); var z = item.series.xaxis.ticks[item.dataIndex].label; - + '; + if ($this->showpointvalue > 0) $this->_stringtoshow.=' showTooltip_'.$tag.'(item.pageX, item.pageY, item.series.label + "
" + z + " => " + y); + '; + $this->_stringtoshow.=' } } else {