[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2003 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: pointmort.php,v 1.7 2005/07/10 15:46:19 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/pointmort.php,v $ 21 * 22 */ 23 require ("./pre.inc.php"); 24 25 function pt ($db, $sql) { 26 $result = $db->query($sql); 27 if ($result) { 28 $num = $db->num_rows(); 29 $i = 0; 30 $total = 0 ; 31 $month = 1 ; 32 while ($i < $num) { 33 $obj = $db->fetch_object($result); 34 35 $ca[$obj->dm] = $obj->sum; 36 37 $i++; 38 } 39 40 $db->free(); 41 return $ca; 42 } 43 } 44 45 function pm ($db) { 46 $sql = "SELECT amount, date_format('%Y%m',month) as dm FROM ".MAIN_DB_PREFIX."pointmort"; 47 $result = $db->query($sql); 48 if ($result) { 49 $num = $db->num_rows(); 50 $i = 0; $total = 0 ; 51 52 $month = 1 ; 53 while ($i < $num) { 54 $obj = $db->fetch_object($result); 55 56 $ca[$obj->dm] = $obj->amount; 57 58 print $obj->dm ."=". $obj->amount ."<br>"; 59 60 $i++; 61 } 62 63 $db->free(); 64 return $ca; 65 } 66 } 67 68 69 function ppt ($db) { 70 71 $sql = "SELECT sum(f.amount), date_format(f.datef,'%Y%m') as dm"; 72 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; 73 $sql .= " GROUP BY dm"; 74 75 $ca = pt($db, $sql); 76 $ptmt = pm($db); 77 78 79 print "<TABLE class=\"border\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">"; 80 print "<TR class=\"liste_titre\">"; 81 print "<TD> </TD>"; 82 print "<TD>".$langs->trans("Month")."</TD>"; 83 print "<TD align=\"right\">CA</TD>"; 84 print "<TD align=\"right\">Point mort</TD>"; 85 print "<TD align=\"right\">Delta</TD>"; 86 print "<TD align=\"right\">Somme</TD>"; 87 print "<TD align=\"right\">Somme par an</TD>"; 88 print "<TD align=\"right\">Somme / nb mois</TD>"; 89 print "<TD align=\"right\">Ecart</TD>"; 90 print "</TR>\n"; 91 $bc[0]="bgcolor=\"#90c090\""; 92 $bc[1]="bgcolor=\"#b0e0b0\""; 93 $var = 1 ; 94 $pmt = 0 ; 95 $subpmt = 0 ; $totalca = 0 ; 96 $totalpm = 0; 97 $xdate = mktime(0, 0, 0, 7 , 1, 2000); 98 $oldyear = 0; 99 $i = 1; 100 while ($xdate < time()) { 101 if ($oldyear <> date("Y",$xdate)) { 102 $oldyear = date("Y",$xdate); 103 $subpmt = 0 ; 104 print '<TR><td> </td><td>'.$oldyear.'</td>'; 105 print '<td colspan="7" align="center"> </td></tr>'; 106 } 107 108 $var=!$var; 109 110 print "<TR $bc[$var]><td>$i</td>"; 111 print "<TD>".strftime("%Y %B", $xdate)."</TD>\n"; 112 113 $b = strftime("%Y", $xdate) . strftime("%m", $xdate); 114 $totalca = $ca[$b] + $totalca; 115 $totalpm = $ptmt[$b] + $totalpm; 116 $pm = $ca[$b] - $ptmt[$b]; 117 $pmt = $pmt + $pm; 118 $subpmt = $subpmt + $pm; 119 120 if ($ca[$b]) { 121 print "<TD align=\"right\">".$ca[$b]."</TD>\n"; 122 } else { 123 print "<TD align=\"right\">0</TD>\n"; 124 } 125 126 print "<TD align=\"right\">".$ptmt[$b]."</TD>\n"; 127 if ($pm > 0) { 128 print "<TD align=\"right\"><b>+$pm</b></TD>\n"; 129 } else { 130 print "<TD align=\"right\">$pm</TD>\n"; 131 } 132 print "<TD align=\"right\">$pmt</TD>\n"; 133 print "<TD align=\"right\">$subpmt</TD>\n"; 134 135 $pmbymonth = round($pmt/$i); 136 137 print "<TD align=\"right\">$pmbymonth</TD>\n"; 138 139 $pmbymdelta = ($pmbymonth - $pmbymontha); 140 141 if ( $pmbymdelta > 0 ) { 142 print "<TD align=\"right\"><b> +$pmbymdelta</b></TD>\n"; 143 } else { 144 print "<TD align=\"right\">$pmbymdelta</TD>\n"; 145 } 146 147 $pmbymontha = $pmbymonth; 148 149 print "</TR>\n"; 150 151 $xdate = mktime(0, 0, 0, date("m", $xdate + (33 * 24 * 3600)), 1 , date("Y", $xdate + (33 * 24 * 3600))) ; 152 $i++; 153 } 154 print "<tr><td colspan=\"2\" align=\"right\">Totaux:</td><td align=\"right\">$totalca</td>"; 155 print "<td align=\"right\">$totalpm</td><td align=\"right\" bgcolor=\"#f0f0f0\">$pmt</td>"; 156 print "<td colspan=\"4\"> </td></tr>"; 157 print "</table>"; 158 } 159 160 161 /* 162 * 163 */ 164 165 llxHeader(); 166 167 print "<b>Point mort</b>"; 168 169 ppt($db, 0); 170 171 172 print "<br><br><br><table cellspacing=0 border=1 cellpadding=3>"; 173 print "<tr><td bgcolor=\"#e0e0e0\"><a href=\"pmt.php\">Paramétrer le point mort</a></td></tr>"; 174 print "</table>"; 175 176 177 $db->close(); 178 179 llxFooter("<em>Dernière modification $Date: 2005/07/10 15:46:19 $ révision $Revision: 1.7 $</em>"); 180 ?>
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 |
![]() |