From 4a1dfa60a5e662dcc3c49808d75d0a36ee11d0c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2015 13:14:19 +0200 Subject: [PATCH 1/5] Uniformize code --- htdocs/comm/askpricesupplier/list.php | 16 +++--- htdocs/comm/list.php | 2 +- htdocs/comm/mailing/cibles.php | 4 +- htdocs/comm/propal/list.php | 7 +-- htdocs/comm/prospect/list.php | 11 ++-- htdocs/commande/list.php | 41 +++++--------- htdocs/compta/facture/fiche-rec.php | 30 ++++++----- htdocs/contact/list.php | 2 +- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +-- htdocs/expedition/list.php | 5 +- htdocs/expensereport/list.php | 7 ++- htdocs/fichinter/list.php | 5 +- htdocs/fourn/commande/list.php | 4 +- htdocs/fourn/facture/list.php | 4 +- htdocs/fourn/list.php | 2 +- htdocs/holiday/list.php | 5 +- htdocs/product/list.php | 7 +-- htdocs/product/stock/card.php | 8 ++- htdocs/product/stock/list.php | 63 ++++++++++++++++------ htdocs/product/stock/mouvement.php | 8 +-- htdocs/projet/list.php | 4 +- htdocs/societe/list.php | 9 +++- htdocs/societe/rib.php | 2 +- htdocs/theme/eldy/style.css.php | 4 +- htdocs/user/index.php | 2 +- 26 files changed, 151 insertions(+), 109 deletions(-) diff --git a/htdocs/comm/askpricesupplier/list.php b/htdocs/comm/askpricesupplier/list.php index bce521489e0..2e78045b308 100644 --- a/htdocs/comm/askpricesupplier/list.php +++ b/htdocs/comm/askpricesupplier/list.php @@ -270,22 +270,22 @@ if ($result) print ''; print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AskPriceSupplierDate'),$_SERVER["PHP_SELF"],'p.date_livraison','',$param, 'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - + // Date print ''; //print $langs->trans('Month').': '; @@ -294,7 +294,7 @@ if ($result) $syear = $year; $formother->select_year($syear,'year',1, 20, 5); print ''; - + // Amount print ''; print ''; @@ -353,7 +353,7 @@ if ($result) print ''; print "\n"; - + $url = DOL_URL_ROOT.'/comm/card.php?socid='.$objp->rowid; // Company @@ -364,12 +364,12 @@ if ($result) print ''; print $companystatic->getNomUrl(1,'customer'); print ''; - + // Date askprice print ''; print dol_print_date($db->jdate($objp->dp), 'day'); print "\n"; - + print ''.price($objp->total_ht)."\n"; $userstatic->id=$objp->fk_user_author; diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index 43c2f4155fc..126ffc5f470 100644 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -205,7 +205,7 @@ if ($result) $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 6958821a05f..5e2aa787dba 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -420,7 +420,7 @@ if ($object->fetch($id) >= 0) } print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print ''; @@ -459,7 +459,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print '  '; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index c8e96919f84..36484d718c7 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -9,8 +9,8 @@ * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015 Jean-François Ferry -* + * Copyright (C) 2015 Jean-François Ferry + * * 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 @@ -255,6 +255,7 @@ if ($result) if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_author) $param.='&search_author='.$search_author; if ($search_town) $param.='&search_town='.$search_town; + print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_commercial.png'); // Lignes des champs de filtre @@ -310,7 +311,7 @@ if ($result) print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 5f841b609da..70847f479c3 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -351,9 +351,8 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); - + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; @@ -416,7 +415,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print ''; + print ''; print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); print ''; @@ -474,8 +473,8 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print ''; - print $prospectstatic->LibStatut($prospectstatic->status,3); + print ''; + print $prospectstatic->LibStatut($prospectstatic->status,5); print ''; print ''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 351a4171dd6..1b3f8432b52 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -130,13 +130,8 @@ $sql.= ' WHERE c.fk_soc = s.rowid'; $sql.= ' AND c.entity IN ('.getEntity('commande', 1).')'; if ($socid) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_ref) { - $sql .= natural_search('c.ref', $search_ref); -} -if ($sall) -{ - $sql .= natural_search(array('c.ref', 'c.note_private'), $sall); -} +if ($search_ref) $sql .= natural_search('c.ref', $search_ref); +if ($sall) $sql .= natural_search(array('c.ref', 'c.note_private'), $sall); if ($viewstatut <> '') { if ($viewstatut < 4 && $viewstatut > -3) @@ -190,24 +185,12 @@ else if ($deliveryyear > 0) { $sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_get_first_day($deliveryyear,1,false))."' AND '".$db->idate(dol_get_last_day($deliveryyear,12,false))."'"; } -if (!empty($search_company)) -{ - $sql .= natural_search('s.nom', $search_company); -} -if (!empty($search_ref_customer)) -{ - $sql.= ' AND c.ref_client LIKE \'%'.$db->escape($search_ref_customer).'%\''; -} +if (!empty($search_company)) $sql .= natural_search('s.nom', $search_company); +if (!empty($search_ref_customer)) $sql.= natural_search('c.ref_client', $search_ref_customer); if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) -{ - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; -} -if ($search_total_ht != '') -{ - $sql.= natural_search('c.total_ht', $search_total_ht, 1); -} -$sql.= ' ORDER BY '.$sortfield.' '.$sortorder; +if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); +$sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -216,7 +199,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($limit + 1,$offset); //print $sql; @@ -291,7 +273,7 @@ if ($resql) if (! empty($moreforfilter)) { print ''; - print ''; + print ''; print $moreforfilter; print ''; } @@ -304,6 +286,7 @@ if ($resql) print_liste_field_titre($langs->trans('DeliveryDate'),$_SERVER["PHP_SELF"],'c.date_livraison','',$param, 'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'c.total_ht','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'c.fk_statut','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print ''; print ''; @@ -328,6 +311,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print ''; print ''; print "\n"; @@ -493,6 +477,8 @@ if ($resql) // Statut print ''.$generic_commande->LibStatut($objp->fk_statut,$objp->facturee,5).''; + print ''; + print ''; $total+=$objp->total_ht; @@ -507,7 +493,8 @@ if ($resql) print ''.$langs->trans('TotalHT').''; // Total HT print ''.price($total).''; - print ' '; + print ''; + print ''; print ''; } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index bcb7d44559c..aab2e0b18d5 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Juanjo Menent @@ -129,7 +129,7 @@ if ($action == 'create') print ''; print ''; print ''; - + dol_fiche_head(); $rowspan=4; @@ -202,7 +202,7 @@ if ($action == 'create') $sql = 'SELECT l.fk_product, l.product_type, l.label as custom_label, l.description, l.qty, l.rowid, l.tva_tx,'; $sql.= ' l.fk_remise_except,'; $sql.= ' l.remise_percent, l.subprice, l.info_bits,'; - $sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.total_ht, l.total_tva as total_vat, l.total_ttc,'; $sql.= ' l.date_start,'; $sql.= ' l.date_end,'; $sql.= ' l.product_type,'; @@ -220,7 +220,7 @@ if ($action == 'create') $num = $db->num_rows($result); $i = 0; $total = 0; - echo ''; + echo '
'; if ($num) { print ''; @@ -572,7 +572,7 @@ else /* * List mode */ - $sql = "SELECT s.nom as name, s.rowid as socid, f.titre, f.total, f.rowid as facid"; + $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; @@ -594,8 +594,10 @@ else print ''; print_liste_field_titre($langs->trans("Ref")); print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"s.nom","","&socid=$socid","",$sortfiled,$sortorder); - print_liste_field_titre($langs->trans("Amount"),'','','','','align="right"'); - print_liste_field_titre(''); + print_liste_field_titre($langs->trans("AmountHT"),'','','','','align="right"'); + print_liste_field_titre($langs->trans("AmountVAT"),'','','','','align="right"'); + print_liste_field_titre($langs->trans("AmountTTC"),'','','','','align="right"'); + print_liste_field_titre(''); // Field may contains ling text print "\n"; if ($num > 0) @@ -616,19 +618,21 @@ else print ''; print ''."\n"; + print ''."\n"; + print ''."\n"; - echo '\n"; + print ""; + print "\n"; $i++; } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index a564bafc4a9..c6ac982e348 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -311,7 +311,7 @@ if ($result) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"p.tms", $begin, $param, 'align="center"', $sortfield,$sortorder); print_liste_field_titre($langs->trans("ContactVisibility"),$_SERVER["PHP_SELF"],"p.priv", $begin, $param, 'align="center"', $sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut", $begin, $param, 'align="center"', $sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Lines for filter fields diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 7f0e27ac27d..74a2440ca1c 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -876,7 +876,7 @@ class FormOther $min_year = $currentyear-$min_year; if(empty($selected) && empty($useempty)) $selected = $currentyear; - $out.= ''; if($useempty) { $selected_html=''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ff3c968a1d6..0e86a1b6163 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2639,7 +2639,7 @@ function dol_print_error_email($prefixcode) * @param string $td Options of attribute td ("" by defaut, example: 'align="center"') * @param string $sortfield Current field used to sort * @param string $sortorder Current sort order - * @param string $prefix Prefix for css + * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag. * @return void */ function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="", $prefix="") @@ -2659,7 +2659,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar * @param string $moreattrib Add more attributes on th ("" by defaut) * @param string $sortfield Current field used to sort * @param string $sortorder Current sort order - * @param string $prefix Prefix for css + * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag. * @return string */ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="") @@ -2675,7 +2675,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m // If field is used as sort criteria we use a specific class // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") - if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="liste_titre_sel" '. $moreattrib.'>'; + if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; else $out.= '<'.$tag.' class="'.$prefix.'liste_titre" '. $moreattrib.'>'; if (! empty($conf->dol_optimize_smallscreen) && empty($thead) && $field) // If this is a sort field diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 45f59975ee0..aa629955f53 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -133,7 +133,7 @@ if ($resql) print_liste_field_titre($langs->trans("DateReceived"), $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder); } print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Lignes des champs de filtre @@ -158,7 +158,8 @@ if ($resql) // Status print ''; // Search - print ''; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index c0b30b6c873..ef7b8d5311a 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -191,7 +191,7 @@ if ($resql) print_liste_field_titre($langs->trans("TotalVAT"),$_SERVER["PHP_SELF"],"d.total_tva","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("TotalTTC"),$_SERVER["PHP_SELF"],"d.total_ttc","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Statut"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Filters @@ -263,10 +263,13 @@ if ($resql) print ''; $expensereporttmp->status=$objp->status; - print ''; + + print ''; + print "\n"; $total_total_ht = $total_total_ht + $objp->total_ht; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 367af084cde..0e9a5a8c4e0 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -145,7 +145,7 @@ if ($result) print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],"fd.duree","",$urlparam,'align="right"',$sortfield,$sortorder); } print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$urlparam,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; @@ -224,6 +224,7 @@ else dol_print_error($db); } -$db->close(); llxFooter(); + +$db->close(); \ No newline at end of file diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index d73fa983e1c..c21830e66e8 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García @@ -200,7 +200,7 @@ if ($resql) print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"dc","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('DateDeliveryPlanned'),$_SERVER["PHP_SELF"],'cf.date_livraison','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cf.fk_statut","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 5fe72b44328..d93f1c4beea 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2015 juanjo Menent * Copyright (C) 2015 Abbes Bahfir * Copyright (C) 2015 Ferran Marcet - * + * * 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 @@ -264,7 +264,7 @@ if ($resql) print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"fac.total_ht","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"fac.total_ttc","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Line for filters diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php index 692671fba31..3333ffefba2 100644 --- a/htdocs/fourn/list.php +++ b/htdocs/fourn/list.php @@ -202,7 +202,7 @@ if ($resql) print $hookmanager->resPrint; print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 8e2e04019ce..f5d67b13517 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -276,7 +276,7 @@ print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],'','','', print_liste_field_titre($langs->trans("DateDebCP"),$_SERVER["PHP_SELF"],"cp.date_debut","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateFinCP"),$_SERVER["PHP_SELF"],"cp.date_fin","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="center"',$sortfield,$sortorder); -print_liste_field_titre(''); +print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // FILTRES @@ -395,7 +395,8 @@ if (! empty($holiday->holiday)) print ''; print ''; print ''; - print ''; + print ''; + print ''; print ''."\n"; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index c7e0da02de3..77e8373d2a7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -324,7 +324,7 @@ else if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) print ''; print_liste_field_titre($langs->trans("Sell"), $_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Buy"), $_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Lignes des champs de filtre @@ -381,11 +381,11 @@ else print ''; } - print ''; - print ''; @@ -393,6 +393,7 @@ else print ''; print ''; print ''; + print ''; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index df4c8b9d054..22ed390bc8f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -518,6 +518,10 @@ else print ''; print ''; + $head = stock_prepare_head($object); + + dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); + print '
'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''; - + print ''; if ($user->rights->facture->creer) { - echo ''; - echo $langs->trans("CreateBill"),''; + print ''; + print $langs->trans("CreateBill").''; } else { - echo " "; + print " "; } - echo "
'; + print ''; + print ''; print ''; print '
'.price($objp->total_ttc).''; + print ''; //print $objp->status; print $expensereporttmp->getLibStatut(5); print '
'.dol_print_date($infos_CP['date_debut'],'day').''.dol_print_date($infos_CP['date_fin'],'day').''.$holidaystatic->LibStatut($infos_CP['statut'],5).''.$holidaystatic->LibStatut($infos_CP['statut'],5).'
'.$langs->trans("PhysicalStock").'
'; + print ''; print $form->selectarray('tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$tosell,1); print ''; + print ''; print $form->selectarray('tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$tobuy,1); print '
'; // Ref @@ -559,7 +563,9 @@ else print '
'; - print '
'; + dol_fiche_end(); + + print '
'; print ''; print '     '; print ''; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 225a33a9483..2c48b4587a0 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -31,9 +31,10 @@ $langs->load("stocks"); // Security check $result=restrictedArea($user,'stock'); -$sref=GETPOST("sref","alpha"); -$snom=GETPOST("snom","alpha"); +$search_ref=GETPOST("sref","alpha")?GETPOST("sref","alpha"):GETPOST("search_ref","alpha"); +$search_label=GETPOST("snom","alpha")?GETPOST("snom","alpha"):GETPOST("search_label","alpha"); $sall=GETPOST("sall","alpha"); +$search_status=GETPOST("search_status","int"); $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); @@ -52,6 +53,7 @@ $year = strftime("%Y",time()); */ $form=new Form($db); +$warehouse=new Entrepot($db); $sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,"; $sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; @@ -59,22 +61,14 @@ $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql.= " WHERE e.entity IN (".getEntity('stock', 1).")"; -if ($sref) -{ - $sql.= " AND e.label LIKE '%".$db->escape($sref)."%'"; -} -if ($sall) -{ - $sql.= " AND (e.label LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.description LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.address LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.town LIKE '%".$db->escape($sall)."%')"; -} +if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref +if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label +if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; +if ($sall) $sql.= natural_search(array('e.label','e.description','e.lieu','e.address','e.town'), $sall); $sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); - +print $sql; $result = $db->query($sql); if ($result) { @@ -87,6 +81,12 @@ if ($result) print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder,'',$num); + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; print ""; @@ -95,8 +95,34 @@ if ($result) print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'','','align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; + // Lignes des champs de filtre + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + if ($num) { $entrepot=new Entrepot($db); @@ -128,6 +154,9 @@ if ($result) print ''; // Status print ''; + + print ''; + print "\n"; $total += price2num($objp->estimatedvalue,'MU'); @@ -148,7 +177,8 @@ if ($result) print $form->textwithtooltip($langs->trans("Variable"),$htmltext); } print ''; - print ''; + print ''; + print ''; print "\n"; } @@ -156,6 +186,7 @@ if ($result) print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); + print ''; + print ''; + print ''; + print '
'.$entrepot->LibStatut($objp->statut,5).'
 
"; + print '
'; } else { diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 82c8ded066f..a556798cdd1 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -501,12 +501,12 @@ if ($resql) print ''; print ''; - print $langs->trans('Month').': '; + print ''; if (empty($conf->productbatch->enabled)) print ' '; - else print '
'; - print $langs->trans('Year').': '; + //else print '
'; $syear = $year?$year:-1; - $formother->select_year($syear,'year',1, 20, 5); + print ''; + //print $formother->selectyear($syear,'year',1, 20, 5); print ''; // Product Ref print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 489f85f7405..abe0a5858fc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -281,7 +281,7 @@ if ($resql) if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print_liste_field_titre($langs->trans("OpportunityStatus"),$_SERVER["PHP_SELF"],'p.fk_opp_statut',"",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; @@ -331,7 +331,7 @@ if ($resql) print ''; print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('Draft'),'1'=>$langs->trans('Opened'),'2'=>$langs->trans('Closed')),$search_status); print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 1019e7ee167..281746fe824 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -337,6 +337,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Fields title search @@ -390,11 +391,13 @@ if ($resql) print $hookmanager->resPrint; // Status + print ''; + print ''; print ''; - print '  '; print ''; print ''; + print "\n"; $var=True; @@ -452,7 +455,9 @@ if ($resql) print $hookmanager->resPrint; // Status - print ''.$companystatic->getLibStatut(3).''; + print ''.$companystatic->getLibStatut(5).''; + + print ''; print ''."\n"; $i++; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 4bf13f0b390..57ca545a053 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -377,7 +377,7 @@ if ($socid && $action != 'edit' && $action != "create") print ''.$langs->trans("WithdrawMode").''; } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; foreach ($rib_list as $rib) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 00f137252e2..ba094124462 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -404,7 +404,9 @@ th .button { -webkit-border-radius:0px !important; border-radius:0px !important; } - +.maxwidthsearch { /* Max width of column with the search picto */ + width: 54px; +} .valignmiddle { vertical-align: middle; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 80a5c52a232..a6c845ee69f 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -139,7 +139,7 @@ if ($result) print_liste_field_titre($langs->trans("LastConnexion"),$_SERVER['PHP_SELF'],"u.datelastlogin",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("HierarchicalResponsible"),$_SERVER['PHP_SELF'],"u2.login",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER['PHP_SELF'],"u.statut",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Search bar From a29ca4394381694fb1c6b29567d2a55e2c5ade4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2015 14:32:17 +0200 Subject: [PATCH 2/5] Prepare merge of merge tools and invoice list --- htdocs/compta/facture/list.php | 46 +-- htdocs/compta/facture/mergepdftool.php | 10 +- htdocs/compta/paiement.php | 6 +- htdocs/compta/paiement/list.php | 43 ++- htdocs/core/menus/standard/eldy.lib.php | 1 + htdocs/langs/en_US/projects.lang | 2 + htdocs/projet/class/projectstats.class.php | 327 ++++++++++++++++++ htdocs/projet/stats/index.php | 367 +++++++++++++++++++++ 8 files changed, 755 insertions(+), 47 deletions(-) create mode 100644 htdocs/projet/class/projectstats.class.php create mode 100644 htdocs/projet/stats/index.php diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 18f5fe4db34..a38049ae10f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -180,30 +180,12 @@ if ($filtre) $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); } } -if ($search_ref) -{ - $sql .= natural_search('f.facnumber', $search_ref); -} -if ($search_refcustomer) -{ - $sql .= natural_search('f.ref_client', $search_refcustomer); -} -if ($search_societe) -{ - $sql .= natural_search('s.nom', $search_societe); -} -if ($search_montant_ht != '') -{ - $sql.= natural_search('f.total', $search_montant_ht, 1); -} -if ($search_montant_ttc != '') -{ - $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); -} -if ($search_status != '') -{ - $sql.= " AND f.fk_statut = '".$db->escape($search_status)."'"; -} +if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref); +if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); +if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); +if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_status != '') $sql.= " AND f.fk_statut = '".$db->escape($search_status)."'"; if ($month > 0) { if ($year > 0 && empty($day)) @@ -258,7 +240,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($limit+1,$offset); //print $sql; @@ -307,7 +288,7 @@ if ($resql) if ($moreforfilter) { print ''; - print ''; + print ''; print $moreforfilter; print ''; } @@ -323,6 +304,7 @@ if ($resql) print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Filters lines @@ -345,9 +327,10 @@ if ($resql) print ''; print ''; print ''; - print ' '; + print ''; print ''; - print ' '; + print ''; + print ''; print ''; print ''; print "\n"; @@ -439,7 +422,9 @@ if ($resql) print ''; print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$paiement,$objp->type); print ""; - //print " "; + + print ""; + print "\n"; $total_ht+=$objp->total_ht; $total_tva+=$objp->total_tva; @@ -457,7 +442,8 @@ if ($resql) print ''.price($total_tva,0,$langs).''; print ''.price($total_ttc,0,$langs).''; print ''.price($totalrecu,0,$langs).''; - print ' '; + print ''; + print ''; print ''; } } diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index e8010229a8e..d29f237c331 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -654,13 +654,16 @@ if ($resql) print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); + + $searchpitco=''; + $searchpitco.=''; if (empty($mode)) { - print_liste_field_titre($langs->trans("PDFMerge"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($searchpitco,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); } else { - print_liste_field_titre($langs->trans("Remind"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($searchpitco,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); } print "\n"; @@ -695,9 +698,6 @@ if ($resql) print $form->selectarray('filtre', $liststatus, $filter, 1); print ''; print ''; - print ''; - print ''; - print '
'; if (empty($mode)) { if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index fe32541a0fc..aaebcf697f3 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -705,7 +705,7 @@ if (! GETPOST('action')) print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'dp','','','',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Type'),$_SERVER["PHP_SELF"],'libelle','','','',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Amount'),$_SERVER["PHP_SELF"],'fa_amount','','','align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; while ($i < min($num,$limit)) @@ -728,6 +728,6 @@ if (! GETPOST('action')) } } -$db->close(); - llxFooter(); + +$db->close(); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index f2b6bcf1490..d284a128631 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -68,6 +68,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_company=""; } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('paymentlist')); +$extrafields = new ExtraFields($db); + + + /* * View */ @@ -81,24 +87,37 @@ if (GETPOST("orphelins")) // Paiements lies a aucune facture (pour aide au diagnostic) $sql = "SELECT p.rowid, p.datep as dp, p.amount,"; $sql.= " p.statut, p.num_paiement,"; - //$sql.= " c.libelle as paiement_type"; $sql.= " c.code as paiement_code"; + // Add fields for extrafields + foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p,"; $sql.= " ".MAIN_DB_PREFIX."c_paiement as c)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; $sql.= " WHERE p.fk_paiement = c.id"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND pf.fk_facture IS NULL"; + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; } else { $sql = "SELECT DISTINCT p.rowid, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives $sql.= " p.statut, p.num_paiement,"; - //$sql.= " c.libelle as paiement_type,"; $sql.= " c.code as paiement_code,"; $sql.= " ba.rowid as bid, ba.label,"; $sql.= " s.rowid as socid, s.nom as name"; - //$sql.= " f.facnumber"; + // Add fields for extrafields + foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement as p)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; @@ -127,6 +146,10 @@ else if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; if ($search_amount) $sql .=" AND p.amount='".$db->escape(price2num($search_amount))."'"; if ($search_company) $sql .= natural_search('s.nom', $search_company); + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; } $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); @@ -157,11 +180,13 @@ if ($resql) print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$paramlist,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$paramlist,'align="right"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("Invoices"),"","","",$paramlist,'align="left"',$sortfield,$sortorder); - if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) - { - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$paramlist,'align="right"',$sortfield,$sortorder); - } - print_liste_field_titre(''); + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$paramlist,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Lines for filters fields @@ -199,7 +224,7 @@ if ($resql) $var=!$var; print ""; - print ''; + print ''; $paymentstatic->id=$objp->rowid; $paymentstatic->ref=$objp->rowid; print $paymentstatic->getNomUrl(1); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b2e1992f0f9..7f2640fad4a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1194,6 +1194,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire && $user->rights->projet->lire, '', $mainmenu, 'projects'); $newmenu->add("/projet/card.php?leftmenu=projects&action=create", $langs->trans("NewProject"), 1, $user->rights->projet->creer && $user->rights->projet->creer); $newmenu->add("/projet/list.php?leftmenu=projects", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire); + $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire && $user->rights->projet->lire); if (empty($conf->global->PROJECT_HIDE_TASKS)) { diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index aadd6603853..de6f0fe0576 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -158,3 +158,5 @@ AssignTask=Assign ProjectOverview=Overview ManageTasks=Use projects to follow tasks and time ManageOpportunitiesStatus=Use projects to follow leads/opportinuties +ProjectNbProjectByMonth=Nb of created projects by month +ProjectsStatistics=Statistics on projects/leads \ No newline at end of file diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php new file mode 100644 index 00000000000..27335777db1 --- /dev/null +++ b/htdocs/projet/class/projectstats.class.php @@ -0,0 +1,327 @@ + + * + * 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 . + */ +include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; + + +class ProjectStats extends Stats +{ + protected $db; + private $project; + public $userid; + public $socid; + public $year; + function __construct($db) { + global $conf, $user; + + $this->db = $db; + + require_once 'project.class.php'; + + $this->project = new Project($this->db); + } + + + /** + * Return all leads grouped by status + * + * @param int $limit Limit results + * @return array|int + * @throws Exception + */ + function getAllProjectByStatus($limit = 5) + { + global $conf, $user, $langs; + + $datay = array (); + + $sql = "SELECT"; + $sql .= " count(DISTINCT t.rowid), t.fk_opp_status"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; + $sql .= $this->buildWhere(); + $sql .= " GROUP BY t.fk_opp_status"; + + $result = array (); + $res = array (); + + dol_syslog(get_class($this) . '::' . __METHOD__ . "", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + $other = 0; + while ( $i < $num ) { + $row = $this->db->fetch_row($resql); + if ($i < $limit || $num == $limit) + $result[$i] = array ( + $this->projet->status[$row[1]] . '(' . $row[0] . ')', + $row[0] + ); + else + $other += $row[1]; + $i ++; + } + if ($num > $limit) + $result[$i] = array ( + $langs->transnoentitiesnoconv("Other"), + $other + ); + $this->db->free($resql); + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . '::' . __METHOD__ . ' ' . $this->error, LOG_ERR); + return - 1; + } + + return $result; + } + + /** + * Return count, and sum of products + * + * @return array of values + */ + function getAllByYear() + { + global $conf, $user, $langs; + + $datay = array (); + + $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; + $sql .= $this->buildWhere(); + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); + + return $this->_getAllByYear($sql); + } + /** + * + * @return string + */ + public function buildWhere() { + $sqlwhere_str = ''; + $sqlwhere = array (); + + $sqlwhere[] = ' t.entity IN (' . getEntity('project') . ')'; + + if (! empty($this->userid)) + $sqlwhere[] = ' t.fk_user_resp=' . $this->userid; + if (! empty($this->socid)) + $sqlwhere[] = ' t.fk_soc=' . $this->socid; + if (! empty($this->year) && empty($this->yearmonth)) + $sqlwhere[] = " date_format(t.datec,'%Y')='" . $this->year . "'"; + if (! empty($this->yearmonth)) + $sqlwhere[] = " t.datec BETWEEN '" . $this->db->idate(dol_get_first_day($this->yearmonth)) . "' AND '" . $this->db->idate(dol_get_last_day($this->yearmonth)) . "'"; + + if (! empty($this->status)) + $sqlwhere[] = " t.fk_opp_status IN (" . $this->status . ")"; + + if (count($sqlwhere) > 0) { + $sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere); + } + + return $sqlwhere_str; + } + + /** + * Return Project number by month for a year + * + * @param int $year scan + * @return array of values + */ + function getNbByMonth($year) { + global $user; + + $this->yearmonth = $year; + + $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; + $sql .= $this->buildWhere(); + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + $this->yearmonth=0; + + $res = $this->_getNbByMonth($year, $sql); + // var_dump($res);print '
'; + return $res; + } + + /** + * Return the Project amount by month for a year + * + * @param int $year scan + * @return array with amount by month + */ + function getAmountByMonth($year) { + global $user; + + $this->yearmonth = $year; + + $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount)"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; + $sql .= $this->buildWhere(); + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + $this->yearmonth=0; + + $res = $this->_getAmountByMonth($year, $sql); + // var_dump($res);print '
'; + return $res; + } + + /** + * Return amount of elements by month for several years + * + * @param int $endyear End year + * @param int $startyear Start year + * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) + * @return array of values + */ + function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0) + { + global $conf, $user, $langs; + + if ($startyear > $endyear) return - 1; + + $datay = array(); + + // Search into cache + if (! empty($cachedelay)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/json.lib.php'; + } + + $newpathofdestfile = $conf->user->dir_temp . '/' . get_class($this) . '_' . __FUNCTION__ . '_' . (empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix . '_') . $langs->defaultlang . '_user' . $user->id . '.cache'; + $newmask = '0644'; + + $nowgmt = dol_now(); + + $foundintocache = 0; + if ($cachedelay > 0) { + $filedate = dol_filemtime($newpathofdestfile); + if ($filedate >= ($nowgmt - $cachedelay)) { + $foundintocache = 1; + + $this->_lastfetchdate[get_class($this) . '_' . __FUNCTION__] = $filedate; + } else { + dol_syslog(get_class($this) . '::' . __FUNCTION__ . " cache file " . $newpathofdestfile . " is not found or older than now - cachedelay (" . $nowgmt . " - " . $cachedelay . ") so we can't use it."); + } + } + + // Load file into $data + if ($foundintocache) // Cache file found and is not too old + { + dol_syslog(get_class($this) . '::' . __FUNCTION__ . " read data from cache file " . $newpathofdestfile . " " . $filedate . "."); + $data = dol_json_decode(file_get_contents($newpathofdestfile), true); + } else { + $year = $startyear; + while ( $year <= $endyear ) { + $datay[$year] = $this->getTransformRateByMonth($year); + $year ++; + } + + $data = array (); + // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) + for($i = 0; $i < 12; $i ++) { + $data[$i][] = $datay[$endyear][$i][0]; // set label + $year = $startyear; + while ( $year <= $endyear ) { + $data[$i][] = $datay[$year][$i][1]; // set yval for x=i + $year ++; + } + } + } + + // Save cache file + if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) { + dol_syslog(get_class($this) . '::' . __FUNCTION__ . " save cache file " . $newpathofdestfile . " onto disk."); + if (! dol_is_dir($conf->user->dir_temp)) + dol_mkdir($conf->user->dir_temp); + $fp = fopen($newpathofdestfile, 'w'); + fwrite($fp, dol_json_encode($data)); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) + $newmask = $conf->global->MAIN_UMASK; + @chmod($newpathofdestfile, octdec($newmask)); + + $this->_lastfetchdate[get_class($this) . '_' . __FUNCTION__] = $nowgmt; + } + + return $data; + } + + /** + * Return the Project transformation rate by month for a year + * + * @param int $year scan + * @return array with amount by month + */ + function getTransformRateByMonth($year) { + global $user; + + $this->yearmonth = $year; + + $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; + $sql .= $this->buildWhere(); + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + $res_total = $this->_getNbByMonth($year, $sql); + + $this->status=6; + + $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; + $sql .= $this->buildWhere(); + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + $this->status=0; + $this->yearmonth=0; + + $res_only_wined = $this->_getNbByMonth($year, $sql); + + $res=array(); + + foreach($res_total as $key=>$total_row) { + //var_dump($total_row); + if (!empty($total_row[1])) { + $res[$key]=array($total_row[0],(100*$res_only_wined[$key][1])/$total_row[1]); + } else { + $res[$key]=array($total_row[0],0); + } + + } + // var_dump($res);print '
'; + return $res; + } +} \ No newline at end of file diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php new file mode 100644 index 00000000000..fdb272ed70e --- /dev/null +++ b/htdocs/projet/stats/index.php @@ -0,0 +1,367 @@ + + * + * 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 . + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/projectstats.class.php'; + +// Security check +if (! $user->rights->projet->lire) + accessforbidden(); + + +$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); + +$userid=GETPOST('userid','int'); +$socid=GETPOST('socid','int'); +// Security check +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} +$nowyear=strftime("%Y", dol_now()); +$year = GETPOST('year')>0?GETPOST('year'):$nowyear; +//$startyear=$year-2; +$startyear=$year-1; +$endyear=$year; + +$langs->load('projects'); + + +/* + * View + */ + +$form=new Form($db); + +$includeuserlist=array(); + + +llxHeader('', $langs->trans('Projects')); + +$title=$langs->trans("ProjectsStatistics"); +$dir=$conf->projet->dir_output.'/temp'; + +print_fiche_titre($title,'','title_project.png'); + +dol_mkdir($dir); + + +$stats_project= new ProjectStats($db); +if (!empty($userid) && $userid!=-1) $stats_project->userid=$userid; +if (!empty($socid) && $socid!=-1) $stats_project->socid=$socid; +if (!empty($year)) $stats_project->year=$year; + + + +if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ + $data1 = $stats_project->getAllProjectByStatus(); + if (!is_array($data1) && $data1<0) { + setEventMessages($stats_project->error, null, 'errors'); + } + if (empty($data1)) + { + $showpointvalue=0; + $nocolor=1; + $data1=array(array(0=>$langs->trans("None"),1=>1)); + } + + $filenamenb = $conf->project->dir_output . "/stats/projectbystatus.png"; + $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&file=projectbystatus.png'; + $px = new DolGraph(); + $mesg = $px->isGraphKo(); + if (empty($mesg)) { + $i=0;$tot=count($data1);$legend=array(); + while ($i <= $tot) + { + $data1[$i][0]=$data1[$i][0]; // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[]=$data1[$i][0]; + $i++; + } + $px->SetData($data1); + unset($data1); + + if ($nocolor) + $px->SetDataColor(array ( + array ( + 220, + 220, + 220 + ) + )); + $px->SetPrecisionY(0); + $px->SetLegend($legend); + $px->setShowLegend(0); + $px->setShowPointValue($showpointvalue); + $px->setShowPercent(1); + $px->SetMaxValue($px->GetCeilMaxValue()); + $px->SetWidth(300); + $px->SetHeight(300); + $px->SetShading(3); + $px->SetHorizTickIncrement(1); + $px->SetCssPrefix("cssboxes"); + $px->SetType(array ( + 'pie' + )); + $px->SetTitle($langs->trans('ProjectNbProjectByStatus')); + $result=$px->draw($filenamenb, $fileurlnb); + if ($result<0) { + setEventMessages($px->error, null, 'errors'); + } + } else { + setEventMessages(null, $mesgs, 'errors'); + } +} + + +// Build graphic number of object +// $data = array(array('Lib',val1,val2,val3),...) +$data = $stats_project->getNbByMonthWithPrevYear($endyear,$startyear); +//var_dump($data); + +$filenamenb = $conf->project->dir_output . "/stats/projectnbprevyear-".$year.".png"; +$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&file=projectnbprevyear-'.$year.'.png'; + +$px1 = new DolGraph(); +$mesg = $px1->isGraphKo(); +if (! $mesg) +{ + $px1->SetData($data); + $px1->SetPrecisionY(0); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("ProjectNbProject")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->SetPrecisionY(0); + $px1->mode='depth'; + $px1->SetTitle($langs->trans("ProjectNbProjectByMonth")); + + $px1->draw($filenamenb,$fileurlnb); +} + + +if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ + // Build graphic amount of object + $data = $stats_project->getAmountByMonthWithPrevYear($endyear,$startyear); + //var_dump($data); + // $data = array(array('Lib',val1,val2,val3),...) + + $filenamenb = $conf->project->dir_output . "/stats/projectamountprevyear-".$year.".png"; + $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&file=projectamountprevyear-'.$year.'.png'; + + $px2 = new DolGraph(); + $mesg = $px2->isGraphKo(); + if (! $mesg) + { + $px2->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("ProjectAmountOfProject")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->SetPrecisionY(0); + $px2->mode='depth'; + $px2->SetTitle($langs->trans("ProjectAmountOfProjectsByMonth")); + + $px2->draw($filenamenb,$fileurlnb); + } +} + +if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ + // Build graphic with transformation rate + $data = $stats_project->getTransformRateByMonthWithPrevYear($endyear,$startyear); + //var_dump($data); + // $data = array(array('Lib',val1,val2,val3),...) + + $filenamenb = $conf->project->dir_output . "/stats/projecttransrateprevyear-".$year.".png"; + $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&file=projecttransrateprevyear-'.$year.'.png'; + + $px3 = new DolGraph(); + $mesg = $px3->isGraphKo(); + if (! $mesg) + { + $px3->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue(min(0,$px3->GetFloorMinValue())); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetYLabel($langs->trans("ProjectTransRateOfProject")); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->SetPrecisionY(0); + $px3->mode='depth'; + $px3->SetTitle($langs->trans("ProjectTransRateOfProjectsByMonth")); + + $px3->draw($filenamenb,$fileurlnb); + } +} + + +// Show array +$stats_project->year=0; +$data_all_year = $stats_project->getAllByYear(); +if (!empty($year)) $stats_project->year=$year; +$arrayyears=array(); +foreach($data_all_year as $val) { + $arrayyears[$val['year']]=$val['year']; +} +if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; + + +$h=0; +$head = array(); +$head[$h][0] = DOL_URL_ROOT . '/projet/stats/index.php?mode='.$mode; +$head[$h][1] = $langs->trans("ByMonthYear"); +$head[$h][2] = 'byyear'; +$h++; + +complete_head_from_modules($conf,$langs,null,$head,$h,$type); + +dol_fiche_head($head,'byyear',$langs->trans("Statistics"), 0, ''); + + +print '
'; + +print '
'; +print ''; +print ''; +// Company +print ''; +// User +/*print '';*/ +// Year +print ''; +print ''; +print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; +if ($mode == 'customer') $filter='s.client in (1,2,3)'; +if ($mode == 'supplier') $filter='s.fournisseur = 1'; +print $form->select_company($socid,'socid',$filter,1); +print '
'.$langs->trans("ProjectCommercial").''; +print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist); +print '
'.$langs->trans("Year").''; +if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; +if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; +arsort($arrayyears); +print $form->selectarray('year',$arrayyears,$year,0); +print '
'; +print '
'; +print '

