dolibarr 18.0.6
note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
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 3 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 <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
31if (isModEnabled('project')) {
32 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
33}
34
35// Load translation files required by the page
36$langs->loadLangs(array('companies', 'contracts'));
37
38$action = GETPOST('action', 'aZ09');
39$confirm = GETPOST('confirm', 'alpha');
40$socid = GETPOST('socid', 'int');
41$id = GETPOST('id', 'int');
42$ref = GETPOST('ref', 'alpha');
43
44// Security check
45if ($user->socid) {
46 $socid = $user->socid;
47}
48// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
49//$hookmanager->initHooks(array('contractcard', 'globalcard')); -> Conflict with contrat\card.php
50$hookmanager->initHooks(array('contractnote'));
51
52$result = restrictedArea($user, 'contrat', $id);
53
54$object = new Contrat($db);
55$object->fetch($id, $ref);
56
57$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
58$permissionnote = $user->hasRight('contrat', 'creer'); // Used by the include of actions_setnotes.inc.php
59
60
61/*
62 * Actions
63 */
64
65$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
66if ($reshook < 0) {
67 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
68}
69if (empty($reshook)) {
70 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
71}
72
73
74
75/*
76 * View
77 */
78
79llxHeader('', $langs->trans("Contract"), "");
80
81$form = new Form($db);
82
83if ($id > 0 || !empty($ref)) {
84 $object->fetch_thirdparty();
85
86 $head = contract_prepare_head($object);
87
88 $hselected = 2;
89
90 print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract');
91
92 // Contract card
93
94 $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
95
96
97 $morehtmlref = '';
98 //if (!empty($modCodeContract->code_auto)) {
99 $morehtmlref .= $object->ref;
100 /*} else {
101 $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
102 $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
103 }*/
104
105 $morehtmlref .= '<div class="refidno">';
106 // Ref customer
107 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
108 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
109 // Ref supplier
110 $morehtmlref .= '<br>';
111 $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
112 $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
113 // Thirdparty
114 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
115 // Project
116 if (isModEnabled('project')) {
117 $langs->load("projects");
118 $morehtmlref .= '<br>';
119 if (0) {
120 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
121 if ($action != 'classify') {
122 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
123 }
124 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
125 } else {
126 if (!empty($object->fk_project)) {
127 $proj = new Project($db);
128 $proj->fetch($object->fk_project);
129 $morehtmlref .= $proj->getNomUrl(1);
130 if ($proj->title) {
131 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
132 }
133 }
134 }
135 }
136 $morehtmlref .= '</div>';
137
138
139 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
140
141
142 print '<div class="fichecenter">';
143 print '<div class="underbanner clearboth"></div>';
144
145 print '<table class="border centpercent tableforfield">';
146
147
148 // Ligne info remises tiers
149 print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
150 if ($object->thirdparty->remise_percent) {
151 print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
152 } else {
153 print $langs->trans("CompanyHasNoRelativeDiscount");
154 }
155 $absolute_discount = $object->thirdparty->getAvailableDiscounts();
156 print '. ';
157 if ($absolute_discount) {
158 print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency));
159 } else {
160 print $langs->trans("CompanyHasNoAbsoluteDiscount");
161 }
162 print '.';
163 print '</td></tr>';
164
165 // Date
166 print '<tr>';
167 print '<td class="titlefield">';
168 print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0);
169 print '</td><td>';
170 print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker');
171 print '</td>';
172 print '</tr>';
173
174 print "</table>";
175
176 print '</div>';
177
178 //print '<br>';
179
180 $cssclass='titlefield';
181 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
182
183 print dol_get_fiche_end();
184}
185
186
187llxFooter();
188$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage contracts.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.