Ajout ChangeContrat

This commit is contained in:
Rodolphe Quiedeville 2005-05-17 15:25:40 +00:00
parent 7b9b470c82
commit 9036b62465
2 changed files with 78 additions and 3 deletions

View File

@ -80,7 +80,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
}
}
if ($_POST["action"] == 'updateremise')
if ($_POST["action"] == 'updateremise' && $user->rights->telephonie->ligne->creer)
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
@ -95,6 +95,17 @@ if ($_POST["action"] == 'updateremise')
}
}
if ($_POST["action"] == 'changecontrat' && $user->rights->telephonie->ligne->creer)
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->ChangeContrat($user, $_POST["contrat"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_POST["action"] == 'addcontact')
{
$ligne = new LigneTel($db);
@ -687,7 +698,7 @@ else
$i++;
}
}
$db->free();
$db->free();
}
else
@ -705,7 +716,7 @@ else
print "</table><br />";
if ($_GET["action"] == "editremise" && $ligne->statut <> 6)
if ($_GET["action"] == "editremise" && $ligne->statut <> 6 && $user->rights->telephonie->ligne->creer)
{
/**
* Edition de la remise
@ -728,6 +739,53 @@ else
print '</form>';
}
if ($_GET["action"] == "chgcontrat" && $user->rights->telephonie->ligne->creer)
{
/**
* Edition de la remise
*/
print '<form action="fiche.php?id='.$ligne->id.'" method="POST">';
print '<input type="hidden" name="action" value="changecontrat">';
print '<table class="border" width="100%" cellpadding="4" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Migrer vers un autre contrat</td></tr>';
print '<tr><td width="20%">Nouveau contrat</td><td>';
print '<select name="contrat">';
$sql = "SELECT c.rowid, c.ref ";
$sql .= "FROM ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " WHERE c.rowid <> ".$ligne->contrat;
$sql .= " AND c.fk_client_comm = ".$ligne->client_comm_id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
print '<option value="'.$row[0].'">'.$row[1];
$i++;
}
$db->free();
}
else
{
print $sql;
}
print '</select></td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" value="Migrer"></td></tr>';
print '</table><br />';
print '</form>';
}
}
@ -1163,6 +1221,11 @@ if ($_GET["action"] == '')
print "<a class=\"tabAction\" href=\"fiche.php?action=contact&amp;id=$ligne->id\">".$langs->trans("Contact")."</a>";
}
if ( $user->rights->telephonie->ligne->creer && $ligne->statut < 4)
{
print "<a class=\"tabAction\" href=\"fiche.php?action=chgcontrat&amp;id=$ligne->id\">".$langs->trans("Changer de contrat")."</a>";
}
if ( $user->rights->telephonie->ligne->creer && $ligne->statut < 4)
{
print "<a class=\"tabAction\" href=\"fiche.php?action=editremise&amp;id=$ligne->id\">".$langs->trans("Changer la remise")."</a>";

View File

@ -704,5 +704,17 @@ class LigneTel {
return -2;
}
}
function ChangeContrat($user, $contrat_id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne";
$sql .= " SET fk_contrat = ".$contrat_id ;
$sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
return 0;
}
}
?>