Fix: Uniformisation code et correction sur generation fiche intervention
This commit is contained in:
parent
b5008ce41c
commit
6f71ce4713
@ -36,6 +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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$langs->load("interventions");
|
||||||
|
|
||||||
$user->getrights("ficheinter");
|
$user->getrights("ficheinter");
|
||||||
if (!$user->rights->ficheinter->lire) accessforbidden();
|
if (!$user->rights->ficheinter->lire) accessforbidden();
|
||||||
|
|
||||||
@ -97,14 +99,27 @@ 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
|
/*
|
||||||
if ($_GET["action"] == 'generate' && $_GET["id"])
|
* Générer ou regénérer le document PDF
|
||||||
|
*/
|
||||||
|
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||||
{
|
{
|
||||||
fichinter_pdf_create($db, $_GET["id"], $_POST['model']);
|
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
|
||||||
|
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||||
|
$result=fichinter_pdf_create($db, $_REQUEST['id'], '', $_REQUEST['model'], $outputlangs);
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db,$result);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Affichage page
|
||||||
|
*/
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$sel = new Form($db);
|
$sel = new Form($db);
|
||||||
@ -334,11 +349,16 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
|||||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=valid">'.$langs->trans("Valid").'</a>';
|
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)
|
||||||
if ($fichinter->statut == 0 or !file_exists($file))
|
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=generate">'.$langs->trans("BuildPDF").'</a>';
|
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=builddoc">'.$langs->trans("BuildPDF").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fichinter->statut >= 0)
|
||||||
|
{
|
||||||
|
$langs->load("bills");
|
||||||
|
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=builddoc">'.$langs->trans("RebuildPDF").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
|
*
|
||||||
|
* 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/
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* $Source$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\file htdocs/includes/modules/commande/mod_commande_muguet.php
|
||||||
|
\ingroup commande
|
||||||
|
\brief Fichier contenant la classe du modèle de numérotation de référence de commande Muguet
|
||||||
|
\version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
|
||||||
|
|
||||||
|
/** \class mod_commande_marbre
|
||||||
|
\brief Classe du modèle de numérotation de référence de commande Marbre
|
||||||
|
*/
|
||||||
|
|
||||||
|
class mod_commande_fournisseur_muguet extends ModeleNumRefCommandes
|
||||||
|
{
|
||||||
|
var $prefix='CF';
|
||||||
|
var $error='';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Constructeur
|
||||||
|
*/
|
||||||
|
function mod_commande_fournisseur_muguet()
|
||||||
|
{
|
||||||
|
$this->nom = "Muguet";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Renvoi la description du modele de numérotation
|
||||||
|
* \return string Texte descripif
|
||||||
|
*/
|
||||||
|
function info()
|
||||||
|
{
|
||||||
|
return "Renvoie le numéro sous la forme ".$this->prefix."yymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Renvoi un exemple de numérotation
|
||||||
|
* \return string Example
|
||||||
|
*/
|
||||||
|
function getExample()
|
||||||
|
{
|
||||||
|
return $this->prefix."0501-0001";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
|
||||||
|
* de conflits qui empechera cette numérotation de fonctionner.
|
||||||
|
* \return boolean false si conflit, true si ok
|
||||||
|
*/
|
||||||
|
function canBeActivated()
|
||||||
|
{
|
||||||
|
$coyymm='';
|
||||||
|
|
||||||
|
$sql = "SELECT MAX(ref)";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$row = $db->fetch_row($resql);
|
||||||
|
if ($row) $coyymm = substr($row[0],0,6);
|
||||||
|
}
|
||||||
|
if (! $coyymm || eregi($this->prefix.'[0-9][0-9][0-9][0-9]',$coyymm))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error='Une commande commençant par $coyymm existe en base et est incompatible avec cette numérotation. Supprimer la ou renommer la pour activer ce module.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Renvoi prochaine valeur attribuée
|
||||||
|
* \return string Valeur
|
||||||
|
*/
|
||||||
|
function getNextValue()
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
|
||||||
|
$coyymm='';
|
||||||
|
$sql = "SELECT MAX(ref)";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$row = $db->fetch_row($resql);
|
||||||
|
if ($row) $coyymm = substr($row[0],0,6);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si champ respectant le modèle a été trouvée
|
||||||
|
if (eregi('^'+$this->prefix+'[0-9][0-9][0-9][0-9]',$coyymm))
|
||||||
|
{
|
||||||
|
// Recherche rapide car restreint par un like sur champ indexé
|
||||||
|
$posindice=8;
|
||||||
|
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||||
|
$sql.= " WHERE ref like '${coyymm}%'";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$row = $db->fetch_row($resql);
|
||||||
|
$max = $row[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$max=0;
|
||||||
|
}
|
||||||
|
$yymm = strftime("%y%m",time());
|
||||||
|
$num = sprintf("%04s",$max+1);
|
||||||
|
|
||||||
|
return $this->prefix."$yymm-$num";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief Renvoie la référence de commande suivante non utilisée
|
||||||
|
* \param objsoc Objet société
|
||||||
|
* \return string Texte descripif
|
||||||
|
*/
|
||||||
|
function commande_get_num($objsoc=0)
|
||||||
|
{
|
||||||
|
return $this->getNextValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@ -36,13 +36,15 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
|
|||||||
|
|
||||||
class mod_facture_terre extends ModeleNumRefFactures
|
class mod_facture_terre extends ModeleNumRefFactures
|
||||||
{
|
{
|
||||||
|
var $prefix='FA';
|
||||||
|
var $error='';
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numérotation
|
/** \brief Renvoi la description du modele de numérotation
|
||||||
* \return string Texte descripif
|
* \return string Texte descripif
|
||||||
*/
|
*/
|
||||||
function info()
|
function info()
|
||||||
{
|
{
|
||||||
return "Renvoie le numéro sous la forme FAyymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0";
|
return "Renvoie le numéro sous la forme ".$this->prefix."yymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numérotation
|
/** \brief Renvoi un exemple de numérotation
|
||||||
@ -50,7 +52,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
*/
|
*/
|
||||||
function getExample()
|
function getExample()
|
||||||
{
|
{
|
||||||
return "FA0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
|
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
|
||||||
@ -69,7 +71,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
if ($row) $fayymm = substr($row[0],0,6);
|
if ($row) $fayymm = substr($row[0],0,6);
|
||||||
}
|
}
|
||||||
if (! $fayymm || eregi('FA[0-9][0-9][0-9][0-9]',$fayymm))
|
if (! $fayymm || eregi($this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -99,7 +101,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si champ respectant le modèle a été trouvée
|
// Si champ respectant le modèle a été trouvée
|
||||||
if (eregi('^FA[0-9][0-9][0-9][0-9]',$fayymm))
|
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
|
||||||
{
|
{
|
||||||
// Recherche rapide car restreint par un like sur champ indexé
|
// Recherche rapide car restreint par un like sur champ indexé
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
@ -120,7 +122,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
$yymm = strftime("%y%m",time());
|
$yymm = strftime("%y%m",time());
|
||||||
$num = sprintf("%04s",$max+1);
|
$num = sprintf("%04s",$max+1);
|
||||||
|
|
||||||
return "FA$yymm-$num";
|
return $this->prefix."$yymm-$num";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Renvoie la référence de facture suivante non utilisée
|
/** \brief Renvoie la référence de facture suivante non utilisée
|
||||||
|
|||||||
@ -42,12 +42,23 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Constructeur
|
\brief Constructeur
|
||||||
\param db handler accès base de donnée
|
\param db Handler accès base de donnée
|
||||||
*/
|
*/
|
||||||
function pdf_soleil($db=0)
|
function pdf_soleil($db=0)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
$this->name = 'soleil';
|
||||||
$this->description = "Modèle de fiche d'intervention standard";
|
$this->description = "Modèle de fiche d'intervention standard";
|
||||||
|
|
||||||
|
// Dimension page pour format A4
|
||||||
|
$this->type = 'pdf';
|
||||||
|
$this->page_largeur = 210;
|
||||||
|
$this->page_hauteur = 297;
|
||||||
|
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||||
|
$this->marge_gauche=10;
|
||||||
|
$this->marge_droite=10;
|
||||||
|
$this->marge_haute=10;
|
||||||
|
$this->marge_basse=10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +68,7 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
*/
|
*/
|
||||||
function write_pdf_file($id)
|
function write_pdf_file($id)
|
||||||
{
|
{
|
||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf,$mysoc;
|
||||||
|
|
||||||
if ($conf->fichinter->dir_output)
|
if ($conf->fichinter->dir_output)
|
||||||
{
|
{
|
||||||
@ -69,22 +80,29 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fichref = sanitize_string($fich->ref);
|
$fichref = sanitize_string($fich->ref);
|
||||||
|
|
||||||
$dir = $conf->fichinter->dir_output . "/" . $fichref;
|
$dir = $conf->fichinter->dir_output . "/" . $fichref;
|
||||||
$file = $dir . "/" . $fichref . ".pdf";
|
$file = $dir . "/" . $fichref . ".pdf";
|
||||||
|
|
||||||
if (! is_dir($dir))
|
if (! file_exists($dir))
|
||||||
{
|
{
|
||||||
create_exdir($dir);
|
if (create_exdir($dir) < 0)
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (file_exists($dir))
|
||||||
{
|
{
|
||||||
$pdf=new FPDF('P','mm','A4');
|
// Initialisation document vierge
|
||||||
|
$pdf=new FPDF('P','mm',$this->format);
|
||||||
$pdf->Open();
|
$pdf->Open();
|
||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
|
|
||||||
$pdf->SetXY(10,5);
|
$posy=$this->marge_haute;
|
||||||
|
|
||||||
|
$pdf->SetXY($this->marge_gauche,$posy);
|
||||||
|
|
||||||
// Logo
|
// Logo
|
||||||
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
|
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
|
||||||
if ($logo)
|
if ($logo)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# Dolibarr language file - en_US - interventions
|
# Dolibarr language file - en_US - interventions
|
||||||
Intervention=Intervention
|
Intervention=Intervention
|
||||||
Interventions=Interventions
|
Interventions=Interventions
|
||||||
InterventionCard=InterventionCard
|
InterventionCard=Intervention card
|
||||||
NewIntervention=New intervention
|
NewIntervention=New intervention
|
||||||
EditIntervention=Editer intervention
|
EditIntervention=Editer intervention
|
||||||
AddIntervention=Add intervention
|
AddIntervention=Add intervention
|
||||||
|
|||||||
@ -167,6 +167,10 @@ insert into llx_const (name, value, type, visible) values ('DON_ADDON',
|
|||||||
insert into llx_const (name, value, type, visible) values ('PROPALE_ADDON', 'mod_propale_marbre','chaine',0);
|
insert into llx_const (name, value, type, visible) values ('PROPALE_ADDON', 'mod_propale_marbre','chaine',0);
|
||||||
insert into llx_const (name, value, type, visible) values ('PROPALE_ADDON_PDF', 'azur','chaine',0);
|
insert into llx_const (name, value, type, visible) values ('PROPALE_ADDON_PDF', 'azur','chaine',0);
|
||||||
insert into llx_const (name, value, type, visible) values ('COMMANDE_ADDON', 'mod_commande_ivoire','chaine',0);
|
insert into llx_const (name, value, type, visible) values ('COMMANDE_ADDON', 'mod_commande_ivoire','chaine',0);
|
||||||
|
insert into llx_const (name, value, type, visible) values ('COMMANDE_ADDON_PDF', 'einstein','chaine',0);
|
||||||
|
insert into llx_const (name, value, type, visible) values ('COMMANDE_SUPPLIER_ADDON', 'mod_commande_fournisseur_muguet','chaine',0);
|
||||||
|
insert into llx_const (name, value, type, visible) values ('COMMANDE_SUPPLIER_ADDON_PDF', 'muscadet','chaine',0);
|
||||||
|
insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON', 'enlevement','chaine',0);
|
||||||
insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON_PDF','rouget','chaine',0);
|
insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON_PDF','rouget','chaine',0);
|
||||||
insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON_PDF','soleil','chaine',0);
|
insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON_PDF','soleil','chaine',0);
|
||||||
insert into llx_const (name, value, type, visible) values ('FACTURE_ADDON', 'terre','chaine',0);
|
insert into llx_const (name, value, type, visible) values ('FACTURE_ADDON', 'terre','chaine',0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user