dolibarr 21.0.0-alpha
stocktransfer_agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php';
31require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
32
33
34// Load translation files required by the page
35$langs->loadLangs(array("stocks", "other"));
36
37// Get parameters
38$id = GETPOSTINT('id');
39$ref = GETPOST('ref', 'alpha');
40$action = GETPOST('action', 'alpha');
41$cancel = GETPOST('cancel', 'aZ09');
42$backtopage = GETPOST('backtopage', 'alpha');
43
44if (GETPOST('actioncode', 'array')) {
45 $actioncode = GETPOST('actioncode', 'array', 3);
46 if (!count($actioncode)) {
47 $actioncode = '0';
48 }
49} else {
50 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
51}
52$search_rowid = GETPOST('search_rowid');
53$search_agenda_label = GETPOST('search_agenda_label');
54
55$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
56$sortfield = GETPOST("sortfield", 'alpha');
57$sortorder = GETPOST("sortorder", 'alpha');
58$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
59if (empty($page) || $page == -1) {
60 $page = 0;
61} // If $page is not defined, or '' or -1
62$offset = $limit * $page;
63$pageprev = $page - 1;
64$pagenext = $page + 1;
65if (!$sortfield) {
66 $sortfield = 'a.datep,a.id';
67}
68if (!$sortorder) {
69 $sortorder = 'DESC,DESC';
70}
71
72// Initialize a technical objects
73$object = new StockTransfer($db);
74$extrafields = new ExtraFields($db);
75$diroutputmassaction = $conf->stocktransfer->dir_output.'/temp/massgeneration/'.$user->id;
76$hookmanager->initHooks(array('stocktransferagenda', 'globalcard')); // Note that conf->hooks_modules contains array
77// Fetch optionals attributes and labels
78$extrafields->fetch_name_optionals_label($object->table_element);
79
80// Load object
81include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
82if ($id > 0 || !empty($ref)) {
83 $upload_dir = $conf->stocktransfer->multidir_output[$object->entity]."/".$object->id;
84}
85
86$permissiontoread = $user->hasRight('stocktransfer', 'stocktransfer', 'read');
87$permissiontoadd = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
88$permissionnote = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_setnotes.inc.php
89$permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED);
90$permissiondellink = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_dellink.inc.php
91$upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1];
92
93// Security check - Protection if external user
94//if ($user->socid > 0) accessforbidden();
95//if ($user->socid > 0) $socid = $user->socid;
96//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
97//$result = restrictedArea($user, 'stocktransfer', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
98//$result = restrictedArea($user, 'stocktransfer', $object->id, '', 'stocktransfer');
99
100if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
102}
103
104
105/*
106 * Actions
107 */
108
109$parameters = array('id'=>$id);
110$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
111if ($reshook < 0) {
112 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
113}
114
115if (empty($reshook)) {
116 // Cancel
117 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
118 header("Location: ".$backtopage);
119 exit;
120 }
121
122 // Purge search criteria
123 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
124 $actioncode = '';
125 $search_agenda_label = '';
126 }
127}
128
129
130
131/*
132 * View
133 */
134
135$form = new Form($db);
136
137if ($object->id > 0) {
138 $title = $langs->trans("Agenda");
139 $help_url = '';
140 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-stock-stocktransfer_stocktransfer_agenda');
141
142 if (isModEnabled('notification')) {
143 $langs->load("mails");
144 }
145 $head = stocktransferPrepareHead($object);
146
147
148 print dol_get_fiche_head($head, 'agenda', $langs->trans("StockTransfer"), -1, $object->picto);
149
150 // Object card
151 // ------------------------------------------------------------
152 $linkback = '<a href="'.dol_buildpath('/stocktransfer/stocktransfer_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
153
154 $morehtmlref = '<div class="refidno">';
155 /*
156 // Ref customer
157 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
158 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
159 // Thirdparty
160 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
161 // Project
162 if (isModEnabled('project'))
163 {
164 $langs->load("projects");
165 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
166 if ($permissiontoadd)
167 {
168 if ($action != 'classify')
169 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
170 $morehtmlref.=' : ';
171 if ($action == 'classify') {
172 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
173 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
174 $morehtmlref.='<input type="hidden" name="action" value="classin">';
175 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
176 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
177 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
178 $morehtmlref.='</form>';
179 } else {
180 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
181 }
182 } else {
183 if (!empty($object->fk_project)) {
184 $proj = new Project($db);
185 $proj->fetch($object->fk_project);
186 $morehtmlref .= ': '.$proj->getNomUrl();
187 } else {
188 $morehtmlref .= '';
189 }
190 }
191 }*/
192 $morehtmlref .= '</div>';
193
194
195 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
196
197 print '<div class="fichecenter">';
198 print '<div class="underbanner clearboth"></div>';
199
200 $object->info($object->id);
201 dol_print_object_info($object, 1);
202
203 print '</div>';
204
205 print dol_get_fiche_end();
206
207
208
209 // Actions buttons
210
211 $objthirdparty = $object;
212 $objcon = new stdClass();
213
214 $out = '&origin='.$object->element.'&originid='.$object->id;
215 $permok = $user->hasRight('agenda', 'myactions', 'create');
216 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
217 //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
218 if (get_class($objthirdparty) == 'Societe') {
219 $out .= '&amp;socid='.$objthirdparty->id;
220 }
221 $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1';
222 //$out.=$langs->trans("AddAnAction").' ';
223 //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
224 //$out.="</a>";
225 }
226
227
228 print '<div class="tabsAction">';
229
230 if (isModEnabled('agenda')) {
231 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
232 print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
233 } else {
234 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
235 }
236 }
237
238 print '</div>';
239
240 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
241 $param = '&id='.$object->id.'&socid='.$socid;
242 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
243 $param .= '&contextpage='.urlencode($contextpage);
244 }
245 if ($limit > 0 && $limit != $conf->liste_limit) {
246 $param .= '&limit='.((int) $limit);
247 }
248
249
250 //print load_fiche_titre($langs->trans("ActionsOnStockTransfer"), '', '');
251
252 // List of all actions
253 $filters = array();
254 $filters['search_agenda_label'] = $search_agenda_label;
255 $filters['search_rowid'] = $search_rowid;
256
257 // TODO Replace this with same code than into list.php
258 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, '');
259 }
260}
261
262// End of page
263llxFooter();
264$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class for StockTransfer.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $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).
llxFooter()
Footer empty.
Definition document.php:107
dol_print_object_info($object, $usetable=0)
Show information on an object TODO Move this into html.formother.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
stocktransferPrepareHead($object)
Prepare array of tabs for StockTransfer.