53if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
54 $res = @include str_replace(
"..",
"", $_SERVER[
"CONTEXT_DOCUMENT_ROOT"]).
"/main.inc.php";
57$tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME'];
58$tmp2 = realpath(__FILE__);
60$j = strlen($tmp2) - 1;
61while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
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";
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";
72if (!$res && file_exists(
"../main.inc.php")) {
73 $res = @include
"../main.inc.php";
75if (!$res && file_exists(
"../../main.inc.php")) {
76 $res = @include
"../../main.inc.php";
78if (!$res && file_exists(
"../../../main.inc.php")) {
79 $res = @include
"../../../main.inc.php";
82 die(
"Include of main fails");
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';
101$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
109$action =
GETPOST(
'action',
'aZ09');
110$confirm =
GETPOST(
'confirm',
'alpha');
113$backtopage =
GETPOST(
'backtopage',
'alpha');
114$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
115$optioncss =
GETPOST(
'optioncss',
'aZ');
116$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
121$diroutputmassaction =
$conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
122$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
126$extrafields->fetch_name_optionals_label(
$object->table_element);
129$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
132$search_all = trim(
GETPOST(
"search_all",
'alpha'));
134foreach (
$object->fields as $key => $val) {
135 if (
GETPOST(
'search_'.$key,
'alpha')) {
136 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
140if (empty($action) && empty($id) && empty($ref)) {
145include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
149$enablepermissioncheck =
getDolGlobalInt(
'MYMODULE_ENABLE_PERMISSION_CHECK');
150if ($enablepermissioncheck) {
151 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
152 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
153 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
154 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
155 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
157 $permissiontoread = 1;
158 $permissiontoadd = 1;
159 $permissiontodelete = 1;
161 $permissiondellink = 1;
164$upload_dir =
$conf->mymodule->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/myobject';
176if (!$permissiontoread) {
187$parameters = array();
188$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
190 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
193if (empty($reshook)) {
194 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
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;
201 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
206 $triggermodname =
$object->TRIGGER_PREFIX.
'_MODIFY';
209 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
212 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
215 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
219 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
223 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
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';
250if ($action !=
'create' && !
$object->id) {
254$form =
new Form($db);
257$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
259if ($action ==
'create') {
260 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
264llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
282if ($action ==
'create') {
283 if (empty($permissiontoadd)) {
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">';
293 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
295 if ($backtopageforcancel) {
296 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
298 if ($dol_openinpopup) {
299 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
305 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
311 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
313 print
'</table>'.
"\n";
317 print $form->buttonsSaveCancel(
"Create");
325if (
$object->id > 0 && $action ==
'edit') {
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.
'">';
333 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
335 if ($backtopageforcancel) {
336 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
341 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
344 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
347 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
353 print $form->buttonsSaveCancel();
359if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
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');
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);
377 if ($action ==
'clone') {
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);
408 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
409 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
410 if (empty($reshook)) {
411 $formconfirm .= $hookmanager->resPrint;
412 } elseif ($reshook > 0) {
413 $formconfirm = $hookmanager->resPrint;
423 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
429 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
431 $morehtmlref =
'<div class="refidno">';
463 $morehtmlref .=
'</div>';
466 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
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";
477 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
480 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
486 print
'<div class="clearboth"></div>';
495 if (!empty(
$object->table_element_line)) {
497 $result =
$object->getLinesArray();
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.
'">
507 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
508 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
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%">';
521 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
522 if ($action !=
'editline') {
525 $parameters = array();
526 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
528 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
530 if (empty($reshook)) {
536 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
546 if ($action !=
'presend' && $action !=
'editline') {
547 print
'<div class="tabsAction">'.
"\n";
548 $parameters = array();
549 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
551 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
554 if (empty($reshook)) {
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');
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);
570 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
574 if (
$object->status == $object::STATUS_DRAFT) {
576 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
578 $langs->load(
"errors");
579 print dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
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')));
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)) {
620 $buttonId =
'action-delete';
623 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
632 if (
GETPOST(
'modelselected')) {
637 if ($action !=
'presend') {
638 print
'<div class="fichecenter"><div class="fichehalfleft">';
639 print
'<a name="builddoc"></a>';
641 $includedocgeneration = 0;
644 if ($includedocgeneration) {
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;
650 $delallowed = $permissiontoadd;
651 print $formfile->showdocuments(
$object->element.
'@'.
$object->module, $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
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);
663 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
666 print
'</div><div class="fichehalfright">';
673 $includeeventlist = 0;
676 if ($includeeventlist) {
677 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
679 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
683 print
'</div></div>';
688 if (
GETPOST(
'modelselected')) {
693 $modelmail =
'myobject';
694 $defaulttopic =
'InformationMessage';
695 $diroutput =
$conf->mymodule->dir_output;
696 $trackid =
'myobject'.$object->id;
698 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
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.
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.