From e82f65cef2f9455cfac92a91caf0f1d10848fdb7 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 27 Sep 2016 17:38:54 +0200 Subject: [PATCH] NEW : add field and filters on ca by third report --- htdocs/compta/stats/casoc.php | 113 +++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index dade07fd0e3..02ebbcc1989 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -27,8 +27,10 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; @@ -61,6 +63,10 @@ if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accountin // Date range $year=GETPOST("year"); $month=GETPOST("month"); +$search_societe = GETPOST("search_societe"); +$search_zip = GETPOST("search_zip"); +$search_town = GETPOST("search_town"); +$search_country = GETPOST("search_country"); $date_startyear = GETPOST("date_startyear"); $date_startmonth = GETPOST("date_startmonth"); $date_startday = GETPOST("date_startday"); @@ -128,6 +134,10 @@ $headerparams['q'] = $q; $tableparams = array(); $tableparams['search_categ'] = $selected_cat; +$tableparams['search_societe'] = $search_societe; +$tableparams['search_zip'] = $search_zip; +$tableparams['search_town'] = $search_town; +$tableparams['search_country'] = $search_country; $tableparams['subcat'] = ($subcat === true)?'yes':''; // Adding common parameters @@ -180,7 +190,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl // Show Array $catotal=0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,"; + $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,"; $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if ($selected_cat === -2) // Without any category @@ -216,7 +226,7 @@ if ($modecompta == 'CREANCES-DETTES') { * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) */ - $sql = "SELECT s.rowid as socid, s.nom as name, sum(pf.amount) as amount_ttc"; + $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; @@ -246,6 +256,10 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } } +if(!empty($search_societe)) $sql.= ' AND s.nom LIKE "%'.$search_societe.'%"'; +if(!empty($search_zip)) $sql.= ' AND s.zip LIKE "%'.$search_zip.'%"'; +if(!empty($search_town)) $sql.= ' AND s.town LIKE "%'.$search_town.'%"'; +if($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.''; $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= " GROUP BY s.rowid, s.nom"; @@ -262,6 +276,9 @@ if ($result) { $amount_ht[$obj->socid] = $obj->amount; $amount[$obj->socid] = $obj->amount_ttc; $name[$obj->socid] = $obj->name.' '.$obj->firstname; + $address_zip[$obj->socid] = $obj->zip; + $address_town[$obj->socid] = $obj->town; + $address_pays[$obj->socid] = getCountry($obj->fk_pays); $catotal_ht+=$obj->amount; $catotal+=$obj->amount_ttc; $i++; @@ -294,6 +311,9 @@ if ($modecompta != 'CREANCES-DETTES') { $obj = $db->fetch_object($result); $amount[$obj->rowid] += $obj->amount_ttc; $name[$obj->rowid] = $obj->name; + $address_zip[$obj->rowid] = $obj->zip; + $address_town[$obj->rowid] = $obj->town; + $address_pays[$obj->rowid] = getCountry($obj->fk_pays); $catotal+=$obj->amount_ttc; $i++; } @@ -323,7 +343,7 @@ if ($subcat) { print ' checked'; } print'>'; -print ''; +print ''; print ''; print ''; print ''; @@ -338,6 +358,33 @@ print_liste_field_titre( "", $sortfield,$sortorder ); +print_liste_field_titre( + $langs->trans("Zip"), + $_SERVER["PHP_SELF"], + "zip", + "", + $paramslink, + "", + $sortfield,$sortorder + ); +print_liste_field_titre( + $langs->trans("Town"), + $_SERVER["PHP_SELF"], + "town", + "", + $paramslink, + "", + $sortfield,$sortorder + ); +print_liste_field_titre( + $langs->trans("Country"), + $_SERVER["PHP_SELF"], + "country", + "", + $paramslink, + "", + $sortfield,$sortorder + ); if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre( $langs->trans('AmountHT'), @@ -381,6 +428,27 @@ print_liste_field_titre( 'align="center" width="20%"' ); print "\n"; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print $form->select_country($search_country, 'search_country'); +//print ''; +print ''; +print ' '; +print ' '; +print ' '; +print ' '; +print ''; + $var=true; if (count($amount)) { @@ -410,6 +478,30 @@ if (count($amount)) { arsort($amount); $arrayforsort=$amount; } + if ($sortfield == 'zip' && $sortorder == 'asc') { + asort($address_zip); + $arrayforsort=$address_zip; + } + if ($sortfield == 'zip' && $sortorder == 'desc') { + arsort($address_zip); + $arrayforsort=$address_zip; + } + if ($sortfield == 'town' && $sortorder == 'asc') { + asort($address_town); + $arrayforsort=$address_town; + } + if ($sortfield == 'town' && $sortorder == 'desc') { + arsort($address_town); + $arrayforsort=$address_town; + } + if ($sortfield == 'country' && $sortorder == 'asc') { + asort($address_pays); + $arrayforsort=$address_town; + } + if ($sortfield == 'country' && $sortorder == 'desc') { + arsort($address_pays); + $arrayforsort=$address_town; + } foreach($arrayforsort as $key=>$value) { $var=!$var; @@ -427,6 +519,18 @@ if (count($amount)) { } print "".$linkname."\n"; + print ''; + print $address_zip[$key]; + print ''; + + print ''; + print $address_town[$key]; + print ''; + + print ''; + print $address_pays[$key]; + print ''; + // Amount w/o VAT print ''; if ($modecompta != 'CREANCES-DETTES') { @@ -486,6 +590,9 @@ if (count($amount)) { // Total print ''; print ''.$langs->trans("Total").''; + print ' '; + print ' '; + print ' '; if ($modecompta != 'CREANCES-DETTES') { print ''; } else {