* Copyright (C) 2004 Laurent Destailleur * * 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$ * */ /*! \file htdocs/commande/fiche.php \ingroup commande \brief Fiche commande \version $Revision$ */ require("./pre.inc.php"); $langs->load("contracts"); $langs->load("orders"); $langs->load("companies"); $user->getrights('contrat'); if (!$user->rights->contrat->lire) accessforbidden(); require("../project.class.php"); require("../propal.class.php"); require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } /* * */ if ($_POST["action"] == 'add') { $datecontrat = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $contrat = new Contrat($db); $contrat->soc_id = $_POST["soc_id"]; $contrat->date_contrat = $datecontrat; $contrat->commercial_id = $_POST["commercial"]; $contrat->note = $_POST["note"]; $contrat->projetid = $_POST["projetid"]; $contrat->remise_percent = $_POST["remise_percent"]; /* $contrat->add_product($_POST["idprod1"],$_POST["qty1"],$_POST["remise_percent1"]); $contrat->add_product($_POST["idprod2"],$_POST["qty2"],$_POST["remise_percent2"]); $contrat->add_product($_POST["idprod3"],$_POST["qty3"],$_POST["remise_percent3"]); $contrat->add_product($_POST["idprod4"],$_POST["qty4"],$_POST["remise_percent4"]); */ $result = $contrat->create($user); if ($result == 0) { Header("Location: fiche.php?id=".$contrat->id); } $_GET["id"] = $contrat->id; $action = ''; } /* * */ if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) { $contrat = new Contrat($db); $contrat->fetch($_GET["id"]); $result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"]); if ($result == 0) { Header("Location: fiche.php?id=".$contrat->id); } } llxHeader('',$langs->trans("Contract"),"Contrat"); $html = new Form($db); /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ $id = $_GET["id"]; if ($id > 0) { $contrat = New Contrat($db); if ( $contrat->fetch($id) > 0) { $author = new User($db); $author->id = $contrat->user_author_id; $author->fetch(); $commercial_signature = new User($db); $commercial_signature->id = $contrat->commercial_signature_id; $commercial_signature->fetch(); $commercial_suivi = new User($db); $commercial_suivi->id = $contrat->commercial_suivi_id; $commercial_suivi->fetch(); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; $head[$h][1] = $langs->trans("Contract"); $h++; $head[$h][0] = DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id; $head[$h][1] = $langs->trans("Edition de la ligne"); $hselected = $h; dolibarr_fiche_head($head, $hselected, $contrat->societe->nom); /* * Contrat */ print ''; print ""; print ''; print '"; print ''; print "\n"; print '"; print ''; print ''; print "
".$langs->trans("Customer")."'; print ''.$contrat->societe->nom.''; print $contrat->statuts[$contrat->statut]; print "
'.$langs->trans("Date").'".strftime("%A %d %B %Y",$contrat->date_contrat)."Projet'; if ($contrat->projet_id > 0) { $projet = New Project($db); $projet->fetch($contrat->projet_id); print ''.$projet->title.''; } else { print 'Classer le contrat'; } print " 
'.$langs->trans("Commercial suivi").''.$commercial_suivi->fullname.''.$langs->trans("Commercial signature").''.$commercial_signature->fullname.'
"; /* * Confirmation de la validation * */ if ($_GET["action"] == 'active' && $user->rights->contrat->activer) { print '
'; $dateact = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateact,"Activer le service","Etes-vous sûr de vouloir activer ce service en date du ".strftime("%A %d %B %Y", $dateact)." ?","confirm_active"); } /* * Lignes de contrats * */ echo '
'; $sql = "SELECT l.statut, l.label, l.fk_product, l.description, l.price_ht, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice"; $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as l"; $sql .= " WHERE l.fk_contrat = ".$id; $sql .= " AND rowid = ".$_GET["ligne"]; $sql .= " ORDER BY l.rowid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; $total = 0; if ($num) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; } $var=True; while ($i < $num) { $objp = $db->fetch_object(); print "\n"; if ($objp->fk_product > 0) { print ''; } else { print "\n"; } print ''; print ''; if ($objp->remise_percent > 0) { print '\n"; } else { print ''; } print '\n"; print ''; print "\n"; $i++; $var=!$var; } $db->free(); } else { print $db->error(); } print ''; print "

\n"; if ( $user->rights->contrat->activer && $contrat->statut == 0 && $objp->statut <> 4) { /** * Activer la ligne de contrat */ $form = new Form($db); print '

'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("Discount").'P.U.  
'; print 'statut '; print ''.stripslashes(nl2br($objp->label)).''; if ($objp->description) { print '
'.stripslashes(nl2br($objp->description)); } print '
".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.' %'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice)."  
'; print '
'; print ''; print ''; print ''; print ''; print ''; print '
Activer le service'; print '
Date d\'activation'; if ($_POST["remonth"]) { $dateact = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } else { $dateact = time(); } print $form->select_date($dateact); print '
Intervenant'.$user->fullname.'
Commentaire
'; print '
'; print ' 
'; } } else { /* Contrat non trouvée */ print "Contrat inexistante ou accés refusé"; } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>