Fix: bug #9908 overview: PDF de fiche d'intervention non gnr
This commit is contained in:
parent
e9ee2df17c
commit
c816fa9d08
@ -20,10 +20,11 @@
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/** \file htdocs/fichinter/fiche.php
|
||||
\brief Fichier fiche intervention
|
||||
\ingroup ficheinter
|
||||
\version $Revision$
|
||||
/**
|
||||
\file htdocs/fichinter/fiche.php
|
||||
\brief Fichier fiche intervention
|
||||
\ingroup ficheinter
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -33,90 +34,90 @@ require("../project.class.php");
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$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"];
|
||||
$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)
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ( $db->num_rows() )
|
||||
{
|
||||
$objsoc = $db->fetch_object($result);
|
||||
}
|
||||
$db->free();
|
||||
if ( $db->num_rows($result) )
|
||||
{
|
||||
$objsoc = $db->fetch_object($result);
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
|
||||
/*
|
||||
* Traitements des actions
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_GET["action"] == 'valid')
|
||||
{
|
||||
$fichinter = new Fichinter($db);
|
||||
$fichinter->id = $_GET["id"];
|
||||
$fichinter->valid($user->id, $conf->fichinter->outputdir);
|
||||
$fichinter = new Fichinter($db);
|
||||
$fichinter->id = $_GET["id"];
|
||||
$fichinter->valid($user->id, $conf->fichinter->outputdir);
|
||||
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'add')
|
||||
{
|
||||
$fichinter = new Fichinter($db);
|
||||
$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"];
|
||||
$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
|
||||
$id = $fichinter->create();
|
||||
$_GET["id"]=$id; // Force raffraichissement sur fiche venant d'etre créée
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'update')
|
||||
{
|
||||
$fichinter = new Fichinter($db);
|
||||
$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->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
|
||||
$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"]);
|
||||
$mesg = "PDF généré";
|
||||
fichinter_pdf_create($db, $_GET["id"]);
|
||||
}
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
|
||||
$sel = new Form($db);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Mode creation
|
||||
@ -125,291 +126,247 @@ if ($_GET["action"] == 'generate' && $_GET["id"])
|
||||
*/
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
print_titre("Création d'une fiche d'intervention");
|
||||
print_titre($langs->trans("AddIntervention"));
|
||||
|
||||
if ( $objsoc->prefix_comm )
|
||||
if ( $objsoc->prefix_comm )
|
||||
{
|
||||
$numpr = "FI-" . $objsoc->prefix_comm . "-" . strftime("%y%m%d", time());
|
||||
|
||||
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num = $db->result(0, 0);
|
||||
$db->free();
|
||||
if ($num > 0)
|
||||
{
|
||||
$numpr .= "." . ($num + 1);
|
||||
}
|
||||
}
|
||||
$numpr = "FI-" . $objsoc->prefix_comm . "-" . strftime("%y%m%d", time());
|
||||
|
||||
$fix = new Fichinter($db);
|
||||
$numpr = $fix->get_new_num($objsoc->prefix_comm);
|
||||
|
||||
print "<form action=\"fiche.php\" 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 class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>';
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td><b>".$objsoc->nom."</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("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>".$langs->trans("Ref")."</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
|
||||
print "<tr><td>".$langs->trans("Duration")." (".$langs->trans("days").")</td><td><input name=\"duree\"></td></tr>\n";
|
||||
|
||||
if ($conf->projet->enabled) {
|
||||
// Projet associé
|
||||
$langs->load("project");
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
|
||||
print '<option value="0"></option>';
|
||||
|
||||
$sql = "SELECT p.rowid, p.title FROM ".MAIN_DB_PREFIX."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();
|
||||
print "<option value=\"$projet->rowid\">$projet->title</option>";
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
print '</select>';
|
||||
|
||||
if ($numprojet==0) {
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>'.$langs->trans("Add").'</a>';
|
||||
}
|
||||
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'";
|
||||
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->result(0, 0);
|
||||
$db->free($result);
|
||||
if ($num > 0)
|
||||
{
|
||||
$numpr .= "." . ($num + 1);
|
||||
}
|
||||
}
|
||||
|
||||
$fix = new Fichinter($db);
|
||||
$numpr = $fix->get_new_num($objsoc->prefix_comm);
|
||||
|
||||
print "<form action=\"fiche.php\" method=\"post\">";
|
||||
|
||||
$smonth = 1;
|
||||
$syear = date("Y", time());
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>';
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td><b>".$objsoc->nom."</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("Date")."</td><td>";
|
||||
$sel->select_date(time(),"p");
|
||||
print "</td></tr>";
|
||||
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
||||
|
||||
print "<tr><td>".$langs->trans("Ref")."</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
|
||||
print "<tr><td>".$langs->trans("Duration")." (".$langs->trans("days").")</td><td><input name=\"duree\"></td></tr>\n";
|
||||
|
||||
if ($conf->projet->enabled) {
|
||||
// Projet associ
|
||||
$langs->load("project");
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
|
||||
print '<option value="0"></option>';
|
||||
|
||||
$sql = "SELECT p.rowid, p.title FROM ".MAIN_DB_PREFIX."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();
|
||||
print "<option value=\"$projet->rowid\">$projet->title</option>";
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
print '</select>';
|
||||
|
||||
if ($numprojet==0) {
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>'.$langs->trans("Add").'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("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=\"".$langs->trans("Add")."\">";
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("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=\"".$langs->trans("Add")."\">";
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
print "Vous devez d'abord associer un prefixe commercial a cette societe" ;
|
||||
print "Vous devez d'abord associer un prefixe commercial a cette societe" ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sel = new Form($db);
|
||||
|
||||
/*
|
||||
*
|
||||
* Mode update
|
||||
* Mise a jour de la fiche d'intervention
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Mode update
|
||||
* Mise a jour de la fiche d'intervention
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
|
||||
$fichinter = new Fichinter($db);
|
||||
$fichinter->fetch($_GET["id"]);
|
||||
$fichinter = new Fichinter($db);
|
||||
$fichinter->fetch($_GET["id"]);
|
||||
|
||||
/*
|
||||
* Initialisation de la liste des projets
|
||||
*/
|
||||
$prj = new Project($db);
|
||||
$listeprj = $prj->liste_array($fichinter->societe_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=\"fiche.php\" method=\"post\">";
|
||||
print_titre($langs->trans("EditIntervention"));
|
||||
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
|
||||
print "<input type=\"hidden\" name=\"id\" value=\"".$_GET["id"]."\">";
|
||||
print "<form action=\"fiche.php\" method=\"post\">";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Date")."</td><td>";
|
||||
$sel->select_date($fichinter->date);
|
||||
print "</select></td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Duration")." (".$langs->trans("days").')</td><td><input name="duree" value="'.$fichinter->duree.'"></td></tr>';
|
||||
|
||||
if ($conf->projet->enabled) {
|
||||
// Projet associé
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$sel->select_array("projetidp",$listeprj,$fichinter->projet_id);
|
||||
|
||||
if (sizeof($listeprj) == 0)
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
|
||||
print "<input type=\"hidden\" name=\"id\" value=\"".$_GET["id"]."\">";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Date")."</td><td>";
|
||||
$sel->select_date($fichinter->date);
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Duration")." (".$langs->trans("days").')</td><td><input name="duree" value="'.$fichinter->duree.'"></td></tr>';
|
||||
|
||||
if ($conf->projet->enabled) {
|
||||
// Projet associ
|
||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$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.php?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
||||
print 'Cette société n\'a pas de projet. ';
|
||||
print '<a href='.DOL_URL_ROOT.'/comm/projet/fiche.php?socidp='.$socidp.'&action=create>Créer un projet</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
|
||||
print '<td><textarea name="note" wrap="soft" cols="60" rows="15">';
|
||||
print $fichinter->note;
|
||||
print '</textarea>';
|
||||
print '</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("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=\"".$langs->trans("Save")."\">";
|
||||
print '</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
print "</form>";
|
||||
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print "<input type=\"submit\" value=\"".$langs->trans("Save")."\">";
|
||||
print '</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
print "</form>";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Mode visu
|
||||
*
|
||||
*/
|
||||
* Mode visu
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
{
|
||||
print_fiche_titre("Fiche d'intervention",$mesg);
|
||||
print_fiche_titre($langs->trans("Intervention"),$mesg);
|
||||
|
||||
$fichinter = new Fichinter($db);
|
||||
if ($fichinter->fetch($_GET["id"]))
|
||||
$fichinter = new Fichinter($db);
|
||||
if ($fichinter->fetch($_GET["id"]))
|
||||
{
|
||||
$fichinter->fetch_client();
|
||||
$fichinter->fetch_client();
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td><a href="../comm/fiche.php?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>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>';
|
||||
if ($conf->projet->enabled) {
|
||||
$fichinter->fetch_projet();
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td>'.$fichinter->projet.'</td></tr>';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print nl2br($fichinter->note);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</td></tr>';
|
||||
print "</table>";
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td><a href="../comm/fiche.php?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>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>';
|
||||
if ($conf->projet->enabled) {
|
||||
$fichinter->fetch_projet();
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td>'.$fichinter->projet.'</td></tr>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$fichinter->statut.'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print nl2br($fichinter->note);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<br>';
|
||||
print '<div class="tabsAction">';
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<br>';
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
|
||||
if ($fichinter->statut == 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
$file = $conf->fichinter->dir_output . "/$fichinter->ref/$fichinter->ref.pdf";
|
||||
if ($fichinter->statut == 0 or !file_exists($file))
|
||||
{
|
||||
$langs->load("bills");
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=generate">'.$langs->trans("BuildPDF").'</a>';
|
||||
}
|
||||
|
||||
if ($fichinter->statut == 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table width="50%" cellspacing="2"><tr><td width="50%" valign="top">';
|
||||
print_titre("Documents générés");
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
$file = $conf->fichinter->dir_output . "/$fichinter->ref/$fichinter->ref.pdf";
|
||||
$relativepath="$fichinter->ref/$fichinter->ref.pdf";
|
||||
|
||||
$var=true;
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
|
||||
if ($fichinter->statut == 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
if ($fichinter->statut == 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||
}
|
||||
|
||||
$file = $conf->fichinter->dir_output."/".$fichinter->ref."/".$fichinter->ref.pdf;
|
||||
if ($fichinter->statut == 0 or !file_exists($file))
|
||||
{
|
||||
$langs->load("bills");
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=generate">'.$langs->trans("BuildPDF").'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table width="50%" cellspacing="2"><tr><td width="50%" valign="top">';
|
||||
|
||||
print_titre($langs->trans("Documents"));
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
$file = $conf->fichinter->dir_output . "/$fichinter->ref/$fichinter->ref.pdf";
|
||||
$relativepath="$fichinter->ref/$fichinter->ref.pdf";
|
||||
|
||||
$var=true;
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print "<tr $bc[0]><td>Ficheinter PDF</a></td>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'">'.$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";
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print "<tr $bc[0]><td>Ficheinter PDF</a></td>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'">'.$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
|
||||
else
|
||||
{
|
||||
print "Fiche inexistante";
|
||||
print "Fiche inexistante";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -22,7 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*! \file htdocs/includes/modules/fichinter/modules_fichinter.php
|
||||
/**
|
||||
\file htdocs/includes/modules/fichinter/modules_fichinter.php
|
||||
\ingroup ficheinter
|
||||
\brief Fichier contenant la classe mère de generation des fiches interventions en PDF
|
||||
et la classe mère de numérotation des fiches interventions
|
||||
@ -30,22 +31,23 @@
|
||||
*/
|
||||
|
||||
|
||||
/*! \class ModelePDFFicheinter
|
||||
\brief Classe mère des modèles de fiche intervention
|
||||
/**
|
||||
\class ModelePDFFicheinter
|
||||
\brief Classe mère des modèles de fiche intervention
|
||||
*/
|
||||
|
||||
class ModelePDFFicheinter extends FPDF
|
||||
{
|
||||
var $error='';
|
||||
|
||||
/*! \brief Constructeur
|
||||
/** \brief Constructeur
|
||||
*/
|
||||
function ModelePDFFicheinter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/**
|
||||
\brief Renvoi le dernier message d'erreur de création de fiche intervention
|
||||
*/
|
||||
function pdferror()
|
||||
@ -56,7 +58,7 @@ class ModelePDFFicheinter extends FPDF
|
||||
}
|
||||
|
||||
|
||||
/*! \class ModeleNumRefFicheinter
|
||||
/** \class ModeleNumRefFicheinter
|
||||
\brief Classe mère des modèles de numérotation des références de fiches d'intervention
|
||||
*/
|
||||
|
||||
@ -64,7 +66,7 @@ class ModeleNumRefFicheinter
|
||||
{
|
||||
var $error='';
|
||||
|
||||
/*! \brief Renvoi la description par defaut du modele de numérotation
|
||||
/** \brief Renvoi la description par defaut du modele de numérotation
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function info()
|
||||
@ -74,7 +76,7 @@ class ModeleNumRefFicheinter
|
||||
return $langs->trans("NoDescription");
|
||||
}
|
||||
|
||||
/*! \brief Renvoi un exemple de numérotation
|
||||
/** \brief Renvoi un exemple de numérotation
|
||||
* \return string Example
|
||||
*/
|
||||
function getExample()
|
||||
@ -84,7 +86,7 @@ class ModeleNumRefFicheinter
|
||||
return $langs->trans("NoExample");
|
||||
}
|
||||
|
||||
/*!
|
||||
/**
|
||||
\brief Renvoi le dernier message d'erreur de création de fiche intervention
|
||||
*/
|
||||
function numreferror()
|
||||
@ -95,10 +97,11 @@ class ModeleNumRefFicheinter
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
/**
|
||||
\brief Crée une fiche intervention sur disque en fonction du modèle de FICHEINTER_ADDON_PDF
|
||||
\param db objet base de donnée
|
||||
\param facid id de la facture à créer
|
||||
\return int 0 si KO, 1 si OK
|
||||
*/
|
||||
function fichinter_pdf_create($db, $facid)
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -21,138 +22,155 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*! \file htdocs/includes/modules/fichinter/pdf_soleil.modules.php
|
||||
\ingroup ficheinter
|
||||
\brief Fichier de la classe permettant de générer les fiches d'intervention au modèle Soleil
|
||||
\version $Revision$
|
||||
/**
|
||||
\file htdocs/includes/modules/fichinter/pdf_soleil.modules.php
|
||||
\ingroup ficheinter
|
||||
\brief Fichier de la classe permettant de générer les fiches d'intervention au modèle Soleil
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
/*! \class pdf_soleil
|
||||
\brief Classe permettant de générer les fiches d'intervention au modèle Soleil
|
||||
/**
|
||||
\class pdf_soleil
|
||||
\brief Classe permettant de générer les fiches d'intervention au modèle Soleil
|
||||
*/
|
||||
|
||||
class pdf_soleil extends ModelePDFFicheinter
|
||||
{
|
||||
|
||||
/*! \brief Constructeur
|
||||
\param db handler accès base de donnée
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param db handler accès base de donnée
|
||||
*/
|
||||
function pdf_soleil($db=0)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->description = "Modèle de fiche d'intervention stantdard";
|
||||
function pdf_soleil($db=0)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->description = "Modèle de fiche d'intervention stantdard";
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Fonction générant la fiche d'intervention sur le disque
|
||||
\param id id de la fiche intervention à générer
|
||||
/**
|
||||
\brief Fonction générant la fiche d'intervention sur le disque
|
||||
\param id id de la fiche intervention à générer
|
||||
\return int 1=ok, 0=ko
|
||||
*/
|
||||
function write_pdf_file($id)
|
||||
function write_pdf_file($id)
|
||||
{
|
||||
global $conf;
|
||||
global $user,$langs,$conf;
|
||||
|
||||
$fich = new Fichinter($this->db,"",$id);
|
||||
if ($fich->fetch($id))
|
||||
{
|
||||
$dir = $conf->fichinter->dir_output . "/" . $fich->ref . "/" ;
|
||||
$file = $dir . $fich->ref . ".pdf";
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
umask(0);
|
||||
mkdir($dir, 0755);
|
||||
}
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
$fich = new Fichinter($this->db,"",$id);
|
||||
if ($fich->fetch($id))
|
||||
{
|
||||
$forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
|
||||
$fichref = str_replace($forbidden_chars,"_",$fich->ref);
|
||||
|
||||
$pdf=new FPDF('P','mm','A4');
|
||||
$pdf->Open();
|
||||
$pdf->AddPage();
|
||||
|
||||
$pdf->SetXY(10,5);
|
||||
if (defined("FAC_PDF_INTITULE"))
|
||||
{
|
||||
$pdf->SetTextColor(0,0,200);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->MultiCell(60, 8, FAC_PDF_INTITULE, 0, 'L');
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(70,70,170);
|
||||
if (defined("FAC_PDF_ADRESSE"))
|
||||
{
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->MultiCell(40, 5, FAC_PDF_ADRESSE);
|
||||
}
|
||||
if (defined("FAC_PDF_TEL"))
|
||||
{
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->MultiCell(40, 5, "Tél : ".FAC_PDF_TEL);
|
||||
}
|
||||
if (defined("MAIN_INFO_SIREN"))
|
||||
{
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->MultiCell(40, 5, "SIREN : ".MAIN_INFO_SIREN);
|
||||
}
|
||||
|
||||
if (defined("FAC_PDF_INTITULE2"))
|
||||
{
|
||||
$pdf->SetXY(100,5);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->SetTextColor(0,0,200);
|
||||
$pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R');
|
||||
}
|
||||
/*
|
||||
* Adresse Client
|
||||
*/
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$fich->fetch_client();
|
||||
$pdf->SetXY(102,42);
|
||||
$pdf->MultiCell(66,5, $fich->client->nom);
|
||||
$pdf->SetFont('Arial','B',11);
|
||||
$pdf->SetXY(102,47);
|
||||
$pdf->MultiCell(66,5, $fich->client->adresse . "\n" . $fich->client->cp . " " . $fich->client->ville);
|
||||
$pdf->rect(100, 40, 100, 40);
|
||||
|
||||
|
||||
$pdf->SetTextColor(200,0,0);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $fich->date));
|
||||
$pdf->Text(11, 94, "Fiche d'intervention : ".$fich->ref);
|
||||
|
||||
/*
|
||||
*/
|
||||
$dir = $conf->fichinter->dir_output . "/" . $fichref;
|
||||
$file = $dir . "/" . $fichref . ".pdf";
|
||||
|
||||
/*
|
||||
*/
|
||||
$pdf->SetFillColor(220,220,220);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$tab_top = 100;
|
||||
$tab_height = 110;
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
umask(0);
|
||||
if (! mkdir($dir, 0755))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->SetXY (10, $tab_top);
|
||||
$pdf->MultiCell(190,8,'Désignation',0,'L',0);
|
||||
$pdf->line(10, $tab_top + 8, 200, $tab_top + 8 );
|
||||
|
||||
$pdf->Rect(10, $tab_top, 190, $tab_height);
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$pdf->SetFont('Arial','', 10);
|
||||
if (file_exists($dir))
|
||||
{
|
||||
|
||||
$pdf->SetXY (10, $tab_top + 8 );
|
||||
$pdf->MultiCell(190, 5, $fich->note, 0, 'J', 0);
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$pdf->Output($file);
|
||||
}
|
||||
}
|
||||
$pdf=new FPDF('P','mm','A4');
|
||||
$pdf->Open();
|
||||
$pdf->AddPage();
|
||||
|
||||
$pdf->SetXY(10,5);
|
||||
if (defined("FAC_PDF_INTITULE"))
|
||||
{
|
||||
$pdf->SetTextColor(0,0,200);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->MultiCell(60, 8, FAC_PDF_INTITULE, 0, 'L');
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(70,70,170);
|
||||
if (defined("FAC_PDF_ADRESSE"))
|
||||
{
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->MultiCell(40, 5, FAC_PDF_ADRESSE);
|
||||
}
|
||||
if (defined("FAC_PDF_TEL"))
|
||||
{
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->MultiCell(40, 5, "Tél : ".FAC_PDF_TEL);
|
||||
}
|
||||
if (defined("MAIN_INFO_SIREN"))
|
||||
{
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->MultiCell(40, 5, "SIREN : ".MAIN_INFO_SIREN);
|
||||
}
|
||||
|
||||
if (defined("FAC_PDF_INTITULE2"))
|
||||
{
|
||||
$pdf->SetXY(100,5);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->SetTextColor(0,0,200);
|
||||
$pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R');
|
||||
}
|
||||
/*
|
||||
* Adresse Client
|
||||
*/
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$fich->fetch_client();
|
||||
$pdf->SetXY(102,42);
|
||||
$pdf->MultiCell(66,5, $fich->client->nom);
|
||||
$pdf->SetFont('Arial','B',11);
|
||||
$pdf->SetXY(102,47);
|
||||
$pdf->MultiCell(66,5, $fich->client->adresse . "\n" . $fich->client->cp . " " . $fich->client->ville);
|
||||
$pdf->rect(100, 40, 100, 40);
|
||||
|
||||
|
||||
$pdf->SetTextColor(200,0,0);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $fich->date));
|
||||
$pdf->Text(11, 94, "Fiche d'intervention : ".$fich->ref);
|
||||
|
||||
$pdf->SetFillColor(220,220,220);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$tab_top = 100;
|
||||
$tab_height = 110;
|
||||
|
||||
$pdf->SetXY (10, $tab_top);
|
||||
$pdf->MultiCell(190,8,'Désignation',0,'L',0);
|
||||
$pdf->line(10, $tab_top + 8, 200, $tab_top + 8 );
|
||||
|
||||
$pdf->Rect(10, $tab_top, 190, $tab_height);
|
||||
|
||||
$pdf->SetFont('Arial','', 10);
|
||||
|
||||
$pdf->SetXY (10, $tab_top + 8 );
|
||||
$pdf->MultiCell(190, 5, $fich->note, 0, 'J', 0);
|
||||
|
||||
$pdf->Close();
|
||||
|
||||
$pdf->Output($file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("ErrorConstantNotDefined","FICHINTER_OUTPUTDIR");
|
||||
return 0;
|
||||
}
|
||||
$this->error=$langs->trans("ErrorUnknown");
|
||||
return 0; // Erreur par defaut
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user