dolibarr/htdocs/fichinter/note.php

171 lines
4.9 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
2011-05-17 20:58:59 +02:00
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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
2011-08-01 01:45:11 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/fichinter/note.php
* \ingroup fichinter
* \brief Fiche d'information sur une fiche d'intervention
2008-11-02 23:23:13 +01:00
*/
2010-03-27 16:06:19 +01:00
require("../main.inc.php");
2010-04-28 14:24:06 +02:00
require_once(DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php");
$langs->load('companies');
2011-07-02 19:33:24 +02:00
$langs->load("interventions");
2011-05-17 20:58:59 +02:00
$fichinterid = GETPOST("id");
$action=GETPOST("action");
2008-02-24 14:18:40 +01:00
// Security check
2008-02-25 21:03:21 +01:00
if ($user->societe_id) $socid=$user->societe_id;
2008-02-24 14:18:40 +01:00
$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
/******************************************************************************/
/* Actions */
/******************************************************************************/
2011-05-17 20:58:59 +02:00
if ($action == 'update_public' && $user->rights->ficheinter->creer)
{
$fichinter = new Fichinter($db);
2011-05-17 20:58:59 +02:00
$fichinter->fetch($fichinterid);
$db->begin();
2008-11-02 23:23:13 +01:00
2011-05-17 20:58:59 +02:00
$res=$fichinter->update_note_public(GETPOST("note_public"),$user);
if ($res < 0)
{
$mesg='<div class="error">'.$fichinter->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
}
2011-05-17 20:58:59 +02:00
if ($action == 'update' && $user->rights->ficheinter->creer)
{
$fichinter = new Fichinter($db);
2011-05-17 20:58:59 +02:00
$fichinter->fetch($fichinterid);
$db->begin();
2011-05-17 20:58:59 +02:00
$res=$fichinter->update_note(GETPOST("note_private"),$user);
if ($res < 0)
{
$mesg='<div class="error">'.$fichinter->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
}
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
llxHeader();
$html = new Form($db);
2011-05-17 20:58:59 +02:00
if ($fichinterid)
{
if ($mesg) print $mesg;
2008-11-02 23:23:13 +01:00
$fichinter = new Fichinter($db);
2011-05-17 20:58:59 +02:00
if ( $fichinter->fetch($fichinterid) )
{
$societe = new Societe($db);
if ( $societe->fetch($fichinter->socid) )
{
$head = fichinter_prepare_head($fichinter);
dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention');
2008-11-02 23:23:13 +01:00
print '<table class="border" width="100%">';
2008-11-02 23:23:13 +01:00
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$fichinter->ref.'</td></tr>';
// Soci<63>t<EFBFBD>
2008-11-02 23:23:13 +01:00
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
// Note publique
2008-11-02 23:23:13 +01:00
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
2011-05-17 20:58:59 +02:00
if ($action == 'edit')
2008-11-02 23:23:13 +01:00
{
print '<form method="post" action="note.php?id='.$fichinter->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-11-02 23:23:13 +01:00
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$fichinter->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($fichinter->note_public?nl2br($fichinter->note_public):"&nbsp;");
}
print "</td></tr>";
2008-11-02 23:23:13 +01:00
// Note priv<69>e
if (! $user->societe_id)
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
2011-05-17 20:58:59 +02:00
if ($action == 'edit')
2008-11-02 23:23:13 +01:00
{
print '<form method="post" action="note.php?id='.$fichinter->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-11-02 23:23:13 +01:00
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note_private" cols="80" rows="8">'.$fichinter->note_private."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
2008-11-02 23:23:13 +01:00
print ($fichinter->note_private?nl2br($fichinter->note_private):"&nbsp;");
}
print "</td></tr>";
}
2008-11-02 23:23:13 +01:00
print "</table>";
print '</div>';
/*
* Actions
*/
print '<div class="tabsAction">';
2011-05-17 20:58:59 +02:00
if ($user->rights->ficheinter->creer && GETPOST("action") <> 'edit')
{
print '<a class="butAction" href="note.php?id='.$fichinter->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
}
print '</div>';
}
2008-11-02 23:23:13 +01:00
}
}
$db->close();
llxFooter();
?>