51if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
52 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
55$tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
56while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
60if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
61 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
63if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
64 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
67if (!$res && file_exists(
"../main.inc.php")) {
68 $res = @include
"../main.inc.php";
70if (!$res && file_exists(
"../../main.inc.php")) {
71 $res = @include
"../../main.inc.php";
73if (!$res && file_exists(
"../../../main.inc.php")) {
74 $res = @include
"../../../main.inc.php";
77 die(
"Include of main fails");
80require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
81require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
82require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
87$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
94$action =
GETPOST(
'action',
'aZ09');
95$confirm =
GETPOST(
'confirm',
'alpha');
96$cancel =
GETPOST(
'cancel',
'aZ09');
97$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
98$backtopage =
GETPOST(
'backtopage',
'alpha');
99$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
100$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
101$optioncss =
GETPOST(
'optioncss',
'aZ');
102$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
104if (!empty($backtopagejsfields)) {
105 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
106 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
112$diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
113$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
116$extrafields->fetch_name_optionals_label(
$object->table_element);
118$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
121$search_all = trim(
GETPOST(
"search_all",
'alpha'));
123foreach (
$object->fields as $key => $val) {
124 if (
GETPOST(
'search_'.$key,
'alpha')) {
125 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
129if (empty($action) && empty($id) && empty($ref)) {
134include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
138$enablepermissioncheck = 0;
139if ($enablepermissioncheck) {
140 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
141 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
142 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
143 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
144 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
146 $permissiontoread = 1;
147 $permissiontoadd = 1;
148 $permissiontodelete = 1;
150 $permissiondellink = 1;
153$upload_dir = $conf->mymodule->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/myobject';
160if (!isModEnabled(
"mymodule")) {
163if (!$permissiontoread) {
174$parameters = array();
175$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
180if (empty($reshook)) {
181 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
183 if (empty($backtopage) || ($cancel && empty($id))) {
184 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
185 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
186 $backtopage = $backurlforlist;
188 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
193 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
196 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
199 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
202 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
208 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
210 if ($action ==
'set_thirdparty' && $permissiontoadd) {
211 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
213 if ($action ==
'classin' && $permissiontoadd) {
218 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
219 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
220 $trackid =
'myobject'.$object->id;
221 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
231$form =
new Form($db);
235$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
237if ($action ==
'create') {
238 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
242llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
261if ($action ==
'create') {
262 if (empty($permissiontoadd)) {
268 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
269 print
'<input type="hidden" name="token" value="'.newToken().
'">';
270 print
'<input type="hidden" name="action" value="add">';
272 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
274 if ($backtopageforcancel) {
275 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
277 if ($backtopagejsfields) {
278 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
280 if ($dol_openinpopup) {
281 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
287 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
290 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
293 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
295 print
'</table>'.
"\n";
299 print $form->buttonsSaveCancel(
"Create");
307if (($id || $ref) && $action ==
'edit') {
308 print
load_fiche_titre($langs->trans(
"MyObject"),
'',
'object_'.$object->picto);
310 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
312 print
'<input type="hidden" name="action" value="update">';
313 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
315 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
317 if ($backtopageforcancel) {
318 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
323 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
326 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
329 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
335 print $form->buttonsSaveCancel();
341if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
344 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
349 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
350 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
353 if ($action ==
'deleteline') {
354 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
358 if ($action ==
'clone') {
360 $formquestion = array();
361 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
365 if ($action ==
'xxx') {
366 $text = $langs->trans(
'ConfirmActionMyObject',
$object->ref);
375 $formquestion = array();
387 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
391 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
392 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
393 if (empty($reshook)) {
394 $formconfirm .= $hookmanager->resPrint;
395 } elseif ($reshook > 0) {
396 $formconfirm = $hookmanager->resPrint;
405 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
407 $morehtmlref =
'<div class="refidno">';
439 $morehtmlref .=
'</div>';
442 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
445 print
'<div class="fichecenter">';
446 print
'<div class="fichehalfleft">';
447 print
'<div class="underbanner clearboth"></div>';
448 print
'<table class="border centpercent tableforfield">'.
"\n";
454 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
457 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
463 print
'<div class="clearboth"></div>';
472 if (!empty(
$object->table_element_line)) {
474 $result =
$object->getLinesArray();
476 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
477 <input type="hidden" name="token" value="' .
newToken().
'">
478 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
479 <input type="hidden" name="mode" value="">
480 <input type="hidden" name="page_y" value="">
481 <input type="hidden" name="id" value="' .
$object->id.
'">
484 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
485 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
488 print
'<div class="div-table-responsive-no-min">';
489 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
490 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
494 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
498 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
499 if ($action !=
'editline') {
502 $parameters = array();
503 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
507 if (empty($reshook)) {
508 $object->formAddObjectLine(1, $mysoc, $soc);
513 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
524 if ($action !=
'presend' && $action !=
'editline') {
525 print
'<div class="tabsAction">'.
"\n";
526 $parameters = array();
527 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
532 if (empty($reshook)) {
534 if (empty($user->socid)) {
535 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
539 if (
$object->status == $object::STATUS_VALIDATED) {
540 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
544 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
547 if (
$object->status == $object::STATUS_DRAFT) {
549 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
551 $langs->load(
"errors");
552 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
557 if ($permissiontoadd) {
558 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
580 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
581 $buttonId =
'action-delete-no-ajax';
582 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
584 $buttonId =
'action-delete';
587 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
594 if (
GETPOST(
'modelselected')) {
598 if ($action !=
'presend') {
599 print
'<div class="fichecenter"><div class="fichehalfleft">';
600 print
'<a name="builddoc"></a>';
602 $includedocgeneration = 0;
605 if ($includedocgeneration) {
607 $relativepath = $objref.
'/'.$objref.
'.pdf';
608 $filedir = $conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
609 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
610 $genallowed = $permissiontoread;
611 $delallowed = $permissiontoadd;
612 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
616 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'myobject'));
617 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
620 print
'</div><div class="fichehalfright">';
627 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
629 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
631 print
'</div></div>';
635 if (
GETPOST(
'modelselected')) {
640 $modelmail =
'myobject';
641 $defaulttopic =
'InformationMessage';
642 $diroutput = $conf->mymodule->dir_output;
643 $trackid =
'myobject'.$object->id;
645 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
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.
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.