From 5ee8333882bf09fd2341daf8c21beae3fe83e45e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jul 2009 16:06:19 +0000 Subject: [PATCH] Doc --- htdocs/compta/stats/casoc.php | 224 +++++++++++++++++----------------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index dc4edb1fc51..8fffd9c6cbe 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * @@ -20,10 +20,10 @@ */ /** - \file htdocs/compta/stats/casoc.php - \brief Page reporting CA par societe - \version $Id$ -*/ + * \file htdocs/compta/stats/casoc.php + * \brief Page reporting CA par societe + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php"); @@ -52,22 +52,22 @@ $html=new Form($db); // Affiche en-tete de rapport if ($modecompta=="CREANCES-DETTES") { - $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period=$langs->trans("Year")." ".$year; - $periodlink=''.img_previous().' '.img_next().''; - $description=$langs->trans("RulesCADue"); - $builddate=time(); - $exportlink=$langs->trans("NotYetAvailable"); + $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); + $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $period=$langs->trans("Year")." ".$year; + $periodlink=''.img_previous().' '.img_next().''; + $description=$langs->trans("RulesCADue"); + $builddate=time(); + $exportlink=$langs->trans("NotYetAvailable"); } else { - $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $period=$langs->trans("Year")." ".$year; - $periodlink=''.img_previous().' '.img_next().''; - $description=$langs->trans("RulesCAIn"); - $builddate=time(); - $exportlink=$langs->trans("NotYetAvailable"); + $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); + $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $period=$langs->trans("Year")." ".$year; + $periodlink=''.img_previous().' '.img_next().''; + $description=$langs->trans("RulesCAIn"); + $builddate=time(); + $exportlink=$langs->trans("NotYetAvailable"); } report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink); @@ -76,28 +76,28 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl $catotal=0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT s.rowid as socid, s.nom as name, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.fk_statut in (1,2)"; - $sql.= " AND f.fk_soc = s.rowid"; - if ($year) $sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'"; + $sql = "SELECT s.rowid as socid, s.nom as name, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."facture as f"; + $sql.= " WHERE f.fk_statut in (1,2)"; + $sql.= " AND f.fk_soc = s.rowid"; + if ($year) $sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'"; } else { - /* - * 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) - */ + /* + * 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 .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " WHERE p.rowid = pf.fk_paiement"; - $sql.= " AND pf.fk_facture = f.rowid"; - $sql.= " AND f.fk_soc = s.rowid"; - if ($year) $sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'"; + $sql .= " WHERE p.rowid = pf.fk_paiement"; + $sql.= " AND pf.fk_facture = f.rowid"; + $sql.= " AND f.fk_soc = s.rowid"; + if ($year) $sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'"; } $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; @@ -107,54 +107,54 @@ $sql.= " ORDER BY s.rowid"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i=0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $amount[$obj->socid] += $obj->amount_ttc; - $name[$obj->socid] = $obj->name; - $catotal+=$obj->amount_ttc; - $i++; - } + $num = $db->num_rows($result); + $i=0; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $amount[$obj->socid] += $obj->amount_ttc; + $name[$obj->socid] = $obj->name; + $catotal+=$obj->amount_ttc; + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } // On ajoute les paiements anciennes version, non lies par paiement_facture if ($modecompta != 'CREANCES-DETTES') { - $sql = "SELECT 'Autres' as nom, '0' as idp, sum(p.amount) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql.= " WHERE pf.rowid IS NULL"; - $sql.= " AND p.fk_bank = b.rowid"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity = ".$conf->entity; - if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'"; - $sql.= " GROUP BY nom"; - $sql.= " ORDER BY nom"; + $sql = "SELECT 'Autres' as nom, '0' as idp, sum(p.amount) as amount_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql.= " WHERE pf.rowid IS NULL"; + $sql.= " AND p.fk_bank = b.rowid"; + $sql.= " AND b.fk_account = ba.rowid"; + $sql.= " AND ba.entity = ".$conf->entity; + if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'"; + $sql.= " GROUP BY nom"; + $sql.= " ORDER BY nom"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i=0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $amount[$obj->rowid] += $obj->amount_ttc; - $name[$obj->rowid] = $obj->name; - $catotal+=$obj->amount_ttc; - $i++; - } - } - else { - dol_print_error($db); - } + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i=0; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $amount[$obj->rowid] += $obj->amount_ttc; + $name[$obj->rowid] = $obj->name; + $catotal+=$obj->amount_ttc; + $i++; + } + } + else { + dol_print_error($db); + } } @@ -169,49 +169,49 @@ $var=true; if (sizeof($amount)) { - $arrayforsort=$name; - - // On d�finit tableau arrayforsort - if ($sortfield == 'nom' && $sortorder == 'asc') { - asort($name); - $arrayforsort=$name; - } - if ($sortfield == 'nom' && $sortorder == 'desc') { - arsort($name); - $arrayforsort=$name; - } - if ($sortfield == 'amount_ttc' && $sortorder == 'asc') { - asort($amount); - $arrayforsort=$amount; - } - if ($sortfield == 'amount_ttc' && $sortorder == 'desc') { - arsort($amount); - $arrayforsort=$amount; - } + $arrayforsort=$name; - foreach($arrayforsort as $key=>$value) - { - $var=!$var; - print ""; + // On d�finit tableau arrayforsort + if ($sortfield == 'nom' && $sortorder == 'asc') { + asort($name); + $arrayforsort=$name; + } + if ($sortfield == 'nom' && $sortorder == 'desc') { + arsort($name); + $arrayforsort=$name; + } + if ($sortfield == 'amount_ttc' && $sortorder == 'asc') { + asort($amount); + $arrayforsort=$amount; + } + if ($sortfield == 'amount_ttc' && $sortorder == 'desc') { + arsort($amount); + $arrayforsort=$amount; + } - $fullname=$name[$key]; - if ($key > 0) { - $linkname=''.img_object($langs->trans("ShowCompany"),'company').' '.$fullname.''; - } - else { - $linkname=$langs->trans("PaymentsNotLinkedToInvoice"); - } - print "".$linkname."\n"; - print ''.price($amount[$key]).''; - print ''.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : ' ').''; - print "\n"; - $i++; - } + foreach($arrayforsort as $key=>$value) + { + $var=!$var; + print ""; - // Total - print ''.$langs->trans("Total").''.price($catotal).' '; + $fullname=$name[$key]; + if ($key > 0) { + $linkname=''.img_object($langs->trans("ShowCompany"),'company').' '.$fullname.''; + } + else { + $linkname=$langs->trans("PaymentsNotLinkedToInvoice"); + } + print "".$linkname."\n"; + print ''.price($amount[$key]).''; + print ''.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : ' ').''; + print "\n"; + $i++; + } - $db->free($result); + // Total + print ''.$langs->trans("Total").''.price($catotal).' '; + + $db->free($result); } print "";