Gestion de la grille de tarif

This commit is contained in:
Rodolphe Quiedeville 2007-04-26 12:53:26 +00:00
parent b707bedeb8
commit 007ef2bbc3
2 changed files with 46 additions and 15 deletions

View File

@ -21,6 +21,7 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php');
if (!$user->rights->telephonie->fournisseur->lire)
accessforbidden();
@ -53,7 +54,8 @@ if ($_POST["action"] == 'update' && $_GET["id"])
$fourn->email_commande = $_POST["email_commande"];
$fourn->methode_commande = $_POST["methode"];
$fourn->commande_bloque = $_POST["commande_bloque"];
$fourn->grille = $_POST["grille"];
if ( $fourn->update($user) == 0)
{
Header("Location: fiche.php?id=".$fourn->id);
@ -90,6 +92,9 @@ if ($cancel == $langs->trans("Cancel"))
$action = '';
}
$ta = new TelephonieTarifGrille($db);
$ta->GetListe($user,'achat');
/*
* Création
*
@ -118,11 +123,8 @@ if ($_GET["action"] == 'create')
print '</td>';
print '<td>méthode utilisée pour les commandes de lignes</td></tr>';
require DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php';
$ta = new TelephonieTarifGrille($db);
$ta->GetListe($user,'achat');
$ta->liste_name[0] = ' Creer une nouvelle grille';
asort($ta->liste_name);
print '<tr><td width="20%">Grille de tarif</td>';
print '<td>';
print $html->select_array("grille",$ta->liste_name);
@ -187,6 +189,15 @@ if ($_GET["id"] > 0)
print '</td>';
print '<td>Les commandes vers ce fournisseur sont bloquées</td></tr>';
print '<tr><td width="20%">Grille de tarif</td>';
print '<td>';
print $html->select_array("grille",$ta->liste_name, $fourn->grille);
print '</td>';
print '<td>Grille de tarif</td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit" value="Update"></td></tr>';
print '</table></form><br />';
}
@ -223,12 +234,15 @@ if ($_GET["id"] > 0)
print '<tr><td width="20%">Méthode de commande</td>';
print '<td>'.$fourn->class_commande.'</td>';
print '<td>méthode utilisée pour les commandes de lignes</td></tr>';
print '<tr><td width="20%">Blocage des commandes</td>';
print '<td>'.$art[$fourn->commande_bloque].'</td>';
print '<td>Les commandes sont bloquées</td></tr>';
print '<tr><td width="20%">Grille de tarif</td>';
print '<td>'.$ta->liste_name[$fourn->grille].'</td>';
print '<td>Grille de tarif</td></tr>';
print '</table><br /></div>';
}
}

View File

@ -19,6 +19,7 @@
* $Source$
*
*/
require_once(DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php');
class FournisseurTelephonie {
var $db;
@ -40,16 +41,31 @@ class FournisseurTelephonie {
*
*
*/
function create()
function create($user)
{
$res = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_fournisseur";
$sql .= " (nom, email_commande, commande_active, class_commande)";
$sql .= " VALUES ('".$this->nom."','".$this->email_commande."',1,'".$this->methode_commande."')";
if (! $this->db->query($sql) )
if ($this->grille == 0)
{
$res = -1;
$grille = new TelephonieTarifGrille($this->db);
if ($grille->CreateGrille($user, $this->nom, 'achat') <> 0)
{
$res = -2;
}
$this->grille = $grille->id;
}
if ($res == 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_fournisseur";
$sql .= " (nom, email_commande, commande_active, class_commande,fk_tarif_grille)";
$sql .= " VALUES ('".$this->nom."','".$this->email_commande."',1,'".$this->methode_commande."',".$this->grille.")";
if (! $this->db->query($sql) )
{
$res = -1;
}
}
return $res;
}
@ -85,7 +101,7 @@ class FournisseurTelephonie {
$this->id = $id;
$sql = "SELECT f.rowid, f.nom, f.email_commande, f.commande_active";
$sql .= ", f.class_commande, f.commande_bloque";
$sql .= ", f.class_commande, f.commande_bloque, f.fk_tarif_grille";
$sql .= ", f.num_client";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur as f";
$sql .= " WHERE f.rowid = ".$this->id;
@ -102,6 +118,7 @@ class FournisseurTelephonie {
$this->commande_enable = $obj->commande_active;
$this->class_commande = $obj->class_commande;
$this->commande_bloque = $obj->commande_bloque;
$this->grille = $obj->fk_tarif_grille;
return 0;
}