Qual: Mutualisation code des onglets

New: Possibilit d'diter les notes prives et publiques
This commit is contained in:
Laurent Destailleur 2006-02-16 23:25:41 +00:00
parent eb7cc7d688
commit 264b99a0b0
5 changed files with 269 additions and 65 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005 Destailleur Laurent <eldy@users.sourceforge.net>
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2006 Destailleur Laurent <eldy@users.sourceforge.net>
*
* 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

View File

@ -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;

View File

@ -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='<div class="error">'.$contrat->error.'</div>';
}
$_GET["socid"]=$_POST["soc_id"];
$_GET["action"]='create';
$action = '';
@ -348,8 +348,11 @@ if ($_GET["action"] == 'create')
print "</td></tr>";
}
print '<tr><td>'.$langs->trans("Comment").'</td><td valign="top">';
print '<textarea name="note" wrap="soft" cols="70" rows="3"></textarea></td></tr>';
print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'"></textarea></td></tr>';
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td valign="top">';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'"></textarea></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
@ -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);
/*

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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");

179
htdocs/contrat/note.php Normal file
View File

@ -0,0 +1,179 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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='<div class="error">'.$contrat->error.'</div>';
$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='<div class="error">'.$contrat->error.'</div>';
$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 '<table class="border" width="100%">';
// Reference
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$contrat->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Customer").'</td>';
print '<td colspan="3">';
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?id='.$contrat->id.'">';
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="'.ROWS_8.'">'.$contrat->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($contrat->note_public?nl2br($contrat->note_public):"&nbsp;");
}
print "</td></tr>";
// Note privée
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?id='.$contrat->id.'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="'.ROWS_8.'">'.$contrat->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($contrat->note?nl2br($contrat->note):"&nbsp;");
}
print "</td></tr>";
print "</table>";
/*
* Actions
*/
print '</div>';
print '<div class="tabsAction">';
if ($user->rights->contrat->creer && $_GET["action"] <> 'edit')
{
print "<a class=\"tabAction\" href=\"note.php?id=".$contrat->id."&amp;action=edit\">".$langs->trans('Edit')."</a>";
}
print "</div>";
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>