Fix: PDF soleil
This commit is contained in:
parent
c0852b1a87
commit
5c2bfc49a8
@ -19,69 +19,71 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file htdocs/fichinter/fichinter.class.php
|
/** \file htdocs/fichinter/fichinter.class.php
|
||||||
\ingroup ficheinter
|
\ingroup ficheinter
|
||||||
\brief Fichier de la classe des gestion des fiches interventions
|
\brief Fichier de la classe des gestion des fiches interventions
|
||||||
\version $Id$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
||||||
|
|
||||||
|
|
||||||
/** \class Ficheinter
|
/**
|
||||||
\brief Classe des gestion des fiches interventions
|
* \class Ficheinter
|
||||||
*/
|
* \brief Classe des gestion des fiches interventions
|
||||||
|
*/
|
||||||
class Fichinter extends CommonObject
|
class Fichinter extends CommonObject
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $element='fichinter';
|
var $element='fichinter';
|
||||||
var $table_element='fichinter';
|
var $table_element='fichinter';
|
||||||
var $fk_element='fk_fichinter';
|
var $fk_element='fk_fichinter';
|
||||||
var $table_element_line='fichinterdet';
|
var $table_element_line='fichinterdet';
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
|
|
||||||
var $socid; // Id client
|
var $socid; // Id client
|
||||||
var $client; // Objet societe client (a charger par fetch_client)
|
var $client; // Objet societe client (a charger par fetch_client)
|
||||||
|
|
||||||
var $author;
|
var $author;
|
||||||
var $ref;
|
var $ref;
|
||||||
var $date;
|
var $date;
|
||||||
var $date_delivery;
|
var $date_delivery;
|
||||||
var $duree;
|
var $duree;
|
||||||
var $description;
|
var $description;
|
||||||
var $note_private;
|
var $note_private;
|
||||||
var $note_public;
|
var $note_public;
|
||||||
var $projet_id;
|
var $projet_id;
|
||||||
var $modelpdf;
|
var $modelpdf;
|
||||||
|
|
||||||
|
var $lignes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Constructeur de la classe
|
||||||
|
* \param DB Handler acces base de donnees
|
||||||
|
* \param socid Id societe
|
||||||
|
*/
|
||||||
|
function Fichinter($DB, $socid="")
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$this->db = $DB ;
|
||||||
|
$this->socid = $socid;
|
||||||
|
$this->products = array();
|
||||||
|
$this->projet_id = 0;
|
||||||
|
|
||||||
|
// Statut 0=brouillon, 1=valide
|
||||||
|
$this->statuts[0]=$langs->trans("Draft");
|
||||||
|
$this->statuts[1]=$langs->trans("Validated");
|
||||||
|
$this->statuts_short[0]=$langs->trans("Draft");
|
||||||
|
$this->statuts_short[1]=$langs->trans("Validated");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Constructeur de la classe
|
* \brief Cree une fiche intervention en base
|
||||||
* \param DB Handler acces base de donnees
|
* \return int <0 if KO, >0 if OK
|
||||||
* \param socid Id societe
|
*/
|
||||||
*/
|
function create()
|
||||||
function Fichinter($DB, $socid="")
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
|
|
||||||
$this->db = $DB ;
|
|
||||||
$this->socid = $socid;
|
|
||||||
$this->products = array();
|
|
||||||
$this->projet_id = 0;
|
|
||||||
|
|
||||||
// Statut 0=brouillon, 1=valide
|
|
||||||
$this->statuts[0]=$langs->trans("Draft");
|
|
||||||
$this->statuts[1]=$langs->trans("Validated");
|
|
||||||
$this->statuts_short[0]=$langs->trans("Draft");
|
|
||||||
$this->statuts_short[1]=$langs->trans("Validated");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief Cree une fiche intervention en base
|
|
||||||
* \return int <0 if KO, >0 if OK
|
|
||||||
*/
|
|
||||||
function create()
|
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Fichinter.class::create ref=".$this->ref);
|
dolibarr_syslog("Fichinter.class::create ref=".$this->ref);
|
||||||
|
|
||||||
@ -129,175 +131,175 @@ class Fichinter extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Met a jour une intervention
|
* \brief Met a jour une intervention
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function update($id)
|
function update($id)
|
||||||
{
|
{
|
||||||
if (! is_numeric($this->duree)) { $this->duree = 0; }
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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 .= ", description = '".addslashes($this->description)."'";
|
$sql .= ", description = '".addslashes($this->description)."'";
|
||||||
$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;
|
||||||
|
|
||||||
dolibarr_syslog("Fichinter::update sql=".$sql);
|
dolibarr_syslog("Fichinter::update sql=".$sql);
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR);
|
dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge en memoire la fiche intervention
|
* \brief Charge en memoire la fiche intervention
|
||||||
* \param rowid Id de la fiche a charger
|
* \param rowid Id de la fiche a charger
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function fetch($rowid)
|
function fetch($rowid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT ref, description, fk_soc, fk_statut,";
|
$sql = "SELECT ref, description, fk_soc, fk_statut,";
|
||||||
$sql.= " ".$this->db->pdate(datei)." as di, duree, fk_projet, note_public, note_private, model_pdf";
|
$sql.= " ".$this->db->pdate(datei)." as di, duree, fk_projet, note_public, note_private, model_pdf";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
||||||
$sql.= " WHERE rowid=".$rowid;
|
$sql.= " WHERE rowid=".$rowid;
|
||||||
|
|
||||||
dolibarr_syslog("Fichinter::fetch sql=".$sql);
|
dolibarr_syslog("Fichinter::fetch sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows($resql))
|
if ($this->db->num_rows($resql))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $rowid;
|
$this->id = $rowid;
|
||||||
$this->ref = $obj->ref;
|
$this->ref = $obj->ref;
|
||||||
$this->description = $obj->description;
|
$this->description = $obj->description;
|
||||||
$this->socid = $obj->fk_soc;
|
$this->socid = $obj->fk_soc;
|
||||||
$this->statut = $obj->fk_statut;
|
$this->statut = $obj->fk_statut;
|
||||||
$this->date = $obj->di;
|
$this->date = $obj->di;
|
||||||
$this->duree = $obj->duree;
|
$this->duree = $obj->duree;
|
||||||
$this->projetidp = $obj->fk_projet;
|
$this->projetidp = $obj->fk_projet;
|
||||||
$this->note_public = $obj->note_public;
|
$this->note_public = $obj->note_public;
|
||||||
$this->note_private = $obj->note_private;
|
$this->note_private = $obj->note_private;
|
||||||
$this->modelpdf = $obj->model_pdf;
|
$this->modelpdf = $obj->model_pdf;
|
||||||
|
|
||||||
if ($this->statut == 0) $this->brouillon = 1;
|
if ($this->statut == 0) $this->brouillon = 1;
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR);
|
dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Valide une fiche intervention
|
* \brief Valide une fiche intervention
|
||||||
* \param user User qui valide
|
* \param user User qui valide
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function valid($user, $outputdir)
|
function valid($user, $outputdir)
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
|
||||||
$sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id;
|
$sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id;
|
||||||
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
||||||
|
|
||||||
dolibarr_syslog("Fichinter::valid sql=".$sql);
|
dolibarr_syslog("Fichinter::valid sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('FICHEINTER_VALIDATE',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('FICHEINTER_VALIDATE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR);
|
dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Retourne le libelle du statut de l'intervantion
|
|
||||||
* \return string Libelle
|
|
||||||
*/
|
|
||||||
function getLibStatut($mode=0)
|
|
||||||
{
|
|
||||||
return $this->LibStatut($this->statut,$mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Renvoi le libelle d'un statut donne
|
|
||||||
* \param statut id statut
|
|
||||||
* \return string Libelle
|
|
||||||
*/
|
|
||||||
function LibStatut($statut,$mode=0)
|
|
||||||
{
|
|
||||||
if ($mode == 0)
|
|
||||||
{
|
|
||||||
return $this->statuts[$statut];
|
|
||||||
}
|
}
|
||||||
if ($mode == 1)
|
}
|
||||||
{
|
|
||||||
return $this->statuts_short[$statut];
|
|
||||||
}
|
|
||||||
if ($mode == 2)
|
|
||||||
{
|
|
||||||
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0').' '.$this->statuts_short[$statut];
|
|
||||||
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6').' '.$this->statuts_short[$statut];
|
|
||||||
}
|
|
||||||
if ($mode == 3)
|
|
||||||
{
|
|
||||||
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0');
|
|
||||||
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6');
|
|
||||||
}
|
|
||||||
if ($mode == 4)
|
|
||||||
{
|
|
||||||
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0').' '.$this->statuts[$statut];
|
|
||||||
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6').' '.$this->statuts[$statut];
|
|
||||||
}
|
|
||||||
if ($mode == 5)
|
|
||||||
{
|
|
||||||
if ($statut==0) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut0');
|
|
||||||
if ($statut==1) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut6');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Verifie si la ref n'est pas deja utilisee
|
* \brief Retourne le libelle du statut de l'intervantion
|
||||||
* \param soc objet societe
|
* \return string Libelle
|
||||||
*/
|
*/
|
||||||
function verifyNumRef($soc)
|
function getLibStatut($mode=0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."fichinter";
|
return $this->LibStatut($this->statut,$mode);
|
||||||
$sql.= " WHERE ref = '".$this->ref."'";
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
/**
|
||||||
|
* \brief Renvoi le libelle d'un statut donne
|
||||||
|
* \param statut id statut
|
||||||
|
* \return string Libelle
|
||||||
|
*/
|
||||||
|
function LibStatut($statut,$mode=0)
|
||||||
|
{
|
||||||
|
if ($mode == 0)
|
||||||
|
{
|
||||||
|
return $this->statuts[$statut];
|
||||||
|
}
|
||||||
|
if ($mode == 1)
|
||||||
|
{
|
||||||
|
return $this->statuts_short[$statut];
|
||||||
|
}
|
||||||
|
if ($mode == 2)
|
||||||
|
{
|
||||||
|
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0').' '.$this->statuts_short[$statut];
|
||||||
|
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6').' '.$this->statuts_short[$statut];
|
||||||
|
}
|
||||||
|
if ($mode == 3)
|
||||||
|
{
|
||||||
|
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0');
|
||||||
|
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6');
|
||||||
|
}
|
||||||
|
if ($mode == 4)
|
||||||
|
{
|
||||||
|
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0').' '.$this->statuts[$statut];
|
||||||
|
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6').' '.$this->statuts[$statut];
|
||||||
|
}
|
||||||
|
if ($mode == 5)
|
||||||
|
{
|
||||||
|
if ($statut==0) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut0');
|
||||||
|
if ($statut==1) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut6');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Verifie si la ref n'est pas deja utilisee
|
||||||
|
* \param soc objet societe
|
||||||
|
*/
|
||||||
|
function verifyNumRef($soc)
|
||||||
|
{
|
||||||
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."fichinter";
|
||||||
|
$sql.= " WHERE ref = '".$this->ref."'";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
@ -309,97 +311,97 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie la reference de fiche intervention suivante non utilisee en fonction du module
|
* \brief Renvoie la reference de fiche intervention suivante non utilisee en fonction du module
|
||||||
* de numerotation actif defini dans FICHEINTER_ADDON
|
* de numerotation actif defini dans FICHEINTER_ADDON
|
||||||
* \param soc objet societe
|
* \param soc objet societe
|
||||||
* \return string reference libre pour la fiche intervention
|
* \return string reference libre pour la fiche intervention
|
||||||
*/
|
*/
|
||||||
function getNextNumRef($soc)
|
function getNextNumRef($soc)
|
||||||
{
|
{
|
||||||
global $db, $langs;
|
global $db, $langs;
|
||||||
$langs->load("interventions");
|
$langs->load("interventions");
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/fichinter/";
|
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/fichinter/";
|
||||||
|
|
||||||
if (defined("FICHEINTER_ADDON") && FICHEINTER_ADDON)
|
if (defined("FICHEINTER_ADDON") && FICHEINTER_ADDON)
|
||||||
{
|
{
|
||||||
$file = FICHEINTER_ADDON.".php";
|
$file = FICHEINTER_ADDON.".php";
|
||||||
|
|
||||||
// Chargement de la classe de numerotation
|
// Chargement de la classe de numerotation
|
||||||
$classname = FICHEINTER_ADDON;
|
$classname = FICHEINTER_ADDON;
|
||||||
require_once($dir.$file);
|
require_once($dir.$file);
|
||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
|
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNumRef($soc,$this);
|
$numref = $obj->getNumRef($soc,$this);
|
||||||
|
|
||||||
if ( $numref != "")
|
if ( $numref != "")
|
||||||
{
|
{
|
||||||
return $numref;
|
return $numref;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db,"Fichinter::getNextNumRef ".$obj->error);
|
dolibarr_print_error($db,"Fichinter::getNextNumRef ".$obj->error);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
|
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Information sur l'objet fiche intervention
|
* \brief Information sur l'objet fiche intervention
|
||||||
* \param id id de la fiche d'intervention
|
* \param id id de la fiche d'intervention
|
||||||
*/
|
*/
|
||||||
function info($id)
|
function info($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT f.rowid, ";
|
$sql = "SELECT f.rowid, ";
|
||||||
$sql.= $this->db->pdate("f.datec")." as datec, ".$this->db->pdate("f.date_valid")." as datev";
|
$sql.= $this->db->pdate("f.datec")." as datec, ".$this->db->pdate("f.date_valid")." as datev";
|
||||||
$sql.= ", f.fk_user_author, f.fk_user_valid";
|
$sql.= ", f.fk_user_author, f.fk_user_valid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
||||||
$sql.= " WHERE f.rowid = ".$id;
|
$sql.= " WHERE f.rowid = ".$id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows($result))
|
if ($this->db->num_rows($result))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
|
|
||||||
$this->date_creation = $obj->datec;
|
$this->date_creation = $obj->datec;
|
||||||
$this->date_validation = $obj->datev;
|
$this->date_validation = $obj->datev;
|
||||||
|
|
||||||
$cuser = new User($this->db, $obj->fk_user_author);
|
$cuser = new User($this->db, $obj->fk_user_author);
|
||||||
$cuser->fetch();
|
$cuser->fetch();
|
||||||
$this->user_creation = $cuser;
|
$this->user_creation = $cuser;
|
||||||
|
|
||||||
if ($obj->fk_user_valid)
|
if ($obj->fk_user_valid)
|
||||||
{
|
{
|
||||||
$vuser = new User($this->db, $obj->fk_user_valid);
|
$vuser = new User($this->db, $obj->fk_user_valid);
|
||||||
$vuser->fetch();
|
$vuser->fetch();
|
||||||
$this->user_validation = $vuser;
|
$this->user_validation = $vuser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Classe la fiche d'intervention dans un projet
|
* \brief Classe la fiche d'intervention dans un projet
|
||||||
* \param project_id Id du projet dans lequel classer la facture
|
* \param project_id Id du projet dans lequel classer la facture
|
||||||
*/
|
*/
|
||||||
function set_project($user, $project_id)
|
function set_project($user, $project_id)
|
||||||
{
|
{
|
||||||
if ($user->rights->ficheinter->creer)
|
if ($user->rights->ficheinter->creer)
|
||||||
@ -427,9 +429,9 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Efface fiche intervention
|
* \brief Efface fiche intervention
|
||||||
* \param user Objet du user qui efface
|
* \param user Objet du user qui efface
|
||||||
*/
|
*/
|
||||||
function delete($user)
|
function delete($user)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
@ -489,107 +491,107 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Definit une date de livraison du bon d'intervention
|
* \brief Definit une date de livraison du bon d'intervention
|
||||||
* \param user Objet utilisateur qui modifie
|
* \param user Objet utilisateur qui modifie
|
||||||
* \param date_creation date de livraison
|
* \param date_creation date de livraison
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_date_delivery($user, $date_delivery)
|
function set_date_delivery($user, $date_delivery)
|
||||||
{
|
{
|
||||||
if ($user->rights->ficheinter->creer)
|
if ($user->rights->ficheinter->creer)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
|
||||||
$sql.= " SET datei = ".$this->db->idate($date_delivery);
|
$sql.= " SET datei = ".$this->db->idate($date_delivery);
|
||||||
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->date_delivery = $date_delivery;
|
$this->date_delivery = $date_delivery;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Fichinter::set_date_delivery Erreur SQL");
|
dolibarr_syslog("Fichinter::set_date_delivery Erreur SQL");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Definit le label de l'intervention
|
* \brief Definit le label de l'intervention
|
||||||
* \param user Objet utilisateur qui modifie
|
* \param user Objet utilisateur qui modifie
|
||||||
* \param description description
|
* \param description description
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_description($user, $description)
|
function set_description($user, $description)
|
||||||
{
|
{
|
||||||
if ($user->rights->ficheinter->creer)
|
if ($user->rights->ficheinter->creer)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
|
||||||
$sql.= " SET description = '".addslashes($description)."'";
|
$sql.= " SET description = '".addslashes($description)."'";
|
||||||
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Fichinter::set_description Erreur SQL");
|
dolibarr_syslog("Fichinter::set_description Erreur SQL");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajout d'une ligne d'intervention, en base
|
* \brief Ajout d'une ligne d'intervention, en base
|
||||||
* \param fichinterid Id de la fiche d'intervention
|
* \param fichinterid Id de la fiche d'intervention
|
||||||
* \param desc Description de la ligne
|
* \param desc Description de la ligne
|
||||||
* \param date_intervention Date de l'intervention
|
* \param date_intervention Date de l'intervention
|
||||||
* \param duration Duree de l'intervention
|
* \param duration Duree de l'intervention
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
*/
|
*/
|
||||||
function addline($fichinterid, $desc, $date_intervention, $duration)
|
function addline($fichinterid, $desc, $date_intervention, $duration)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration");
|
dolibarr_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration");
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Insertion ligne
|
// Insertion ligne
|
||||||
$ligne=new FichinterLigne($this->db);
|
$ligne=new FichinterLigne($this->db);
|
||||||
|
|
||||||
$ligne->fk_fichinter = $fichinterid;
|
$ligne->fk_fichinter = $fichinterid;
|
||||||
$ligne->desc = $desc;
|
$ligne->desc = $desc;
|
||||||
$ligne->datei = $date_intervention;
|
$ligne->datei = $date_intervention;
|
||||||
$ligne->duration = $duration;
|
$ligne->duration = $duration;
|
||||||
|
|
||||||
$result=$ligne->insert();
|
$result=$ligne->insert();
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise la fiche intervention avec valeurs fictives aleatoire
|
* \brief Initialise la fiche intervention avec valeurs fictives aleatoire
|
||||||
* Sert a generer une fiche intervention pour l'aperu des modeles ou demo
|
* Sert a generer une fiche intervention pour l'aperu des modeles ou demo
|
||||||
*/
|
*/
|
||||||
function initAsSpecimen()
|
function initAsSpecimen()
|
||||||
{
|
{
|
||||||
global $user,$langs;
|
global $user,$langs;
|
||||||
@ -659,26 +661,63 @@ class Fichinter extends CommonObject
|
|||||||
$this->total_tva = $xnbp*19.6;
|
$this->total_tva = $xnbp*19.6;
|
||||||
$this->total_ttc = $xnbp*119.6;
|
$this->total_ttc = $xnbp*119.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initialise la fiche intervention avec valeurs fictives aleatoire
|
||||||
|
* Sert a generer une fiche intervention pour l'aperu des modeles ou demo
|
||||||
|
* \return int <0 OK, >0 KO
|
||||||
|
*/
|
||||||
|
function fetch_lines()
|
||||||
|
{
|
||||||
|
$sql = 'SELECT rowid';
|
||||||
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet';
|
||||||
|
$sql.= ' where fk_fichinter = '.$this->id;
|
||||||
|
|
||||||
|
dolibarr_syslog("Fichinter::fetch_lines sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$objp = $this->db->fetch_object($result);
|
||||||
|
|
||||||
|
$fichinterligne = new FichinterLigne($this->db);
|
||||||
|
$fichinterligne->id = $objp->rowid;
|
||||||
|
//...
|
||||||
|
|
||||||
|
$this->lignes[$i] = $fichinterligne;
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$this->db->free($result);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class FichinterLigne
|
\class FichinterLigne
|
||||||
\brief Classe permettant la gestion des lignes d'intervention
|
\brief Classe permettant la gestion des lignes d'intervention
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FichinterLigne
|
class FichinterLigne
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
// From llx_fichinterdet
|
// From llx_fichinterdet
|
||||||
var $rowid;
|
var $rowid;
|
||||||
var $fk_fichinter;
|
var $fk_fichinter;
|
||||||
var $desc; // Description ligne
|
var $desc; // Description ligne
|
||||||
var $datei; // Date intervention
|
var $datei; // Date intervention
|
||||||
var $duration; // Duree de l'intervention
|
var $duration; // Duree de l'intervention
|
||||||
var $rang = 0;
|
var $rang = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -877,50 +916,49 @@ class FichinterLigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Supprime une ligne d'intervention
|
* \brief Supprime une ligne d'intervention
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
*/
|
*/
|
||||||
function delete_line()
|
function delete_line()
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("FichinterLigne::delete_line lineid=".$this->rowid);
|
dolibarr_syslog("FichinterLigne::delete_line lineid=".$this->rowid);
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->rowid;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->rowid;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
dolibarr_syslog("FichinterLigne::delete_line sql=".$sql);
|
dolibarr_syslog("FichinterLigne::delete_line sql=".$sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$result = $this->update_total();
|
$result = $this->update_total();
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error()." sql=".$sql;
|
$this->error=$this->db->error()." sql=".$sql;
|
||||||
dolibarr_syslog("FichinterLigne::delete_line Error ".$this->error);
|
dolibarr_syslog("FichinterLigne::delete_line Error ".$this->error);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user