[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: remuneration.php,v 1.14 2005/11/16 12:23:16 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/distributeurs/remuneration.php,v $ 20 * 21 */ 22 require ("./pre.inc.php"); 23 24 if ($user->distributeur_id && $user->responsable_distributeur_id == 0) 25 { 26 accessforbidden(); 27 } 28 29 if ($user->distributeur_id) 30 { 31 $_GET["id"] = $user->distributeur_id; 32 } 33 34 llxHeader(); 35 36 $page = $_GET["page"]; 37 $sortorder = $_GET["sortorder"]; 38 $sortfield = $_GET["sortfield"]; 39 if ($sortorder == "") $sortorder="DESC"; 40 if ($sortfield == "") $sortfield="p.datepo"; 41 42 /* 43 * 44 * 45 */ 46 47 if ($_GET["id"]) 48 { 49 $h = 0; 50 $distri = new DistributeurTelephonie($db); 51 $distri->fetch($_GET["id"]); 52 53 $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id; 54 $head[$h][1] = $distri->nom; 55 $h++; 56 57 $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id; 58 $head[$h][1] = "Contrat"; 59 $h++; 60 61 $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id; 62 $head[$h][1] = "Rémunérations"; 63 $hselected = $h; 64 $h++; 65 66 $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id; 67 $head[$h][1] = "Prises d'ordre"; 68 $h++; 69 70 $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id; 71 $head[$h][1] = "Statistiques"; 72 $h++; 73 74 dolibarr_fiche_head($head, $hselected, "Distributeur"); 75 76 print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; 77 print '<tr><td width="40%" valign="top">'; 78 79 if ($page == -1) { $page = 0 ; } 80 81 $offset = $conf->liste_limit * $page ; 82 $pageprev = $page - 1; 83 $pagenext = $page + 1; 84 85 /* 86 * Mode Liste 87 * 88 */ 89 90 if ($_GET["month"] > 0) 91 { 92 $datetime = mktime(12,12,12,substr($_GET["month"], -2), 1 , substr($_GET["month"],0,4)); 93 $month = substr("00".strftime("%m", $datetime), -2); 94 $year = strftime("%Y", $datetime); 95 $monthprev = $month; 96 $yearprev = $year; 97 } 98 else 99 { 100 $datetime = time(); 101 $month = substr("00".strftime("%m", $datetime), -2); 102 $year = strftime("%Y", $datetime); 103 104 if ($month == 1) 105 { 106 $monthprev = "12"; 107 $yearprev = $year - 1; 108 } 109 else 110 { 111 $monthprev = substr("00".($month - 1), -2) ; 112 $yearprev = $year; 113 } 114 } 115 116 $mois = strftime("%B %Y", mktime(12,0,0,$monthprev,1,$yearprev)); 117 118 119 $sql = "SELECT s.idp, s.nom, a.fk_contrat, c.statut, sum(a.montant) as montant"; 120 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_avance as a"; 121 $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c"; 122 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 123 124 $sql .= " WHERE a.fk_distributeur =".$distri->id; 125 $sql .= " AND a.fk_contrat = c.rowid"; 126 $sql .= " AND c.fk_soc = s.idp"; 127 $sql .= " AND a.date ='".$yearprev.$monthprev."'"; 128 $sql .= " GROUP BY s.idp"; 129 $sql .= " ORDER BY s.nom ASC"; 130 131 $resql = $db->query($sql); 132 if ($resql) 133 { 134 $num = $db->num_rows($resql); 135 $i = 0; 136 137 print_barre_liste("Rémunération sur prise d'ordre pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num); 138 139 print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; 140 print '<tr class="liste_titre"><td>Client</td>'; 141 print '<td align="right">Montant</td>'; 142 print "</tr>\n"; 143 $total = 0; 144 $var=True; 145 146 while ($i < min($num,$conf->liste_limit)) 147 { 148 $obj = $db->fetch_object($resql); 149 print "<tr $bc[$var]>"; 150 print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'; 151 print img_file(); 152 print '</a> '; 153 print '<img src="../contrat/statut'.$obj->statut.'.png"> '; 154 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n"; 155 print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n"; 156 print "</tr>\n"; 157 $total += $obj->montant; 158 $i++; 159 $var=!$var; 160 } 161 print "<tr $bc[$var]>\n"; 162 print '<td>Total</td>'; 163 print '<td align="right">'.sprintf("%01.2f",$total)."</td>\n"; 164 print "</tr>\n</table>\n"; 165 $db->free(); 166 } 167 else 168 { 169 print $db->error() . ' ' . $sql; 170 } 171 172 173 print '</td><td width="40%" valign="top">'; 174 175 print_barre_liste("Rémunération sur CA pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num); 176 177 print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; 178 print '<tr class="liste_titre"><td>Client</td>'; 179 print '<td align="right">Montant</td>'; 180 print "</tr>\n"; 181 182 $total = 0; 183 184 $sql = "SELECT s.idp, s.nom, a.fk_contrat,c.statut,sum(a.montant) as montant"; 185 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_regul as a"; 186 $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c"; 187 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 188 189 $sql .= " WHERE a.fk_distributeur =".$distri->id; 190 $sql .= " AND a.fk_contrat = c.rowid"; 191 $sql .= " AND c.fk_soc = s.idp"; 192 $sql .= " AND a.date ='".$yearprev.$monthprev."'"; 193 194 $sql .= " GROUP BY s.idp"; 195 $sql .= " ORDER BY s.nom ASC"; 196 197 $resql = $db->query($sql); 198 199 if ($resql) 200 { 201 while ($obj = $db->fetch_object($resql)) 202 { 203 print "<tr $bc[$var]>"; 204 print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'; 205 print img_file(); 206 print '</a> '; 207 print '<img src="../contrat/statut'.$obj->statut.'.png"> '; 208 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n"; 209 print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n"; 210 print "</tr>\n"; 211 $var=!$var; 212 $total += $obj->montant; 213 } 214 } 215 216 $sql = "SELECT s.idp, s.nom, a.fk_contrat, sum(a.montant) as montant, c.statut"; 217 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a"; 218 $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c"; 219 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 220 221 $sql .= " WHERE a.fk_distributeur =".$distri->id; 222 $sql .= " AND a.fk_contrat = c.rowid"; 223 $sql .= " AND c.fk_soc = s.idp"; 224 $sql .= " AND a.date ='".$yearprev.$monthprev."'"; 225 $sql .= " AND a.avance = 0"; 226 $sql .= " GROUP BY s.idp"; 227 $sql .= " ORDER BY s.nom ASC"; 228 229 $resql = $db->query($sql); 230 if ($resql) 231 { 232 $num = $db->num_rows($resql); 233 $i = 0; 234 235 while ($i < $num) 236 { 237 $obj = $db->fetch_object($resql); 238 239 print "<tr $bc[$var]>"; 240 print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'; 241 print img_file(); 242 print '</a> '; 243 print '<img src="../contrat/statut'.$obj->statut.'.png"> '; 244 print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n"; 245 print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n"; 246 print "</tr>\n"; 247 $total += $obj->montant; 248 $var=!$var; 249 $i++; 250 } 251 print "<tr $bc[$var]>\n"; 252 print '<td>Total</td>'; 253 print '<td align="right">'.sprintf("%01.2f",$total)."</td>\n"; 254 print "</tr>\n"; 255 $db->free(); 256 } 257 else 258 { 259 print $db->error() . ' ' . $sql; 260 } 261 print "</table>\n"; 262 263 264 print '</td><td width="20%" valign="top">'; 265 266 print_barre_liste("Curseur", $page, "po.php", "", $sortfield, $sortorder, '', $num); 267 268 $sql = "SELECT distinct(a.date)"; 269 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as a"; 270 $sql .= " WHERE a.fk_distributeur =".$distri->id; 271 $sql .= " ORDER BY a.date DESC"; 272 273 $resql = $db->query($sql); 274 if ($resql) 275 { 276 $num = $db->num_rows($resql); 277 $i = 0; 278 print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; 279 print '<tr class="liste_titre"><td>Mois</td>'; 280 print "</tr>\n"; 281 282 $var=True; 283 284 while ( $obj = $db->fetch_object($resql)) 285 { 286 $var=!$var; 287 288 print "<tr $bc[$var]><td>"; 289 print '<a href="'.DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$_GET["id"]; 290 print '&month='.$obj->date.'">'.$obj->date."</a></td>\n"; 291 print "</tr>\n"; 292 } 293 print "</table>"; 294 $db->free(); 295 } 296 else 297 { 298 print $db->error() . ' ' . $sql; 299 } 300 301 302 print '</td></tr></table>'; 303 } 304 305 $db->close(); 306 307 llxFooter("<em>Dernière modification $Date: 2005/11/16 12:23:16 $ révision $Revision: 1.14 $</em>"); 308 ?>
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 |
![]() |