Modif des fichiers php3 en php
This commit is contained in:
parent
fa7d38b2bf
commit
66dc85a751
@ -1,423 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
*
|
|
||||||
* 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 "<form action=\"$PHP_SELF?socidp=$socidp\" method=\"post\">";
|
|
||||||
|
|
||||||
$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 '<table border="1" cellspadding="3" cellspacing="0" width="100%">';
|
|
||||||
|
|
||||||
print "<tr><td>Société</td><td><b>".$objsoc->nom."</td></tr>";
|
|
||||||
|
|
||||||
print "<tr><td>Date</td><td>";
|
|
||||||
$cday = date("d", time());
|
|
||||||
print "<select name=\"pday\">";
|
|
||||||
for ($day = 1 ; $day < $sday + 32 ; $day++)
|
|
||||||
{
|
|
||||||
if ($day == $cday)
|
|
||||||
{
|
|
||||||
print "<option value=\"$day\" SELECTED>$day";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<option value=\"$day\">$day";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print "</select>";
|
|
||||||
$cmonth = date("n", time());
|
|
||||||
print "<select name=\"pmonth\">";
|
|
||||||
for ($month = $smonth ; $month < $smonth + 12 ; $month++) {
|
|
||||||
if ($month == $cmonth)
|
|
||||||
{
|
|
||||||
print "<option value=\"$month\" SELECTED>" . $strmonth[$month];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<option value=\"$month\">" . $strmonth[$month];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print "</select>";
|
|
||||||
|
|
||||||
print "<select name=\"pyear\">";
|
|
||||||
|
|
||||||
for ($year = $syear ; $year < $syear + 5 ; $year++)
|
|
||||||
{
|
|
||||||
print "<option value=\"$year\">$year";
|
|
||||||
}
|
|
||||||
print "</select></td></tr>";
|
|
||||||
|
|
||||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
|
||||||
|
|
||||||
print "<tr><td>Numéro</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
|
|
||||||
print "<tr><td>Durée (en jours)</td><td><input name=\"duree\"></td></tr>\n";
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Projet associé
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
print '<tr><td valign="top">Projet</td><td><select name="projetidp">';
|
|
||||||
print '<option value="0"></option>';
|
|
||||||
|
|
||||||
$sql = "SELECT p.rowid, p.title FROM llx_projet as p WHERE p.fk_soc = $socidp";
|
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
|
||||||
{
|
|
||||||
$i = 0 ;
|
|
||||||
$numprojet = $db->num_rows();
|
|
||||||
while ($i < $numprojet) {
|
|
||||||
$projet = $db->fetch_object($i);
|
|
||||||
print "<option value=\"$projet->rowid\">$projet->title</option>";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$db->free();
|
|
||||||
} else {
|
|
||||||
print $db->error();
|
|
||||||
}
|
|
||||||
print '</select>';
|
|
||||||
if ($numprojet==0) {
|
|
||||||
print 'Cette société n\'a pas de projet. ';
|
|
||||||
print '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php3?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td valign="top">Description</td>';
|
|
||||||
print "<td><textarea name=\"note\" wrap=\"soft\" cols=\"60\" rows=\"15\"></textarea>";
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td colspan="2" align="center">';
|
|
||||||
print "<input type=\"submit\" value=\"Enregistrer\">";
|
|
||||||
print '</td></tr>';
|
|
||||||
print '</table>';
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
}
|
|
||||||
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 "<form action=\"$PHP_SELF?id=$id\" method=\"post\">";
|
|
||||||
|
|
||||||
print '<table border="1" cellspadding="3" cellspacing="0" width="100%">';
|
|
||||||
print "<tr><td>Date</td><td>";
|
|
||||||
/*
|
|
||||||
* set $reday, $remonth, $reyear
|
|
||||||
*/
|
|
||||||
print_date_select($fichinter->date);
|
|
||||||
|
|
||||||
print "</select></td></tr>";
|
|
||||||
|
|
||||||
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
|
|
||||||
|
|
||||||
print '<tr><td>Numéro</td><td>'.$fichinter->ref.'</td></tr>';
|
|
||||||
print '<tr><td>Durée (en jours)</td><td><input name="duree" value="'.$fichinter->duree.'"></td></tr>';
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Projet associé
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<tr><td valign="top">Projet</td><td>';
|
|
||||||
|
|
||||||
$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 '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php3?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
|
|
||||||
print '<tr><td valign="top">Description</td>';
|
|
||||||
print '<td><textarea name="note" wrap="soft" cols="60" rows="15">';
|
|
||||||
print $fichinter->note;
|
|
||||||
print '</textarea>';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td colspan="2" align="center">';
|
|
||||||
print "<input type=\"submit\" value=\"Enregistrer\">";
|
|
||||||
print '</td></tr>';
|
|
||||||
print "</table>";
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
|
|
||||||
print "<hr noshade>";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 '<table border="1" cellspadding="3" cellspacing="0" width="100%">';
|
|
||||||
print '<tr><td>Société</td><td><a href="../comm/fiche.php3?socid='.$fichinter->client->id.'">'.$fichinter->client->nom.'</a></td></tr>';
|
|
||||||
print '<tr><td width="20%">Date</td><td>'.strftime("%A %d %B %Y",$fichinter->date).'</td></tr>';
|
|
||||||
print '<tr><td>Numéro</td><td>'.$fichinter->ref.'</td></tr>';
|
|
||||||
print '<tr><td>Durée</td><td>'.$fichinter->duree.'</td></tr>';
|
|
||||||
print '<tr><td valign="top">Projet</td><td> </td></tr>';
|
|
||||||
print '<tr><td valign="top">Description</td>';
|
|
||||||
print '<td colspan="3">';
|
|
||||||
print nl2br($fichinter->note);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '</td></tr>';
|
|
||||||
print "</table>";
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
print '<br><table border="1" cellspadding="3" cellspacing="0" width="100%"><tr>';
|
|
||||||
|
|
||||||
if ($user->societe_id == 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ($fichinter->statut == 0)
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%"><a href="fiche.php3?id='.$id.'&action=edit">Mettre à jour</a></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
|
|
||||||
$file = FICHEINTER_OUTPUTDIR . "/$fichinter->ref/$fichinter->ref.pdf";
|
|
||||||
|
|
||||||
if ($fichinter->statut == 0 or !file_exists($file))
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%"><a href="fiche.php3?id='.$id.'&action=generate">Génération du pdf</a></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
|
|
||||||
if ($fichinter->statut == 0)
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%"><a href="fiche.php3?id='.$id.'&action=valid">Valider</a></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</tr></table>';
|
|
||||||
|
|
||||||
print "<table width=\"50%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
|
|
||||||
print_titre("Documents générés");
|
|
||||||
print "<table width=\"100%\" cellspacing=0 border=1 cellpadding=3>";
|
|
||||||
|
|
||||||
$file = FICHEINTER_OUTPUTDIR . "/$fichinter->ref/$fichinter->ref.pdf";
|
|
||||||
if (file_exists($file))
|
|
||||||
{
|
|
||||||
print "<tr $bc[0]><td>Ficheinter PDF</a></td>";
|
|
||||||
print '<td><a href="'.FICHEINTER_OUTPUT_URL.'/'.$fichinter->ref.'/'.$fichinter->ref.'.pdf">'.$fichinter->ref.'.pdf</a></td>';
|
|
||||||
print '<td align="right">'.filesize($file). ' bytes</td>';
|
|
||||||
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</table></td></tr></table>\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "Fiche inexistante";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
llxFooter();
|
|
||||||
?>
|
|
||||||
@ -1,241 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
*
|
|
||||||
* 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() . '<b><br>'.$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() . '<b><br>'.$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
* $Source$
|
* $Source$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require("./pre.inc.php3");
|
require("./pre.inc.php");
|
||||||
require("../contact.class.php3");
|
require("../contact.class.php3");
|
||||||
|
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
@ -82,7 +82,7 @@ if ( $db->query($sql) )
|
|||||||
$objp = $db->fetch_object( $i);
|
$objp = $db->fetch_object( $i);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<TR $bc[$var]>";
|
print "<TR $bc[$var]>";
|
||||||
print "<TD><a href=\"fiche.php3?id=$objp->fichid\">$objp->ref</a></TD>\n";
|
print "<TD><a href=\"fiche.php?id=$objp->fichid\">$objp->ref</a></TD>\n";
|
||||||
|
|
||||||
print '<td><a href="index.php?socid='.$objp->idp.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0"></a> ';
|
print '<td><a href="index.php?socid='.$objp->idp.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0"></a> ';
|
||||||
print "<a href=\"../comm/fiche.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
|
print "<a href=\"../comm/fiche.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
|
||||||
@ -92,7 +92,7 @@ if ( $db->query($sql) )
|
|||||||
|
|
||||||
if ($user->societe_id == 0)
|
if ($user->societe_id == 0)
|
||||||
{
|
{
|
||||||
print '<TD align="center"><a href="fiche.php3?socidp='.$objp->idp.'&action=create">[Fiche Inter]</A></td>';
|
print '<TD align="center"><a href="fiche.php?socidp='.$objp->idp.'&action=create">[Fiche Inter]</A></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,232 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
# Copyright (C) 2000-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
#
|
|
||||||
# $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 "<br>\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 "<br>\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 "<br>\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 (<FH>) {
|
|
||||||
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 (<FH>) {
|
|
||||||
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 (<FH>) {
|
|
||||||
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 "<p>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();
|
|
||||||
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
*
|
|
||||||
* 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();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<style type="text/css">
|
|
||||||
p.code { background: #cfcfcf }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<?PHP
|
|
||||||
|
|
||||||
|
|
||||||
print_titre("Liste des fiches d'intervention");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$file = $conf->fichinter->outputdir . "/$fichinter_ref/$fichinter_ref.tex";
|
|
||||||
|
|
||||||
print $file .'<p class="code">';
|
|
||||||
|
|
||||||
$fcontents = file ($file);
|
|
||||||
|
|
||||||
if (file_exists($file)) {
|
|
||||||
|
|
||||||
|
|
||||||
while (list ($line_num, $line) = each ($fcontents)) {
|
|
||||||
echo htmlspecialchars ($line), "<br>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// readfile($file);
|
|
||||||
}
|
|
||||||
print "</p>";
|
|
||||||
|
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
||||||
?>
|
|
||||||
Loading…
Reference in New Issue
Block a user