dolibarr  16.0.5
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 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
30 if (!empty($conf->project->enabled)) {
31  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
32 }
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array('companies', 'contracts'));
36 
37 $action = GETPOST('action', 'aZ09');
38 $confirm = GETPOST('confirm', 'alpha');
39 $socid = GETPOST('socid', 'int');
40 $id = GETPOST('id', 'int');
41 $ref = GETPOST('ref', 'alpha');
42 
43 // Security check
44 if ($user->socid) {
45  $socid = $user->socid;
46 }
47 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
48 //$hookmanager->initHooks(array('contractcard', 'globalcard')); -> Conflict with contrat\card.php
49 $hookmanager->initHooks(array('contractnote'));
50 
51 $result = restrictedArea($user, 'contrat', $id);
52 
53 $object = new Contrat($db);
54 $object->fetch($id, $ref);
55 
56 $permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
57 
58 
59 /*
60  * Actions
61  */
62 
63 $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
64 if ($reshook < 0) {
65  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
66 }
67 if (empty($reshook)) {
68  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
69 }
70 
71 
72 
73 /*
74  * View
75  */
76 
77 llxHeader('', $langs->trans("Contract"), "");
78 
79 $form = new Form($db);
80 
81 if ($id > 0 || !empty($ref)) {
82  $object->fetch_thirdparty();
83 
84  $head = contract_prepare_head($object);
85 
86  $hselected = 2;
87 
88  print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract');
89 
90  // Contract card
91 
92  $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
93 
94 
95  $morehtmlref = '';
96  //if (! empty($modCodeContract->code_auto)) {
97  $morehtmlref .= $object->ref;
98  /*} else {
99  $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
100  $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
101  }*/
102 
103  $morehtmlref .= '<div class="refidno">';
104  // Ref customer
105  $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
106  $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
107  // Ref supplier
108  $morehtmlref .= '<br>';
109  $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
110  $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
111  // Thirdparty
112  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
113  // Project
114  if (!empty($conf->project->enabled)) {
115  $langs->load("projects");
116  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
117  if ($user->rights->contrat->creer) {
118  if ($action != 'classify') {
119  //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
120  $morehtmlref .= ' : ';
121  }
122  if ($action == 'classify') {
123  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
124  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
125  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
126  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
127  $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
128  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
129  $morehtmlref .= '</form>';
130  } else {
131  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
132  }
133  } else {
134  if (!empty($object->fk_project)) {
135  $proj = new Project($db);
136  $proj->fetch($object->fk_project);
137  $morehtmlref .= ' : '.$proj->getNomUrl(1);
138  if ($proj->title) {
139  $morehtmlref .= ' - '.$proj->title;
140  }
141  } else {
142  $morehtmlref .= '';
143  }
144  }
145  }
146  $morehtmlref .= '</div>';
147 
148 
149  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
150 
151 
152  print '<div class="fichecenter">';
153  print '<div class="underbanner clearboth"></div>';
154 
155  print '<table class="border centpercent tableforfield">';
156 
157 
158  // Ligne info remises tiers
159  print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
160  if ($object->thirdparty->remise_percent) {
161  print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
162  } else {
163  print $langs->trans("CompanyHasNoRelativeDiscount");
164  }
165  $absolute_discount = $object->thirdparty->getAvailableDiscounts();
166  print '. ';
167  if ($absolute_discount) {
168  print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency));
169  } else {
170  print $langs->trans("CompanyHasNoAbsoluteDiscount");
171  }
172  print '.';
173  print '</td></tr>';
174 
175  // Date
176  print '<tr>';
177  print '<td class="titlefield">';
178  print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0);
179  print '</td><td>';
180  print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker');
181  print '</td>';
182  print '</tr>';
183 
184  print "</table>";
185 
186  print '</div>';
187 
188  //print '<br>';
189 
190  $cssclass='titlefield';
191  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
192 
193  print dol_get_fiche_end();
194 }
195 
196 
197 llxFooter();
198 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
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.
Definition: functions.lib.php:2046
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
Contrat
Class to manage contracts.
Definition: contrat.class.php:43
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
contract_prepare_head
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
Definition: contract.lib.php:31
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59