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