/[dolibarr]/dolibarr/htdocs/telephonie/distributeurs/remuneration.php
ViewVC logotype

Diff of /dolibarr/htdocs/telephonie/distributeurs/remuneration.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by rodolphe, Thu Nov 10 10:26:26 2005 UTC revision 1.10 by rodolphe, Wed Nov 16 12:13:42 2005 UTC
# Line 33  if ($user->distributeur_id) Line 33  if ($user->distributeur_id)
33    
34  llxHeader();  llxHeader();
35    
   
36  $page = $_GET["page"];  $page = $_GET["page"];
37  $sortorder = $_GET["sortorder"];  $sortorder = $_GET["sortorder"];
38  $sortfield = $_GET["sortfield"];  $sortfield = $_GET["sortfield"];
# Line 91  if ($_GET["id"]) Line 90  if ($_GET["id"])
90    if ($_GET["month"] > 0)    if ($_GET["month"] > 0)
91      {      {
92        $datetime = mktime(12,12,12,substr($_GET["month"], -2), 1 , substr($_GET["month"],0,4));        $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    else
99      {      {
100        $datetime = time();        $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    $month = substr("00".strftime("%m", $datetime), -2);    $mois = strftime("%B %Y", mktime(12,0,0,$monthprev,1,$yearprev));
   $year = strftime("%Y", $datetime);        
   $mois = strftime("%B %Y", $datetime);  
117    
   $sql = "SELECT s.idp, s.nom, a.fk_contrat, sum(a.montant) as montant";  
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";    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_avance as a";
121    $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";    $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
122    $sql .= " , ".MAIN_DB_PREFIX."societe as s";    $sql .= " , ".MAIN_DB_PREFIX."societe as s";
# Line 110  if ($_GET["id"]) Line 124  if ($_GET["id"])
124    $sql .= " WHERE a.fk_distributeur =".$distri->id;    $sql .= " WHERE a.fk_distributeur =".$distri->id;
125    $sql .= " AND a.fk_contrat = c.rowid";    $sql .= " AND a.fk_contrat = c.rowid";
126    $sql .= " AND c.fk_soc = s.idp";    $sql .= " AND c.fk_soc = s.idp";
127    $sql .= " AND a.date ='".$year.$month."'";    $sql .= " AND a.date ='".$yearprev.$monthprev."'";
128    $sql .= " GROUP BY s.idp";    $sql .= " GROUP BY s.idp";
129    $sql .= " ORDER BY s.nom ASC";    $sql .= " ORDER BY s.nom ASC";
130        
# Line 135  if ($_GET["id"]) Line 149  if ($_GET["id"])
149            print "<tr $bc[$var]>";                    print "<tr $bc[$var]>";        
150            print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';            print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';
151            print img_file();            print img_file();
152            print '</a>&nbsp;';                  print '</a>&nbsp;';
153              print '<img src="../contrat/statut'.$obj->statut.'.png">&nbsp;';
154            print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n";            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";              print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";  
156            print "</tr>\n";            print "</tr>\n";
# Line 157  if ($_GET["id"]) Line 172  if ($_GET["id"])
172    
173    print '</td><td width="40%" valign="top">';    print '</td><td width="40%" valign="top">';
174    
175    $sql = "SELECT s.idp, s.nom, a.fk_contrat, sum(a.montant) as montant";    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      $var=True;
183      $total = 0;
184    
185      $sql = "SELECT s.idp, s.nom, a.fk_contrat,c.statut,sum(a.montant) as montant";
186      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_regul as a";
187      $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
188      $sql .= " , ".MAIN_DB_PREFIX."societe as s";
189    
190      $sql .= " WHERE a.fk_distributeur =".$distri->id;
191      $sql .= " AND a.fk_contrat = c.rowid";
192      $sql .= " AND c.fk_soc = s.idp";
193      $sql .= " AND a.date ='".$yearprev.$monthprev."'";
194    
195      $sql .= " GROUP BY s.idp";
196      $sql .= " ORDER BY s.nom ASC";
197    
198      $resql = $db->query($sql);
199    
200      if ($resql)
201        {
202          while ($obj = $db->fetch_object($resql))
203            {
204              print "<tr $bc[$var]>";
205              print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';
206              print img_file();
207              print '</a>&nbsp;';
208              print '<img src="../contrat/statut'.$obj->statut.'.png">&nbsp;';
209              print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n";
210              print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";  
211              print "</tr>\n";
212    
213              $total += $obj->montant;
214            }
215        }
216    
217      $sql = "SELECT s.idp, s.nom, a.fk_contrat, sum(a.montant) as montant";
218    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";
219    $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";    $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
220    $sql .= " , ".MAIN_DB_PREFIX."societe as s";    $sql .= " , ".MAIN_DB_PREFIX."societe as s";
# Line 166  if ($_GET["id"]) Line 222  if ($_GET["id"])
222    $sql .= " WHERE a.fk_distributeur =".$distri->id;    $sql .= " WHERE a.fk_distributeur =".$distri->id;
223    $sql .= " AND a.fk_contrat = c.rowid";    $sql .= " AND a.fk_contrat = c.rowid";
224    $sql .= " AND c.fk_soc = s.idp";    $sql .= " AND c.fk_soc = s.idp";
225    $sql .= " AND a.date ='".$year.$month."'";    $sql .= " AND a.date ='".$yearprev.$monthprev."'";
226    $sql .= " AND a.avance = 0";    $sql .= " AND a.avance = 0";
227    $sql .= " GROUP BY s.idp";    $sql .= " GROUP BY s.idp";
228    $sql .= " ORDER BY s.nom ASC";    $sql .= " ORDER BY s.nom ASC";
229      
230    $resql = $db->query($sql);    $resql = $db->query($sql);
231    if ($resql)    if ($resql)
232      {      {
233        $num = $db->num_rows($resql);        $num = $db->num_rows($resql);
234        $i = 0;        $i = 0;
235                
       print_barre_liste("Rémunération sur CA pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num);  
         
       print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';  
       print '<tr class="liste_titre"><td>Client</td>';  
       print '<td align="right">Montant</td>';  
       print "</tr>\n";  
         
       $var=True;  
       $total = 0;  
236        while ($i < $num)        while ($i < $num)
237          {          {
238            $obj = $db->fetch_object($resql);            $obj = $db->fetch_object($resql);
239                        
240            print "<tr $bc[$var]>";                    print "<tr $bc[$var]>";
241            print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';            print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';
242            print img_file();            print img_file();
243            print '</a>&nbsp;';                  print '</a>&nbsp;';
244            print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n";            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";              print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";  
246            print "</tr>\n";            print "</tr>\n";
# Line 204  if ($_GET["id"]) Line 251  if ($_GET["id"])
251        print "<tr $bc[$var]>\n";          print "<tr $bc[$var]>\n";  
252        print '<td>Total</td>';        print '<td>Total</td>';
253        print '<td align="right">'.sprintf("%01.2f",$total)."</td>\n";              print '<td align="right">'.sprintf("%01.2f",$total)."</td>\n";      
254        print "</tr>\n</table>\n";        print "</tr>\n";
255        $db->free();        $db->free();
256      }      }
257    else    else
258      {      {
259        print $db->error() . ' ' . $sql;        print $db->error() . ' ' . $sql;
260      }      }
261      print "</table>\n";
262    
263    
264    print '</td><td width="20%" valign="top">';    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)";    $sql = "SELECT distinct(a.date)";
269    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as a";    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as a";

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26