Gestion de la prise d'ordre

This commit is contained in:
Rodolphe Quiedeville 2005-05-12 14:48:43 +00:00
parent e2788e015a
commit 1e576ebadc
2 changed files with 91 additions and 2 deletions

View File

@ -85,6 +85,16 @@ if ($_POST["action"] == 'addcontact')
}
}
if ($_POST["action"] == 'addpo' && $user->rights->telephonie->ligne->creer)
{
$contrat = new TelephonieContrat($db);
$contrat->fetch($_GET["id"]);
$contrat->addpo($_POST["montant"]) ;
Header("Location: fiche.php?id=".$contrat->id);
}
if ($_GET["action"] == 'delcontact')
{
$contrat = new TelephonieContrat($db);
@ -96,7 +106,7 @@ if ($_GET["action"] == 'delcontact')
}
}
if ($_GET["action"] == 'delete')
if ($_GET["action"] == 'delete' && $user->rights->telephonie->ligne->creer)
{
$contrat = new TelephonieContrat($db);
$contrat->id = $_GET["id"];
@ -105,6 +115,8 @@ if ($_GET["action"] == 'delete')
Header("Location: index.php");
}
llxHeader("","","Fiche Contrat");
if ($cancel == $langs->trans("Cancel"))
@ -893,7 +905,31 @@ else
{
print '<input type="submit" value="Ajouter">';
}
print '<a href="fiche.php?id='.$ligne->id.'">Annuler</a></td></tr>';
print '<a href="fiche.php?id='.$contrat->id.'">Annuler</a></td></tr>';
print '</table>';
print '</form>';
}
/*
* Contact
*
*
*/
if ($_GET["action"] == 'po')
{
print_fiche_titre('Ajouter une prise d\'ordre');
print '<form action="fiche.php?id='.$contrat->id.'" method="post">';
print '<input type="hidden" name="action" value="addpo">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td valign="top" width="20%">Montant</td><td valign="top" colspan="2">';
print '<input name="montant" size="8"> euros HT</td></tr>';
print '</td></tr>';
print '<tr><td colspan="3" align="center">';
print '<input type="submit" value="Ajouter">';
print '<a href="fiche.php?id='.$contrat->id.'">Annuler</a></td></tr>';
print '</table>';
print '</form>';
@ -933,6 +969,11 @@ if ($_GET["action"] == '')
print "<a class=\"tabAction\" href=\"fiche.php?action=contact&amp;id=$contrat->id\">".$langs->trans("Contact")."</a>";
if ($user->rights->telephonie->ligne->creer)
{
print "<a class=\"tabAction\" href=\"fiche.php?action=po&amp;id=$contrat->id\">Ajouter une prise d'ordre</a>";
}
print "<a class=\"tabAction\" href=\"fiche.php?action=edit&amp;id=$contrat->id\">".$langs->trans("Edit")."</a>";
if ($user->rights->telephonie->ligne->creer && $numlignes == 0)

View File

@ -444,5 +444,53 @@ class TelephonieContrat {
}
return $po;
}
/*
*
*
*/
function addpo($montant)
{
$po = 0;
$montant = ereg_replace(",",".",$montant);
if ($montant > 0)
{
$did = 0;
$sql = "SELECT dc.fk_distributeur ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux as dc";
$sql .= " WHERE dc.fk_user = ".$this->commercial_sign_id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$row = $this->db->fetch_row($resql);
$did = $row[0];
}
$this->db->free($resql);
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat_priseordre";
$sql .= " (fk_contrat, datepo, montant, fk_user, fk_distributeur)";
$sql .= " VALUES (".$this->id.",now(), ".$montant;
$sql .= ",".$this->commercial_sign_id.",".$did.")";
$resql = $this->db->query($sql);
if ($resql)
{
}
else
{
dolibarr_syslog($sql);
}
}
}
}
?>