*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$mesg = '';
$dt = time();
$h = strftime("%H",$dt);
$m = strftime("%M",$dt);
$s = strftime("%S",$dt);
if ($_POST["action"] == 'add')
{
$ligne = new LigneTel($db);
$ligne->numero = $_POST["numero"];
$ligne->client_comm = $_POST["client_comm"];
$ligne->client = $_POST["client"];
$ligne->client_facture = $_POST["client_facture"];
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial = $_POST["commercial"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = $_POST["remise"];
$ligne->note = $_POST["note"];
if ( $ligne->create($user) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
else
{
$_GET["action"] = 'create';
}
}
if ($_POST["action"] == 'addcontact')
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->add_contact($_POST["contact_id"]) )
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'delcontact')
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->del_contact($_GET["contact_id"]) )
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'active')
{
$ligne = new LigneTel($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 3, $datea) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'refuse')
{
$ligne = new LigneTel($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 7, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'resilier')
{
$ligne = new LigneTel($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $ligne->set_statut($user, 4) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'annuleresilier')
{
$ligne = new LigneTel($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $ligne->set_statut($user, 3) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'confirmresilier')
{
$ligne = new LigneTel($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 6, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'acommander')
{
$ligne = new LigneTel($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $ligne->set_statut($user, 1, '', $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
$ligne->numero = $_POST["numero"];
$ligne->client_comm = $_POST["client_comm"];
$ligne->client = $_POST["client"];
$ligne->client_facture = $_POST["client_facture"];
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial = $_POST["commercial"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = $_POST["remise"];
$ligne->note = $_POST["note"];
if ( $ligne->update($user) )
{
$action = '';
$mesg = 'Fiche mise à jour';
}
else
{
$action = 're-edit';
$mesg = 'Fiche non mise à jour !' . " " . $entrepot->mesg_error;
}
}
llxHeader("","","Fiche Ligne");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Création
*
*/
if ($_GET["action"] == 'create')
{
$form = new Form($db);
print_titre("Nouvelle ligne");
if (is_object($ligne))
{
// La création a échouée
print $ligne->error_message;
}
else
{
$ligne = new LigneTel($db);
}
print "