dolibarr  17.0.4
myobject_card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) ---Put here your own copyright and developer email---
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 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
29 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
30 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
31 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
32 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
33 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
34 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
35 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
36 //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
37 //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
38 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
39 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
40 //if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
41 //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
42 //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
43 //if (! defined('NOSESSION')) define('NOSESSION', '1'); // Disable session
44 
45 // Load Dolibarr environment
46 $res = 0;
47 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
48 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
49  $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
50 }
51 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
52 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
54  $i--; $j--;
55 }
56 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
57  $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
58 }
59 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
60  $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
61 }
62 // Try main.inc.php using relative path
63 if (!$res && file_exists("../main.inc.php")) {
64  $res = @include "../main.inc.php";
65 }
66 if (!$res && file_exists("../../main.inc.php")) {
67  $res = @include "../../main.inc.php";
68 }
69 if (!$res && file_exists("../../../main.inc.php")) {
70  $res = @include "../../../main.inc.php";
71 }
72 if (!$res) {
73  die("Include of main fails");
74 }
75 
76 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
77 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
78 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
79 dol_include_once('/mymodule/class/myobject.class.php');
80 dol_include_once('/mymodule/lib/mymodule_myobject.lib.php');
81 
82 // Load translation files required by the page
83 $langs->loadLangs(array("mymodule@mymodule", "other"));
84 
85 // Get parameters
86 $id = GETPOST('id', 'int');
87 $ref = GETPOST('ref', 'alpha');
88 $lineid = GETPOST('lineid', 'int');
89 
90 $action = GETPOST('action', 'aZ09');
91 $confirm = GETPOST('confirm', 'alpha');
92 $cancel = GETPOST('cancel', 'aZ09');
93 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
94 $backtopage = GETPOST('backtopage', 'alpha');
95 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
96 $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
97 
98 // Initialize technical objects
99 $object = new MyObject($db);
100 $extrafields = new ExtraFields($db);
101 $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
102 $hookmanager->initHooks(array('myobjectcard', 'globalcard')); // Note that conf->hooks_modules contains array
103 
104 // Fetch optionals attributes and labels
105 $extrafields->fetch_name_optionals_label($object->table_element);
106 
107 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
108 
109 // Initialize array of search criterias
110 $search_all = GETPOST("search_all", 'alpha');
111 $search = array();
112 foreach ($object->fields as $key => $val) {
113  if (GETPOST('search_'.$key, 'alpha')) {
114  $search[$key] = GETPOST('search_'.$key, 'alpha');
115  }
116 }
117 
118 if (empty($action) && empty($id) && empty($ref)) {
119  $action = 'view';
120 }
121 
122 // Load object
123 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
124 
125 // There is several ways to check permission.
126 // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
127 $enablepermissioncheck = 0;
128 if ($enablepermissioncheck) {
129  $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read');
130  $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
131  $permissiontodelete = $user->hasRight('mymodule', 'myobject', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
132  $permissionnote = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_setnotes.inc.php
133  $permissiondellink = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_dellink.inc.php
134 } else {
135  $permissiontoread = 1;
136  $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
137  $permissiontodelete = 1;
138  $permissionnote = 1;
139  $permissiondellink = 1;
140 }
141 
142 $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1].'/myobject';
143 
144 // Security check (enable the most restrictive one)
145 //if ($user->socid > 0) accessforbidden();
146 //if ($user->socid > 0) $socid = $user->socid;
147 //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
148 //restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
149 if (!isModEnabled("mymodule")) {
150  accessforbidden();
151 }
152 if (!$permissiontoread) {
153  accessforbidden();
154 }
155 
156 
157 /*
158  * Actions
159  */
160 
161 $parameters = array();
162 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
163 if ($reshook < 0) {
164  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
165 }
166 
167 if (empty($reshook)) {
168  $error = 0;
169 
170  $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
171 
172  if (empty($backtopage) || ($cancel && empty($id))) {
173  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
174  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
175  $backtopage = $backurlforlist;
176  } else {
177  $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
178  }
179  }
180  }
181 
182  $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
183 
184  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
185  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
186 
187  // Actions when linking object each other
188  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
189 
190  // Actions when printing a doc from card
191  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
192 
193  // Action to move up and down lines of object
194  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
195 
196  // Action to build doc
197  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
198 
199  if ($action == 'set_thirdparty' && $permissiontoadd) {
200  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
201  }
202  if ($action == 'classin' && $permissiontoadd) {
203  $object->setProject(GETPOST('projectid', 'int'));
204  }
205 
206  // Actions to send emails
207  $triggersendname = 'MYMODULE_MYOBJECT_SENTBYMAIL';
208  $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
209  $trackid = 'myobject'.$object->id;
210  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
211 }
212 
213 
214 
215 
216 /*
217  * View
218  *
219  * Put here all code to build page
220  */
221 
222 $form = new Form($db);
223 $formfile = new FormFile($db);
224 $formproject = new FormProjets($db);
225 
226 $title = $langs->trans("MyObject");
227 $help_url = '';
228 llxHeader('', $title, $help_url);
229 
230 // Example : Adding jquery code
231 // print '<script type="text/javascript">
232 // jQuery(document).ready(function() {
233 // function init_myfunc()
234 // {
235 // jQuery("#myid").removeAttr(\'disabled\');
236 // jQuery("#myid").attr(\'disabled\',\'disabled\');
237 // }
238 // init_myfunc();
239 // jQuery("#mybutton").click(function() {
240 // init_myfunc();
241 // });
242 // });
243 // </script>';
244 
245 
246 // Part to create
247 if ($action == 'create') {
248  if (empty($permissiontoadd)) {
249  accessforbidden('NotEnoughPermissions', 0, 1);
250  }
251 
252  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("MyObject")), '', 'object_'.$object->picto);
253 
254  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
255  print '<input type="hidden" name="token" value="'.newToken().'">';
256  print '<input type="hidden" name="action" value="add">';
257  if ($backtopage) {
258  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
259  }
260  if ($backtopageforcancel) {
261  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
262  }
263 
264  print dol_get_fiche_head(array(), '');
265 
266  // Set some default values
267  //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
268 
269  print '<table class="border centpercent tableforfieldcreate">'."\n";
270 
271  // Common attributes
272  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
273 
274  // Other attributes
275  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
276 
277  print '</table>'."\n";
278 
279  print dol_get_fiche_end();
280 
281  print $form->buttonsSaveCancel("Create");
282 
283  print '</form>';
284 
285  //dol_set_focus('input[name="ref"]');
286 }
287 
288 // Part to edit record
289 if (($id || $ref) && $action == 'edit') {
290  print load_fiche_titre($langs->trans("MyObject"), '', 'object_'.$object->picto);
291 
292  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
293  print '<input type="hidden" name="token" value="'.newToken().'">';
294  print '<input type="hidden" name="action" value="update">';
295  print '<input type="hidden" name="id" value="'.$object->id.'">';
296  if ($backtopage) {
297  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
298  }
299  if ($backtopageforcancel) {
300  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
301  }
302 
303  print dol_get_fiche_head();
304 
305  print '<table class="border centpercent tableforfieldedit">'."\n";
306 
307  // Common attributes
308  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
309 
310  // Other attributes
311  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
312 
313  print '</table>';
314 
315  print dol_get_fiche_end();
316 
317  print $form->buttonsSaveCancel();
318 
319  print '</form>';
320 }
321 
322 // Part to show record
323 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
324  $head = myobjectPrepareHead($object);
325 
326  print dol_get_fiche_head($head, 'card', $langs->trans("MyObject"), -1, $object->picto);
327 
328  $formconfirm = '';
329 
330  // Confirmation to delete
331  if ($action == 'delete') {
332  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
333  }
334  // Confirmation to delete line
335  if ($action == 'deleteline') {
336  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
337  }
338 
339  // Clone confirmation
340  if ($action == 'clone') {
341  // Create an array for form
342  $formquestion = array();
343  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
344  }
345 
346  // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
347  if ($action == 'xxx') {
348  $text = $langs->trans('ConfirmActionMyObject', $object->ref);
349  /*if (isModEnabled('notification'))
350  {
351  require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
352  $notify = new Notify($db);
353  $text .= '<br>';
354  $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
355  }*/
356 
357  $formquestion = array();
358 
359  /*
360  $forcecombo=0;
361  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
362  $formquestion = array(
363  // 'text' => $langs->trans("ConfirmClone"),
364  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
365  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
366  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
367  );
368  */
369  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
370  }
371 
372  // Call Hook formConfirm
373  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
374  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
375  if (empty($reshook)) {
376  $formconfirm .= $hookmanager->resPrint;
377  } elseif ($reshook > 0) {
378  $formconfirm = $hookmanager->resPrint;
379  }
380 
381  // Print form confirm
382  print $formconfirm;
383 
384 
385  // Object card
386  // ------------------------------------------------------------
387  $linkback = '<a href="'.dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
388 
389  $morehtmlref = '<div class="refidno">';
390  /*
391  // Ref customer
392  $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
393  $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') ? ':'.getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1);
394  // Thirdparty
395  $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
396  if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
397  $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
398  }
399  // Project
400  if (isModEnabled('project')) {
401  $langs->load("projects");
402  $morehtmlref .= '<br>';
403  if ($permissiontoadd) {
404  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
405  if ($action != 'classify') {
406  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
407  }
408  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
409  } else {
410  if (!empty($object->fk_project)) {
411  $proj = new Project($db);
412  $proj->fetch($object->fk_project);
413  $morehtmlref .= $proj->getNomUrl(1);
414  if ($proj->title) {
415  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
416  }
417  }
418  }
419  }
420  */
421  $morehtmlref .= '</div>';
422 
423 
424  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
425 
426 
427  print '<div class="fichecenter">';
428  print '<div class="fichehalfleft">';
429  print '<div class="underbanner clearboth"></div>';
430  print '<table class="border centpercent tableforfield">'."\n";
431 
432  // Common attributes
433  //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
434  //unset($object->fields['fk_project']); // Hide field already shown in banner
435  //unset($object->fields['fk_soc']); // Hide field already shown in banner
436  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
437 
438  // Other attributes. Fields from hook formObjectOptions and Extrafields.
439  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
440 
441  print '</table>';
442  print '</div>';
443  print '</div>';
444 
445  print '<div class="clearboth"></div>';
446 
447  print dol_get_fiche_end();
448 
449 
450  /*
451  * Lines
452  */
453 
454  if (!empty($object->table_element_line)) {
455  // Show object lines
456  $result = $object->getLinesArray();
457 
458  print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
459  <input type="hidden" name="token" value="' . newToken().'">
460  <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
461  <input type="hidden" name="mode" value="">
462  <input type="hidden" name="page_y" value="">
463  <input type="hidden" name="id" value="' . $object->id.'">
464  ';
465 
466  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
467  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
468  }
469 
470  print '<div class="div-table-responsive-no-min">';
471  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
472  print '<table id="tablelines" class="noborder noshadow" width="100%">';
473  }
474 
475  if (!empty($object->lines)) {
476  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
477  }
478 
479  // Form to add new line
480  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
481  if ($action != 'editline') {
482  // Add products/services form
483 
484  $parameters = array();
485  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
486  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
487  if (empty($reshook))
488  $object->formAddObjectLine(1, $mysoc, $soc);
489  }
490  }
491 
492  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
493  print '</table>';
494  }
495  print '</div>';
496 
497  print "</form>\n";
498  }
499 
500 
501  // Buttons for actions
502 
503  if ($action != 'presend' && $action != 'editline') {
504  print '<div class="tabsAction">'."\n";
505  $parameters = array();
506  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
507  if ($reshook < 0) {
508  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
509  }
510 
511  if (empty($reshook)) {
512  // Send
513  if (empty($user->socid)) {
514  print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
515  }
516 
517  // Back to draft
518  if ($object->status == $object::STATUS_VALIDATED) {
519  print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
520  }
521 
522  print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
523 
524  // Validate
525  if ($object->status == $object::STATUS_DRAFT) {
526  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
527  print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
528  } else {
529  $langs->load("errors");
530  print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
531  }
532  }
533 
534  // Clone
535  if ($permissiontoadd) {
536  print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
537  }
538 
539  /*
540  if ($permissiontoadd) {
541  if ($object->status == $object::STATUS_ENABLED) {
542  print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
543  } else {
544  print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
545  }
546  }
547  if ($permissiontoadd) {
548  if ($object->status == $object::STATUS_VALIDATED) {
549  print dolGetButtonAction('', $langs->trans('Cancel'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
550  } else {
551  print dolGetButtonAction('', $langs->trans('Re-Open'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
552  }
553  }
554  */
555 
556  // Delete
557  $params = array();
558  print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params);
559  }
560  print '</div>'."\n";
561  }
562 
563 
564  // Select mail models is same action as presend
565  if (GETPOST('modelselected')) {
566  $action = 'presend';
567  }
568 
569  if ($action != 'presend') {
570  print '<div class="fichecenter"><div class="fichehalfleft">';
571  print '<a name="builddoc"></a>'; // ancre
572 
573  $includedocgeneration = 0;
574 
575  // Documents
576  if ($includedocgeneration) {
577  $objref = dol_sanitizeFileName($object->ref);
578  $relativepath = $objref.'/'.$objref.'.pdf';
579  $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref;
580  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
581  $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
582  $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
583  print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
584  }
585 
586  // Show links to link elements
587  $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
588  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
589 
590 
591  print '</div><div class="fichehalfright">';
592 
593  $MAXEVENT = 10;
594 
595  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id);
596 
597  // List of actions on element
598  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
599  $formactions = new FormActions($db);
600  $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
601 
602  print '</div></div>';
603  }
604 
605  //Select mail models is same action as presend
606  if (GETPOST('modelselected')) {
607  $action = 'presend';
608  }
609 
610  // Presend form
611  $modelmail = 'myobject';
612  $defaulttopic = 'InformationMessage';
613  $diroutput = $conf->mymodule->dir_output;
614  $trackid = 'myobject'.$object->id;
615 
616  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
617 }
618 
619 // End of page
620 llxFooter();
621 $db->close();
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:118
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class for MyObject.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isModEnabled($module)
Is Dolibarr module enabled.
$formconfirm
if ($action == 'delbookkeepingyear') {
myobjectPrepareHead($object)
Prepare array of tabs for MyObject.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.