* Copyright (C) 2004-2005 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/fichinter/fiche.php \brief Fichier fiche intervention \ingroup ficheinter \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/project.class.php"); // Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } if ($_GET["socidp"]) { $sql = "SELECT s.nom, s.idp, s.prefix_comm FROM ".MAIN_DB_PREFIX."societe as s WHERE s.idp = ".$_GET["socidp"]; $result = $db->query($sql); if ($result) { if ( $db->num_rows($result) ) { $objsoc = $db->fetch_object($result); } $db->free($result); } else { dolibarr_print_error($db); } } /* * Traitements des actions */ if ($_GET["action"] == 'valid') { $fichinter = new Fichinter($db); $fichinter->id = $_GET["id"]; $fichinter->valid($user->id, $conf->fichinter->outputdir); } if ($_POST["action"] == 'add') { $fichinter = new Fichinter($db); $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["pmonth"], $_POST["pday"], $_POST["pyear"])); $fichinter->socidp = $_POST["socidp"]; $fichinter->duree = $_POST["duree"]; $fichinter->projet_id = $_POST["projetidp"]; $fichinter->author = $user->id; $fichinter->note = $_POST["note"]; $fichinter->ref = $_POST["ref"]; $id = $fichinter->create(); $_GET["id"]=$id; // Force raffraichissement sur fiche venant d'etre créée } if ($_POST["action"] == 'update') { $fichinter = new Fichinter($db); $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); $fichinter->socidp = $_POST["socidp"]; $fichinter->duree = $_POST["duree"]; $fichinter->projet_id = $_POST["projetidp"]; $fichinter->author = $user->id; $fichinter->note = $_POST["note"]; $fichinter->ref = $_POST["ref"]; $fichinter->update($_POST["id"]); $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre créée } /** * Generation du pdf */ if ($_GET["action"] == 'generate' && $_GET["id"]) { fichinter_pdf_create($db, $_GET["id"]); } llxHeader(); $sel = new Form($db); /* * * Mode creation * Creation d'une nouvelle fiche d'intervention * */ if ($_GET["action"] == 'create') { print_titre($langs->trans("AddIntervention")); $numpr = "FI-"."-" . strftime("%y%m%d", time()); $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'"; $resql=$db->query($sql); if ($resql) { $num = $db->result(0, 0); $db->free($resql); if ($num > 0) { $numpr .= "." . ($num + 1); } } $fix = new Fichinter($db); $numpr = $fix->get_new_num($objsoc->prefix_comm); print "
"; $smonth = 1; $syear = date("Y", time()); print ''; print ''; print ""; print ""; print ""; print "\n"; print "\n"; if ($conf->projet->enabled) { // Projet associ $langs->load("project"); print ''; print ''; print "'; print ''; print '
".$langs->trans("Company")."".$objsoc->nom."
".$langs->trans("Date").""; $sel->select_date(time(),"p",'','','','fichinter'); print "
".$langs->trans("Ref")."
".$langs->trans("Duration")." (".$langs->trans("days").")
'.$langs->trans("Project").''; if ($numprojet==0) { print 'Cette société n\'a pas de projet. '; $user->getrights("projet"); if ($user->rights->projet->creer) { print ''.$langs->trans("Add").''; } } } print '
'.$langs->trans("Description").'"; print '
'; print ''; print '
'; print '
'; } /* * * Mode update * Mise a jour de la fiche d'intervention * */ if ($_GET["action"] == 'edit') { $fichinter = new Fichinter($db); $fichinter->fetch($_GET["id"]); dolibarr_fiche_head($head, $a, $langs->trans("EditIntervention")); /* * Initialisation de la liste des projets */ print "
"; print ""; print ""; print ''; print ''; print ""; print ''; if ($conf->projet->enabled) { // Projet associé print ''; } print ''; print ''; print ''; print '
'.$langs->trans("Ref").''.$fichinter->ref.'
".$langs->trans("Date").""; $sel->select_date($fichinter->date,'','','','','update'); print "
'.$langs->trans("Duration")." (".$langs->trans("days").')
'.$langs->trans("Project").''; $sel->select_projects($fichinter->societe_id,$fichinter->projet_id,"projetidp"); print '
'.$langs->trans("Description").''; print '
'; print ''; print '
'; print '
'; print ''; } /* * Mode visu * */ if ($_GET["id"] && $_GET["action"] != 'edit') { if ($mesg) print $mesg."
"; dolibarr_fiche_head($head, $a, $langs->trans("InterventionCard")); $fichinter = new Fichinter($db); $result=$fichinter->fetch($_GET["id"]); if (! $result > 0) { dolibarr_print_error($db); exit; } $fichinter->fetch_client(); print ''; print ''; print ''; print ''; print ''; if ($conf->projet->enabled) { $fichinter->fetch_projet(); print ''; } print ''; print ''; print ''; print ''; print "
'.$langs->trans("Ref").''.$fichinter->ref.'
'.$langs->trans("Company").''.$fichinter->client->nom.'
'.$langs->trans("Date").''.dolibarr_print_date($fichinter->date,"%A %d %B %Y").'
'.$langs->trans("Duration").''.$fichinter->duree.'
'.$langs->trans("Ref").''.$fichinter->projet.'
'.$langs->trans("Status").''.$fichinter->getLibStatut().'
'.$langs->trans("Description").''; print nl2br($fichinter->note); print '
"; print ''; /** * Barre d'actions * */ print '
'; if ($user->societe_id == 0) { if ($fichinter->statut == 0) { print ''.$langs->trans("Edit").''; } if ($fichinter->statut == 0) { print ''.$langs->trans("Valid").''; } $file = $conf->fichinter->dir_output."/".$fichinter->ref."/".$fichinter->ref.pdf; if ($fichinter->statut == 0 or !file_exists($file)) { $langs->load("bills"); print ''.$langs->trans("BuildPDF").''; } } print '
'; print '
'; /* * Documents générés */ $filename=sanitize_string($fichinter->ref); $filedir=$conf->fichinter->dir_output . "/".$fichinter->ref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id; //$genallowed=$user->rights->fichinter->creer; //$delallowed=$user->rights->fichinter->supprimer; $genallowed=0; $delallowed=0; $var=true; print "
\n"; $sel->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$ficheinter->modelpdf); print "
"; print " "; print "
\n"; } $db->close(); llxFooter(); ?>