59require
"../main.inc.php";
60require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
63require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
64require_once DOL_DOCUMENT_ROOT.
'/intracommreport/lib/intracommreport.lib.php';
67$langs->loadLangs(array(
"intracommreport",
"other"));
74$action =
GETPOST(
'action',
'aZ09');
75$confirm =
GETPOST(
'confirm',
'alpha');
76$cancel =
GETPOST(
'cancel',
'aZ09');
77$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
78$backtopage =
GETPOST(
'backtopage',
'alpha');
79$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
80$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
81$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
83if (!empty($backtopagejsfields)) {
84 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
85 $dol_openinpopup = $tmpbacktopagejsfields[0];
91$diroutputmassaction = $conf->intracommreport->dir_output.
'/temp/massgeneration/'.$user->id;
92$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
95$extrafields->fetch_name_optionals_label(
$object->table_element);
97$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
100$search_all = trim(
GETPOST(
"search_all",
'alpha'));
102foreach (
$object->fields as $key => $val) {
103 if (
GETPOST(
'search_'.$key,
'alpha')) {
104 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
108if (empty($action) && empty($id) && empty($ref)) {
113include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
117$enablepermissioncheck = 1;
118if ($enablepermissioncheck) {
119 $permissiontoread = $user->hasRight(
'intracommreport',
'read');
120 $permissiontoadd = $user->hasRight(
'intracommreport',
'write');
121 $permissiontodelete = $user->hasRight(
'intracommreport',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
122 $permissionnote = $user->hasRight(
'intracommreport',
'write');
123 $permissiondellink = $user->hasRight(
'intracommreport',
'write');
125 $permissiontoread = 1;
126 $permissiontoadd = 1;
127 $permissiontodelete = 1;
129 $permissiondellink = 1;
132$upload_dir = $conf->intracommreport->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/intracommreport';
139if (!isModEnabled(
"intracommreport")) {
142if (!$permissiontoread) {
153$parameters = array();
154$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
159if (empty($reshook)) {
160 $backurlforlist =
dol_buildpath(
'/intracommreport/list.php', 1);
162 if (empty($backtopage) || ($cancel && empty($id))) {
163 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
164 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
165 $backtopage = $backurlforlist;
167 $backtopage =
dol_buildpath(
'/intracommreport/card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
172 $triggermodname =
'INTRACOMMREPORT_MODIFY';
175 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
178 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
181 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
187 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
189 if ($action ==
'set_thirdparty' && $permissiontoadd) {
190 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
192 if ($action ==
'classin' && $permissiontoadd) {
197 $triggersendname =
'INTRACOMMREPORT_SENTBYMAIL';
198 $autocopy =
'MAIN_MAIL_AUTOCOPY_INTRACOMMREPORT_TO';
199 $trackid =
'intracommreport'.$object->id;
200 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
210$form =
new Form($db);
214$title = $langs->trans(
"IntraCommReport").
" - ".$langs->trans(
'Card');
216if ($action ==
'create') {
217 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"IntraCommReport"));
221llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
240if ($action ==
'create') {
241 if (empty($permissiontoadd)) {
247 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
248 print
'<input type="hidden" name="token" value="'.newToken().
'">';
249 print
'<input type="hidden" name="action" value="add">';
251 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
253 if ($backtopageforcancel) {
254 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
256 if ($backtopagejsfields) {
257 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
259 if ($dol_openinpopup) {
260 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
266 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
269 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
272 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
274 print
'</table>'.
"\n";
278 print $form->buttonsSaveCancel(
"Create");
286if (($id || $ref) && $action ==
'edit') {
287 print
load_fiche_titre($langs->trans(
"IntraCommReport"),
'',
'object_'.$object->picto);
289 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="action" value="update">';
292 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
294 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
296 if ($backtopageforcancel) {
297 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
302 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
305 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
314 print $form->buttonsSaveCancel();
320if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
323 print
dol_get_fiche_head($head,
'card', $langs->trans(
"IntraCommReport"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
328 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
329 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteIntraCommReport'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
332 if ($action ==
'deleteline') {
333 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
337 if ($action ==
'clone') {
339 $formquestion = array();
340 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
344 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
345 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
346 if (empty($reshook)) {
347 $formconfirm .= $hookmanager->resPrint;
348 } elseif ($reshook > 0) {
349 $formconfirm = $hookmanager->resPrint;
358 $linkback =
'<a href="'.dol_buildpath(
'/intracommreport/list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
360 $morehtmlref =
'<div class="refidno">';
392 $morehtmlref .=
'</div>';
395 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
398 print
'<div class="fichecenter">';
399 print
'<div class="fichehalfleft">';
400 print
'<div class="underbanner clearboth"></div>';
401 print
'<table class="border centpercent tableforfield">'.
"\n";
407 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
410 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
416 print
'<div class="clearboth"></div>';
425 if (!empty(
$object->table_element_line)) {
427 $result =
$object->getLinesArray();
429 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
430 <input type="hidden" name="token" value="' .
newToken().
'">
431 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
432 <input type="hidden" name="mode" value="">
433 <input type="hidden" name="page_y" value="">
434 <input type="hidden" name="id" value="' .
$object->id.
'">
437 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
438 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
441 print
'<div class="div-table-responsive-no-min">';
442 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
443 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
453 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
454 if ($action !=
'editline') {
457 $parameters = array();
458 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
462 if (empty($reshook)) {
463 $object->formAddObjectLine(1, $mysoc, $soc);
468 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
479 if ($action !=
'presend' && $action !=
'editline') {
480 print
'<div class="tabsAction">'.
"\n";
481 $parameters = array();
482 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
487 if (empty($reshook)) {
489 if (empty($user->socid)) {
490 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
494 if (
$object->status == $object::STATUS_VALIDATED) {
495 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
499 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
502 if (
$object->status == $object::STATUS_DRAFT) {
504 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
506 $langs->load(
"errors");
507 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
512 if ($permissiontoadd) {
513 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
535 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
536 $buttonId =
'action-delete-no-ajax';
537 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
539 $buttonId =
'action-delete';
542 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
549 if (
GETPOST(
'modelselected')) {
553 if ($action !=
'presend') {
554 print
'<div class="fichecenter"><div class="fichehalfleft">';
555 print
'<a name="builddoc"></a>';
557 $includedocgeneration = 0;
560 if ($includedocgeneration) {
562 $relativepath = $objref.
'/'.$objref.
'.pdf';
563 $filedir = $conf->intracommreport->dir_output.
'/'.
$object->element.
'/'.$objref;
564 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
565 $genallowed = $permissiontoread;
566 $delallowed = $permissiontoadd;
567 print $formfile->showdocuments(
'intracommreport:IntraCommReport',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
571 $linktoelem = $form->showLinkToObjectBlock(
$object, array(), array(
'intracommreport'));
572 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
575 print
'</div><div class="fichehalfright">';
581 $includeeventlist = 0;
584 if ($includeeventlist) {
585 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
587 $somethingshown = $formactions->showactions(
$object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
590 print
'</div></div>';
594 if (
GETPOST(
'modelselected')) {
599 $modelmail =
'intracommreport';
600 $defaulttopic =
'InformationMessage';
601 $diroutput = $conf->intracommreport->dir_output;
602 $trackid =
'intracommreport'.$object->id;
604 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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.