diff --git a/htdocs/fichinter/fiche.php3 b/htdocs/fichinter/fiche.php3 deleted file mode 100644 index 256a5cae273..00000000000 --- a/htdocs/fichinter/fiche.php3 +++ /dev/null @@ -1,423 +0,0 @@ - - * - * 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"); - -/* - * Sécurité accés client - */ -if ($user->societe_id > 0) -{ - $action = ''; - $socidp = $user->societe_id; -} - -if ($socidp) -{ - $sql = "SELECT s.nom, s.idp, s.prefix_comm FROM llx_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 du pdf - * - */ -if ($action == 'generate' && $id) -{ - fichinter_pdf_create($db, $id); - $mesg = "PDF généré"; -} -/* - * - * 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); - } - } - - $fix = new Fichinter($db); - $numpr = $fix->get_new_num($objsoc->prefix_comm); - - print "
"; - - $strmonth[1] = "Janvier"; - $strmonth[2] = "Février"; - $strmonth[3] = "Mars"; - $strmonth[4] = "Avril"; - $strmonth[5] = "Mai"; - $strmonth[6] = "Juin"; - $strmonth[7] = "Juillet"; - $strmonth[8] = "Août"; - $strmonth[9] = "Septembre"; - $strmonth[10] = "Octobre"; - $strmonth[11] = "Novembre"; - $strmonth[12] = "Décembre"; - - $smonth = 1; - $syear = date("Y", time()); - print ''; - - print ""; - - print ""; - - print ""; - - print "\n"; - print "\n"; - - /* - * - * Projet associé - * - */ - print ''; - - print ''; - print "'; - - print ''; - print '
Société".$objsoc->nom."
Date"; - $cday = date("d", time()); - print ""; - $cmonth = date("n", time()); - print ""; - - print "
Numéro
Durée (en jours)
Projet'; - if ($numprojet==0) { - print 'Cette société n\'a pas de projet. '; - print 'Créer un projet'; - } - print '
Description"; - print '
'; - print ""; - 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 ''; - print ""; - - print ""; - - print ''; - print ''; - - /* - * - * Projet associé - * - */ - - print ''; - - - print ''; - print ''; - - print ''; - print "
Date"; - /* - * set $reday, $remonth, $reyear - */ - print_date_select($fichinter->date); - - print "
Numéro'.$fichinter->ref.'
Durée (en jours)
Projet'; - - $sel = new Form($db); - $sel->select_array("projetidp",$listeprj,$fichinter->projet_id); - - if (sizeof($listeprj) == 0) - { - print 'Cette société n\'a pas de projet. '; - print 'Créer un projet'; - } - print '
Description'; - print '
'; - print ""; - print '
"; - - print "
"; - - print "
"; - -} - -/* - * Mode Fiche - * Affichage de la fiche d'intervention - * - * - */ - -if ($id) -{ - print_fiche_titre("Fiche d'intervention",$mesg); - - $fichinter = new Fichinter($db); - if ( $fichinter->fetch($id) ) - { - $fichinter->fetch_client(); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print "
Société'.$fichinter->client->nom.'
Date'.strftime("%A %d %B %Y",$fichinter->date).'
Numéro'.$fichinter->ref.'
Durée'.$fichinter->duree.'
Projet 
Description'; - print nl2br($fichinter->note); - print '
"; - - /* - * - */ - print '
'; - - if ($user->societe_id == 0) - { - - if ($fichinter->statut == 0) - { - print ''; - } - else - { - print ''; - } - - print ''; - - $file = FICHEINTER_OUTPUTDIR . "/$fichinter->ref/$fichinter->ref.pdf"; - - if ($fichinter->statut == 0 or !file_exists($file)) - { - print ''; - } - else - { - print ''; - } - - print ''; - - if ($fichinter->statut == 0) - { - print ''; - } - else - { - print ''; - } - - } - else - { - print ''; - print ''; - print ''; - print ''; - print ''; - } - - print '
Mettre à jour--Génération du pdf--Valider------
'; - - print "
"; - print_titre("Documents générés"); - print ""; - - $file = FICHEINTER_OUTPUTDIR . "/$fichinter->ref/$fichinter->ref.pdf"; - if (file_exists($file)) - { - print ""; - print ''; - print ''; - print ''; - } - - print "
Ficheinter PDF'.$fichinter->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; - - } - else - { - print "Fiche inexistante"; - } -} - - -$db->close(); -llxFooter(); -?> diff --git a/htdocs/fichinter/fichinter.class.php3 b/htdocs/fichinter/fichinter.class.php3 deleted file mode 100644 index c553425d816..00000000000 --- a/htdocs/fichinter/fichinter.class.php3 +++ /dev/null @@ -1,241 +0,0 @@ - - * - * 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$ - * - */ - -class Fichinter -{ - var $id; - var $db; - var $socidp; - var $author; - var $ref; - var $date; - var $duree; - var $note; - var $projet_id; - - Function Fichinter($DB, $soc_idp="") - { - $this->db = $DB ; - $this->socidp = $soc_idp; - $this->products = array(); - $this->projet_id = 0; - } - - Function add_product($idproduct) - { - if ($idproduct > 0) - { - $i = sizeof($this->products); - $this->products[$i] = $idproduct; - } - } - /* - * - * - * - */ - Function create() - { - /* - * Insertion dans la base - */ - if (!strlen($this->duree)) { $this->duree = 0; } - - $sql = "INSERT INTO llx_fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree, fk_projet) "; - $sql .= " VALUES ($this->socidp, $this->date, now(), '$this->ref', $this->author, '$this->note', $this->duree, $this->projet_id)"; - $sqlok = 0; - - if (! $this->db->query($sql) ) - { - print $this->db->error() . '
'.$sql; - } - return $this->db->last_insert_id(); - } - /* - * - * - * - */ - Function update($id) - { - if (! strlen($this->projet_id)) - { - $this->projet_id = 0; - } - - /* - * Insertion dans la base - */ - $sql = "UPDATE llx_fichinter SET "; - $sql .= " datei = $this->date"; - $sql .= ", note = '$this->note'"; - $sql .= ", duree = $this->duree"; - $sql .= ", fk_projet = $this->projet_id"; - $sql .= " WHERE rowid = $id"; - - if (! $this->db->query($sql) ) - { - - print $this->db->error() . '
'.$sql; - } - return 1; - } - /* - * - * - * - */ - Function get_new_num($prefix_comm) - { - - $sql = "SELECT max(ref) FROM llx_fichinter WHERE ref like 'FI-".$prefix_comm."-%'"; - - if ($this->db->query($sql) ) - { - if ($this->db->num_rows()) - { - $row = $this->db->fetch_row(0); - $num = $row[0]; - /* - *$num = substr($num, strlen($num) - 4, 4); - *$num = $num + 1; - *$num = '0000' . $num; - *$num = 'FI-' . $prefix_comm . '-' . substr($num, strlen($num) - 4, 4); - */ - $num = substr($num, 3); - $num = substr(strstr($num, "-"),1); - - $num = $num + 1; - //$num = '0000' . $num; - //$num = 'FI-' . $prefix_comm . '-' . substr($num, strlen($num) - 4, 4); - $num = 'FI-' . $prefix_comm . '-' . $num; - return $num; - } - } - else - { - print $this->db->error(); - } - } - - /* - * - * - */ - Function fetch($rowid) - { - - $sql = "SELECT ref,note,fk_soc,fk_statut,duree,".$this->db->pdate(datei)."as di, fk_projet FROM llx_fichinter WHERE rowid=$rowid;"; - - if ($this->db->query($sql) ) - { - if ($this->db->num_rows()) - { - $obj = $this->db->fetch_object(0); - - $this->id = $rowid; - $this->date = $obj->di; - $this->duree = $obj->duree; - $this->ref = $obj->ref; - $this->note = stripslashes($obj->note); - $this->societe_id = $obj->fk_soc; - $this->projet_id = $obj->fk_projet; - $this->statut = $obj->fk_statut; - - $this->db->free(); - return 1; - } - } - else - { - print $this->db->error(); - return 0; - } - } - /* - * - * - * - */ - Function valid($userid, $outputdir) - { - $action_notify = 1; // ne pas modifier cette valeur - - $this->fetch($this->id); - - $sql = "UPDATE llx_fichinter SET fk_statut = 1, date_valid=now(), fk_user_valid=$userid"; - $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; - - if ($this->db->query($sql) ) - { - /* - * Set generates files readonly - * - */ - umask(0); - $file = $outputdir . "/$this->ref/$this->ref.tex"; - if (is_writeable($file)) - { - chmod($file, 0444); - } - $file = $outputdir . "/$this->ref/$this->ref.ps"; - if (is_writeable($file)) - { - chmod($file, 0444); - } - $filepdf = FICHEINTER_OUTPUTDIR . "/$this->ref/$this->ref.pdf"; - if (is_writeable($filepdf)) - { - chmod($filepdf, 0444); - } - - /* - * Notify - * - */ - $mesg = "La fiche d'intervention ".$this->ref." a été validée.\n"; - - $notify = New Notify($this->db); - $notify->send($action_notify, $this->societe_id, $mesg, "ficheinter", $this->id, $filepdf); - - return 1; - } - else - { - print $this->db->error() . ' in ' . $sql; - } - - } - /* - * - * - * - */ - Function fetch_client() - { - $client = new Societe($this->db); - $client->fetch($this->societe_id); - $this->client = $client; - } -} -?> - diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index b8f400a0b0d..b01deccaa5f 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -19,7 +19,7 @@ * $Source$ * */ -require("./pre.inc.php3"); +require("./pre.inc.php"); require("../contact.class.php3"); if ($user->societe_id > 0) @@ -82,7 +82,7 @@ if ( $db->query($sql) ) $objp = $db->fetch_object( $i); $var=!$var; print ""; - print "fichid\">$objp->ref\n"; + print "fichid\">$objp->ref\n"; print ' '; print "idp\">$objp->nom\n"; @@ -92,7 +92,7 @@ if ( $db->query($sql) ) if ($user->societe_id == 0) { - print '[Fiche Inter]'; + print '[Fiche Inter]'; } else { diff --git a/htdocs/fichinter/pre.inc.php3 b/htdocs/fichinter/pre.inc.php3 deleted file mode 100644 index b226a0f462f..00000000000 --- a/htdocs/fichinter/pre.inc.php3 +++ /dev/null @@ -1,44 +0,0 @@ - - * - * 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("../main.inc.php3"); - -function llxHeader($head = "", $urlp = "") -{ - global $user, $conf; - - /* - * - * - */ - top_menu($head); - - $menu = new Menu(); - - $menu->add(DOL_URL_ROOT."/comm/clients.php3","Clients"); - - $menu->add("index.php","Fiches d'intervention"); - - left_menu($menu->liste); -} - - -?> diff --git a/htdocs/fichinter/tex-fichinter.pl b/htdocs/fichinter/tex-fichinter.pl deleted file mode 100755 index 18774222f05..00000000000 --- a/htdocs/fichinter/tex-fichinter.pl +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2000-2002 Rodolphe Quiedeville -# -# $Id$ -# $Source$ -# -# 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. -# or see http://www.gnu.org/ -# -# Génération des fiche d'intervention -# -use strict; -use POSIX; -use DBI; -use Sys::Syslog qw(:DEFAULT setlogsock); -use Getopt::Long; - Getopt::Long::Configure("bundling"); - -Sys::Syslog::setlogsock('unix'); -Sys::Syslog::openlog($0, 'pid', 'daemon'); - - - -my($html, $debug, $verbose, $idfiche, $do_pdf, $do_ps, $templatesdir, $outputdir) = (0,0); - -exit unless GetOptions("fichinter=i" =>\$idfiche, - "templates=s" =>\$templatesdir, - "output=s" =>\$outputdir, - "ps" =>\$do_ps, - "pdf" =>\$do_pdf, - "html" =>\$html, - "v+" =>\$verbose); - -Sys::Syslog::syslog('info', 'Start Fiche Inter '.$idfiche); -Sys::Syslog::syslog('info', '['.$idfiche.'] Start'); -my $DEBUG = 1; - - - -my $mdir = "$outputdir"; -unless (-d $mdir) { - mkdir($mdir,0777) || die "cannot mkdir " . $mdir . ": $!"; -} -print "Output in : $outputdir\n" if $verbose > 1; -print "
\n" if ($verbose > 1 && $html); -# -# -# Fetch datas -# -Sys::Syslog::syslog('info', '['.$idfiche.'] Fetch data'); -my ($numfiche, $societe, $date, $ville, $destinataire, $address, $note, $duree); - -my $dbh = DBI->connect("","","") || die $DBI::errstr ; - -my $sql = "SELECT f.rowid, f.ref, s.nom, s.address, s.cp, s.ville, unix_timestamp(f.datei) as di, f.duree, f.note"; -$sql .= " FROM llx_fichinter as f, societe as s"; -$sql .= " WHERE s.idp = f.fk_soc AND f.rowid = $idfiche"; - -my $sth = $dbh->prepare("$sql") || die $dbh->errstr ; -if ( $sth->execute ) { - - if (! $sth->rows ) { - $sth->finish; - $dbh->disconnect if $dbh; - print "\n" . $dbh->errstr; - print "\n$sql\n"; - exit ; - } - - while (my $hsr = $sth->fetchrow_hashref ) { - $numfiche = $hsr->{"ref"}; - $societe = $hsr->{"nom"}; - $destinataire = $hsr->{"firstname"} . " " . $hsr->{"name"}; - $date = $hsr->{"di"}; - $duree = $hsr->{"duree"}; - $note = $hsr->{"note"}; - $address = $hsr->{"address"}; - $ville = $hsr->{"cp"} . " " . $hsr->{"ville"}; - } - $sth->finish; -} else { - die $dbh->errstr; -} - -$outputdir .= "/".$numfiche; - -Sys::Syslog::syslog('info', '['.$idfiche.'] Outputdir : ' . $outputdir); -unless (-d $outputdir) { - print "Make dir : $outputdir\n" if $verbose > 1; - mkdir($outputdir,0777) || die "cannot mkdir " . $outputdir . ": $!"; -} - -print "Output in : $outputdir\n" if $verbose > 1; -print "
\n" if ($verbose > 1 && $html); -# -# Decoupage de l'adresse en 2 lignes -# -# -my ($adresse2, $adresse1) = ("",$address); -$_ = $address; -if (/^(.*)\n(.*)/) { - $adresse1 = "$1"; - $adresse2 = "$2"; - print "|$adresse1|\n"; - print "|$adresse2|\n"; -} -print "|$address|\n"; -print "
\n" if ($verbose > 1 && $html); - -# -# - -my $tempfilename = "$outputdir/temp"; -open (FT, ">$tempfilename") || die "can't open $tempfilename: $!"; -print FT $note; -close (FT); - -# - - -unless (open (FC, ">$outputdir/$numfiche.tex") ) { - print "can't write in $outputdir/$numfiche.tex: $!"; - Sys::Syslog::syslog('info', '['.$idfiche.'] ' . $!); -} else { - Sys::Syslog::syslog('info', '['.$idfiche.'] ' . $outputdir.'/'.$numfiche.'.tex opened'); -} - -$date = strftime("%A %d %B %Y", localtime($date)); -# -# Body -# -my $bodyfilename = "$templatesdir/header.tex"; -open (FH, "<$bodyfilename") || die "can't open $bodyfilename: $!"; -while () { - s|\_SOCIETE\_|$societe|g; - s|\_ADRESSE1\_|$adresse1|g; - s|\_ADRESSE2\_|$adresse2|g; - s|\_VILLE\_|$ville|g; - s|\_DATE\_|$date|g; - s|\_DUREE\_|$duree|g; - s|\_NUMFICHE\_|$numfiche|g; - - print FC $_; -} -close (FH); - -# -# Body -# -my ($line) = (0); -open (FH, "<$tempfilename") || die "can't open $tempfilename: $!"; -while () { - print FC "\n"; - print FC $_; - print FC "\\\\"; - print FC "\n"; - $line++; -} -close (FH); -print FC "\n"; - - -# -# Footer -# -my $footfilename = "$templatesdir/footer.tex"; -open (FH, "<$footfilename") || die "can't open $footfilename: $!"; -while () { - s|\_SOCIETE\_|$societe|g; - s|\_ADRESSE1\_|$adresse1|g; - s|\_ADRESSE2\_|$adresse2|g; - s|\_VILLE\_|$ville|g; - s|\_DATE\_|$date|g; - s|\_NUMFICHE\_|$numfiche|g; - - print FC $_; -} -close (FH); - -close (FC); - -$dbh->disconnect if $dbh; -# -# -# Generation des documents -# -# -if (-r "$outputdir/$numfiche.tex" ) { - system("cd $outputdir/ ; recode -q -d iso8859-1..ltex < $numfiche.tex > recode-$numfiche.tex"); -} -# -# -if (-r "$outputdir/recode-$numfiche.tex") { - print "Generate dvi file\n"; - system("cd $outputdir/ ; latex recode-$numfiche.tex "); -} -# -# -# - - -print "

Generate pdf file\n"; -if (-r "$outputdir/recode-$numfiche.tex") { - system("cd $outputdir/ ; pdflatex recode-$numfiche.tex > /dev/null"); -} - -if (-r "$outputdir/recode-$numfiche.tex") { - system("cd $outputdir/ ; mv recode-$numfiche.pdf $numfiche.pdf > /dev/null"); -} - -if (-r "$outputdir/recode-$numfiche.dvi") { - print "Generate ps file\n"; - system("cd $outputdir/ ; dvips recode-$numfiche.dvi -o $numfiche.ps "); -} - - -Sys::Syslog::syslog('info', 'End ficheinter '.$idfiche); -Sys::Syslog::closelog(); - diff --git a/htdocs/fichinter/texview.php3 b/htdocs/fichinter/texview.php3 deleted file mode 100644 index 2346dfc82eb..00000000000 --- a/htdocs/fichinter/texview.php3 +++ /dev/null @@ -1,60 +0,0 @@ - - * - * 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("../contact.class.php3"); - -llxHeader(); - -?> - - -fichinter->outputdir . "/$fichinter_ref/$fichinter_ref.tex"; - -print $file .'

'; - -$fcontents = file ($file); - -if (file_exists($file)) { - - - while (list ($line_num, $line) = each ($fcontents)) { - echo htmlspecialchars ($line), "
\n"; - } - - - -// readfile($file); -} -print "

"; - - -llxFooter("Dernière modification $Date$ révision $Revision$"); -?>