Implémentation de la suppression de ligne
This commit is contained in:
parent
e4b1298f2e
commit
d032c70736
@ -58,6 +58,17 @@ if ($_POST["action"] == 'add')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||||
|
{
|
||||||
|
$ligne = new LigneTel($db);
|
||||||
|
$ligne->fetch_by_id($_GET["id"]);
|
||||||
|
|
||||||
|
if ( $ligne->delete($user) == 0)
|
||||||
|
{
|
||||||
|
Header("Location: index.php");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'updateremise')
|
if ($_POST["action"] == 'updateremise')
|
||||||
{
|
{
|
||||||
$ligne = new LigneTel($db);
|
$ligne = new LigneTel($db);
|
||||||
@ -129,7 +140,6 @@ if ($_GET["action"] == 'refuse')
|
|||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=".$ligne->id);
|
Header("Location: fiche.php?id=".$ligne->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["action"] == 'resilier')
|
if ($_GET["action"] == 'resilier')
|
||||||
@ -523,6 +533,21 @@ else
|
|||||||
|
|
||||||
print_fiche_titre('Fiche Ligne', $mesg);
|
print_fiche_titre('Fiche Ligne', $mesg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'delete' && $ligne->statut == -1)
|
||||||
|
{
|
||||||
|
$html = new Form($db);
|
||||||
|
|
||||||
|
$html->form_confirm("fiche.php"."?id=".$_GET["id"],"Suppression de ligne","Etes-vous sûr de vouloir supprimer la ligne : ".dolibarr_print_phone($ligne->numero)." ?","confirm_delete");
|
||||||
|
print '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||||
|
|
||||||
if ($ligne->contrat)
|
if ($ligne->contrat)
|
||||||
@ -554,8 +579,6 @@ else
|
|||||||
print $client->cp . " " .$client->ville;
|
print $client->cp . " " .$client->ville;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$client_facture = new Societe($db);
|
$client_facture = new Societe($db);
|
||||||
$client_facture->fetch($ligne->client_facture_id);
|
$client_facture->fetch($ligne->client_facture_id);
|
||||||
|
|
||||||
@ -699,7 +722,6 @@ else
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Edition
|
* Edition
|
||||||
*
|
*
|
||||||
@ -862,11 +884,8 @@ else
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
print '<tr><td width="20%">Remise LMN</td><td>'.$ligne->remise.' %</td></tr>';
|
print '<tr><td width="20%">Remise LMN</td><td>'.$ligne->remise.' %</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
print '<tr><td width="20%" valign="top">Note</td><td>';
|
print '<tr><td width="20%" valign="top">Note</td><td>';
|
||||||
print '<textarea name="note" rows="4" cols="50">';
|
print '<textarea name="note" rows="4" cols="50">';
|
||||||
print nl2br($ligne->note);
|
print nl2br($ligne->note);
|
||||||
@ -1100,6 +1119,11 @@ if ($_GET["action"] == '')
|
|||||||
print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$ligne->id\">".$langs->trans("Edit")."</a>";
|
print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$ligne->id\">".$langs->trans("Edit")."</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $user->rights->telephonie->ligne->creer && $ligne->statut == -1)
|
||||||
|
{
|
||||||
|
print "<a class=\"butDelete\" href=\"fiche.php?action=delete&id=$ligne->id\">".$langs->trans("Delete")."</a>";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|||||||
@ -52,12 +52,8 @@ class LigneTel {
|
|||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
||||||
$sql .= " SET ";
|
$sql .= " SET ";
|
||||||
$sql .= " fk_client_comm = $this->client_comm, ";
|
|
||||||
$sql .= " fk_soc = $this->client, ";
|
|
||||||
$sql .= " ligne = '$this->numero', ";
|
$sql .= " ligne = '$this->numero', ";
|
||||||
$sql .= " fk_soc_facture = $this->client_facture, ";
|
|
||||||
$sql .= " fk_fournisseur = $this->fournisseur, ";
|
$sql .= " fk_fournisseur = $this->fournisseur, ";
|
||||||
$sql .= " fk_commercial = $this->commercial, ";
|
|
||||||
$sql .= " fk_concurrent = $this->concurrent, ";
|
$sql .= " fk_concurrent = $this->concurrent, ";
|
||||||
$sql .= " note = '$this->note'";
|
$sql .= " note = '$this->note'";
|
||||||
$sql .= " WHERE rowid = $this->id";
|
$sql .= " WHERE rowid = $this->id";
|
||||||
@ -168,10 +164,16 @@ class LigneTel {
|
|||||||
{
|
{
|
||||||
if (strlen(trim($this->numero)) == 10)
|
if (strlen(trim($this->numero)) == 10)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* fk_commercial est encore définit pour supporter la migration en douceur
|
||||||
|
* à terme cette colonne sera supprimé
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
||||||
$sql .= " (datec,fk_soc, fk_client_comm, ligne, fk_soc_facture, fk_fournisseur, note, remise, fk_commercial, statut, fk_user_creat, fk_concurrent, fk_contrat)";
|
$sql .= " (datec,fk_soc, fk_client_comm, ligne, fk_soc_facture, fk_fournisseur, note, remise, fk_commercial, fk_commercial_sign, fk_commercial_suiv, statut, fk_user_creat, fk_concurrent, fk_contrat)";
|
||||||
$sql .= " VALUES (";
|
$sql .= " VALUES (";
|
||||||
$sql .= "now(),$this->client,$this->client_comm,'$this->numero',$this->client_facture,$this->fournisseur, '$this->note','$this->remise',$this->commercial, -1,$user->id, $this->concurrent, $this->contrat)";
|
$sql .= "now(),$this->client,$this->client_comm,'$this->numero',$this->client_facture,$this->fournisseur, '$this->note','$this->remise',$this->commercial_sign, $this->commercial_sign, $this->commercial_suiv, -1,$user->id, $this->concurrent, $this->contrat)";
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
@ -194,6 +196,8 @@ class LigneTel {
|
|||||||
{
|
{
|
||||||
$this->error_message = "Echec de la création de la ligne";
|
$this->error_message = "Echec de la création de la ligne";
|
||||||
dolibarr_syslog("LigneTel::Create Error -1");
|
dolibarr_syslog("LigneTel::Create Error -1");
|
||||||
|
dolibarr_syslog("LigneTel::Create ".$this->db->error());
|
||||||
|
dolibarr_syslog("LigneTel::Create $sql");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,7 +227,7 @@ class LigneTel {
|
|||||||
$sql .= " , mode_paiement, fk_concurrent, code_analytique";
|
$sql .= " , mode_paiement, fk_concurrent, code_analytique";
|
||||||
$sql .= " , fk_user_creat, fk_user_commande";
|
$sql .= " , fk_user_creat, fk_user_commande";
|
||||||
$sql .= " , fk_contrat ";
|
$sql .= " , fk_contrat ";
|
||||||
$sql .= " , fk_commercial, fk_commercial_suiv";
|
$sql .= " , fk_commercial_suiv, fk_commercial_sign";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as tl";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as tl";
|
||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
@ -250,7 +254,8 @@ class LigneTel {
|
|||||||
$this->client_id = $obj->fk_soc;
|
$this->client_id = $obj->fk_soc;
|
||||||
$this->client_facture_id = $obj->fk_soc_facture;
|
$this->client_facture_id = $obj->fk_soc_facture;
|
||||||
$this->fournisseur_id = $obj->fk_fournisseur;
|
$this->fournisseur_id = $obj->fk_fournisseur;
|
||||||
$this->commercial_id = $obj->fk_commercial;
|
$this->commercial_id = $obj->fk_commercial_suiv;
|
||||||
|
$this->commercial_sign_id = $obj->fk_commercial_sign;
|
||||||
$this->commercial_suiv_id = $obj->fk_commercial_suiv;
|
$this->commercial_suiv_id = $obj->fk_commercial_suiv;
|
||||||
$this->concurrent_id = $obj->fk_concurrent;
|
$this->concurrent_id = $obj->fk_concurrent;
|
||||||
$this->statut = $obj->statut;
|
$this->statut = $obj->statut;
|
||||||
@ -269,6 +274,8 @@ class LigneTel {
|
|||||||
$this->facturable = 0;
|
$this->facturable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->note = stripslashes($obj->note);
|
||||||
|
|
||||||
$result = 1;
|
$result = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -498,6 +505,71 @@ class LigneTel {
|
|||||||
|
|
||||||
$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function delete($user)
|
||||||
|
{
|
||||||
|
$erro = 0;
|
||||||
|
if ($this->statut == -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($this->db->begin())
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne_remise";
|
||||||
|
$sql .= " WHERE fk_ligne=".$this->id;
|
||||||
|
|
||||||
|
if (!$this->db->query($sql))
|
||||||
|
{
|
||||||
|
dolibarr_syslog("LigneTel::Delete Error -5");
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne_statut";
|
||||||
|
$sql .= " WHERE fk_ligne=".$this->id;
|
||||||
|
|
||||||
|
if (!$this->db->query($sql))
|
||||||
|
{
|
||||||
|
dolibarr_syslog("LigneTel::Delete Error -4");
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_contact_facture";
|
||||||
|
$sql .= " WHERE fk_ligne=".$this->id;
|
||||||
|
|
||||||
|
if (!$this->db->query($sql))
|
||||||
|
{
|
||||||
|
dolibarr_syslog("LigneTel::Delete Error -3");
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
||||||
|
$sql .= " WHERE rowid =".$this->id;
|
||||||
|
|
||||||
|
if (!$this->db->query($sql))
|
||||||
|
{
|
||||||
|
dolibarr_syslog("LigneTel::Delete Error -2");
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****/
|
||||||
|
|
||||||
|
if (!$error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user