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");
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';
100$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
108$action =
GETPOST(
'action',
'aZ09');
109$confirm =
GETPOST(
'confirm',
'alpha');
112$backtopage =
GETPOST(
'backtopage',
'alpha');
113$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
114$optioncss =
GETPOST(
'optioncss',
'aZ');
115$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
120$diroutputmassaction =
$conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
121$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
125$extrafields->fetch_name_optionals_label(
$object->table_element);
128$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
131$search_all = trim(
GETPOST(
"search_all",
'alpha'));
133foreach (
$object->fields as $key => $val) {
134 if (
GETPOST(
'search_'.$key,
'alpha')) {
135 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
139if (empty($action) && empty($id) && empty($ref)) {
144include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
148$enablepermissioncheck =
getDolGlobalInt(
'MYMODULE_ENABLE_PERMISSION_CHECK');
149if ($enablepermissioncheck) {
150 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
151 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
152 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
153 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
154 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
156 $permissiontoread = 1;
157 $permissiontoadd = 1;
158 $permissiontodelete = 1;
160 $permissiondellink = 1;
163$upload_dir =
$conf->mymodule->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/myobject';
173if (!$permissiontoread) {
184$parameters = array();
185$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
190if (empty($reshook)) {
191 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
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;
198 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
203 $triggermodname =
$object->TRIGGER_PREFIX.
'_MODIFY';
206 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
209 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
212 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
216 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
220 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
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';
248$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
250if ($action ==
'create') {
251 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
255llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
273if ($action ==
'create') {
274 if (empty($permissiontoadd)) {
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">';
284 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
286 if ($backtopageforcancel) {
287 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
289 if ($dol_openinpopup) {
290 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
296 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
299 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
302 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
304 print
'</table>'.
"\n";
308 print $form->buttonsSaveCancel(
"Create");
316if (($id || $ref) && $action ==
'edit') {
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.
'">';
324 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
326 if ($backtopageforcancel) {
327 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
332 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
335 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
338 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
344 print $form->buttonsSaveCancel();
350if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
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');
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);
365 if ($action ==
'clone') {
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);
395 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
396 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
397 if (empty($reshook)) {
398 $formconfirm .= $hookmanager->resPrint;
399 } elseif ($reshook > 0) {
400 $formconfirm = $hookmanager->resPrint;
410 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
416 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
418 $morehtmlref =
'<div class="refidno">';
450 $morehtmlref .=
'</div>';
453 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
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";
464 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
467 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
473 print
'<div class="clearboth"></div>';
482 if (!empty(
$object->table_element_line)) {
484 $result =
$object->getLinesArray();
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.
'">
494 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
495 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
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%">';
509 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
510 if ($action !=
'editline') {
513 $parameters = array();
514 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
518 if (empty($reshook)) {
525 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
535 if ($action !=
'presend' && $action !=
'editline') {
536 print
'<div class="tabsAction">'.
"\n";
537 $parameters = array();
538 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
543 if (empty($reshook)) {
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');
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);
555 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
558 if (
$object->status == $object::STATUS_DRAFT) {
560 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
562 $langs->load(
"errors");
563 print dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
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);
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)) {
595 $buttonId =
'action-delete';
598 print dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
605 if (
GETPOST(
'modelselected')) {
609 if ($action !=
'presend') {
610 print
'<div class="fichecenter"><div class="fichehalfleft">';
611 print
'<a name="builddoc"></a>';
613 $includedocgeneration = 0;
616 if ($includedocgeneration) {
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;
622 $delallowed = $permissiontoadd;
623 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
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);
635 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
638 print
'</div><div class="fichehalfright">';
643 $morehtmlcenter = dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.
$object->id);
645 $includeeventlist = 0;
648 if ($includeeventlist) {
649 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
651 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
655 print
'</div></div>';
659 if (
GETPOST(
'modelselected')) {
664 $modelmail =
'myobject';
665 $defaulttopic =
'InformationMessage';
666 $diroutput =
$conf->mymodule->dir_output;
667 $trackid =
'myobject'.$object->id;
669 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.
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.