diff --git a/htdocs/telephonie/ligne/fiche.php b/htdocs/telephonie/ligne/fiche.php index d538fdee91fad9fba8f6ddd333abb31db165dd9e..8d5509215b855c9b2ac969590add93a838072482 100644 --- a/htdocs/telephonie/ligne/fiche.php +++ b/htdocs/telephonie/ligne/fiche.php @@ -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&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&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&id=$ligne->id\">".$langs->trans("Changer la remise")."</a>"; diff --git a/htdocs/telephonie/lignetel.class.php b/htdocs/telephonie/lignetel.class.php index fb8f3e30e596ea831c64d91cff8fa7835e9b736c..f7de1d790be3db200f152c3f3e0f738ebba56a49 100644 --- a/htdocs/telephonie/lignetel.class.php +++ b/htdocs/telephonie/lignetel.class.php @@ -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; + } + } ?>