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';
192$form =
new Form($db);
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');
222if ($action ==
'create') {
223 if (empty($permissiontoadd)) {
229 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
230 print
'<input type="hidden" name="token" value="'.newToken().
'">';
231 print
'<input type="hidden" name="action" value="add">';
233 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
235 if ($backtopageforcancel) {
236 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
238 if ($dol_openinpopup) {
239 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
245 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
248 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
251 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
253 print
'</table>'.
"\n";
257 print $form->buttonsSaveCancel(
"Create");
265if (($id || $ref) && $action ==
'edit') {
266 print
load_fiche_titre($langs->trans(
"IntraCommReport"),
'',
'object_'.$object->picto);
268 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
269 print
'<input type="hidden" name="token" value="'.newToken().
'">';
270 print
'<input type="hidden" name="action" value="update">';
271 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
273 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
275 if ($backtopageforcancel) {
276 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
281 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
284 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
287 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
293 print $form->buttonsSaveCancel();
299if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
302 print
dol_get_fiche_head($head,
'card', $langs->trans(
"IntraCommReport"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
307 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
308 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteIntraCommReport'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
311 if ($action ==
'deleteline') {
312 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
316 if ($action ==
'clone') {
318 $formquestion = array();
319 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
323 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
324 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
325 if (empty($reshook)) {
326 $formconfirm .= $hookmanager->resPrint;
327 } elseif ($reshook > 0) {
328 $formconfirm = $hookmanager->resPrint;
337 $linkback =
'<a href="'.dol_buildpath(
'/intracommreport/list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
339 $morehtmlref =
'<div class="refidno">';
371 $morehtmlref .=
'</div>';
374 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
377 print
'<div class="fichecenter">';
378 print
'<div class="fichehalfleft">';
379 print
'<div class="underbanner clearboth"></div>';
380 print
'<table class="border centpercent tableforfield">'.
"\n";
386 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
389 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
395 print
'<div class="clearboth"></div>';
404 if (!empty(
$object->table_element_line)) {
406 $result =
$object->getLinesArray();
408 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
409 <input type="hidden" name="token" value="' .
newToken().
'">
410 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
411 <input type="hidden" name="mode" value="">
412 <input type="hidden" name="page_y" value="">
413 <input type="hidden" name="id" value="' .
$object->id.
'">
416 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
417 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
420 print
'<div class="div-table-responsive-no-min">';
421 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
422 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
432 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
433 if ($action !=
'editline') {
436 $parameters = array();
437 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
441 if (empty($reshook)) {
447 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
458 if ($action !=
'presend' && $action !=
'editline') {
459 print
'<div class="tabsAction">'.
"\n";
460 $parameters = array();
461 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
466 if (empty($reshook)) {
468 if (empty($user->socid)) {
469 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&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&token='.
newToken(),
'', $permissiontoadd);
478 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
481 if (
$object->status == $object::STATUS_DRAFT) {
483 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
485 $langs->load(
"errors");
486 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
491 if ($permissiontoadd) {
492 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
514 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
515 $buttonId =
'action-delete-no-ajax';
516 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
518 $buttonId =
'action-delete';
521 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
528 if (
GETPOST(
'modelselected')) {
532 if ($action !=
'presend') {
533 print
'<div class="fichecenter"><div class="fichehalfleft">';
534 print
'<a name="builddoc"></a>';
536 $includedocgeneration = 0;
539 if ($includedocgeneration) {
541 $relativepath = $objref.
'/'.$objref.
'.pdf';
542 $filedir = $conf->intracommreport->dir_output.
'/'.
$object->element.
'/'.$objref;
543 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
544 $genallowed = $permissiontoread;
545 $delallowed = $permissiontoadd;
546 print $formfile->showdocuments(
'intracommreport:IntraCommReport',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
550 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'intracommreport'), 1);
551 $linktoelem = $tmparray[
'linktoelem'];
552 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
553 print $htmltoenteralink;
555 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
557 print
'</div><div class="fichehalfright">';
563 $includeeventlist = 0;
566 if ($includeeventlist) {
567 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
569 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
572 print
'</div></div>';
576 if (
GETPOST(
'modelselected')) {
581 $modelmail =
'intracommreport';
582 $defaulttopic =
'InformationMessage';
583 $diroutput = $conf->intracommreport->dir_output;
584 $trackid =
'intracommreport'.$object->id;
586 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.
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'.
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.
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.