* * 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.php3"); require("./fichinter.class.php3"); require("../project.class.php3"); $db = new Db(); $sql = "SELECT s.nom, s.idp, s.prefix_comm FROM societe as s WHERE s.idp = $socidp;"; $result = $db->query($sql); if ($result) { if ( $db->num_rows() ) { $objsoc = $db->fetch_object(0); } $db->free(); } llxHeader(); /* * Traitements des actions * * */ if ($action == 'valid') { $fichinter = new Fichinter($db); $fichinter->id = $id; $fichinter->valid($user->id, $conf->fichinter->outputdir); } if ($action == 'add') { $fichinter = new Fichinter($db); $fichinter->date = $db->idate(mktime(12, 1 , 1, $pmonth, $pday, $pyear)); $fichinter->socidp = $socidp; $fichinter->duree = $duree; $fichinter->projet_id = $projetidp; $fichinter->author = $user->id; $fichinter->note = $note; $fichinter->ref = $ref; $id = $fichinter->create(); } if ($action == 'update') { $fichinter = new Fichinter($db); $fichinter->date = $db->idate(mktime(12, 1 , 1, $remonth, $reday, $reyear)); $fichinter->socidp = $socidp; $fichinter->duree = $duree; $fichinter->projet_id = $projetidp; $fichinter->author = $user->id; $fichinter->note = $note; $fichinter->ref = $ref; $fichinter->update($id); } /* * * Generation * */ if ($action == 'generate') { if ($id) { //$DBI = "dbi:mysql:dbname=lolixdev:host=espy:user=rodo"; $command = 'export LC_TIME=fr_FR ; export DBI_DSN="dbi:'.$conf->db->type.':dbname='.$conf->db->name.':host='.$conf->db->host.'"'; $command .= " ; ./tex-fichinter.pl --fichinter=".$id ; $command .= " --pdf --ps -vv --html"; $command .= " --output=" .$conf->fichinter->outputdir; $command .= " --templates=" .$conf->fichinter->templatesdir; $output = system($command); print $output; print "
command : $command
";
}
else
{
print $db->error();
}
}
/*
*
* Mode creation
* Creation d'une nouvelle fiche d'intervention
*
*/
if ($action == 'create')
{
print_titre("Création d'une fiche d'intervention");
if ( $objsoc->prefix_comm )
{
$numpr = "FI-" . $objsoc->prefix_comm . "-" . strftime("%y%m%d", time());
$sql = "SELECT count(*) FROM llx_propal WHERE ref like '$numpr%'";
if ( $db->query($sql) )
{
$num = $db->result(0, 0);
$db->free();
if ($num > 0) {
$numpr .= "." . ($num + 1);
}
}
print "";
print "
";
}
else
{
print "Vous devez d'abord associer un prefixe commercial a cette societe" ;
}
}
/*
*
* Mode update
* Mise a jour de la fiche d'intervention
*
*/
if ($action == 'edit')
{
$fichinter = new Fichinter($db);
$fichinter->fetch($id);
/*
* Initialisation de la liste des projets
*/
$prj = new Project($db);
$listeprj = $prj->liste_array($fichinter->societe_id);
print_titre("Mettre à jour Fiche d'intervention");
print "";
print "
";
}
/*
* Mode Fiche
* Affichage de la fiche d'intervention
*
*
*/
if ($id)
{
$fichinter = new Fichinter($db);
$fichinter->fetch($id);
print_titre("Fiche d'intervention");
print '';
print '
";
print ' ';
print 'Date '.strftime("%A %d %B %Y",$fichinter->date).' ';
print 'Numéro '.$fichinter->ref.' ';
print 'Durée '.$fichinter->duree.' ';
print 'Projet ';
print 'Commentaires ';
print '';
print nl2br($fichinter->note);
print ' ';
$file = $conf->fichinter->outputdir . "/$fichinter->ref/$fichinter->ref.pdf";
if (file_exists($file))
{
print 'Documents liste... ';
}
$file = $conf->fichinter->outputdir . "/$fichinter->ref/$fichinter->ref.ps";
if (file_exists($file))
{
print 'PDF '.$fichinter->ref.'.pdf ';
print ''.filesize($file). ' bytes ';
print ''.strftime("%d %b %Y %H:%M:%S",filemtime($file)).' ';
print ' ';
}
$file = $conf->fichinter->outputdir . "/$fichinter->ref/$fichinter->ref.tex";
if (file_exists($file)) {
print 'PS '.$fichinter->ref.'.ps ';
print ''.filesize($file).' bytes ';
print ''.strftime("%d %b %Y %H:%M:%S",filemtime($file)).' ';
print ' ';
}
print '';
print "tex '.$fichinter->ref.'.tex';
print ' [view]';
print ' ';
print ''.filesize($file).' bytes ';
print ''.strftime("%d %b %Y %H:%M:%S",filemtime($file)).' ';
print '
';
}
/*
*
* Liste des fiches
*
*/
$sql = "SELECT s.nom,s.idp, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, fk_projet";
$sql .= " FROM societe as s, llx_fichinter as f ";
$sql .= " WHERE f.fk_soc = s.idp ";
if ($socidp)
{
$sql .= "AND s.idp = $socidp";
}
if ($fichinter > 0)
{
$sql .= "AND s.idp = $fichinter->societe_id";
}
$sql .= " ORDER BY f.datei DESC ;";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print "';
if ($fichinter->statut == 0)
{
print ' Mettre à jour ';
print '- ';
print 'Génération du pdf ';
print '- ';
print 'Valider ';
}
else
{
print '- ';
print '- ';
print '- ';
print '- ';
print '- ';
}
print '
| Num | "; print "Société | "; print "Date | "; print "Statut | "; print " |
| fichid\">$objp->ref | \n"; print "idp\">$objp->nom | \n"; print "".strftime("%d %B %Y",$objp->dp)." | \n"; print "$objp->fk_statut | \n"; print '[Fiche Inter] | '; print "
$sql"; } $db->close(); llxFooter(); ?>