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