[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: exercices.php,v 1.22 2005/07/10 17:46:04 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/stats/exercices.php,v $ 21 * 22 */ 23 require ("./pre.inc.php"); 24 require ("./lib.inc.php"); 25 26 /* 27 * 28 */ 29 30 llxHeader(); 31 32 /* 33 * Sécurité accés client 34 */ 35 if ($user->societe_id > 0) 36 { 37 $socidp = $user->societe_id; 38 } 39 40 $mode='recettes'; 41 if ($conf->compta->mode == 'CREANCES-DETTES') { $mode='creances'; } 42 43 44 print_titre("Comparatif CA année en cours avec année précédente (".$langs->trans("Currency".$conf->monnaie)." HT, ".$mode.")"); 45 print "<br>\n"; 46 47 48 function factures ($db, $year, $month, $paye) 49 { 50 global $bc,$langs; 51 52 $sql = "SELECT s.nom, s.idp, f.facnumber, f.total as amount,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid "; 53 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye"; 54 $sql .= " AND date_format(f.datef, '%Y') = $year "; 55 $sql .= " AND round(date_format(f.datef, '%m')) = $month "; 56 $sql .= " ORDER BY f.datef DESC "; 57 58 $result = $db->query($sql); 59 if ($result) { 60 $num = $db->num_rows(); 61 if ($num > 0) { 62 $i = 0; 63 print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">"; 64 print "<TR bgcolor=\"orange\"><td colspan=\"3\"><b>Factures</b></td></tr>"; 65 print "<TR bgcolor=\"orange\">"; 66 print "<TD>Societe</td>"; 67 print "<TD>Num</TD>"; 68 print "<TD align=\"right\">Date</TD>"; 69 print "<TD align=\"right\">Montant</TD>"; 70 print "<TD align=\"right\">Payé</TD>"; 71 print "</TR>\n"; 72 $var=True; 73 while ($i < $num) { 74 $objp = $db->fetch_object($result); 75 $var=!$var; 76 print "<TR $bc[$var]>"; 77 print "<TD><a href=\"comp.php?socidp=$objp->idp\">$objp->nom</a></TD>\n"; 78 print "<TD><a href=\"facture.php?facid=$objp->facid\">$objp->facnumber</a></TD>\n"; 79 if ($objp->df > 0 ) { 80 print "<TD align=\"right\">".dolibarr_print_date($objp->df)."</TD>\n"; 81 } else { 82 print "<TD align=\"right\"><b>!!!</b></TD>\n"; 83 } 84 85 print "<TD align=\"right\">".price($objp->amount)."</TD>\n"; 86 87 $payes[1] = "oui"; 88 $payes[0] = "<b>non</b>"; 89 90 91 print "<TD align=\"right\">".$payes[$objp->paye]."</TD>\n"; 92 print "</TR>\n"; 93 94 $total = $total + $objp->amount; 95 96 $i++; 97 } 98 print "<tr><td align=\"right\"><b>".$langs->trans("Total")." : ".price($total)."</b></td><td></td></tr>"; 99 print "</TABLE>"; 100 $db->free(); 101 } 102 } 103 } 104 105 106 function pt ($db, $sql, $year) { 107 global $bc,$langs; 108 109 $result = $db->query($sql); 110 if ($result) { 111 $num = $db->num_rows(); 112 $i = 0; $total = 0 ; 113 print '<table class="border" width="100%">'; 114 print "<tr class=\"liste_titre\">"; 115 print '<td>'.$langs->trans("Month").'</td>'; 116 print '<td align="right">'.$langs->trans("Amount").'</td></tr>'; 117 $var=True; 118 $month = 1 ; 119 120 while ($i < $num) { 121 $obj = $db->fetch_object($result); 122 $var=!$var; 123 124 if ($obj->dm > $month ) { 125 for ($b = $month ; $b < $obj->dm ; $b++) { 126 print "<tr $bc[$var]>"; 127 print "<td>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</td>\n"; 128 print "<td align=\"right\">0</td>\n"; 129 print "</tr>\n"; 130 $var=!$var; 131 $ca[$b] = 0; 132 } 133 } 134 135 if ($obj->sum > 0) { 136 print "<tr $bc[$var]>"; 137 print "<td>"; 138 print strftime("%B",mktime(12,0,0,$obj->dm, 1, $year))."</td>\n"; 139 print "<td align=\"right\">".price($obj->sum)."</td>\n"; 140 141 print "</tr>\n"; 142 $month = $obj->dm + 1; 143 $ca[$obj->dm] = $obj->sum; 144 $total = $total + $obj->sum; 145 } 146 $i++; 147 } 148 149 if ($num) { 150 $beg = $obj->dm; 151 } else { 152 $beg = 1 ; 153 } 154 155 if ($beg <= 12 ) { 156 for ($b = $beg + 1 ; $b < 13 ; $b++) { 157 $var=!$var; 158 print "<tr $bc[$var]>"; 159 print "<td>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</td>\n"; 160 print "<td align=\"right\">0</td>\n"; 161 print "</tr>\n"; 162 $ca[$b] = 0; 163 } 164 } 165 166 print "<tr class=\"total\"><td align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td></tr>"; 167 print "</table>"; 168 169 $db->free(); 170 return $ca; 171 } else { 172 print $db->error(); 173 } 174 } 175 176 function ppt ($db, $year, $socidp) 177 { 178 global $bc,$conf,$langs; 179 print "<table width=\"100%\">"; 180 181 print "<tr class=\"liste_titre\"><td align=\"center\" width=\"30%\">"; 182 print "CA ".($year - 1); 183 184 print "</td><td align=\"center\">CA $year</td>"; 185 print '<td align="center">Delta</td></tr>'; 186 print "<tr><td valign=\"top\" width=\"30%\">"; 187 188 $sql = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm"; 189 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; 190 $sql .= " WHERE f.fk_statut = 1"; 191 $sql .= " AND date_format(f.datef,'%Y') = ".($year-1); 192 193 if ($conf->compta->mode != 'CREANCES-DETTES') { 194 $sql .= " AND f.paye = 1"; 195 } 196 if ($socidp) 197 { 198 $sql .= " AND f.fk_soc = $socidp"; 199 } 200 $sql .= " GROUP BY dm"; 201 202 $prev = pt($db, $sql, $year - 1); 203 204 print "</td><td valign=\"top\" width=\"30%\">"; 205 206 $sql = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm"; 207 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; 208 $sql .= " WHERE f.fk_statut = 1"; 209 $sql .= " AND date_format(f.datef,'%Y') = $year "; 210 if ($conf->compta->mode != 'CREANCES-DETTES') { 211 $sql .= " AND f.paye = 1"; 212 } 213 if ($socidp) 214 { 215 $sql .= " AND f.fk_soc = $socidp"; 216 } 217 $sql .= " GROUP BY dm"; 218 219 $ca = pt($db, $sql, $year); 220 221 print "</td><td valign=\"top\" width=\"30%\">"; 222 223 print '<table class="border" width="100%" cellspacing="0" cellpadding="3">'; 224 print "<tr class=\"liste_titre\">"; 225 print '<td>'.$langs->trans("Month").'</td>'; 226 print '<td align="right">'.$langs->trans("Amount").'</td>'; 227 print '<td align="right">Cumul</td>'; 228 print "</tr>\n"; 229 230 $var = 1 ; 231 for ($b = 1 ; $b <= 12 ; $b++) 232 { 233 $var=!$var; 234 235 $delta = $ca[$b] - $prev[$b]; 236 $deltat = $deltat + $delta ; 237 print "<TR $bc[$var]>"; 238 print "<TD>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</TD>\n"; 239 print "<TD align=\"right\">".price($delta)."</TD>\n"; 240 print "<TD align=\"right\">".price($deltat)."</TD>\n"; 241 print "</TR>\n"; 242 } 243 244 245 print '<tr class="total"><td align="right">Total :</td><td align="right"><b>'.price($deltat).'<b></td></tr>'; 246 247 print '</table>'; 248 print '</td></tr></table>'; 249 250 } 251 252 253 $cyear = strftime ("%Y", time()); 254 ppt($db, $cyear, $socidp); 255 256 $db->close(); 257 258 259 llxFooter("<em>Dernière modification $Date: 2005/07/10 17:46:04 $ révision $Revision: 1.22 $</em>"); 260 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |