dolibarr  7.0.0-beta
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@capnetworks.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 <http://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->projet->enabled)) {
31  require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
32 }
33 
34 $langs->load("companies");
35 $langs->load("contracts");
36 
37 $action=GETPOST('action','alpha');
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->societe_id) $socid=$user->societe_id;
45 $result=restrictedArea($user,'contrat',$id);
46 
47 $object = new Contrat($db);
48 $object->fetch($id,$ref);
49 
50 $permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
51 
52 
53 /*
54  * Actions
55  */
56 
57 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
58 
59 
60 
61 /*
62  * View
63  */
64 
65 llxHeader('',$langs->trans("Contract"),"");
66 
67 $form = new Form($db);
68 
69 if ($id > 0 || ! empty($ref))
70 {
71  $object->fetch_thirdparty();
72 
73  $head = contract_prepare_head($object);
74 
75  $hselected = 2;
76 
77  dol_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract');
78 
79  // Contract card
80 
81  $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
82 
83 
84  $morehtmlref='';
85  //if (! empty($modCodeContract->code_auto)) {
86  $morehtmlref.=$object->ref;
87  /*} else {
88  $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
89  $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
90  }*/
91 
92  $morehtmlref.='<div class="refidno">';
93  // Ref customer
94  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
95  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
96  // Ref supplier
97  $morehtmlref.='<br>';
98  $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
99  $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
100  // Thirdparty
101  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
102  // Project
103  if (! empty($conf->projet->enabled))
104  {
105  $langs->load("projects");
106  $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
107  if ($user->rights->contrat->creer)
108  {
109  if ($action != 'classify')
110  //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
111  $morehtmlref.=' : ';
112  if ($action == 'classify') {
113  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
114  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
115  $morehtmlref.='<input type="hidden" name="action" value="classin">';
116  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
117  $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
118  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
119  $morehtmlref.='</form>';
120  } else {
121  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
122  }
123  } else {
124  if (! empty($object->fk_project)) {
125  $proj = new Project($db);
126  $proj->fetch($object->fk_project);
127  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
128  $morehtmlref.=$proj->ref;
129  $morehtmlref.='</a>';
130  } else {
131  $morehtmlref.='';
132  }
133  }
134  }
135  $morehtmlref.='</div>';
136 
137 
138  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
139 
140 
141  print '<div class="fichecenter">';
142  print '<div class="underbanner clearboth"></div>';
143 
144  print '<table class="border" width="100%">';
145 
146 
147  // Ligne info remises tiers
148  print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
149  if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
150  else print $langs->trans("CompanyHasNoRelativeDiscount");
151  $absolute_discount=$object->thirdparty->getAvailableDiscounts();
152  print '. ';
153  if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
154  else print $langs->trans("CompanyHasNoAbsoluteDiscount");
155  print '.';
156  print '</td></tr>';
157 
158  // Date
159  print '<tr>';
160  print '<td class="titlefield">';
161  print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,0);
162  print '</td><td>';
163  print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,0,'datehourpicker');
164  print '</td>';
165  print '</tr>';
166 
167  print "</table>";
168 
169  print '</div>';
170 
171  //print '<br>';
172 
173  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
174 
175  dol_fiche_end();
176 
177 }
178 
179 
180 llxFooter();
181 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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.
Class to manage contracts.
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:46
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...
print
Draft customers invoices.
Definition: index.php:91
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.