Fix: bug #16322 : Création PDF fiche intervention impossible
This commit is contained in:
parent
5141b2ed6b
commit
e283c1516c
@ -36,12 +36,8 @@ if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/mod
|
|||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php");
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sécurité accés client
|
$user->getrights("ficheinter");
|
||||||
if ($user->societe_id > 0)
|
if (!$user->rights->ficheinter->lire) accessforbidden();
|
||||||
{
|
|
||||||
$action = '';
|
|
||||||
$socidp = $user->societe_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["socidp"])
|
if ($_GET["socidp"])
|
||||||
@ -50,6 +46,13 @@ if ($_GET["socidp"])
|
|||||||
$objsoc->fetch($_GET["socidp"]);
|
$objsoc->fetch($_GET["socidp"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sécurité accés client
|
||||||
|
if ($user->societe_id > 0)
|
||||||
|
{
|
||||||
|
$action = '';
|
||||||
|
$socidp = $user->societe_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Traitements des actions
|
* Traitements des actions
|
||||||
@ -94,15 +97,14 @@ if ($_POST["action"] == 'update')
|
|||||||
$_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre créée
|
$_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre créée
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Generation du pdf
|
||||||
* Generation du pdf
|
|
||||||
*/
|
|
||||||
if ($_GET["action"] == 'generate' && $_GET["id"])
|
if ($_GET["action"] == 'generate' && $_GET["id"])
|
||||||
{
|
{
|
||||||
fichinter_pdf_create($db, $_GET["id"]);
|
fichinter_pdf_create($db, $_GET["id"], $_POST['model']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$sel = new Form($db);
|
$sel = new Form($db);
|
||||||
@ -164,7 +166,7 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
if ($conf->projet->enabled)
|
if ($conf->projet->enabled)
|
||||||
{
|
{
|
||||||
// Projet associ
|
// Projet associe
|
||||||
$langs->load("project");
|
$langs->load("project");
|
||||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
|
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
|
||||||
print '<option value="0"></option>';
|
print '<option value="0"></option>';
|
||||||
@ -352,7 +354,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
|||||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id;
|
$urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id;
|
||||||
//$genallowed=$user->rights->fichinter->creer;
|
//$genallowed=$user->rights->fichinter->creer;
|
||||||
//$delallowed=$user->rights->fichinter->supprimer;
|
//$delallowed=$user->rights->fichinter->supprimer;
|
||||||
$genallowed=0;
|
$genallowed=1;
|
||||||
$delallowed=0;
|
$delallowed=0;
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class Fichinter
|
|||||||
*/
|
*/
|
||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
if (!strlen($this->duree)) { $this->duree = 0; }
|
if (! is_numeric($this->duree)) { $this->duree = 0; }
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, note, duree";
|
||||||
if ($this->projet_id) {
|
if ($this->projet_id) {
|
||||||
@ -108,11 +108,12 @@ class Fichinter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* \brief Met a jour une intervention
|
||||||
*
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function update($id)
|
function update($id)
|
||||||
{
|
{
|
||||||
|
if (! is_numeric($this->duree)) { $this->duree = 0; }
|
||||||
if (! strlen($this->projet_id))
|
if (! strlen($this->projet_id))
|
||||||
{
|
{
|
||||||
$this->projet_id = 0;
|
$this->projet_id = 0;
|
||||||
@ -122,17 +123,18 @@ class Fichinter
|
|||||||
* Insertion dans la base
|
* Insertion dans la base
|
||||||
*/
|
*/
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
|
||||||
$sql .= " datei = $this->date";
|
$sql .= " datei = ".$this->date;
|
||||||
$sql .= ", note = '".addslashes($this->note)."'";
|
$sql .= ", note = '".addslashes($this->note)."'";
|
||||||
$sql .= ", duree = $this->duree";
|
$sql .= ", duree = ".$this->duree;
|
||||||
$sql .= ", fk_projet = $this->projet_id";
|
$sql .= ", fk_projet = ".$this->projet_id;
|
||||||
$sql .= " WHERE rowid = $id";
|
$sql .= " WHERE rowid = $id";
|
||||||
|
|
||||||
if (! $this->db->query($sql) )
|
if (! $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->error().' sql='.$sql;
|
||||||
print $this->db->error() . '<b><br>'.$sql;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,13 +185,15 @@ class Fichinter
|
|||||||
function fetch($rowid)
|
function fetch($rowid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT ref,note,fk_soc,fk_statut,duree,".$this->db->pdate(datei)."as di, fk_projet FROM ".MAIN_DB_PREFIX."fichinter WHERE rowid=$rowid;";
|
$sql = "SELECT ref,note,fk_soc,fk_statut,duree,".$this->db->pdate(datei)." as di, fk_projet";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter WHERE rowid=".$rowid;
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows())
|
if ($this->db->num_rows($resql))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $rowid;
|
$this->id = $rowid;
|
||||||
$this->date = $obj->di;
|
$this->date = $obj->di;
|
||||||
@ -200,14 +204,14 @@ class Fichinter
|
|||||||
$this->projet_id = $obj->fk_projet;
|
$this->projet_id = $obj->fk_projet;
|
||||||
$this->statut = $obj->fk_statut;
|
$this->statut = $obj->fk_statut;
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free($resql);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $this->db->error();
|
$this->error=$this->db->error().' sql='.$sql;
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2253,6 +2253,16 @@ class Form
|
|||||||
$model=new ModelePDFCommandes();
|
$model=new ModelePDFCommandes();
|
||||||
$modellist=$model->liste_modeles($this->db);
|
$modellist=$model->liste_modeles($this->db);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if ($modulepart == 'ficheinter')
|
||||||
|
{
|
||||||
|
if (is_array($genallowed)) $modellist=$genallowed;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/fichinter/modules_fichinter.php');
|
||||||
|
$model=new ModelePDFFicheinter();
|
||||||
|
$modellist=$model->liste_modeles($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'facture')
|
elseif ($modulepart == 'facture')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -148,7 +148,7 @@ class ModeleNumRefFicheinter
|
|||||||
\param outputlangs objet lang a utiliser pour traduction
|
\param outputlangs objet lang a utiliser pour traduction
|
||||||
\return int 0 si KO, 1 si OK
|
\return int 0 si KO, 1 si OK
|
||||||
*/
|
*/
|
||||||
function fichinter_pdf_create($db, $facid, $modele='', $outputlangs)
|
function fichinter_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
$langs->load("ficheinter");
|
$langs->load("ficheinter");
|
||||||
|
|||||||
@ -59,9 +59,15 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
{
|
{
|
||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
$fich = new Fichinter($this->db,"",$id);
|
if ($conf->fichinter->dir_output)
|
||||||
if ($fich->fetch($id))
|
|
||||||
{
|
{
|
||||||
|
$fich = new Fichinter($this->db,"",$id);
|
||||||
|
$result=$fich->fetch($id);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db,$fich->error);
|
||||||
|
}
|
||||||
|
|
||||||
$fichref = sanitize_string($fich->ref);
|
$fichref = sanitize_string($fich->ref);
|
||||||
|
|
||||||
$dir = $conf->fichinter->dir_output . "/" . $fichref;
|
$dir = $conf->fichinter->dir_output . "/" . $fichref;
|
||||||
@ -79,12 +85,23 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
|
|
||||||
$pdf->SetXY(10,5);
|
$pdf->SetXY(10,5);
|
||||||
if (defined("FAC_PDF_INTITULE"))
|
// Logo
|
||||||
{
|
$logo=$mysoc->logo;
|
||||||
$pdf->SetTextColor(0,0,200);
|
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO;
|
||||||
$pdf->SetFont('Arial','B',14);
|
if ($logo)
|
||||||
$pdf->MultiCell(60, 8, FAC_PDF_INTITULE, 0, 'L');
|
{
|
||||||
}
|
if (is_readable($logo))
|
||||||
|
{
|
||||||
|
$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pdf->SetTextColor(200,0,0);
|
||||||
|
$pdf->SetFont('Arial','B',8);
|
||||||
|
$pdf->MultiCell(100, 3, $langs->trans("ErrorLogoFileNotFound",$logo), 0, 'L');
|
||||||
|
$pdf->MultiCell(100, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pdf->SetTextColor(70,70,170);
|
$pdf->SetTextColor(70,70,170);
|
||||||
if (defined("FAC_PDF_ADRESSE"))
|
if (defined("FAC_PDF_ADRESSE"))
|
||||||
@ -161,7 +178,7 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorConstantNotDefined","FICHINTER_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
$this->error=$langs->trans("ErrorUnknown");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user