48if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
49 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
52$tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
56if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
57 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
59if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
60 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
63if (!$res && file_exists(
"../main.inc.php")) {
64 $res = @include
"../main.inc.php";
66if (!$res && file_exists(
"../../main.inc.php")) {
67 $res = @include
"../../main.inc.php";
69if (!$res && file_exists(
"../../../main.inc.php")) {
70 $res = @include
"../../../main.inc.php";
73 die(
"Include of main fails");
76require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
77require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
78require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
83$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
88$lineid =
GETPOST(
'lineid',
'int');
90$action =
GETPOST(
'action',
'aZ09');
91$confirm =
GETPOST(
'confirm',
'alpha');
92$cancel =
GETPOST(
'cancel',
'aZ09');
93$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
94$backtopage =
GETPOST(
'backtopage',
'alpha');
95$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
96$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
97$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
99if (!empty($backtopagejsfields)) {
100 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
101 $dol_openinpopup = $tmpbacktopagejsfields[0];
107$diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
108$hookmanager->initHooks(array(
'myobjectcard',
'globalcard'));
111$extrafields->fetch_name_optionals_label($object->table_element);
113$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
116$search_all =
GETPOST(
"search_all",
'alpha');
118foreach ($object->fields as $key => $val) {
119 if (
GETPOST(
'search_'.$key,
'alpha')) {
120 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
124if (empty($action) && empty($id) && empty($ref)) {
129include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
133$enablepermissioncheck = 0;
134if ($enablepermissioncheck) {
135 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
136 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
137 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
138 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
139 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
141 $permissiontoread = 1;
142 $permissiontoadd = 1;
143 $permissiontodelete = 1;
145 $permissiondellink = 1;
148$upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1].
'/myobject';
155if (!isModEnabled(
"mymodule")) {
158if (!$permissiontoread) {
167$parameters = array();
168$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
173if (empty($reshook)) {
176 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
178 if (empty($backtopage) || ($cancel && empty($id))) {
179 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
180 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
181 $backtopage = $backurlforlist;
183 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
188 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
191 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
194 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
197 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
203 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
205 if ($action ==
'set_thirdparty' && $permissiontoadd) {
206 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
208 if ($action ==
'classin' && $permissiontoadd) {
209 $object->setProject(
GETPOST(
'projectid',
'int'));
213 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
214 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
215 $trackid =
'myobject'.$object->id;
216 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
226$form =
new Form($db);
230$title = $langs->trans(
"MyObject");
251if ($action ==
'create') {
252 if (empty($permissiontoadd)) {
256 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject")),
'',
'object_'.$object->picto);
258 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
259 print
'<input type="hidden" name="token" value="'.newToken().
'">';
260 print
'<input type="hidden" name="action" value="add">';
262 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
264 if ($backtopageforcancel) {
265 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
267 if ($backtopagejsfields) {
268 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
270 if ($dol_openinpopup) {
271 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
279 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
282 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
285 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
287 print
'</table>'.
"\n";
291 print $form->buttonsSaveCancel(
"Create");
299if (($id || $ref) && $action ==
'edit') {
300 print
load_fiche_titre($langs->trans(
"MyObject"),
'',
'object_'.$object->picto);
302 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
303 print
'<input type="hidden" name="token" value="'.newToken().
'">';
304 print
'<input type="hidden" name="action" value="update">';
305 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
307 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
309 if ($backtopageforcancel) {
310 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
315 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
318 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
321 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
327 print $form->buttonsSaveCancel();
333if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
336 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1, $object->picto, 0,
'',
'', 0,
'', 1);
341 if ($action ==
'delete') {
342 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
345 if ($action ==
'deleteline') {
346 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
350 if ($action ==
'clone') {
352 $formquestion = array();
353 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
357 if ($action ==
'xxx') {
358 $text = $langs->trans(
'ConfirmActionMyObject', $object->ref);
367 $formquestion = array();
379 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
383 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
384 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
385 if (empty($reshook)) {
386 $formconfirm .= $hookmanager->resPrint;
387 } elseif ($reshook > 0) {
388 $formconfirm = $hookmanager->resPrint;
397 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
399 $morehtmlref =
'<div class="refidno">';
431 $morehtmlref .=
'</div>';
434 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
437 print
'<div class="fichecenter">';
438 print
'<div class="fichehalfleft">';
439 print
'<div class="underbanner clearboth"></div>';
440 print
'<table class="border centpercent tableforfield">'.
"\n";
446 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
449 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
455 print
'<div class="clearboth"></div>';
464 if (!empty($object->table_element_line)) {
466 $result = $object->getLinesArray();
468 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
469 <input type="hidden" name="token" value="' . newToken().
'">
470 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
471 <input type="hidden" name="mode" value="">
472 <input type="hidden" name="page_y" value="">
473 <input type="hidden" name="id" value="' . $object->id.
'">
476 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
477 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
480 print
'<div class="div-table-responsive-no-min">';
481 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
482 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
485 if (!empty($object->lines)) {
486 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
490 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
491 if ($action !=
'editline') {
494 $parameters = array();
495 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
496 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
498 $object->formAddObjectLine(1, $mysoc, $soc);
502 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
513 if ($action !=
'presend' && $action !=
'editline') {
514 print
'<div class="tabsAction">'.
"\n";
515 $parameters = array();
516 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
521 if (empty($reshook)) {
523 if (empty($user->socid)) {
524 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle');
528 if ($object->status == $object::STATUS_VALIDATED) {
529 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
532 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
535 if ($object->status == $object::STATUS_DRAFT) {
536 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
537 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
539 $langs->load(
"errors");
540 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
545 if ($permissiontoadd) {
546 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid)?
'&socid='.$object->socid:
'').
'&action=clone&token='.newToken(),
'', $permissiontoadd);
568 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete, $params);
575 if (
GETPOST(
'modelselected')) {
579 if ($action !=
'presend') {
580 print
'<div class="fichecenter"><div class="fichehalfleft">';
581 print
'<a name="builddoc"></a>';
583 $includedocgeneration = 0;
586 if ($includedocgeneration) {
588 $relativepath = $objref.
'/'.$objref.
'.pdf';
589 $filedir = $conf->mymodule->dir_output.
'/'.$object->element.
'/'.$objref;
590 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
591 $genallowed = $permissiontoread;
592 $delallowed = $permissiontoadd;
593 print $formfile->showdocuments(
'mymodule:MyObject', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
597 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'myobject'));
598 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
601 print
'</div><div class="fichehalfright">';
605 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
608 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
610 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
612 print
'</div></div>';
616 if (
GETPOST(
'modelselected')) {
621 $modelmail =
'myobject';
622 $defaulttopic =
'InformationMessage';
623 $diroutput = $conf->mymodule->dir_output;
624 $trackid =
'myobject'.$object->id;
626 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.