PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/comm/propal/note.php

https://github.com/zeert/dolibarr
PHP | 159 lines | 92 code | 31 blank | 36 comment | 24 complexity | ff3236c95b6071aefb91203f499e07d2 MD5 | raw file
  1<?php
  2/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3 * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
  4 * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
  5 * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
  6 *
  7 * This program is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License as published by
  9 * the Free Software Foundation; either version 2 of the License, or
 10 * (at your option) any later version.
 11 *
 12 * This program is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 * GNU General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 19 */
 20
 21/**
 22 *	\file       htdocs/comm/propal/note.php
 23 *	\ingroup    propale
 24 *	\brief      Fiche d'information sur une proposition commerciale
 25 */
 26
 27require("../../main.inc.php");
 28require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
 29require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
 30
 31$langs->load('propal');
 32$langs->load('compta');
 33$langs->load('bills');
 34
 35$id = GETPOST('id','int');
 36$ref=GETPOST('ref','alpha');
 37$action=GETPOST('action','alpha');
 38
 39// Security check
 40if ($user->societe_id) $socid=$user->societe_id;
 41$result = restrictedArea($user, 'propale', $id, 'propal');
 42
 43$object = new Propal($db);
 44
 45
 46/******************************************************************************/
 47/*                     Actions                                                */
 48/******************************************************************************/
 49
 50if ($action == 'setnote_public' && $user->rights->propale->creer)
 51{
 52	$object->fetch($id);
 53	$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
 54	if ($result < 0) dol_print_error($db,$object->error);
 55}
 56
 57else if ($action == 'setnote' && $user->rights->propale->creer)
 58{
 59	$object->fetch($id);
 60	$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
 61	if ($result < 0) dol_print_error($db,$object->error);
 62}
 63
 64
 65/******************************************************************************/
 66/* Affichage fiche                                                            */
 67/******************************************************************************/
 68
 69llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
 70
 71$form = new Form($db);
 72
 73if ($id > 0 || ! empty($ref))
 74{
 75	if ($mesg) print $mesg;
 76
 77	$now=dol_now();
 78
 79	if ($object->fetch($id, $ref))
 80	{
 81		$societe = new Societe($db);
 82		if ( $societe->fetch($object->socid) )
 83		{
 84			$head = propal_prepare_head($object);
 85			dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal');
 86
 87			print '<table class="border" width="100%">';
 88
 89			$linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans('BackToList').'</a>';
 90
 91			// Ref
 92			print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
 93			print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
 94			print '</td></tr>';
 95
 96			// Ref client
 97			print '<tr><td>';
 98			print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
 99			print $langs->trans('RefCustomer').'</td><td align="left">';
100			print '</td>';
101			print '</tr></table>';
102			print '</td><td colspan="3">';
103			print $object->ref_client;
104			print '</td>';
105			print '</tr>';
106
107			// Customer
108			if ( is_null($object->client) )
109				$object->fetch_thirdparty();
110			print "<tr><td>".$langs->trans("Company")."</td>";
111			print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
112
113			// Ligne info remises tiers
114			print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
115			if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
116			else print $langs->trans("CompanyHasNoRelativeDiscount");
117			$absolute_discount=$societe->getAvailableDiscounts();
118			print '. ';
119			if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
120			else print $langs->trans("CompanyHasNoAbsoluteDiscount");
121			print '.';
122			print '</td></tr>';
123
124			// Date
125			print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
126			print dol_print_date($object->date,'daytext');
127			print '</td>';
128			print '</tr>';
129
130			// Date fin propal
131			print '<tr>';
132			print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
133			if ($object->fin_validite)
134			{
135				print dol_print_date($object->fin_validite,'daytext');
136				if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
137			}
138			else
139			{
140				print $langs->trans("Unknown");
141			}
142			print '</td>';
143			print '</tr>';
144
145			print "</table>";
146
147			print '<br>';
148
149			include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
150
151			dol_fiche_end();
152		}
153	}
154}
155
156
157llxFooter();
158$db->close();
159?>