[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/contrat/ -> services.php (source)

   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: services.php,v 1.7 2005/09/27 08:57:56 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/contrat/services.php,v $
  20   *
  21   */
  22  
  23  require  "./pre.inc.php";
  24  
  25  $mesg = '';
  26  
  27  if ($_POST["action"] == 'addservice' && $user->rights->telephonie->service->affecter)
  28  {
  29    $contrat = new TelephonieContrat($db);
  30    $contrat->id= $_GET["id"];
  31  
  32    if ( $contrat->add_service($user, $_POST["service_id"]) == 0)
  33      {
  34        Header("Location: services.php?id=".$contrat->id);
  35      }
  36  }
  37  
  38  if ($_GET["action"] == 'rmservice' && $user->rights->telephonie->service->affecter)
  39  {
  40    $contrat = new TelephonieContrat($db);
  41    $contrat->id= $_GET["id"];
  42  
  43    if ( $contrat->remove_service($user, $_GET["service_id"]) == 0)
  44      {
  45        Header("Location: services.php?id=".$contrat->id);
  46      }
  47  }
  48  
  49  llxHeader("","","Fiche Contrat - Services");
  50  
  51  
  52  if ($_GET["id"])
  53  {
  54    $client_comm = new Societe($db);
  55    $contrat = new TelephonieContrat($db);
  56    
  57    if ($contrat->fetch($_GET["id"]) > 0)
  58      {
  59        $result = 1;
  60        $client_comm->fetch($contrat->client_comm_id, $user);
  61      }
  62    else
  63      {
  64        print "Erreur";
  65      }
  66      
  67    if (!$client_comm->perm_read)
  68      {
  69        print "Lecture non authorisée";
  70      }
  71      
  72    if ( $result && $client_comm->perm_read)
  73      { 
  74        if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
  75      {
  76        
  77        $h=0;
  78        $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id;
  79        $head[$h][1] = $langs->trans("Contrat");
  80        $h++;
  81        
  82        $nser = $contrat->count_associated_services();
  83        
  84        $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id;
  85        if ($nser > 0)
  86          {
  87            $head[$h][1] = $langs->trans("Services")." (".$nser.")";
  88          }
  89        else
  90          {
  91            $head[$h][1] = $langs->trans("Services");
  92          }
  93        $hselected = $h;
  94        $h++;
  95        
  96        $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id;
  97        $head[$h][1] = $langs->trans("Stats");
  98        $h++;
  99        
 100        $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id;
 101        $head[$h][1] = $langs->trans("Infos");
 102        $h++;
 103        
 104        dolibarr_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref);
 105        
 106        print_fiche_titre('Fiche Contrat', $mesg);
 107        
 108        print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';            
 109        print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>';
 110        print '<td>Facturé : '.$contrat->facturable.'</td></tr>';
 111        
 112        print '<tr><td width="20%">Client</td><td>';
 113        print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">';
 114        
 115        print $client_comm->nom.'</a></td><td>'.$client_comm->code_client;
 116        print '</td></tr>';
 117        
 118        if ($contrat->client_comm_id <> $contrat->client_id)
 119          {                   
 120            $client = new Societe($db, $contrat->client_id);
 121            $client->fetch($contrat->client_id);
 122            print '<tr><td width="20%">Client (Agence/Filiale)</td><td colspan="2">';
 123            print $client->nom.'<br />';
 124            print $client->cp . " " .$client->ville;
 125            print '</td></tr>';
 126          }
 127        
 128        $commercial = new User($db, $contrat->commercial_sign_id);
 129        $commercial->fetch();
 130        
 131        print '<tr><td width="20%">Commercial Signature</td>';
 132        print '<td colspan="2">'.$commercial->fullname.'</td></tr>';
 133        
 134        $commercial_suiv = new User($db, $contrat->commercial_suiv_id);
 135        $commercial_suiv->fetch();
 136        
 137        print '<tr><td width="20%">Commercial Suivi</td>';
 138        print '<td colspan="2">'.$commercial_suiv->fullname.'</td></tr>';
 139  
 140        /* Contacts */
 141        print '<tr><td valign="top" width="20%">Contact facture</td>';
 142        print '<td valign="top" colspan="2">';
 143  
 144        $sql = "SELECT c.idp, c.name, c.firstname, c.email ";
 145        $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c";
 146        $sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf";
 147        $sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_contrat = ".$contrat->id." ORDER BY name ";
 148        if ( $db->query( $sql) )
 149          {
 150            $num = $db->num_rows();
 151            if ( $num > 0 )
 152          {
 153            $i = 0;
 154            while ($i < $num)
 155              {
 156                $row = $db->fetch_row($i);
 157  
 158                print $row[1] . " " . $row[2] . " &lt;".$row[3]."&gt;<br />";
 159                $i++;
 160              }
 161          }
 162            $db->free();     
 163  
 164          }
 165        else
 166          {
 167            print $sql;
 168          }
 169        print '</td></tr>';
 170        /* Fin Contacts */
 171  
 172        print "</table><br />";
 173  
 174  
 175        /* Services */
 176           
 177        print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 178            
 179        $sql = "SELECT s.libelle, s.statut";
 180        $sql .= " , cs.rowid as serid, s.montant, cs.montant as montant_fac";
 181        $sql .= " , ".$db->pdate("cs.date_creat") . " as date_creat";
 182        $sql .= " , u.name, u.firstname";
 183        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_service as cs";
 184        $sql .= " , ".MAIN_DB_PREFIX."telephonie_service as s";
 185        $sql .= " , ".MAIN_DB_PREFIX."user as u";
 186  
 187        $sql .= " WHERE cs.fk_service = s.rowid";
 188        $sql .= " AND cs.fk_user_creat = u.rowid";
 189        $sql .= " AND cs.fk_contrat = ".$contrat->id;
 190            
 191        if ( $db->query( $sql) )
 192          {
 193            $numlignes = $db->num_rows();
 194            if ( $numlignes > 0 )
 195          {
 196            $i = 0;              
 197            $ligne = new LigneTel($db);
 198                
 199            print '<tr class="liste_titre"><td>Service</td>';
 200            print '<td align="right">Montant Facturé</td>';
 201            print '<td align="right">Montant du service</td>';
 202            if ($user->rights->telephonie->service->affecter)        
 203              print "<td>&nbsp;</td>\n";
 204            print '<td align="center">Ajouté par</td>';
 205            print '<td align="center">Ajouté le</td></tr>';
 206                
 207            while ($i < $numlignes)
 208              {
 209                $obj = $db->fetch_object($i);    
 210                $var=!$var;
 211                
 212                print "<tr $bc[$var]><td>";
 213                
 214                print '<img src="../graph'.$obj->statut.'.png">&nbsp;';
 215                
 216                
 217                print '<a href="'.DOL_URL_ROOT.'/telephonie/service/fiche.php?id='.$obj->serid.'">'.$obj->libelle."</a></td>\n";
 218                
 219                print '<td align="right">'.price($obj->montant_fac)." euros HT</td>\n";
 220                print '<td align="right">'.price($obj->montant)." euros HT</td>\n";
 221  
 222                if ($user->rights->telephonie->service->affecter)
 223              {
 224                print '<td align="center"><a href="services.php?id='.$contrat->id.'&amp;action=rmservice&amp;service_id='.$obj->serid.'">';
 225                print img_delete();
 226                print "</a></td>";
 227              }
 228                print '<td align="center">'.$obj->firstname.' '.$obj->name.'</td>';
 229                print '<td align="center">'.strftime("%d/%m/%y",$obj->date_creat).'</td>';
 230                print "</tr>\n";
 231                $i++;
 232              }
 233          }
 234            $db->free();     
 235            
 236          }
 237        else
 238          {
 239            print $db->error();
 240            print $sql;
 241          }
 242            
 243        print "</table>";
 244      }           
 245        /*
 246         * Service
 247         *
 248         *
 249         */      
 250        if ($user->rights->telephonie->service->affecter)
 251      {      
 252        print_fiche_titre('Ajouter un service', $mesg);
 253        
 254        print '<form action="services.php?id='.$contrat->id.'" method="post">';
 255        print '<input type="hidden" name="action" value="addservice">';      
 256        print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 257        print '<tr><td valign="top" width="20%">Service</td><td valign="top" colspan="2">';
 258        
 259        $sql = "SELECT rowid, libelle ";
 260        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_service ";
 261        $sql .= " WHERE statut = 1";
 262        
 263        if ( $db->query( $sql) )
 264          {
 265            print '<select name="service_id">';
 266            $num = $db->num_rows();
 267            if ( $num > 0 )
 268          {
 269            $i = 0;
 270            while ($i < $num)
 271              {
 272                $row = $db->fetch_row($i);
 273                print '<option value="'.$row[0] .'"';
 274                print '>'.$row[1];
 275                $i++;
 276              }
 277          }
 278            $db->free();     
 279            print '</select>';
 280          }
 281        else
 282          {
 283            print $sql;
 284          }
 285        
 286        print '</td></tr>';
 287        
 288        print '<tr><td colspan="3" align="center">';
 289        if ($num > 0)
 290          {
 291            print '<input type="submit" value="Ajouter">';
 292          }
 293        print '</td></tr>';
 294        print '</table>';
 295        print '</form>';
 296      } 
 297        /*
 298         *
 299         *
 300         *
 301         */
 302        
 303        print '</div>';
 304        
 305      }
 306  }
 307  else
 308  {
 309    print "Error";
 310  }
 311  
 312  
 313  /* ************************************************************************** */
 314  /*                                                                            */ 
 315  /* Barre d'action                                                             */ 
 316  /*                                                                            */ 
 317  /* ************************************************************************** */
 318  
 319  print "\n<br>\n<div class=\"tabsAction\">\n";
 320  
 321  if ($_GET["action"] == '')
 322  {  
 323        
 324  }
 325  
 326  print "</div>";
 327  
 328  
 329  
 330  $db->close();
 331  
 332  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/27 08:57:56 $ r&eacute;vision $Revision: 1.7 $</em>");
 333  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics