From 1e576ebadcfe8da676835a68a357bfc8d1357ee3 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 12 May 2005 14:48:43 +0000 Subject: [PATCH] Gestion de la prise d'ordre --- htdocs/telephonie/contrat/fiche.php | 45 ++++++++++++++++- .../telephonie/telephonie.contrat.class.php | 48 +++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/htdocs/telephonie/contrat/fiche.php b/htdocs/telephonie/contrat/fiche.php index 03ea3f4e58f..da62eb4e34e 100644 --- a/htdocs/telephonie/contrat/fiche.php +++ b/htdocs/telephonie/contrat/fiche.php @@ -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 ''; } - print 'Annuler'; + print 'Annuler'; + print ''; + print ''; + + } + + /* + * Contact + * + * + */ + if ($_GET["action"] == 'po') + { + print_fiche_titre('Ajouter une prise d\'ordre'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; print '
Montant'; + print ' euros HT
'; + print ''; + + print 'Annuler
'; print '
'; @@ -933,6 +969,11 @@ if ($_GET["action"] == '') print "id\">".$langs->trans("Contact").""; + if ($user->rights->telephonie->ligne->creer) + { + print "id\">Ajouter une prise d'ordre"; + } + print "id\">".$langs->trans("Edit").""; if ($user->rights->telephonie->ligne->creer && $numlignes == 0) diff --git a/htdocs/telephonie/telephonie.contrat.class.php b/htdocs/telephonie/telephonie.contrat.class.php index 81d7fd8d849..86cb060bb2f 100644 --- a/htdocs/telephonie/telephonie.contrat.class.php +++ b/htdocs/telephonie/telephonie.contrat.class.php @@ -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); + } + } + } + } ?>