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');
64$cancel =
GETPOST(
'cancel',
'aZ09');
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$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
69$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
71if (!empty($backtopagejsfields)) {
72 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
73 $dol_openinpopup = $tmpbacktopagejsfields[0];
79$diroutputmassaction =
$conf->intracommreport->dir_output.
'/temp/massgeneration/'.$user->id;
80$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
83$extrafields->fetch_name_optionals_label(
$object->table_element);
85$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
88$search_all = trim(
GETPOST(
"search_all",
'alpha'));
90foreach (
$object->fields as $key => $val) {
91 if (
GETPOST(
'search_'.$key,
'alpha')) {
92 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
96if (empty($action) && empty($id) && empty($ref)) {
101include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
105$enablepermissioncheck = 1;
106if ($enablepermissioncheck) {
107 $permissiontoread = $user->hasRight(
'intracommreport',
'read');
108 $permissiontoadd = $user->hasRight(
'intracommreport',
'write');
109 $permissiontodelete = $user->hasRight(
'intracommreport',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
110 $permissionnote = $user->hasRight(
'intracommreport',
'write');
111 $permissiondellink = $user->hasRight(
'intracommreport',
'write');
113 $permissiontoread = 1;
114 $permissiontoadd = 1;
115 $permissiontodelete = 1;
117 $permissiondellink = 1;
120$upload_dir =
$conf->intracommreport->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/intracommreport';
127if (!isModEnabled(
"intracommreport")) {
130if (!$permissiontoread) {
141$parameters = array();
142$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
147if (empty($reshook)) {
148 $backurlforlist =
dol_buildpath(
'/intracommreport/list.php', 1);
150 if (empty($backtopage) || ($cancel && empty($id))) {
151 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
152 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
153 $backtopage = $backurlforlist;
155 $backtopage =
dol_buildpath(
'/intracommreport/card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
160 $triggermodname =
'INTRACOMMREPORT_MODIFY';
163 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
166 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
169 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
175 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
177 if ($action ==
'set_thirdparty' && $permissiontoadd) {
178 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
180 if ($action ==
'classin' && $permissiontoadd) {
185 $triggersendname =
'INTRACOMMREPORT_SENTBYMAIL';
186 $autocopy =
'MAIN_MAIL_AUTOCOPY_INTRACOMMREPORT_TO';
187 $trackid =
'intracommreport'.$object->id;
188 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
198$form =
new Form($db);
202$title = $langs->trans(
"IntraCommReport").
" - ".$langs->trans(
'Card');
204if ($action ==
'create') {
205 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"IntraCommReport"));
209llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
228if ($action ==
'create') {
229 if (empty($permissiontoadd)) {
235 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
236 print
'<input type="hidden" name="token" value="'.newToken().
'">';
237 print
'<input type="hidden" name="action" value="add">';
239 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
241 if ($backtopageforcancel) {
242 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
244 if ($backtopagejsfields) {
245 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
247 if ($dol_openinpopup) {
248 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
254 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
257 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
260 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
262 print
'</table>'.
"\n";
266 print $form->buttonsSaveCancel(
"Create");
274if (($id || $ref) && $action ==
'edit') {
275 print
load_fiche_titre($langs->trans(
"IntraCommReport"),
'',
'object_'.$object->picto);
277 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
278 print
'<input type="hidden" name="token" value="'.newToken().
'">';
279 print
'<input type="hidden" name="action" value="update">';
280 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
282 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
284 if ($backtopageforcancel) {
285 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
290 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
293 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
296 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
302 print $form->buttonsSaveCancel();
308if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
311 print
dol_get_fiche_head($head,
'card', $langs->trans(
"IntraCommReport"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
316 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
317 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteIntraCommReport'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
320 if ($action ==
'deleteline') {
321 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
325 if ($action ==
'clone') {
327 $formquestion = array();
328 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
332 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
333 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
334 if (empty($reshook)) {
335 $formconfirm .= $hookmanager->resPrint;
336 } elseif ($reshook > 0) {
337 $formconfirm = $hookmanager->resPrint;
346 $linkback =
'<a href="'.dol_buildpath(
'/intracommreport/list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
348 $morehtmlref =
'<div class="refidno">';
380 $morehtmlref .=
'</div>';
383 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
386 print
'<div class="fichecenter">';
387 print
'<div class="fichehalfleft">';
388 print
'<div class="underbanner clearboth"></div>';
389 print
'<table class="border centpercent tableforfield">'.
"\n";
395 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
398 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
404 print
'<div class="clearboth"></div>';
413 if (!empty(
$object->table_element_line)) {
415 $result =
$object->getLinesArray();
417 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
418 <input type="hidden" name="token" value="' .
newToken().
'">
419 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
420 <input type="hidden" name="mode" value="">
421 <input type="hidden" name="page_y" value="">
422 <input type="hidden" name="id" value="' .
$object->id.
'">
425 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
426 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
429 print
'<div class="div-table-responsive-no-min">';
430 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
431 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
441 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
442 if ($action !=
'editline') {
445 $parameters = array();
446 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
450 if (empty($reshook)) {
451 $object->formAddObjectLine(1, $mysoc, $soc);
456 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
467 if ($action !=
'presend' && $action !=
'editline') {
468 print
'<div class="tabsAction">'.
"\n";
469 $parameters = array();
470 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
475 if (empty($reshook)) {
477 if (empty($user->socid)) {
478 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
482 if (
$object->status == $object::STATUS_VALIDATED) {
483 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
487 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
490 if (
$object->status == $object::STATUS_DRAFT) {
492 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
494 $langs->load(
"errors");
495 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
500 if ($permissiontoadd) {
501 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
523 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
524 $buttonId =
'action-delete-no-ajax';
525 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
527 $buttonId =
'action-delete';
530 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
537 if (
GETPOST(
'modelselected')) {
541 if ($action !=
'presend') {
542 print
'<div class="fichecenter"><div class="fichehalfleft">';
543 print
'<a name="builddoc"></a>';
545 $includedocgeneration = 0;
548 if ($includedocgeneration) {
550 $relativepath = $objref.
'/'.$objref.
'.pdf';
551 $filedir =
$conf->intracommreport->dir_output.
'/'.
$object->element.
'/'.$objref;
552 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
553 $genallowed = $permissiontoread;
554 $delallowed = $permissiontoadd;
555 print $formfile->showdocuments(
'intracommreport:IntraCommReport',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
559 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'intracommreport'), 1);
560 $linktoelem = $tmparray[
'linktoelem'];
561 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
562 print $htmltoenteralink;
564 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
566 print
'</div><div class="fichehalfright">';
572 $includeeventlist = 0;
575 if ($includeeventlist) {
576 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
578 $somethingshown = $formactions->showactions(
$object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
581 print
'</div></div>';
585 if (
GETPOST(
'modelselected')) {
590 $modelmail =
'intracommreport';
591 $defaulttopic =
'InformationMessage';
592 $diroutput =
$conf->intracommreport->dir_output;
593 $trackid =
'intracommreport'.$object->id;
595 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.
Class to manage intracomm report.
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.
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.
intracommreportPrepareHead($object)
Prepare array of tabs for IntraCommReport.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.