* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ * */ require "./pre.inc.php"; $mesg = ''; if ($_POST["action"] == 'addservice' && $user->rights->telephonie->service->affecter) { $contrat = new TelephonieContrat($db); $contrat->id= $_GET["id"]; if ( $contrat->add_service($user, $_POST["service_id"]) == 0) { Header("Location: services.php?id=".$contrat->id); } } if ($_GET["action"] == 'rmservice' && $user->rights->telephonie->service->affecter) { $contrat = new TelephonieContrat($db); $contrat->id= $_GET["id"]; if ( $contrat->remove_service($user, $_GET["service_id"]) == 0) { Header("Location: services.php?id=".$contrat->id); } } llxHeader("","","Fiche Contrat - Services"); if ($_GET["id"]) { $client_comm = new Societe($db); $contrat = new TelephonieContrat($db); if ($contrat->fetch($_GET["id"]) > 0) { $result = 1; $client_comm->fetch($contrat->client_comm_id, $user); } else { print "Erreur"; } if (!$client_comm->perm_read) { print "Lecture non authorisée"; } if ( $result && $client_comm->perm_read) { if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') { $h=0; $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id; $head[$h][1] = $langs->trans("Contrat"); $h++; $nser = $contrat->count_associated_services(); $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id; if ($nser > 0) { $head[$h][1] = $langs->trans("Services")." (".$nser.")"; } else { $head[$h][1] = $langs->trans("Services"); } $hselected = $h; $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id; $head[$h][1] = $langs->trans("Stats"); $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id; $head[$h][1] = $langs->trans("Infos"); $h++; dolibarr_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref); print_fiche_titre('Fiche Contrat', $mesg); print ''; print ''; print ''; print ''; if ($contrat->client_comm_id <> $contrat->client_id) { $client = new Societe($db, $contrat->client_id); $client->fetch($contrat->client_id); print ''; } $commercial = new User($db, $contrat->commercial_sign_id); $commercial->fetch(); print ''; print ''; $commercial_suiv = new User($db, $contrat->commercial_suiv_id); $commercial_suiv->fetch(); print ''; print ''; /* Contacts */ print ''; print ''; /* Fin Contacts */ print "
Référence'.$contrat->ref.'Facturé : '.$contrat->facturable.'
Client'; print ''; print $client_comm->nom.''.$client_comm->code_client; print '
Client (Agence/Filiale)'; print $client->nom.'
'; print $client->cp . " " .$client->ville; print '
Commercial Signature'.$commercial->fullname.'
Commercial Suivi'.$commercial_suiv->fullname.'
Contact facture'; $sql = "SELECT c.idp, c.name, c.firstname, c.email "; $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf"; $sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_contrat = ".$contrat->id." ORDER BY name "; if ( $db->query( $sql) ) { $num = $db->num_rows(); if ( $num > 0 ) { $i = 0; while ($i < $num) { $row = $db->fetch_row($i); print $row[1] . " " . $row[2] . " <".$row[3].">
"; $i++; } } $db->free(); } else { print $sql; } print '

"; /* Services */ print ''; $sql = "SELECT s.libelle, s.statut"; $sql .= " , cs.rowid as serid, s.montant, cs.montant as montant_fac"; $sql .= " , ".$db->pdate("cs.date_creat") . " as date_creat"; $sql .= " , u.name, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_service as cs"; $sql .= " , ".MAIN_DB_PREFIX."telephonie_service as s"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE cs.fk_service = s.rowid"; $sql .= " AND cs.fk_user_creat = u.rowid"; $sql .= " AND cs.fk_contrat = ".$contrat->id; if ( $db->query( $sql) ) { $numlignes = $db->num_rows(); if ( $numlignes > 0 ) { $i = 0; $ligne = new LigneTel($db); print ''; print ''; print ''; if ($user->rights->telephonie->service->affecter) print "\n"; print ''; print ''; while ($i < $numlignes) { $obj = $db->fetch_object($i); $var=!$var; print "\n"; print '\n"; print '\n"; if ($user->rights->telephonie->service->affecter) { print '"; } print ''; print ''; print "\n"; $i++; } } $db->free(); } else { print $db->error(); print $sql; } print "
ServiceMontant FacturéMontant du service Ajouté parAjouté le
"; print ' '; print ''.$obj->libelle."'.price($obj->montant_fac)." euros HT'.price($obj->montant)." euros HT'; print img_delete(); print "'.$obj->firstname.' '.$obj->name.''.strftime("%d/%m/%y",$obj->date_creat).'
"; } /* * Service * * */ if ($user->rights->telephonie->service->affecter) { print_fiche_titre('Ajouter un service', $mesg); print '
'; print ''; print ''; print ''; print ''; print '
Service'; $sql = "SELECT rowid, libelle "; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_service "; $sql .= " WHERE statut = 1"; if ( $db->query( $sql) ) { print ''; } else { print $sql; } print '
'; if ($num > 0) { print ''; } print '
'; print '
'; } /* * * * */ print ''; } } else { print "Error"; } /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "\n
\n
\n"; if ($_GET["action"] == '') { } print "
"; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>