From 080045ccef52714ea7a90736549b2fd6c2f1f470 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2007 12:36:50 +0000 Subject: [PATCH] Add: ajout de l'onglet info et note dans les fiches d'interventions --- htdocs/fichinter/fichinter.class.php | 96 +++++++++++++-- htdocs/fichinter/info.php | 72 +++++++++++ htdocs/fichinter/note.php | 174 +++++++++++++++++++++++++++ htdocs/lib/fichinter.lib.php | 10 ++ 4 files changed, 341 insertions(+), 11 deletions(-) create mode 100644 htdocs/fichinter/info.php create mode 100644 htdocs/fichinter/note.php diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 299b2cfeb57..2b747836fa6 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -160,10 +160,12 @@ class Fichinter extends CommonObject */ function fetch($rowid) { - $sql = "SELECT ref,description,fk_soc,fk_statut,duree,".$this->db->pdate(datei)." as di, fk_projet"; - $sql.= " FROM ".MAIN_DB_PREFIX."fichinter WHERE rowid=".$rowid; + $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; - dolibarr_syslog("Fichinter.class::fetch rowid=$rowid sql=$sql"); + dolibarr_syslog("Fichinter.class::fetch rowid=$rowid sql=$sql"); $resql=$this->db->query($sql); if ($resql) @@ -172,14 +174,16 @@ class Fichinter extends CommonObject { $obj = $this->db->fetch_object($resql); - $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->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; $this->ref_url = ''.$this->ref.''; @@ -357,5 +361,75 @@ class Fichinter extends CommonObject return ""; } } + + /** + * \brief Mets à jour les commentaires publiques et privé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; + } + } + + /** + * \brief Information sur l'objet propal + * \param id id de la propale + */ + 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); + } + } } ?> \ No newline at end of file diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php new file mode 100644 index 00000000000..0db0c2f21cf --- /dev/null +++ b/htdocs/fichinter/info.php @@ -0,0 +1,72 @@ + + * + * 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$ + */ + +/** + \file htdocs/fichinter/info.php + \ingroup fichinter + \brief Page d'affichage des infos d'une fiche d'intervention + \version $Revision$ +*/ + +require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); + +$langs->load('companies'); + +$fichinterid = isset($_GET["id"])?$_GET["id"]:''; + +// Sécurité d'accès client et commerciaux +$socid = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); + + +/* + * + * + */ + +llxHeader(); + +$fichinter = new Fichinter($db); +$fichinter->fetch($_GET['id']); + +$societe = new Societe($db); +$societe->fetch($fichinter->socid); + +$head = fichinter_prepare_head($fichinter); +dolibarr_fiche_head($head, 'info', $langs->trans('InterventionCard')); + +$fichinter->info($fichinter->id); + +print '
'; +dolibarr_print_object_info($fichinter); +print '
'; + +print ''; + +// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent +print '
'; +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php new file mode 100644 index 00000000000..9082bf84ea1 --- /dev/null +++ b/htdocs/fichinter/note.php @@ -0,0 +1,174 @@ + + * + * 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$ + */ + +/** + \file htdocs/fichinter/note.php + \ingroup fichinter + \brief Fiche d'information sur une fiche d'intervention + \version $Revision$ +*/ + +require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); + +$langs->load('companies'); + +$fichinterid = isset($_GET["id"])?$_GET["id"]:''; + +// Sécurité d'accès client et commerciaux +$socid = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +if ($_POST["action"] == 'update_public' && $user->rights->ficheinter->creer) +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + + $db->begin(); + + $res=$fichinter->update_note($_POST["note_public"],'note_public'); + if ($res < 0) + { + $mesg='
'.$fichinter->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + +if ($_POST['action'] == 'update' && $user->rights->ficheinter->creer) +{ + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + + $db->begin(); + + $res=$fichinter->update_note($_POST["note_private"],'note_private'); + if ($res < 0) + { + $mesg='
'.$fichinter->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + + + +/******************************************************************************/ +/* Affichage fiche */ +/******************************************************************************/ + +llxHeader(); + +$html = new Form($db); + +if ($_GET['id']) +{ + if ($mesg) print $mesg; + + $fichinter = new Fichinter($db); + if ( $fichinter->fetch($_GET['id']) ) + { + $societe = new Societe($db); + if ( $societe->fetch($fichinter->socid) ) + { + $head = fichinter_prepare_head($fichinter); + dolibarr_fiche_head($head, 'note', $langs->trans('InterventionCard')); + + print ''; + + print ''; + + // Société + print ''; + + // Date + print ''; + print ''; + + // Note publique + print ''; + print '"; + + // Note privée + if (! $user->societe_id) + { + print ''; + print '"; + } + + print "
'.$langs->trans('Ref').''.$fichinter->ref_url.'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Date').''; + print dolibarr_print_date($fichinter->date,'daytext'); + print '
'.$langs->trans("NotePublic").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($fichinter->note_public?nl2br($fichinter->note_public):" "); + } + print "
'.$langs->trans("NotePrivate").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($fichinter->note_private?nl2br($fichinter->note_private):" "); + } + print "
"; + + print ''; + + /* + * Actions + */ + + print '
'; + if ($user->rights->ficheinter->creer && $_GET['action'] <> 'edit') + { + print ''.$langs->trans('Edit').''; + } + print '
'; + } + } +} +$db->close(); +llxFooter('$Date$ - $Revision: 1.15 '); +?> diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php index b1b9f2147f1..b74a603a083 100644 --- a/htdocs/lib/fichinter.lib.php +++ b/htdocs/lib/fichinter.lib.php @@ -47,6 +47,16 @@ function fichinter_prepare_head($fichinter) $head[$h][1] = $langs->trans('InterventionContact'); $head[$h][2] = 'contact'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$fichinter->id; + $head[$h][1] = $langs->trans('Note'); + $head[$h][2] = 'note'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$fichinter->id; + $head[$h][1] = $langs->trans('Info'); + $head[$h][2] = 'info'; + $h++; return $head; }