diff --git a/htdocs/compta/casoc.php3 b/htdocs/compta/casoc.php3 deleted file mode 100644 index 3bbb380fb70..00000000000 --- a/htdocs/compta/casoc.php3 +++ /dev/null @@ -1,105 +0,0 @@ - - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ - * - */ -require("./pre.inc.php3"); - -/* - * Sécurité accés client - */ -if ($user->societe_id > 0) -{ - accessforbidden(); -} -/* - * - */ -llxHeader(); - -$db = new Db(); - -print_titre("Chiffre d'affaire par société"); - -/* - * Ca total - * - */ - -$sql = "SELECT sum(f.amount) as ca FROM llx_facture as f"; - -$result = $db->query($sql); -if ($result) -{ - if ($db->num_rows() > 0) - { - $objp = $db->fetch_object(0); - $catotal = $objp->ca; - } -} - -print "Total : ".price($catotal).""; - -if ($catotal == 0) { $catotal = 1; }; - - -$sql = "SELECT s.nom, s.idp, sum(f.amount) as ca"; -$sql .= " FROM llx_societe as s,llx_facture as f"; -$sql .= " WHERE f.fk_soc = s.idp GROUP BY s.nom, s.idp ORDER BY ca DESC"; - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows(); - if ($num > 0) - { - $i = 0; - print "

"; - print ""; - print ""; - print ''; - print "\n"; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - - print "\n"; - print ''; - print ''; - print "\n"; - - print "\n"; - $i++; - } - print "
SociétéMontantPourcentage 
idp\">$objp->nom'.price($objp->ca).''.price(100 / $catotal * $objp->ca).'%idp\">Voir les factures
"; - } - $db->free(); -} -else -{ - print $db->error(); -} - - -$db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); -?> diff --git a/htdocs/compta/comp.php3 b/htdocs/compta/comp.php3 deleted file mode 100644 index 4bd05d8dcf8..00000000000 --- a/htdocs/compta/comp.php3 +++ /dev/null @@ -1,352 +0,0 @@ - - * - * $Id$ - * $Source$ - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ -require("./pre.inc.php3"); - - - -function get_ca_propal ($db, $year, $socidp) { - - $sql = "SELECT sum(f.price - f.remise) as sum FROM llx_propal as f WHERE fk_statut in (1,2) AND date_format(f.datep, '%Y') = $year "; - if ($socidp) { - $sql .= " AND f.fk_soc = $socidp"; - } - - $result = $db->query($sql); - - if ($result) { - return $db->result (0, 0); - } else { - return 0; - } - -} -function get_ca ($db, $year, $socidp) { - - $sql = "SELECT sum(f.amount) as sum FROM llx_facture as f WHERE f.paye = 1 AND date_format(f.datef , '%Y') = $year "; - if ($socidp) { - $sql .= " AND f.fk_soc = $socidp"; - } - - $result = $db->query($sql); - - if ($result) { - return $db->result ( 0, 0); - } else { - return 0; - } - -} - - -function propals ($db, $year, $month) { - global $bc; - $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price - p.remise as price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; - $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; - $sql .= " AND c.id in (1,2)"; - $sql .= " AND date_format(p.datep, '%Y') = $year "; - $sql .= " AND round(date_format(p.datep, '%m')) = $month "; - - - $sql .= " ORDER BY p.fk_statut"; - - $result = $db->query($sql); - $num = $db->num_rows(); - $i = 0; - print "

"; - print ""; - - $oldstatut = -1; - $subtotal = 0; - while ($i < $num) { - $objp = $db->fetch_object( $i); - - if ($objp->statut <> $oldstatut ) { - $oldstatut = $objp->statut; - - if ($i > 0) { - print "\n"; - print "\n"; - } - $subtotal = 0; - - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print "\n"; - $var=True; - } - - $var=!$var; - print ""; - - print "\n"; - - print "\n"; - - print "\n"; - - print "\n"; - print "\n"; - print "\n"; - - $total = $total + $objp->price; - $subtotal = $subtotal + $objp->price; - - $i++; - } - print "\n"; - print "\n"; - print ""; - print ""; - print ""; - print "
Propal
Total : ".price($subtotal)."Euros HT
SocieteRéfDatePrixStatut
idp\">$objp->nompropalid\">$objp->ref".strftime("%d %B %Y",$objp->dp)."".price($objp->price)."$objp->statut
Total : ".price($subtotal)."Euros HT
Total ~ ".francs($total) ." FF HTTotal : ".price($total)."Euros HT
"; - $db->free(); - -} - - -function factures ($db, $year, $month, $paye) { - global $bc; - - $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid "; - $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye"; - $sql .= " AND date_format(f.datef, '%Y') = $year "; - $sql .= " AND round(date_format(f.datef, '%m')) = $month "; - $sql .= " ORDER BY f.datef DESC "; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - if ($num > 0) { - $i = 0; - print "

"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print "\n"; - $var=True; - while ($i < $num) { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - if ($objp->df > 0 ) { - print "\n"; - } else { - print "\n"; - } - - print "\n"; - - $payes[1] = "oui"; - $payes[0] = "non"; - - - print "\n"; - print "\n"; - - $total = $total + $objp->amount; - - $i++; - } - print ""; - print ""; - print "
Factures
SocieteNumDateMontantPayé
idp\">$objp->nomfacid\">$objp->facnumber".strftime("%d %B %Y",$objp->df)."!!!".price($objp->amount)."".$payes[$objp->paye]."
Total ~ ".francs($total)." FF HTTotal : ".price($total)."
"; - $db->free(); - } - } -} - - -function pt ($db, $sql, $year) { - global $bc; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - $i = 0; $total = 0 ; - print "

"; - print ""; - print ""; - print "\n"; - $var=True; - $month = 1 ; - - while ($i < $num) { - $obj = $db->fetch_object( $i); - $var=!$var; - - if ($obj->dm > $month ) { - for ($b = $month ; $b < $obj->dm ; $b++) { - print ""; - print "\n"; - print "\n"; - print "\n"; - $var=!$var; - $ca[$b] = 0; - } - } - - if ($obj->sum > 0) { - print ""; - print "\n"; - print "\n"; - - print "\n"; - $month = $obj->dm + 1; - $ca[$obj->dm] = $obj->sum; - $total = $total + $obj->sum; - } - $i++; - } - - if ($num) { - $beg = $obj->dm; - } else { - $beg = 1 ; - } - - if ($beg <= 12 ) { - for ($b = $beg + 1 ; $b < 13 ; $b++) { - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - $ca[$b] = 0; - } - } - - print ""; - print "
MoisMontant
".strftime("%B",mktime(12,0,0,$b, 1, $year))."0
dm\">"; - print strftime("%B",mktime(12,0,0,$obj->dm, 1, $year))."".price($obj->sum)."
".strftime("%B",mktime(12,0,0,$b, 1, $year))."0
Total :".price($total)."
"; - - $db->free(); - return $ca; - } else { - print $db->error(); - } -} - -function ppt ($db, $year, $socidp) { - global $bc; - print ""; - - print ""; - print ""; - - print "
"; - print "CA Prévisionnel basé sur les propal $year"; - - print "CA Réalisé $yearDelta $year
"; - - $sql = "SELECT sum(f.price - f.remise) as sum, round(date_format(f.datep,'%m')) as dm"; - $sql .= " FROM llx_propal as f WHERE fk_statut in (1,2) AND date_format(f.datep,'%Y') = $year "; - - if ($socidp) { - $sql .= " AND f.fk_soc = $socidp"; - } - - $sql .= " GROUP BY dm"; - - $prev = pt($db, $sql, $year); - - print ""; - - $sql = "SELECT sum(f.amount) as sum, round(date_format(f.datef, '%m')) as dm"; - $sql .= " FROM llx_facture as f WHERE f.paye = 1 AND date_format(f.datef,'%Y') = $year "; - - if ($socidp) { - $sql .= " AND f.fk_soc = $socidp"; - } - $sql .= " GROUP BY dm"; - - $ca = pt($db, $sql, $year); - - print ""; - - print "

"; - print ""; - print ""; - print ""; - print "\n"; - - $var = 1 ; - for ($b = 1 ; $b <= 12 ; $b++) { - $var=!$var; - - $delta = $ca[$b] - $prev[$b]; - $deltat = $deltat + $delta ; - print ""; - print "\n"; - print "\n"; - print "\n"; - } - - $ayear = $year - 1; - $acat = get_ca($db, $ayear, $socidp) - get_ca_propal($db, $ayear, $socidp); - - - print ""; - print ""; - print ""; - - print "
MoisMontant
".strftime("%B",mktime(12,0,0,$b, 1, $year))."".price($delta)."
Total :".price($deltat)."
Rappel $ayear :".price($acat)."
Soit :".price($acat+$deltat)."
"; - print "

"; - -} - - -/* - * - */ - -llxHeader(); - - -$db = new Db(); - - -ppt($db, 2002, $socidp); - - - -if ($details == 1) { - print "
"; - factures ($db, $year, $month, 1); - print ""; - propals ($db, $year, $month); - print "
"; -} -$db->close(); - - -llxFooter("Dernière modification $Date$ révision $Revision$"); -?> diff --git a/htdocs/compta/exercices.php3 b/htdocs/compta/stats/exercices.php similarity index 93% rename from htdocs/compta/exercices.php3 rename to htdocs/compta/stats/exercices.php index 5b6ac7aba62..55f1642b0ee 100644 --- a/htdocs/compta/exercices.php3 +++ b/htdocs/compta/stats/exercices.php @@ -255,7 +255,8 @@ function pt ($db, $sql, $year) { } } -function ppt ($db, $year, $socidp) { +function ppt ($db, $year, $socidp) +{ global $bc; print ""; @@ -269,9 +270,10 @@ function ppt ($db, $year, $socidp) { $sql = "SELECT sum(f.amount) as sum, round(date_format(f.datef, '%m')) as dm"; $sql .= " FROM llx_facture as f WHERE f.paye = 1 AND date_format(f.datef,'%Y') = ".($year-1); - if ($socidp) { - $sql .= " AND f.fk_soc = $socidp"; - } + if ($socidp) + { + $sql .= " AND f.fk_soc = $socidp"; + } $sql .= " GROUP BY dm"; @@ -282,9 +284,10 @@ function ppt ($db, $year, $socidp) { $sql = "SELECT sum(f.amount) as sum, round(date_format(f.datef, '%m')) as dm"; $sql .= " FROM llx_facture as f WHERE f.paye = 1 AND date_format(f.datef,'%Y') = $year "; - if ($socidp) { - $sql .= " AND f.fk_soc = $socidp"; - } + if ($socidp) + { + $sql .= " AND f.fk_soc = $socidp"; + } $sql .= " GROUP BY dm"; $ca = pt($db, $sql, $year); @@ -298,16 +301,17 @@ function ppt ($db, $year, $socidp) { print "\n"; $var = 1 ; - for ($b = 1 ; $b <= 12 ; $b++) { - $var=!$var; + for ($b = 1 ; $b <= 12 ; $b++) + { + $var=!$var; - $delta = $ca[$b] - $prev[$b]; - $deltat = $deltat + $delta ; - print ""; - print "\n"; - print "\n"; - print "\n"; - } + $delta = $ca[$b] - $prev[$b]; + $deltat = $deltat + $delta ; + print ""; + print "\n"; + print "\n"; + print "\n"; + } print ''; @@ -324,9 +328,15 @@ function ppt ($db, $year, $socidp) { llxHeader(); - $db = new Db(); +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $socidp = $user->societe_id; +} ppt($db, 2002, $socidp);
".strftime("%B",mktime(12,0,0,$b, 1, $year))."".price($delta)."
".strftime("%B",mktime(12,0,0,$b, 1, $year))."".price($delta)."
Total :'.price($deltat).'