diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 66e94965a7b..83d6c779a24 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Destailleur Laurent +/* Copyright (C) 2005 Patrick Rouillon + * Copyright (C) 2005-2006 Destailleur Laurent * * 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 @@ -28,6 +28,7 @@ */ require ("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); @@ -216,24 +217,13 @@ if ($id > 0) $contrat = New Contrat($db); if ($contrat->fetch($id) > 0) { - if ($mesg) - print $mesg; + if ($mesg) print $mesg; - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("ContractCard"); - $h ++; + $head = contract_prepare_head($contrat); + + $hselected=1; - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("ContractContacts"); - $hselected = $h; - $h ++; - - $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("Info"); - $h ++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); + dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->ref); /* * Contrat diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index 0481a5d1e1a..2764c6f19cf 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -42,7 +42,8 @@ class Contrat var $id; var $ref; var $product; - var $societe; + + var $societe; // Objet societe var $user_author; var $user_service; @@ -53,6 +54,9 @@ class Contrat var $commercial_signature_id; var $commercial_suivi_id; + var $note; + var $note_public; + var $fk_projet; var $statuts=array(); @@ -261,7 +265,8 @@ class Contrat $sql.= " fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat,"; $sql.= " fk_user_author,"; $sql.= " fk_projet,"; - $sql.= " fk_commercial_signature, fk_commercial_suivi "; + $sql.= " fk_commercial_signature, fk_commercial_suivi,"; + $sql.= " note, note_public"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = $id"; $resql = $this->db->query($sql) ; @@ -286,10 +291,13 @@ class Contrat $this->commercial_signature_id = $result["fk_commercial_signature"]; $this->commercial_suivi_id = $result["fk_commercial_suivi"]; - $this->user_service->id = $result["fk_user_mise_en_service"]; - $this->user_cloture->id = $result["fk_user_cloture"]; + $this->user_service->id = $result["fk_user_mise_en_service"]; + $this->user_cloture->id = $result["fk_user_cloture"]; - $this->fk_projet = $result["fk_projet"]; + $this->note = $result["note"]; + $this->note_public = $result["note_public"]; + + $this->fk_projet = $result["fk_projet"]; $this->societe->fetch($result["fk_soc"]); @@ -739,7 +747,6 @@ class Contrat /** * \brief Mets à jour le prix total du contrat */ - function update_price() { include_once DOL_DOCUMENT_ROOT . "/lib/price.lib.php"; @@ -802,20 +809,66 @@ class Contrat } - /** - * \brief Retourne le libellé du statut du contrat - * \return string Libellé - */ + /** + * \brief Mets à jour les commentaires privés + * \param note Commentaire + * \return int <0 si ko, >0 si ok + */ + function update_note($note) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'contrat'; + $sql.= " SET note = '".addslashes($note)."'"; + $sql.= " WHERE rowid =". $this->id; + + if ($this->db->query($sql)) + { + $this->note = $note; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * \brief Mets à jour les commentaires publiques + * \param note_public Commentaire + * \return int <0 si ko, >0 si ok + */ + function update_note_public($note_public) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'contrat'; + $sql.= " SET note_public = '".addslashes($note_public)."'"; + $sql.= " WHERE rowid =". $this->id; + + if ($this->db->query($sql)) + { + $this->note_public = $note_public; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * \brief Retourne le libellé du statut du contrat + * \return string Libellé + */ function getLibStatut() { return $this->LibStatut($this->statut); } - /** - * \brief Renvoi le libellé d'un statut donné - * \param statut id statut - * \return string Libellé - */ + /** + * \brief Renvoi le libellé d'un statut donné + * \param statut id statut + * \return string Libellé + */ function LibStatut($statut) { global $langs; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 390c2a70ac9..d9419322459 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -28,6 +28,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); @@ -111,7 +112,6 @@ if ($_POST["action"] == 'add') else { $mesg='
'.$contrat->error.'
'; } - $_GET["socid"]=$_POST["soc_id"]; $_GET["action"]='create'; $action = ''; @@ -348,8 +348,11 @@ if ($_GET["action"] == 'create') print ""; } - print ''.$langs->trans("Comment").''; - print ''; + print ''.$langs->trans("NotePublic").''; + print ''; + + print ''.$langs->trans("NotePrivate").''; + print ''; print ''; @@ -459,21 +462,11 @@ else $commercial_suivi->id = $contrat->commercial_suivi_id; $commercial_suivi->fetch(); - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("ContractCard"); - $hselected = $h; - $h++; + $head = contract_prepare_head($contrat); - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("ContractContacts"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("Info"); - $h++; + $hselected = 0; - dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); + dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->ref); /* diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php index 8e492a51d03..fd03eeda46b 100644 --- a/htdocs/contrat/info.php +++ b/htdocs/contrat/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2006 Laurent Destailleur * * 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 @@ -27,7 +27,8 @@ */ require("./pre.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); $langs->load("contracts"); @@ -43,21 +44,9 @@ $contrat = new Contrat($db); $contrat->fetch($_GET["id"]); $contrat->info($_GET["id"]); -$h = 0; +$head = contract_prepare_head($contrat); -$head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; -$head[$h][1] = $langs->trans("ContractCard"); -$hselected = $h; -$h++; - -$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; -$head[$h][1] = $langs->trans("ContractContacts"); -$h++; - -$head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; -$head[$h][1] = $langs->trans("Info"); -$hselected = $h; -$h++; +$hselected = 3; dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").": $contrat->ref"); diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php new file mode 100644 index 00000000000..bdc06f05e7c --- /dev/null +++ b/htdocs/contrat/note.php @@ -0,0 +1,179 @@ + + * Copyright (C) 2004-2006 Laurent Destailleur + * + * 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/contrat/note.php + \ingroup contrat + \brief Fiche de notes sur un contrat + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); +if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); + +$socidp=isset($_GET["socidp"])?$_GET["socidp"]:isset($_POST["socidp"])?$_POST["socidp"]:""; + +$user->getrights('contrat'); +if (!$user->rights->contrat->lire) + accessforbidden(); + +$langs->load("companies"); +$langs->load("contracts"); + +// Sécurité accés +if ($user->societe_id > 0) +{ + unset($_GET["action"]); + $socidp = $user->societe_id; +} + + +$contrat = new Contrat($db); +$contrat->fetch($_GET["id"]); + + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +if ($_POST["action"] == 'update_public' && $user->rights->contrat->creer) +{ + $db->begin(); + + $res=$contrat->update_note_public($_POST["note_public"]); + if ($res < 0) + { + $mesg='
'.$contrat->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + +if ($_POST["action"] == 'update' && $user->rights->contrat->creer) +{ + $db->begin(); + + $res=$contrat->update_note($_POST["note"]); + if ($res < 0) + { + $mesg='
'.$contrat->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + + + +/******************************************************************************/ +/* Affichage fiche */ +/******************************************************************************/ + +llxHeader(); + +$html = new Form($db); + +if ($_GET["id"]) +{ + if ($mesg) print $mesg; + + $soc = new Societe($db, $contrat->societe->id); + $soc->fetch($contrat->societe->id); + + $head = contract_prepare_head($contrat); + + $hselected = 2; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").": ".$contrat->ref); + + + print ''; + + // Reference + print ''; + + print ''; + print ''; + + // Note publique + print ''; + print '"; + + // Note privée + print ''; + print '"; + print "
'.$langs->trans('Ref').''.$contrat->ref.'
'.$langs->trans("Customer").''; + print ''.$soc->nom.'
'.$langs->trans("NotePublic").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($contrat->note_public?nl2br($contrat->note_public):" "); + } + print "
'.$langs->trans("NotePrivate").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($contrat->note?nl2br($contrat->note):" "); + } + print "
"; + + + /* + * Actions + */ + print ''; + print '
'; + + if ($user->rights->contrat->creer && $_GET["action"] <> 'edit') + { + print "id."&action=edit\">".$langs->trans('Edit').""; + } + + print "
"; + + +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?>