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'];
56$tmp2 = realpath(__FILE__);
58$j = strlen($tmp2) - 1;
59while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
63if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
64 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
66if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
67 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/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";
76if (!$res && file_exists(
"../../../main.inc.php")) {
77 $res = @include
"../../../main.inc.php";
80 die(
"Include of main fails");
83require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
84require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
85require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
90$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
97$action =
GETPOST(
'action',
'aZ09');
98$confirm =
GETPOST(
'confirm',
'alpha');
99$cancel =
GETPOST(
'cancel',
'aZ09');
100$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
101$backtopage =
GETPOST(
'backtopage',
'alpha');
102$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
103$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
104$optioncss =
GETPOST(
'optioncss',
'aZ');
105$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
107if (!empty($backtopagejsfields)) {
108 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
109 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
115$diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
116$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
120$extrafields->fetch_name_optionals_label(
$object->table_element);
123$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
126$search_all = trim(
GETPOST(
"search_all",
'alpha'));
128foreach (
$object->fields as $key => $val) {
129 if (
GETPOST(
'search_'.$key,
'alpha')) {
130 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
134if (empty($action) && empty($id) && empty($ref)) {
139include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
143$enablepermissioncheck = 0;
144if ($enablepermissioncheck) {
145 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
146 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
147 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
148 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
149 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
151 $permissiontoread = 1;
152 $permissiontoadd = 1;
153 $permissiontodelete = 1;
155 $permissiondellink = 1;
158$upload_dir = $conf->mymodule->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/myobject';
165if (!isModEnabled(
$object->module)) {
168if (!$permissiontoread) {
179$parameters = array();
180$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
185if (empty($reshook)) {
186 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
188 if (empty($backtopage) || ($cancel && empty($id))) {
189 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
190 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
191 $backtopage = $backurlforlist;
193 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
198 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
201 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
204 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
207 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
213 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
215 if ($action ==
'set_thirdparty' && $permissiontoadd) {
216 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
218 if ($action ==
'classin' && $permissiontoadd) {
223 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
224 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
225 $trackid =
'myobject'.$object->id;
226 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
236$form =
new Form($db);
240$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
242if ($action ==
'create') {
243 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
247llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
266if ($action ==
'create') {
267 if (empty($permissiontoadd)) {
273 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
274 print
'<input type="hidden" name="token" value="'.newToken().
'">';
275 print
'<input type="hidden" name="action" value="add">';
277 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
279 if ($backtopageforcancel) {
280 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
282 if ($backtopagejsfields) {
283 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
285 if ($dol_openinpopup) {
286 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
292 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
295 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
298 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
300 print
'</table>'.
"\n";
304 print $form->buttonsSaveCancel(
"Create");
312if (($id || $ref) && $action ==
'edit') {
315 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
316 print
'<input type="hidden" name="token" value="'.newToken().
'">';
317 print
'<input type="hidden" name="action" value="update">';
318 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
320 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
322 if ($backtopageforcancel) {
323 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
328 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
331 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
334 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
340 print $form->buttonsSaveCancel();
346if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
349 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
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');
358 if ($action ==
'deleteline') {
359 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
363 if ($action ==
'clone') {
365 $formquestion = array();
366 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
370 if ($action ==
'xxx') {
371 $text = $langs->trans(
'ConfirmActionXxx',
$object->ref);
380 $formquestion = array();
392 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
396 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
397 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
398 if (empty($reshook)) {
399 $formconfirm .= $hookmanager->resPrint;
400 } elseif ($reshook > 0) {
401 $formconfirm = $hookmanager->resPrint;
410 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
412 $morehtmlref =
'<div class="refidno">';
444 $morehtmlref .=
'</div>';
447 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
450 print
'<div class="fichecenter">';
451 print
'<div class="fichehalfleft">';
452 print
'<div class="underbanner clearboth"></div>';
453 print
'<table class="border centpercent tableforfield">'.
"\n";
459 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
462 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
468 print
'<div class="clearboth"></div>';
477 if (!empty(
$object->table_element_line)) {
479 $result =
$object->getLinesArray();
481 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
482 <input type="hidden" name="token" value="' .
newToken().
'">
483 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
484 <input type="hidden" name="mode" value="">
485 <input type="hidden" name="page_y" value="">
486 <input type="hidden" name="id" value="' .
$object->id.
'">
489 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
490 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
493 print
'<div class="div-table-responsive-no-min">';
494 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
495 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
503 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
504 if ($action !=
'editline') {
507 $parameters = array();
508 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
512 if (empty($reshook)) {
513 $object->formAddObjectLine(1, $mysoc, $soc);
518 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
529 if ($action !=
'presend' && $action !=
'editline') {
530 print
'<div class="tabsAction">'.
"\n";
531 $parameters = array();
532 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
537 if (empty($reshook)) {
539 if (empty($user->socid)) {
540 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
544 if (
$object->status == $object::STATUS_VALIDATED) {
545 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
549 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
552 if (
$object->status == $object::STATUS_DRAFT) {
554 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
556 $langs->load(
"errors");
557 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
562 if ($permissiontoadd) {
563 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
585 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
586 $buttonId =
'action-delete-no-ajax';
587 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
589 $buttonId =
'action-delete';
592 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
599 if (
GETPOST(
'modelselected')) {
603 if ($action !=
'presend') {
604 print
'<div class="fichecenter"><div class="fichehalfleft">';
605 print
'<a name="builddoc"></a>';
607 $includedocgeneration = 0;
610 if ($includedocgeneration) {
612 $relativepath = $objref.
'/'.$objref.
'.pdf';
613 $filedir = $conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
614 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
615 $genallowed = $permissiontoread;
616 $delallowed = $permissiontoadd;
617 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
621 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'myobject'), 1);
622 $linktoelem = $tmparray[
'linktoelem'];
623 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
624 print $htmltoenteralink;
626 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
629 print
'</div><div class="fichehalfright">';
635 $includeeventlist = 0;
638 if ($includeeventlist) {
639 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
641 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
644 print
'</div></div>';
648 if (
GETPOST(
'modelselected')) {
653 $modelmail =
'myobject';
654 $defaulttopic =
'InformationMessage';
655 $diroutput = $conf->mymodule->dir_output;
656 $trackid =
'myobject'.$object->id;
658 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
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.