2004-10-19 22:43:23 +02:00
|
|
|
|
<?php
|
2003-09-19 13:27:17 +02:00
|
|
|
|
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2006-06-18 16:35:35 +02:00
|
|
|
|
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
2007-05-28 23:02:24 +02:00
|
|
|
|
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
2003-09-19 13:27:17 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-01-09 19:30:34 +01:00
|
|
|
|
/** \file htdocs/fichinter/fichinter.class.php
|
|
|
|
|
|
\ingroup fucheinter
|
|
|
|
|
|
\brief Fichier de la classe des gestion des fiches interventions
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2006-06-18 16:35:35 +02:00
|
|
|
|
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
2005-06-26 00:54:02 +02:00
|
|
|
|
|
2005-01-09 19:30:34 +01:00
|
|
|
|
|
|
|
|
|
|
/** \class Ficheinter
|
|
|
|
|
|
\brief Classe des gestion des fiches interventions
|
|
|
|
|
|
*/
|
2006-06-18 16:35:35 +02:00
|
|
|
|
class Fichinter extends CommonObject
|
2003-09-19 13:27:17 +02:00
|
|
|
|
{
|
2005-09-07 23:47:16 +02:00
|
|
|
|
var $db;
|
2007-06-21 21:49:24 +02:00
|
|
|
|
var $element='fichinter';
|
2006-06-23 21:40:28 +02:00
|
|
|
|
|
|
|
|
|
|
var $id;
|
2006-06-18 16:35:35 +02:00
|
|
|
|
|
2007-06-21 21:49:24 +02:00
|
|
|
|
var $socid; // Id client
|
|
|
|
|
|
var $client; // Objet societe client (<28> charger par fetch_client)
|
2006-06-23 21:40:28 +02:00
|
|
|
|
|
2005-09-07 23:47:16 +02:00
|
|
|
|
var $author;
|
|
|
|
|
|
var $ref;
|
|
|
|
|
|
var $date;
|
|
|
|
|
|
var $duree;
|
2007-06-22 11:29:45 +02:00
|
|
|
|
var $description;
|
2007-06-22 11:27:19 +02:00
|
|
|
|
var $note_private;
|
2007-06-22 10:44:46 +02:00
|
|
|
|
var $note_public;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
var $projet_id;
|
|
|
|
|
|
|
2006-06-18 16:35:35 +02:00
|
|
|
|
|
2005-09-07 23:47:16 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Constructeur de la classe
|
|
|
|
|
|
* \param DB Handler acc<EFBFBD>s base de donn<EFBFBD>es
|
2006-09-13 20:56:30 +02:00
|
|
|
|
* \param socid Id societe
|
2005-09-07 23:47:16 +02:00
|
|
|
|
*/
|
2006-09-13 20:56:30 +02:00
|
|
|
|
function Fichinter($DB, $socid="")
|
2003-09-19 13:27:17 +02:00
|
|
|
|
{
|
2005-09-07 23:47:16 +02:00
|
|
|
|
global $langs;
|
|
|
|
|
|
|
|
|
|
|
|
$this->db = $DB ;
|
2006-09-13 20:56:30 +02:00
|
|
|
|
$this->socid = $socid;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
$this->products = array();
|
|
|
|
|
|
$this->projet_id = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Statut 0=brouillon, 1=valid<69>
|
|
|
|
|
|
$this->statuts[0]=$langs->trans("Draft");
|
|
|
|
|
|
$this->statuts[1]=$langs->trans("Validated");
|
2006-05-10 22:34:25 +02:00
|
|
|
|
$this->statuts_short[0]=$langs->trans("Draft");
|
|
|
|
|
|
$this->statuts_short[1]=$langs->trans("Validated");
|
2003-09-19 13:27:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* \brief Cr<EFBFBD>e une fiche intervention en base
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
function create()
|
2003-09-19 13:27:17 +02:00
|
|
|
|
{
|
2007-05-28 23:02:24 +02:00
|
|
|
|
if (! is_numeric($this->duree)) { $this->duree = 0; }
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
2007-05-28 23:02:24 +02:00
|
|
|
|
// on v<>rifie si la ref n'est pas utilis<69>e
|
|
|
|
|
|
$soc = new Societe($this->db);
|
|
|
|
|
|
$soc->fetch($this->socid);
|
|
|
|
|
|
$this->verifyNumRef($soc);
|
|
|
|
|
|
|
|
|
|
|
|
dolibarr_syslog("Fichinter.class::create ref=".$this->ref);
|
|
|
|
|
|
|
|
|
|
|
|
$this->db->begin();
|
2007-01-25 21:12:45 +01:00
|
|
|
|
|
2007-06-22 10:44:46 +02:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (fk_soc, datei, datec, ref, fk_user_author, description, duree";
|
2005-09-07 23:47:16 +02:00
|
|
|
|
if ($this->projet_id) {
|
|
|
|
|
|
$sql .= ",fk_projet";
|
|
|
|
|
|
}
|
|
|
|
|
|
$sql .= ") ";
|
2007-06-22 10:44:46 +02:00
|
|
|
|
$sql .= " VALUES ($this->socid, $this->date, now(), '$this->ref', $this->author, '".addslashes($this->description)."', $this->duree";
|
2005-09-07 23:47:16 +02:00
|
|
|
|
if ($this->projet_id) {
|
2007-01-25 21:12:45 +01:00
|
|
|
|
$sql .= ", ".$this->projet_id;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
$sql .= ")";
|
|
|
|
|
|
$sqlok = 0;
|
|
|
|
|
|
|
2007-01-25 21:12:45 +01:00
|
|
|
|
dolibarr_syslog("Fichinter::create sql=".$sql);
|
2005-09-07 23:47:16 +02:00
|
|
|
|
$result=$this->db->query($sql);
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
2007-01-25 21:12:45 +01:00
|
|
|
|
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
|
|
|
|
|
|
$this->db->commit();
|
|
|
|
|
|
return $this->id;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2007-01-25 21:12:45 +01:00
|
|
|
|
$this->error=$this->db->error();
|
|
|
|
|
|
dolibarr_syslog("Fichinter::create ".$this->error);
|
|
|
|
|
|
$this->db->rollback();
|
|
|
|
|
|
return -1;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
2003-09-19 13:27:17 +02:00
|
|
|
|
|
|
|
|
|
|
}
|
2005-02-10 23:55:42 +01:00
|
|
|
|
|
2005-09-07 23:47:16 +02:00
|
|
|
|
/*
|
2006-04-29 03:28:16 +02:00
|
|
|
|
* \brief Met a jour une intervention
|
|
|
|
|
|
* \return int <0 si ko, >0 si ok
|
2005-09-07 23:47:16 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function update($id)
|
2003-09-19 13:27:17 +02:00
|
|
|
|
{
|
2006-04-29 03:28:16 +02:00
|
|
|
|
if (! is_numeric($this->duree)) { $this->duree = 0; }
|
2005-09-07 23:47:16 +02:00
|
|
|
|
if (! strlen($this->projet_id))
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->projet_id = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Insertion dans la base
|
|
|
|
|
|
*/
|
|
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$sql .= " datei = ".$this->date;
|
2007-06-22 10:44:46 +02:00
|
|
|
|
$sql .= ", description = '".addslashes($this->description)."'";
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$sql .= ", duree = ".$this->duree;
|
|
|
|
|
|
$sql .= ", fk_projet = ".$this->projet_id;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
$sql .= " WHERE rowid = $id";
|
|
|
|
|
|
|
|
|
|
|
|
if (! $this->db->query($sql) )
|
|
|
|
|
|
{
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$this->error=$this->db->error().' sql='.$sql;
|
|
|
|
|
|
return -1;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
2006-04-29 03:28:16 +02:00
|
|
|
|
|
2005-09-07 23:47:16 +02:00
|
|
|
|
return 1;
|
2003-09-19 13:27:17 +02:00
|
|
|
|
}
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
2006-08-02 02:01:43 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Charge en m<EFBFBD>moire la fiche intervention
|
|
|
|
|
|
* \param rowid Id de la fiche <EFBFBD> charger
|
|
|
|
|
|
* \return int <0 si ko, >0 si ok
|
2005-09-07 23:47:16 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function fetch($rowid)
|
2003-09-19 13:27:17 +02:00
|
|
|
|
{
|
2007-06-22 14:36:50 +02:00
|
|
|
|
$sql = "SELECT ref, description, fk_soc, fk_statut, duree";
|
|
|
|
|
|
$sql.= ", ".$this->db->pdate(datei)." as di, fk_projet, note_public, note_private";
|
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
|
|
|
|
|
$sql.= " WHERE rowid=".$rowid;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
2007-06-22 14:36:50 +02:00
|
|
|
|
dolibarr_syslog("Fichinter.class::fetch rowid=$rowid sql=$sql");
|
2006-08-02 02:01:43 +02:00
|
|
|
|
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$resql=$this->db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2005-09-07 23:47:16 +02:00
|
|
|
|
{
|
2006-04-29 03:28:16 +02:00
|
|
|
|
if ($this->db->num_rows($resql))
|
2005-09-07 23:47:16 +02:00
|
|
|
|
{
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$obj = $this->db->fetch_object($resql);
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
2007-06-22 14:36:50 +02:00
|
|
|
|
$this->id = $rowid;
|
|
|
|
|
|
$this->date = $obj->di;
|
|
|
|
|
|
$this->duree = $obj->duree;
|
|
|
|
|
|
$this->ref = $obj->ref;
|
|
|
|
|
|
$this->description = $obj->description;
|
|
|
|
|
|
$this->socid = $obj->fk_soc;
|
|
|
|
|
|
$this->projet_id = $obj->fk_projet;
|
|
|
|
|
|
$this->statut = $obj->fk_statut;
|
|
|
|
|
|
$this->note_public = $obj->note_public;
|
|
|
|
|
|
$this->note_private = $obj->note_private;
|
2007-06-21 21:49:24 +02:00
|
|
|
|
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$this->db->free($resql);
|
2005-09-07 23:47:16 +02:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2006-04-29 03:28:16 +02:00
|
|
|
|
$this->error=$this->db->error().' sql='.$sql;
|
|
|
|
|
|
return -1;
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
2003-09-19 13:27:17 +02:00
|
|
|
|
}
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
2006-08-05 18:44:43 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Valide une fiche intervention
|
|
|
|
|
|
* \param user User qui valide
|
|
|
|
|
|
* \return int <0 si ko, >0 si ok
|
2005-09-07 23:47:16 +02:00
|
|
|
|
*/
|
2006-08-05 18:44:43 +02:00
|
|
|
|
function valid($user, $outputdir)
|
2003-09-19 13:27:17 +02:00
|
|
|
|
{
|
2006-08-05 18:44:43 +02:00
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
|
|
|
|
|
|
$sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id;
|
|
|
|
|
|
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
|
|
|
|
|
$resql=$this->db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2005-06-26 00:46:19 +02:00
|
|
|
|
{
|
2006-08-05 18:44:43 +02:00
|
|
|
|
// Appel des triggers
|
|
|
|
|
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
|
|
|
|
|
$interface=new Interfaces($this->db);
|
|
|
|
|
|
$result=$interface->run_triggers('FICHEINTER_VALIDATE',$this,$user,$langs,$conf);
|
|
|
|
|
|
// Fin appel triggers
|
2005-09-07 23:47:16 +02:00
|
|
|
|
|
2005-06-26 00:46:19 +02:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2006-08-05 18:44:43 +02:00
|
|
|
|
$this->error=$this->db->error().' sql='.$sql;
|
2005-06-26 00:46:19 +02:00
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
2003-09-19 13:27:17 +02:00
|
|
|
|
}
|
2005-02-11 00:25:05 +01:00
|
|
|
|
|
2005-09-07 23:47:16 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Retourne le libell<EFBFBD> du statut de l'intervantion
|
|
|
|
|
|
* \return string Libell<EFBFBD>
|
|
|
|
|
|
*/
|
2006-05-10 22:34:25 +02:00
|
|
|
|
function getLibStatut($mode=0)
|
2005-09-07 23:47:16 +02:00
|
|
|
|
{
|
2006-05-10 22:34:25 +02:00
|
|
|
|
return $this->LibStatut($this->statut,$mode);
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \brief Renvoi le libell<EFBFBD> d'un statut donn<EFBFBD>
|
|
|
|
|
|
* \param statut id statut
|
|
|
|
|
|
* \return string Libell<EFBFBD>
|
|
|
|
|
|
*/
|
2006-05-10 22:34:25 +02:00
|
|
|
|
function LibStatut($statut,$mode=0)
|
2005-09-07 23:47:16 +02:00
|
|
|
|
{
|
2006-05-10 22:34:25 +02:00
|
|
|
|
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];
|
2007-07-07 19:16:12 +02:00
|
|
|
|
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6').' '.$this->statuts_short[$statut];
|
2006-05-10 22:34:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
if ($mode == 3)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0');
|
2007-07-07 19:16:12 +02:00
|
|
|
|
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6');
|
2006-05-10 22:34:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
if ($mode == 4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($statut==0) return img_picto($this->statuts_short[$statut],'statut0').' '.$this->statuts[$statut];
|
2007-07-07 19:16:12 +02:00
|
|
|
|
if ($statut==1) return img_picto($this->statuts_short[$statut],'statut6').' '.$this->statuts[$statut];
|
2006-05-10 22:34:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
if ($mode == 5)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($statut==0) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut0');
|
2007-07-07 19:16:12 +02:00
|
|
|
|
if ($statut==1) return $this->statuts_short[$statut].' '.img_picto($this->statuts_short[$statut],'statut6');
|
2006-05-10 22:34:25 +02:00
|
|
|
|
}
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
2007-01-25 21:12:45 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \brief Positionne modele derniere generation
|
|
|
|
|
|
* \param user Objet use qui modifie
|
|
|
|
|
|
* \param modelpdf Nom du modele
|
|
|
|
|
|
*/
|
|
|
|
|
|
function set_pdf_model($user, $modelpdf)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($user->rights->facture->creer)
|
|
|
|
|
|
{
|
|
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET model_pdf = '$modelpdf'";
|
|
|
|
|
|
$sql .= " WHERE rowid = ".$this->id;
|
|
|
|
|
|
|
|
|
|
|
|
$resql=$this->db->query($sql);
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->modelpdf=$modelpdf;
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_print_error($this->db);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-05-28 23:02:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \brief V<EFBFBD>rifie si la ref n'est pas d<EFBFBD>j<EFBFBD> utilis<EFBFBD>e
|
|
|
|
|
|
* \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)
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = $this->db->num_rows($result);
|
|
|
|
|
|
if ($num > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->ref = $this->getNextNumRef($soc);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \brief Renvoie la r<EFBFBD>f<EFBFBD>rence de fiche intervention suivante non utilis<EFBFBD>e en fonction du module
|
|
|
|
|
|
* de num<EFBFBD>rotation actif d<EFBFBD>fini dans FICHEINTER_ADDON
|
|
|
|
|
|
* \param soc objet societe
|
|
|
|
|
|
* \return string reference libre pour la fiche intervention
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getNextNumRef($soc)
|
|
|
|
|
|
{
|
|
|
|
|
|
global $db, $langs;
|
|
|
|
|
|
$langs->load("interventions");
|
|
|
|
|
|
|
|
|
|
|
|
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/fichinter/";
|
|
|
|
|
|
|
|
|
|
|
|
if (defined("FICHEINTER_ADDON") && FICHEINTER_ADDON)
|
|
|
|
|
|
{
|
|
|
|
|
|
$file = FICHEINTER_ADDON.".php";
|
|
|
|
|
|
|
|
|
|
|
|
// Chargement de la classe de num<75>rotation
|
|
|
|
|
|
$classname = FICHEINTER_ADDON;
|
|
|
|
|
|
require_once($dir.$file);
|
|
|
|
|
|
|
|
|
|
|
|
$obj = new $classname();
|
|
|
|
|
|
|
|
|
|
|
|
$numref = "";
|
|
|
|
|
|
$numref = $obj->getNumRef($soc,$this);
|
|
|
|
|
|
|
|
|
|
|
|
if ( $numref != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
return $numref;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_print_error($db,"Fichinter::getNextNumRef ".$obj->error);
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-06-22 14:36:50 +02:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \brief Mets <EFBFBD> jour les commentaires publiques et priv<EFBFBD>s
|
|
|
|
|
|
* \param note Commentaire
|
|
|
|
|
|
* \param type Type de note
|
|
|
|
|
|
* \return int <0 si ko, >0 si ok
|
|
|
|
|
|
*/
|
|
|
|
|
|
function update_note($note,$type)
|
|
|
|
|
|
{
|
|
|
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinter';
|
|
|
|
|
|
$sql.= " SET ".$type." = '".addslashes($note)."'";
|
|
|
|
|
|
$sql.= " WHERE rowid =". $this->id;
|
|
|
|
|
|
|
|
|
|
|
|
dolibarr_syslog("Fichinter.class::update_note type=".$type." sql=".$sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->db->query($sql))
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->$type = $type;
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->error=$this->db->error();
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-06-22 14:38:17 +02:00
|
|
|
|
* \brief Information sur l'objet fiche intervention
|
|
|
|
|
|
* \param id id de la fiche d'intervention
|
2007-06-22 14:36:50 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function info($id)
|
|
|
|
|
|
{
|
|
|
|
|
|
$sql = "SELECT f.rowid, ";
|
|
|
|
|
|
$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.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
|
|
|
|
|
$sql.= " WHERE f.rowid = ".$id;
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->num_rows($result))
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $this->db->fetch_object($result);
|
|
|
|
|
|
|
|
|
|
|
|
$this->id = $obj->rowid;
|
|
|
|
|
|
|
|
|
|
|
|
$this->date_creation = $obj->datec;
|
|
|
|
|
|
$this->date_validation = $obj->datev;
|
|
|
|
|
|
|
|
|
|
|
|
$cuser = new User($this->db, $obj->fk_user_author);
|
|
|
|
|
|
$cuser->fetch();
|
|
|
|
|
|
$this->user_creation = $cuser;
|
|
|
|
|
|
|
|
|
|
|
|
if ($obj->fk_user_valid)
|
|
|
|
|
|
{
|
|
|
|
|
|
$vuser = new User($this->db, $obj->fk_user_valid);
|
|
|
|
|
|
$vuser->fetch();
|
|
|
|
|
|
$this->user_validation = $vuser;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
$this->db->free($result);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_print_error($this->db);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2005-09-07 23:47:16 +02:00
|
|
|
|
}
|
2006-04-06 11:29:57 +02:00
|
|
|
|
?>
|