*
* 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");
require("./contrat.class.php");
require("../facture.class.php");
llxHeader();
$mesg = '';
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($action == 'add')
{
$contrat = new Contrat($db);
$id = $product->create($user);
$action = '';
}
if ($HTTP_POST_VARS["action"] == 'miseenservice')
{
$contrat = new Contrat($db);
$contrat->id = $id;
$contrat->fetch($id);
$contrat->mise_en_service($user,
mktime($HTTP_POST_VARS["rehour"],
$HTTP_POST_VARS["remin"],
0,
$HTTP_POST_VARS["remonth"],
$HTTP_POST_VARS["reday"],
$HTTP_POST_VARS["reyear"]),
$HTTP_POST_VARS["duration"]
);
}
if ($action == 'cloture')
{
$contrat = new Contrat($db);
$contrat->id = $id;
$contrat->cloture($user);
}
if ($action == 'update' && $cancel <> 'Annuler')
{
$product = new Product($db);
$product->ref = $HTTP_POST_VARS["ref"];
$product->libelle = $HTTP_POST_VARS["libelle"];
$product->price = $HTTP_POST_VARS["price"];
$product->tva_tx = $HTTP_POST_VARS["tva_tx"];
$product->description = $HTTP_POST_VARS["desc"];
$product->envente = $HTTP_POST_VARS["statut"];
$product->duration_value = $HTTP_POST_VARS["duration_value"];
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
if ( $product->update($id, $user))
{
$action = '';
$mesg = 'Fiche mise à jour';
}
else
{
$action = 'edit';
$mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
}
}
/*
*
*
*/
$html = new Form($db);
if ($action == 'create')
{
print "
';
}
else
{
if ($id)
{
$contrat = new Contrat($db);
$result = $contrat->fetch($id);
if ( $result )
{
print_fiche_titre('Fiche contrat : '.$contrat->id, $mesg);
print '";
}
}
else
{
print "Error";
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print '
';
print '| - | ';
if ($contrat->enservice)
{
print '- | ';
}
else
{
print '[Mise en service] | ';
}
print '- | ';
print '- | ';
if ($contrat->enservice == 1)
{
print '[Clôturer] | ';
}
else
{
print '- | ';
}
print '
';
$db->close();
llxFooter("Dernière modification $Date$ révision $Revision$");
?>