49 if (!$res && !empty(
$_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) $res = @include
$_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
51 $tmp = empty(
$_SERVER[
'SCRIPT_FILENAME']) ?
'' :
$_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
52 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
53 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
54 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
56 if (!$res && file_exists(
"../main.inc.php")) $res = @include
"../main.inc.php";
57 if (!$res && file_exists(
"../../main.inc.php")) $res = @include
"../../main.inc.php";
58 if (!$res && file_exists(
"../../../main.inc.php")) $res = @include
"../../../main.inc.php";
59 if (!$res) die(
"Include of main fails");
61 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
68 $langs->loadLangs(array(
"mymodule@mymodule",
"other"));
73 $action =
GETPOST(
'action',
'aZ09');
74 $confirm =
GETPOST(
'confirm',
'alpha');
75 $cancel =
GETPOST(
'cancel',
'aZ09');
76 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectcard';
77 $backtopage =
GETPOST(
'backtopage',
'alpha');
78 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
84 $diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
85 $hookmanager->initHooks(array(
'myobjectcard',
'globalcard'));
88 $extrafields->fetch_name_optionals_label($object->table_element);
90 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
93 $search_all =
GETPOST(
"search_all",
'alpha');
95 foreach ($object->fields as $key => $val)
97 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
100 if (empty($action) && empty($id) && empty($ref)) $action =
'view';
103 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
106 $permissiontoread = $user->rights->mymodule->myobject->read;
107 $permissiontoadd = $user->rights->mymodule->myobject->write;
108 $permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
109 $permissionnote = $user->rights->mymodule->myobject->write;
110 $permissiondellink = $user->rights->mymodule->myobject->write;
111 $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
126 $parameters = array();
127 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
128 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
134 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
136 if (empty($backtopage) || ($cancel && empty($id))) {
137 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
138 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) $backtopage = $backurlforlist;
139 else $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
143 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
152 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
158 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
160 if ($action ==
'set_thirdparty' && $permissiontoadd)
162 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
164 if ($action ==
'classin' && $permissiontoadd)
166 $object->setProject(
GETPOST(
'projectid',
'int'));
170 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
171 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
172 $trackid =
'myobject'.$object->id;
173 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
185 $form =
new Form($db);
189 $title = $langs->trans(
"MyObject");
194 print '<script type="text/javascript" language="javascript">
195 jQuery(document).ready(function() {
196 function init_myfunc()
198 jQuery("#myid").removeAttr(\'disabled\');
199 jQuery("#myid").attr(\'disabled\',\'disabled\');
202 jQuery("#mybutton").click(function() {
210 if ($action ==
'create')
212 print load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject")),
'',
'object_'.$object->picto);
214 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
215 print '<input type="hidden" name="token" value="'.newToken().
'">';
216 print '<input type="hidden" name="action" value="add">';
217 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
218 if ($backtopageforcancel)
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
225 print '<table class="border centpercent tableforfieldcreate">'.
"\n";
228 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
231 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
233 print '</table>'.
"\n";
237 print '<div class="center">';
238 print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'">';
240 print '<input type="'.($backtopage ?
"submit" :
"button").
'" class="button button-cancel" name="cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'"'.($backtopage ?
'' :
' onclick="javascript:history.go(-1)"').
'>';
249 if (($id || $ref) && $action ==
'edit')
253 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
254 print '<input type="hidden" name="token" value="'.newToken().
'">';
255 print '<input type="hidden" name="action" value="update">';
256 print '<input type="hidden" name="id" value="'.$object->id.
'">';
257 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
258 if ($backtopageforcancel)
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
262 print '<table class="border centpercent tableforfieldedit">'.
"\n";
265 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
268 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
274 print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
275 print ' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
282 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create')))
284 $res = $object->fetch_optionals();
292 if ($action ==
'delete') {
293 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
296 if ($action ==
'deleteline') {
297 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
300 if ($action ==
'clone') {
302 $formquestion = array();
303 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
307 if ($action ==
'xxx')
309 $formquestion = array();
320 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
324 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
325 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
326 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
327 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
335 $linkback = '<a href="'.
dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
337 $morehtmlref = '<div class="refidno">';
374 $morehtmlref .= '</div>';
377 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
380 print '<div class="fichecenter">';
381 print '<div class="fichehalfleft">';
382 print '<div class="underbanner clearboth"></div>';
383 print '<table class="border centpercent tableforfield">'."\
n";
389 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
392 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
398 print '<div class="clearboth"></div>';
407 if (!empty($object->table_element_line))
410 $result = $object->getLinesArray();
412 print ' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
413 <input type="hidden" name="token" value="' .
newToken().
'">
414 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
415 <input type="hidden" name="mode" value="">
416 <input type="hidden" name="id" value="' . $object->id.
'">
419 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
420 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
423 print '<div class="div-table-responsive-no-min">';
424 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline'))
426 print '<table id="tablelines" class="noborder noshadow" width="100%">';
429 if (!empty($object->lines))
431 $object->printObjectLines($action, $mysoc, null,
GETPOST(
'lineid',
'int'), 1);
435 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines')
437 if ($action !=
'editline')
440 $object->formAddObjectLine(1, $mysoc, $soc);
442 $parameters = array();
443 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
447 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline'))
459 if ($action !=
'presend' && $action !=
'editline') {
460 print '<div class="tabsAction">'.
"\n";
461 $parameters = array();
462 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
463 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
468 if (empty($user->socid)) {
469 print dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default',
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle');
473 if ($object->status == $object::STATUS_VALIDATED) {
474 print dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default',
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes',
'', $permissiontoadd);
480 if ($object->status == $object::STATUS_DRAFT) {
481 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
482 print dolGetButtonAction($langs->trans(
'Validate'),
'',
'default',
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes',
'', $permissiontoadd);
484 $langs->load(
"errors");
486 print '<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
491 print dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default',
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object=scrumsprint',
'', $permissiontoadd);
513 print dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete',
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
520 if (
GETPOST(
'modelselected')) {
524 if ($action !=
'presend')
526 print '<div class="fichecenter"><div class="fichehalfleft">';
527 print '<a name="builddoc"></a>';
529 $includedocgeneration = 0;
532 if ($includedocgeneration) {
534 $relativepath = $objref.
'/'.$objref.
'.pdf';
535 $filedir = $conf->mymodule->dir_output.
'/'.$object->element.
'/'.$objref;
536 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
537 $genallowed = $user->rights->mymodule->myobject->read;
538 $delallowed = $user->rights->mymodule->myobject->write;
539 print $formfile->showdocuments(
'mymodule:MyObject', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
543 $linktoelem = $form->showLinkToObjectBlock($object, null, array(
'myobject'));
544 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
547 print '</div><div class="fichehalfright"><div class="ficheaddleft">';
551 $morehtmlright =
'<a href="'.dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id.
'">';
552 $morehtmlright .= $langs->trans(
"SeeAll");
553 $morehtmlright .=
'</a>';
556 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
558 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlright);
560 print '</div></div></div>';
564 if (
GETPOST(
'modelselected')) $action =
'presend';
567 $modelmail =
'myobject';
568 $defaulttopic =
'InformationMessage';
569 $diroutput = $conf->mymodule->dir_output;
570 $trackid =
'myobject'.$object->id;
572 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
myobjectPrepareHead($object)
Prepare array of tabs for MyObject.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
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.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...