24 require
'../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
29 $langs->loadLangs(array(
"intracommreport"));
35 $label = (string)
GETPOST(
'label',
'alphanohtml');
36 $type_declaration = (string)
GETPOST(
'type_declaration',
'alphanohtml');
37 $backtopage =
GETPOST(
'backtopage',
'alpha');
39 "deb" => $langs->trans(
"DEB"),
40 "des" => $langs->trans(
"DES"),
42 $typeOfDeclaration = array(
43 "introduction" => $langs->trans(
"Introduction"),
44 "expedition" => $langs->trans(
"Expedition"),
50 $form =
new Form($db);
54 $hookmanager->initHooks(array(
'intracommcard',
'globalcard'));
59 $parameters = array(
'id' => $id);
61 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
66 if ($user->rights->intracommreport->delete && $action ==
'confirm_delete' && $confirm ==
'yes') {
67 $result = $object->delete($id, $user);
69 if (!empty($backtopage)) {
70 header(
"Location: ".$backtopage);
73 header(
"Location: list.php");
77 $errmesg = $object->error;
81 if ($action ==
'add' && $user->rights->intracommreport->write) {
82 $object->label = trim($label);
83 $object->type = trim($exporttype);
84 $object->type_declaration = $type_declaration;
85 $object->subscription = (int) $subscription;
93 if (empty($object->label)) {
95 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")), null,
'errors');
97 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"intracommreport WHERE ref='".$db->escape($object->label).
"'";
98 $result = $db->query($sql);
100 $num = $db->num_rows($result);
104 $langs->load(
"errors");
105 setEventMessages($langs->trans(
"ErrorLabelAlreadyExists", $login), null,
'errors');
110 $id = $object->create($user);
112 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?id='.$id);
128 if ($action ==
'create') {
129 $title = $langs->trans(
"IntracommReportTitle");
133 print '<form name="charge" method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
134 print '<input type="hidden" name="token" value="'.newToken().
'">';
135 print '<input type="hidden" name="action" value="add" />';
139 print '<table class="border" width="100%">';
142 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"Label").
'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
145 print '<tr><td class="fieldrequired">'.$langs->trans(
"Declaration").
"</td><td>\n";
146 print $form->selectarray(
"declaration", $declaration,
GETPOST(
'declaration',
'alpha') ?
GETPOST(
'declaration',
'alpha') : $object->declaration, 0);
151 print '<td class="titlefieldcreate fieldrequired">';
152 print $langs->trans(
"AnalysisPeriod");
155 print $formother->select_month($month ? date(
'M') : $month,
'month', 0, 1,
'widthauto valignmiddle ');
156 print $formother->select_year($year ? date(
'Y') : $year,
'year', 0, 3, 3);
161 print '<tr><td class="fieldrequired">'.$langs->trans(
"TypeOfDeclaration").
"</td><td>\n";
162 print $form->selectarray(
"type_declaration", $typeOfDeclaration,
GETPOST(
'type_declaration',
'alpha') ?
GETPOST(
'type_declaration',
'alpha') : $object->type_declaration, 0);
169 print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
170 print ' <input type="button" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" onClick="javascript:history.go(-1)">';
176 if ($id > 0 && $action !=
'edit') {
182 $res = $object->fetch($id);
196 if ($action ==
'delete') {
197 $formquestion = array();
199 $formquestion[] = array(
201 'name' =>
'backtopage',
202 'value' => ($backtopage !=
'1' ? $backtopage :
$_SERVER[
"HTTP_REFERER"])
205 print $form->formconfirm(
206 "card.php?rowid=".$id,
207 $langs->trans(
"DeleteReport"),
208 $langs->trans(
"ConfirmDeleteReport"),
216 $linkback =
'<a href="'.DOL_URL_ROOT.
'/intracommreport/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
220 print '<div class="fichecenter">';
221 print '<div class="fichehalfleft">';
223 print '<div class="underbanner clearboth"></div>';
224 print '<table class="border tableforfield centpercent">';
227 print '<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td class="valeur">'.$object->declaration.
"</td></tr>\n";
230 print '<tr><td>'.$langs->trans(
"AnalysisPeriod").
'</td><td class="valeur">'.$object->period.
'</td>';
234 print '<tr><td>'.$langs->trans(
"TypeOfDeclaration").
'</td><td class="valeur">'.$object->type_declaration.
'</td>';
239 print "</div></div></div>\n";
240 print '<div style="clear:both"></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage intracomm report.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
print $_SERVER["PHP_SELF"]
Edit parameters.
GETPOSTINT($paramname, $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.