'; + +print ''; +print ''; +print ''; +print ''; +if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ + print ''; + print ''; +} +print ''; + +$oldyear=0; +foreach ($data_all_year as $val) +{ + $year = $val['year']; + while ($year && $oldyear > $year+1) + { // If we have empty year + $oldyear--; + print ''; + print ''; + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print ''; + print ''; + } + print ''; + print ''; + } + print ''; + print ''; + print ''; + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print ''; + print ''; + } + print ''; + $oldyear=$year; +} + +print '
'.$langs->trans("Year").''.$langs->trans("NbOfProjects").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
0?'&userid='.$userid:'').'">'.$oldyear.'000
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
'; + +print '
'; + +$stringtoshow.= '
'; +if ($mesg) { print $mesg; } +else { + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + $stringtoshow.= $px->show(); + $stringtoshow.= "
\n"; + } + $stringtoshow.= $px1->show(); + $stringtoshow.= "
\n"; + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + $stringtoshow.= $px2->show(); + $stringtoshow.= "
\n"; + $stringtoshow.= $px3->show(); + } +} +$stringtoshow.= '
'; + +print $stringtoshow; + + +print '
'; +print '
'; + + +llxFooter(); +$db->close(); From c69a9996f157d30205493b77525ffac0d9950c4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2015 15:12:15 +0200 Subject: [PATCH 3/5] Uniformize code --- htdocs/compta/salaries/index.php | 2 +- htdocs/compta/sociales/index.php | 5 +++++ htdocs/compta/tva/reglement.php | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 11c9dd3a9ab..0e08b70f87e 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -134,7 +134,7 @@ if ($result) print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 31e98370003..3afbba0df79 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -164,6 +164,7 @@ if ($resql) print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cs.paye","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; @@ -184,6 +185,8 @@ if ($resql) print ''; print ''; print ' '; + // Status + print ' '; print ''; print ''; print "\n"; @@ -228,6 +231,8 @@ if ($resql) print ''.$chargesociale_static->LibStatut($obj->paye,5,$obj->alreadypayed).''; + print ''; + print ''; $i++; } diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index de18f2af661..3f9c0d1bb59 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011-2014 Alexandre Spangaro * @@ -140,7 +140,7 @@ if ($result) print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"dm","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; From 276f057acf741e9afab31468c6bbbcfb27751611 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2015 16:10:03 +0200 Subject: [PATCH 4/5] Clean trigger codes Better error message when we insert duplicate barcode. --- htdocs/admin/agenda.php | 3 ++- htdocs/core/lib/company.lib.php | 7 ++++--- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 4 ++++ htdocs/product/class/product.class.php | 3 ++- htdocs/societe/agenda.php | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 5da5fa621c6..8b28400ab75 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -168,8 +168,9 @@ if (! empty($triggers)) //print 'module='.$module.'
'; if (! empty($conf->$module->enabled)) { - // Discard special case. + // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; + if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; $var=!$var; print ''; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e6b0f0a8dd6..5ba2ea89009 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -971,6 +971,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.=""; + // Date $out.=''; $out.=dol_print_date($datep,'dayhour'); if ($datep2 && $datep2 != $datep) @@ -998,7 +999,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) // Title of event //$out.=''.dol_trunc($obj->label,40).''; - $out.=''.$actionstatic->getNomUrl(1,40).''; + $out.=''.$actionstatic->getNomUrl(1,120).''; // Contact pour cette action if (empty($objcon->id) && $obj->fk_contact > 0) @@ -1240,14 +1241,14 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) //$actionstatic->libelle=$libelle; $actionstatic->libelle=$histo[$key]['note']; $actionstatic->id=$histo[$key]['id']; - $out.=$actionstatic->getNomUrl(1,40); + $out.=$actionstatic->getNomUrl(1,120); } if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { $out.=''.img_object($langs->trans("ShowEMailing"),"email").' '; $transcode=$langs->trans("Action".$histo[$key]['acode']); $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing'); - $out.=dol_trunc($libelle,40); + $out.=dol_trunc($libelle,120); } $out.=''; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 5b0b6705e5a..3bd8c282c38 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -725,3 +725,7 @@ INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES ( INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (6,'WIN' ,'Won', 60, 100,1); INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (7,'LOST' ,'Lost', 70, 0,1); + +DELETE FROM llx_c_action_trigger where code = 'PROPAL_CLASSIFYBILLED'; +DELETE FROM llx_c_action_trigger where code = 'FICHINTER_CLASSIFYBILLED'; + diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a501212c8ba..28af434d56a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -808,7 +808,8 @@ class Product extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref); + if (empty($conf->barcode->enabled)) $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref); + else $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists",$this->barcode); $this->db->rollback(); return -1; } diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 4648992506b..847c23c6719 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2005 Brice Davoleau * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Marcos García From 57a267a30f054d00cc0d11bfe2bdf623fb9619de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jun 2015 17:09:52 +0200 Subject: [PATCH 5/5] NEW Add hooks to allow an external module to complete list of events into calendar views. --- htdocs/comm/action/index.php | 48 +++++++++++++++++++------ htdocs/core/class/hookmanager.class.php | 9 ++--- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e5472727aa2..c414d3409d6 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -341,11 +341,14 @@ dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup); dol_fiche_end(); + +// Define the legend/list of calendard to show +$s=''; $link=''; + $showextcals=$listofextcals; -// Legend -if (! empty($conf->use_javascript_ajax)) + +if (! empty($conf->use_javascript_ajax)) // If javascript on { - $s=''; $s.='' . "\n"; + // Local calendar $s.='
' . $langs->trans("LocalAgenda").'  
'; + + // External calendars if (is_array($showextcals) && count($showextcals) > 0) { $s.='