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';
174if (!$permissiontoread) {
185$parameters = array();
186$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
188 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
191if (empty($reshook)) {
192 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
194 if (empty($backtopage) || ($cancel && empty($id))) {
195 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
196 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
197 $backtopage = $backurlforlist;
199 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
204 $triggermodname =
$object->TRIGGER_PREFIX.
'_MODIFY';
207 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
210 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
213 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
217 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
221 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
235 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
236 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
237 $trackid =
'myobject'.$object->id;
238 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
248if ($action !=
'create' && !
$object->id) {
252$form =
new Form($db);
255$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
257if ($action ==
'create') {
258 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
262llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
280if ($action ==
'create') {
281 if (empty($permissiontoadd)) {
287 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
288 print
'<input type="hidden" name="token" value="'.newToken().
'">';
289 print
'<input type="hidden" name="action" value="add">';
291 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
293 if ($backtopageforcancel) {
294 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
296 if ($dol_openinpopup) {
297 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
303 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
306 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
309 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
311 print
'</table>'.
"\n";
315 print $form->buttonsSaveCancel(
"Create");
323if (
$object->id > 0 && $action ==
'edit') {
326 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
328 print
'<input type="hidden" name="action" value="update">';
329 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
331 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
333 if ($backtopageforcancel) {
334 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
339 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
342 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
345 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
351 print $form->buttonsSaveCancel();
357if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
362 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
363 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
368 if ($action ==
'deleteline') {
369 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
375 if ($action ==
'clone') {
377 $formquestion = array();
378 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
406 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
407 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
408 if (empty($reshook)) {
409 $formconfirm .= $hookmanager->resPrint;
410 } elseif ($reshook > 0) {
411 $formconfirm = $hookmanager->resPrint;
421 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
427 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
429 $morehtmlref =
'<div class="refidno">';
461 $morehtmlref .=
'</div>';
464 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
466 print
'<div class="fichecenter">';
467 print
'<div class="fichehalfleft">';
468 print
'<div class="underbanner clearboth"></div>';
469 print
'<table class="border centpercent tableforfield">'.
"\n";
475 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
478 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
484 print
'<div class="clearboth"></div>';
493 if (!empty(
$object->table_element_line)) {
495 $result =
$object->getLinesArray();
497 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
498 <input type="hidden" name="token" value="' .
newToken().
'">
499 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
500 <input type="hidden" name="mode" value="">
501 <input type="hidden" name="page_y" value="">
502 <input type="hidden" name="id" value="' .
$object->id.
'">
505 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
506 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
509 print
'<div class="div-table-responsive-no-min">';
510 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
511 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
519 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
520 if ($action !=
'editline') {
523 $parameters = array();
524 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
526 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
528 if (empty($reshook)) {
534 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
544 if ($action !=
'presend' && $action !=
'editline') {
545 print
'<div class="tabsAction">'.
"\n";
546 $parameters = array();
547 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
549 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
552 if (empty($reshook)) {
555 if (empty($user->socid)) {
556 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
562 if (
$object->status == $object::STATUS_VALIDATED) {
563 print dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
568 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
572 if (
$object->status == $object::STATUS_DRAFT) {
574 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
576 $langs->load(
"errors");
577 print dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
584 if ($permissiontoadd) {
585 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')));
615 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
616 $buttonId =
'action-delete-no-ajax';
617 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
619 $buttonId =
'action-delete';
622 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
631 if (
GETPOST(
'modelselected')) {
636 if ($action !=
'presend') {
637 print
'<div class="fichecenter"><div class="fichehalfleft">';
638 print
'<a name="builddoc"></a>';
640 $includedocgeneration = 0;
643 if ($includedocgeneration) {
645 $relativepath = $objref.
'/'.$objref.
'.pdf';
646 $filedir =
$conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
647 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
648 $genallowed = $permissiontoread;
649 $delallowed = $permissiontoadd;
650 print $formfile->showdocuments(
$object->element.
'@'.
$object->module, $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
654 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'myobject'), 1);
655 if (is_array($tmparray)) {
656 $linktoelem = $tmparray[
'linktoelem'];
657 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
658 print $htmltoenteralink;
659 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
662 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
665 print
'</div><div class="fichehalfright">';
672 $includeeventlist = 0;
675 if ($includeeventlist) {
676 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
678 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
682 print
'</div></div>';
687 if (
GETPOST(
'modelselected')) {
692 $modelmail =
'myobject';
693 $defaulttopic =
'InformationMessage';
694 $diroutput =
$conf->mymodule->dir_output;
695 $trackid =
'myobject'.$object->id;
697 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.
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.