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

View File

@ -19,6 +19,7 @@
* $Source$ * $Source$
* *
*/ */
require_once(DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php');
class FournisseurTelephonie { class FournisseurTelephonie {
var $db; var $db;
@ -40,16 +41,31 @@ class FournisseurTelephonie {
* *
* *
*/ */
function create() function create($user)
{ {
$res = 0; $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; return $res;
} }
@ -85,7 +101,7 @@ class FournisseurTelephonie {
$this->id = $id; $this->id = $id;
$sql = "SELECT f.rowid, f.nom, f.email_commande, f.commande_active"; $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 .= ", f.num_client";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur as f";
$sql .= " WHERE f.rowid = ".$this->id; $sql .= " WHERE f.rowid = ".$this->id;
@ -102,6 +118,7 @@ class FournisseurTelephonie {
$this->commande_enable = $obj->commande_active; $this->commande_enable = $obj->commande_active;
$this->class_commande = $obj->class_commande; $this->class_commande = $obj->class_commande;
$this->commande_bloque = $obj->commande_bloque; $this->commande_bloque = $obj->commande_bloque;
$this->grille = $obj->fk_tarif_grille;
return 0; return 0;
} }