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