dolibarr  16.0.5
info.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 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/fourn.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 if (!empty($conf->project->enabled)) {
33  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 }
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("suppliers", "orders", "companies", "stocks"));
38 
39 $id = GETPOST('id', 'int');
40 $ref = GETPOST('ref', 'alpha');
41 $action = GETPOST('action', 'aZ09');
42 
43 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
44 $sortfield = GETPOST('sortfield', 'aZ09comma');
45 $sortorder = GETPOST('sortorder', 'aZ09comma');
46 $page = GETPOST("page", 'int');
47 if (empty($page) || $page == -1) {
48  $page = 0;
49 } // If $page is not defined, or '' or -1
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 if (!$sortfield) {
54  $sortfield = 'a.datep,a.id';
55 }
56 if (!$sortorder) {
57  $sortorder = 'DESC,DESC';
58 }
59 
60 if (GETPOST('actioncode', 'array')) {
61  $actioncode = GETPOST('actioncode', 'array', 3);
62  if (!count($actioncode)) {
63  $actioncode = '0';
64  }
65 } else {
66  $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS));
67 }
68 $search_agenda_label = GETPOST('search_agenda_label');
69 
70 // Security check
71 $socid = 0;
72 if ($user->socid) {
73  $socid = $user->socid;
74 }
75 $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
76 
77 if (empty($user->rights->fournisseur->commande->lire)) {
79 }
80 
81 $hookmanager->initHooks(array('ordersuppliercardinfo'));
82 
83 
84 
85 /*
86  * Actions
87  */
88 
89 $parameters = array('id'=>$id);
90 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
91 if ($reshook < 0) {
92  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93 }
94 
95 // Purge search criteria
96 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
97  $actioncode = '';
98  $search_agenda_label = '';
99 }
100 
101 
102 
103 /*
104  * View
105  */
106 
107 $form = new Form($db);
108 $object = new CommandeFournisseur($db);
109 
110 if ($id > 0 || !empty($ref)) {
111  $object->fetch($id, $ref);
112  $object->fetch_thirdparty();
113  $object->info($object->id);
114 }
115 
116 $title = $langs->trans("SupplierOrder").' - '.$langs->trans('Info').' - '.$object->ref.' '.$object->name;
117 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
118  $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
119 }
120 $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
121 llxHeader('', $title, $help_url);
122 
123 $now = dol_now();
124 
125 $head = ordersupplier_prepare_head($object);
126 
127 
128 print dol_get_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order');
129 
130 
131 // Supplier order card
132 
133 $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
134 
135 $morehtmlref = '<div class="refidno">';
136 // Ref supplier
137 $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
138 $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
139 // Thirdparty
140 $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
141 // Project
142 if (!empty($conf->project->enabled)) {
143  $langs->load("projects");
144  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
145  if ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer) {
146  if ($action != 'classify') {
147  //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
148  $morehtmlref .= ' : ';
149  }
150  if ($action == 'classify') {
151  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
152  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
153  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
154  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
155  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
156  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
157  $morehtmlref .= '</form>';
158  } else {
159  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
160  }
161  } else {
162  if (!empty($object->fk_project)) {
163  $proj = new Project($db);
164  $proj->fetch($object->fk_project);
165  $morehtmlref .= ' : '.$proj->getNomUrl(1);
166  if ($proj->title) {
167  $morehtmlref .= ' - '.$proj->title;
168  }
169  } else {
170  $morehtmlref .= '';
171  }
172  }
173 }
174 $morehtmlref .= '</div>';
175 
176 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
177 
178 
179 print '<div class="fichecenter">';
180 print '<div class="underbanner clearboth"></div>';
181 
182 dol_print_object_info($object, 1);
183 
184 print '</div>';
185 
186 print '<div class="clearboth"></div>';
187 
188 print dol_get_fiche_end();
189 
190 
191 
192 
193 // Actions buttons
194 
195 $out = '';
196 $permok = $user->rights->agenda->myactions->create;
197 if ($permok) {
198  $out .= '&originid='.$object->id.'&origin=order_supplier';
199 }
200 
201 
202 print '<div class="tabsAction">';
203 
204 if (isModEnabled('agenda')) {
205  if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
206  print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>';
207  } else {
208  print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
209  }
210 }
211 
212 print '</div>';
213 
214 
215 if (!empty($object->id)) {
216  $param = '&id='.$object->id;
217  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
218  $param .= '&contextpage='.$contextpage;
219  }
220  if ($limit > 0 && $limit != $conf->liste_limit) {
221  $param .= '&limit='.$limit;
222  }
223 
224  print load_fiche_titre($langs->trans("ActionsOnOrder"), '', '');
225 
226  // List of actions on element
227  /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
228  $formactions=new FormActions($db);
229  $somethingshown = $formactions->showactions($object,'project',0);*/
230 
231  // List of todo actions
232  //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
233 
234  // List of done actions
235  //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
236 
237  // List of all actions
238  $filters = array();
239  $filters['search_agenda_label'] = $search_agenda_label;
240  show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
241 }
242 
243 // End of page
244 llxFooter();
245 $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
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
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
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
show_actions_done
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
Definition: company.lib.php:1389
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
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
CommandeFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.commande.class.php:47
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_print_object_info
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
Definition: functions2.lib.php:205
ordersupplier_prepare_head
ordersupplier_prepare_head(CommandeFournisseur $object)
Prepare array with list of tabs.
Definition: fourn.lib.php:135
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
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