diff --git a/htdocs/telephonie/contrat/services.php b/htdocs/telephonie/contrat/services.php index dbf11e80a8c..99fa8343e17 100644 --- a/htdocs/telephonie/contrat/services.php +++ b/htdocs/telephonie/contrat/services.php @@ -24,7 +24,7 @@ require "./pre.inc.php"; $mesg = ''; -if ($_POST["action"] == 'addservice' && $user->rights->telephonie->ligne->creer) +if ($_POST["action"] == 'addservice' && $user->rights->telephonie->service->affecter) { $contrat = new TelephonieContrat($db); $contrat->id= $_GET["id"]; @@ -35,7 +35,7 @@ if ($_POST["action"] == 'addservice' && $user->rights->telephonie->ligne->creer) } } -if ($_GET["action"] == 'rmservice' && $user->rights->telephonie->ligne->creer) +if ($_GET["action"] == 'rmservice' && $user->rights->telephonie->service->affecter) { $contrat = new TelephonieContrat($db); $contrat->id= $_GET["id"]; @@ -134,132 +134,125 @@ if ($_GET["id"]) $commercial_suiv = new User($db, $contrat->commercial_suiv_id); $commercial_suiv->fetch(); - print 'Commercial Suivi'; - print ''.$commercial_suiv->fullname.''; + print 'Commercial Suivi'; + print ''.$commercial_suiv->fullname.''; - /* Contacts */ - print 'Contact facture'; - print ''; + /* Contacts */ + print 'Contact facture'; + print ''; - $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) ) + $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 ) { - $num = $db->num_rows(); - if ( $num > 0 ) + $i = 0; + while ($i < $num) { - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($i); + $row = $db->fetch_row($i); - print $row[1] . " " . $row[2] . " <".$row[3].">
"; - $i++; - } + print $row[1] . " " . $row[2] . " <".$row[3].">
"; + $i++; } - $db->free(); - } - else - { - print $sql; - } - print ''; - /* Fin Contacts */ + $db->free(); - print "
"; + } + else + { + print $sql; + } + print ''; + /* Fin Contacts */ + + print "
"; - /* Services */ + /* Services */ - print ''; + 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 = "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; + $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) ) + if ( $db->query( $sql) ) + { + $numlignes = $db->num_rows(); + if ( $numlignes > 0 ) { - $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) { - $i = 0; - $ligne = new LigneTel($db); - - print ''; - print ''; - print ''; - if ($user->rights->telephonie->ligne->creer) - print "\n"; - print ''; - print ''; - - while ($i < $numlignes) - { - $obj = $db->fetch_object($i); - $var=!$var; + $obj = $db->fetch_object($i); + $var=!$var; - print "\n"; + print ''.$obj->libelle."\n"; - print '\n"; - print '\n"; + print '\n"; + print '\n"; - if ($user->rights->telephonie->ligne->creer) - { + if ($user->rights->telephonie->service->affecter) + { print '"; - } - print ''; - print ''; - print "\n"; - $i++; } + print ''; + print ''; + print "\n"; + $i++; } - $db->free(); + } + $db->free(); - } - else - { - print $db->error(); - print $sql; - } - - print "
ServiceMontant FacturéMontant du service Ajouté parAjouté le
ServiceMontant FacturéMontant du service Ajouté parAjouté le
"; + print "
"; - print ' '; + print ' '; - print ''.$obj->libelle."'.price($obj->montant_fac)." euros HT'.price($obj->montant)." euros HT'.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).'
'.$obj->firstname.' '.$obj->name.''.strftime("%d/%m/%y",$obj->date_creat).'
"; - - } - - - /* - * Service - * - * - */ - - if ($user->rights->telephonie->ligne->creer) - { - + else + { + print $db->error(); + print $sql; + } + + print ""; + } + /* + * Service + * + * + */ + if ($user->rights->telephonie->service->affecter) + { print_fiche_titre('Ajouter un service', $mesg); print '
'; - print ''; - + print ''; print ''; print '
Service'; @@ -301,16 +294,16 @@ if ($_GET["id"]) print '
'; print '
'; } - /* - * - * - * - */ + /* + * + * + * + */ - print ''; + print ''; - } } +} else { print "Error";