38require
"../main.inc.php";
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/intracommreport/lib/intracommreport.lib.php';
55$langs->loadLangs(array(
"intracommreport",
"other"));
62$action =
GETPOST(
'action',
'aZ09');
63$confirm =
GETPOST(
'confirm',
'alpha');
65$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
66$backtopage =
GETPOST(
'backtopage',
'alpha');
67$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
68$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
73$diroutputmassaction =
$conf->intracommreport->dir_output.
'/temp/massgeneration/'.$user->id;
74$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
77$extrafields->fetch_name_optionals_label(
$object->table_element);
79$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
82$search_all = trim(
GETPOST(
"search_all",
'alpha'));
84foreach (
$object->fields as $key => $val) {
85 if (
GETPOST(
'search_'.$key,
'alpha')) {
86 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
90if (empty($action) && empty($id) && empty($ref)) {
95include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
99$enablepermissioncheck = 1;
100if ($enablepermissioncheck) {
101 $permissiontoread = $user->hasRight(
'intracommreport',
'read');
102 $permissiontoadd = $user->hasRight(
'intracommreport',
'write');
103 $permissiontodelete = $user->hasRight(
'intracommreport',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
104 $permissionnote = $user->hasRight(
'intracommreport',
'write');
105 $permissiondellink = $user->hasRight(
'intracommreport',
'write');
107 $permissiontoread = 1;
108 $permissiontoadd = 1;
109 $permissiontodelete = 1;
111 $permissiondellink = 1;
114$upload_dir =
$conf->intracommreport->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/intracommreport';
124if (!$permissiontoread) {
135$parameters = array();
136$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
141if (empty($reshook)) {
142 $backurlforlist =
dol_buildpath(
'/intracommreport/list.php', 1);
144 if (empty($backtopage) || ($cancel && empty($id))) {
145 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
146 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
147 $backtopage = $backurlforlist;
149 $backtopage =
dol_buildpath(
'/intracommreport/card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
154 $triggermodname =
'INTRACOMMREPORT_MODIFY';
157 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
160 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
163 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
169 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
171 if ($action ==
'set_thirdparty' && $permissiontoadd) {
172 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
174 if ($action ==
'classin' && $permissiontoadd) {
179 $triggersendname =
'INTRACOMMREPORT_SENTBYMAIL';
180 $autocopy =
'MAIN_MAIL_AUTOCOPY_INTRACOMMREPORT_TO';
181 $trackid =
'intracommreport'.$object->id;
182 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
196$title = $langs->trans(
"IntraCommReport").
" - ".$langs->trans(
'Card');
198if ($action ==
'create') {
199 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"IntraCommReport"));
203llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
206if ($action ==
'create') {
207 if (empty($permissiontoadd)) {
213 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
214 print
'<input type="hidden" name="token" value="'.newToken().
'">';
215 print
'<input type="hidden" name="action" value="add">';
217 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
219 if ($backtopageforcancel) {
220 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
222 if ($dol_openinpopup) {
223 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
229 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
232 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
235 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
237 print
'</table>'.
"\n";
241 print $form->buttonsSaveCancel(
"Create");
249if (($id || $ref) && $action ==
'edit') {
250 print
load_fiche_titre($langs->trans(
"IntraCommReport"),
'',
'object_'.$object->picto);
252 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
253 print
'<input type="hidden" name="token" value="'.newToken().
'">';
254 print
'<input type="hidden" name="action" value="update">';
255 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
257 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
259 if ($backtopageforcancel) {
260 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
265 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
268 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
271 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
277 print $form->buttonsSaveCancel();
283if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
286 print
dol_get_fiche_head($head,
'card', $langs->trans(
"IntraCommReport"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
291 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
292 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteIntraCommReport'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
295 if ($action ==
'deleteline') {
296 $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 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
308 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
309 if (empty($reshook)) {
310 $formconfirm .= $hookmanager->resPrint;
311 } elseif ($reshook > 0) {
312 $formconfirm = $hookmanager->resPrint;
321 $linkback =
'<a href="'.dol_buildpath(
'/intracommreport/list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
323 $morehtmlref =
'<div class="refidno">';
355 $morehtmlref .=
'</div>';
358 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
361 print
'<div class="fichecenter">';
362 print
'<div class="fichehalfleft">';
363 print
'<div class="underbanner clearboth"></div>';
364 print
'<table class="border centpercent tableforfield">'.
"\n";
370 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
373 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
379 print
'<div class="clearboth"></div>';
388 if (!empty(
$object->table_element_line)) {
390 $result =
$object->getLinesArray();
392 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
393 <input type="hidden" name="token" value="' . newToken().
'">
394 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
395 <input type="hidden" name="mode" value="">
396 <input type="hidden" name="page_y" value="">
397 <input type="hidden" name="id" value="' .
$object->id.
'">
400 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
401 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
404 print
'<div class="div-table-responsive-no-min">';
405 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
406 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
416 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
417 if ($action !=
'editline') {
420 $parameters = array();
421 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
425 if (empty($reshook)) {
431 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
442 if ($action !=
'presend' && $action !=
'editline') {
443 print
'<div class="tabsAction">'.
"\n";
444 $parameters = array();
445 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
450 if (empty($reshook)) {
452 if (empty($user->socid)) {
453 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle');
457 if (
$object->status == $object::STATUS_VALIDATED) {
458 print dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
462 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
465 if (
$object->status == $object::STATUS_DRAFT) {
467 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
469 $langs->load(
"errors");
470 print dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
475 if ($permissiontoadd) {
476 print dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.newToken(),
'', $permissiontoadd);
498 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.newToken();
499 $buttonId =
'action-delete-no-ajax';
500 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
502 $buttonId =
'action-delete';
505 print dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
512 if (
GETPOST(
'modelselected')) {
516 if ($action !=
'presend') {
517 print
'<div class="fichecenter"><div class="fichehalfleft">';
518 print
'<a name="builddoc"></a>';
520 $includedocgeneration = 0;
523 if ($includedocgeneration) {
525 $relativepath = $objref.
'/'.$objref.
'.pdf';
526 $filedir =
$conf->intracommreport->dir_output.
'/'.
$object->element.
'/'.$objref;
527 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
528 $genallowed = $permissiontoread;
529 $delallowed = $permissiontoadd;
530 print $formfile->showdocuments(
'intracommreport:IntraCommReport',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
534 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'intracommreport'), 1);
535 $linktoelem = $tmparray[
'linktoelem'];
536 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
537 print $htmltoenteralink;
539 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
541 print
'</div><div class="fichehalfright">';
545 $morehtmlcenter = dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/intracommreport/intracommreport_agenda.php', 1).
'?id='.
$object->id);
547 $includeeventlist = 0;
550 if ($includeeventlist) {
551 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
553 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
556 print
'</div></div>';
560 if (
GETPOST(
'modelselected')) {
565 $modelmail =
'intracommreport';
566 $defaulttopic =
'InformationMessage';
567 $diroutput =
$conf->intracommreport->dir_output;
568 $trackid =
'intracommreport'.$object->id;
570 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.
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, $morecssdiv='')
Show tabs of a record.
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.
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.
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.