Modif gestion des services
This commit is contained in:
parent
134461ffdd
commit
964b15c727
@ -35,12 +35,12 @@ if ($_POST["action"] == 'addservice')
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'rmservice')
|
||||
if ($_GET["action"] == 'rmservice')
|
||||
{
|
||||
$contrat = new TelephonieContrat($db);
|
||||
$contrat->id= $_GET["id"];
|
||||
|
||||
if ( $contrat->remove_service($user, $_POST["service_id"]) == 0)
|
||||
if ( $contrat->remove_service($user, $_GET["service_id"]) == 0)
|
||||
{
|
||||
Header("Location: services.php?id=".$contrat->id);
|
||||
}
|
||||
@ -189,7 +189,7 @@ if ($cancel == $langs->trans("Cancel"))
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
|
||||
$sql = "SELECT s.libelle, s.statut, s.rowid as serid, s.montant";
|
||||
$sql = "SELECT s.libelle, s.statut, cs.rowid as serid, s.montant, cs.montant as montant_fac";
|
||||
$sql .= ", cs.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_service as cs";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."telephonie_service as s";
|
||||
@ -208,8 +208,9 @@ if ($cancel == $langs->trans("Cancel"))
|
||||
$ligne = new LigneTel($db);
|
||||
|
||||
print '<tr class="liste_titre"><td>Service</td>';
|
||||
print '</td><td align="right">Montant</td><td> </td>';
|
||||
print "</tr>\n";
|
||||
print '<td align="right">Montant Facturé</td>';
|
||||
print '<td align="right">Montant du service</td>';
|
||||
print "<td> </td></tr>\n";
|
||||
|
||||
while ($i < $numlignes)
|
||||
{
|
||||
@ -223,6 +224,7 @@ if ($cancel == $langs->trans("Cancel"))
|
||||
|
||||
print '<a href="'.DOL_URL_ROOT.'/telephonie/service/fiche.php?id='.$obj->serid.'">'.$obj->libelle."</a></td>\n";
|
||||
|
||||
print '<td align="right">'.price($obj->montant_fac)." euros HT</td>\n";
|
||||
print '<td align="right">'.price($obj->montant)." euros HT</td>\n";
|
||||
|
||||
print '<td align="center"><a href="services.php?id='.$contrat->id.'&action=rmservice&service_id='.$obj->serid.'">';
|
||||
|
||||
@ -274,13 +274,36 @@ class TelephonieContrat {
|
||||
*/
|
||||
function add_service($user, $sid)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat_service";
|
||||
$sql .= " (fk_contrat, fk_service, fk_user_creat, date_creat) ";
|
||||
$sql .= " VALUES ($this->id, $sid, $user->id, now() )";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
$result = 0;
|
||||
|
||||
$sql = "SELECT montant FROM ".MAIN_DB_PREFIX."telephonie_service";
|
||||
$sql .= " WHERE rowid=".$sid;
|
||||
|
||||
$resql = $this->db->query( $sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
return 0 ;
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$montant = $row[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
|
||||
if ($result == 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat_service";
|
||||
$sql .= " (fk_contrat, fk_service, fk_user_creat, date_creat, montant) ";
|
||||
$sql .= " VALUES ($this->id, $sid, $user->id, now(),".$montant.")";
|
||||
|
||||
$resql = $this->db->query( $sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -290,8 +313,8 @@ class TelephonieContrat {
|
||||
function remove_service($user, $sid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_contrat_service";
|
||||
$sql .= " (fk_contrat, fk_service, fk_user_creat, date_creat) ";
|
||||
$sql .= " VALUES ($this->id, $sid, $user->id, now() )";
|
||||
$sql .= " WHERE fk_contrat = ".$this->id;
|
||||
$sql .= " AND rowid = ".$sid;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user