39require
"../main.inc.php";
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/intracommreport/lib/intracommreport.lib.php';
56$langs->loadLangs(array(
"intracommreport",
"other"));
63$action =
GETPOST(
'action',
'aZ09');
64$confirm =
GETPOST(
'confirm',
'alpha');
66$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
69$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
74$diroutputmassaction =
$conf->intracommreport->dir_output.
'/temp/massgeneration/'.$user->id;
75$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
78$extrafields->fetch_name_optionals_label(
$object->table_element);
80$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
83$search_all = trim(
GETPOST(
"search_all",
'alpha'));
85foreach (
$object->fields as $key => $val) {
86 if (
GETPOST(
'search_'.$key,
'alpha')) {
87 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
91if (empty($action) && empty($id) && empty($ref)) {
96include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
100$enablepermissioncheck = 1;
101if ($enablepermissioncheck) {
102 $permissiontoread = $user->hasRight(
'intracommreport',
'read');
103 $permissiontoadd = $user->hasRight(
'intracommreport',
'write');
104 $permissiontodelete = $user->hasRight(
'intracommreport',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
105 $permissionnote = $user->hasRight(
'intracommreport',
'write');
106 $permissiondellink = $user->hasRight(
'intracommreport',
'write');
108 $permissiontoread = 1;
109 $permissiontoadd = 1;
110 $permissiontodelete = 1;
112 $permissiondellink = 1;
115$upload_dir =
$conf->intracommreport->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/intracommreport';
125if (!$permissiontoread) {
136$parameters = array();
137$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
142if (empty($reshook)) {
143 $backurlforlist =
dol_buildpath(
'/intracommreport/list.php', 1);
145 if (empty($backtopage) || ($cancel && empty($id))) {
146 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
147 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
148 $backtopage = $backurlforlist;
150 $backtopage =
dol_buildpath(
'/intracommreport/card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
155 $triggermodname =
'INTRACOMMREPORT_MODIFY';
158 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
161 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
164 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
170 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
172 if ($action ==
'set_thirdparty' && $permissiontoadd) {
173 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
175 if ($action ==
'classin' && $permissiontoadd) {
180 $triggersendname =
'INTRACOMMREPORT_SENTBYMAIL';
181 $autocopy =
'MAIN_MAIL_AUTOCOPY_INTRACOMMREPORT_TO';
182 $trackid =
'intracommreport'.$object->id;
183 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
197$title = $langs->trans(
"IntraCommReport").
" - ".$langs->trans(
'Card');
199if ($action ==
'create') {
200 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"IntraCommReport"));
204llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
207if ($action ==
'create') {
208 if (empty($permissiontoadd)) {
214 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
215 print
'<input type="hidden" name="token" value="'.newToken().
'">';
216 print
'<input type="hidden" name="action" value="add">';
218 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
220 if ($backtopageforcancel) {
221 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
223 if ($dol_openinpopup) {
224 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
230 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
233 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
236 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
238 print
'</table>'.
"\n";
242 print $form->buttonsSaveCancel(
"Create");
250if (($id || $ref) && $action ==
'edit') {
251 print
load_fiche_titre($langs->trans(
"IntraCommReport"),
'',
'object_'.$object->picto);
253 print
'<form method="POST" action="'.dolBuildUrl($_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.
'">';
258 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
260 if ($backtopageforcancel) {
261 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
266 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
269 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
272 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
278 print $form->buttonsSaveCancel();
284if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
287 print
dol_get_fiche_head($head,
'card', $langs->trans(
"IntraCommReport"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
292 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
293 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteIntraCommReport'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
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);
301 if ($action ==
'clone') {
303 $formquestion = array();
304 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
308 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
309 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
310 if (empty($reshook)) {
311 $formconfirm .= $hookmanager->resPrint;
312 } elseif ($reshook > 0) {
313 $formconfirm = $hookmanager->resPrint;
322 $linkback =
'<a href="'.dol_buildpath(
'/intracommreport/list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
324 $morehtmlref =
'<div class="refidno">';
356 $morehtmlref .=
'</div>';
359 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
362 print
'<div class="fichecenter">';
363 print
'<div class="fichehalfleft">';
364 print
'<div class="underbanner clearboth"></div>';
365 print
'<table class="border centpercent tableforfield">'.
"\n";
371 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
374 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
380 print
'<div class="clearboth"></div>';
389 if (!empty(
$object->table_element_line)) {
391 $result =
$object->getLinesArray();
393 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
394 <input type="hidden" name="token" value="' .
newToken().
'">
395 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
396 <input type="hidden" name="mode" value="">
397 <input type="hidden" name="page_y" value="">
398 <input type="hidden" name="id" value="' .
$object->id.
'">
401 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
402 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
405 print
'<div class="div-table-responsive-no-min">';
406 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
407 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
417 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
418 if ($action !=
'editline') {
421 $parameters = array();
422 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
426 if (empty($reshook)) {
432 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
443 if ($action !=
'presend' && $action !=
'editline') {
444 print
'<div class="tabsAction">'.
"\n";
445 $parameters = array();
446 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
451 if (empty($reshook)) {
453 if (empty($user->socid)) {
454 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
458 if (
$object->status == $object::STATUS_VALIDATED) {
459 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
463 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
466 if (
$object->status == $object::STATUS_DRAFT) {
468 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
470 $langs->load(
"errors");
471 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
476 if ($permissiontoadd) {
477 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
499 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
500 $buttonId =
'action-delete-no-ajax';
501 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
503 $buttonId =
'action-delete';
506 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
513 if (
GETPOST(
'modelselected')) {
517 if ($action !=
'presend') {
518 print
'<div class="fichecenter"><div class="fichehalfleft">';
519 print
'<a name="builddoc"></a>';
521 $includedocgeneration = 0;
524 if ($includedocgeneration) {
526 $relativepath = $objref.
'/'.$objref.
'.pdf';
527 $filedir =
$conf->intracommreport->dir_output.
'/'.
$object->element.
'/'.$objref;
528 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
529 $genallowed = $permissiontoread;
530 $delallowed = $permissiontoadd;
531 print $formfile->showdocuments(
'intracommreport:IntraCommReport',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
535 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'intracommreport'), 1);
536 $linktoelem = $tmparray[
'linktoelem'];
537 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
538 print $htmltoenteralink;
540 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
542 print
'</div><div class="fichehalfright">';
548 $includeeventlist = 0;
551 if ($includeeventlist) {
552 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
554 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
557 print
'</div></div>';
561 if (
GETPOST(
'modelselected')) {
566 $modelmail =
'intracommreport';
567 $defaulttopic =
'InformationMessage';
568 $diroutput =
$conf->intracommreport->dir_output;
569 $trackid =
'intracommreport'.$object->id;
571 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.
Class to manage intracomm report.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
intracommreportPrepareHead($object)
Prepare array of tabs for IntraCommReport.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.