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