noalyss Version-9
report.inc.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18
19 */
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21/*! \file
22 * \brief handle your own report: create or view report
23 */
24if (!defined('ALLOWED'))
25 die('Appel direct ne sont pas permis');
26require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
27require_once NOALYSS_INCLUDE.'/lib/user_menu.php';
28
29global $http;
30
32$str_dossier=dossier::get();
33$http=new HttpInput();
34
35/* Admin. Dossier */
37
38
40
43if (isset($_POST["del_form"]))
44{
45 $rap=$rap=new Acc_Report($cn,$http->post("fr_id","number"));
46 $rap->delete();
47 $menu=1;
48}
49
50
51
52if (isset($_REQUEST["action"]) && $menu == 0)
53{
54
55 $action=$http->request("action");
56 $rap->id=$http->request('fr_id',"number",0);
57
58 if ($action=="add"&&!isset($_REQUEST['fr_id']))
59 {
60
61 echo '<DIV class="content">';
62 echo '<h1>'._('Définition').'</h1>';
63 echo '<form method="post" >';
64 echo dossier::hidden();
65 $form_definition=new Form_Definition_SQL($cn);
66 /* name cannot be empty */
67 $name=$http->post("fr_name");
68 $name=(trim($name==""))?"auto-".date('d.m.Y H:I'):$name;
69 $form_definition->setp("fr_label",$name);
70
71 $form_definition->save();
72 /** if there is file ($_FILES['report']) then import first */
73 $rap=new Acc_Report($cn);
74 $rap->set_form_definition($form_definition);
75 $rap->upload();
76
77 echo '<DIV class="content">';
78 $iName=$rap->input_name($name);
79 echo '<h3>';
80 echo $iName->input();
81 echo '</h3>';
82
83 $acc_report_mtable=Acc_Report_MTable::build(0, $form_definition->getp("fr_id"));
84 $acc_report_mtable->create_js_script();
85 echo $acc_report_mtable->display_table();
86
87
88 echo "</DIV>";
89 }
90 if ($action=="view" || $action == "record")
91 {
92 echo '<DIV class="content">';
93 $id=$http->request("fr_id","number");
94 $form_definition=new Form_Definition_SQL($cn,$id);
95 $name=$form_definition->getp("fr_label");
96 $rap=new Acc_Report($cn);
97 $rap->set_form_definition($form_definition);
98 $iName=$rap->input_name($name);
99 echo '<h3>';
100 echo $iName->input();
101 echo '</h3>';
102
103 $acc_report_mtable=Acc_Report_MTable::build(0, $id);
104 $acc_report_mtable->create_js_script();
105 echo $acc_report_mtable->display_table();
106
107 echo '<form method="get" action="export.php" style="display:inline" >';
108 echo dossier::hidden();
109 echo HtmlInput::hidden("act", "CSV:reportinit");
110 echo HtmlInput::hidden('f',$id);
111 echo HtmlInput::submit('bt_csv', "Export CSV");
112 echo HtmlInput::request_to_hidden(array('ac', 'action', 'p_action', 'fr_id'));
113 $href=http_build_query(array('ac'=>$http->request('ac'),'gDossier'=>$gDossier));
114
115 echo '</form>';
116 echo '<form style="display:inline" method="post" id="del_form_frm" onsubmit="return confirm_box(\'del_form_frm\',content[47])">';
117 echo HtmlInput::request_to_hidden(array('ac', 'fr_id'));
118 echo HtmlInput::hidden("del_form","1");
119 echo HtmlInput::submit(uniqid(), _('Efface'));
120 echo '</form>';
121 echo '<a style="display:inline" class="button" href="do.php?'.$href.'">'._('Retour').'</a>';
122 echo "</DIV>";
123 }
124}
125else
126{
127 $rap->create();
128 $lis=$rap->get_list();
129 $ac="&ac=".$http->request('ac');
130 $p_action='p_action=defreport';
131 echo '<div class="content">';
132 echo _('Cherche')." ".HtmlInput::filter_table("rapport_table_id", '0', 1);
133
134 echo '<TABLE id="rapport_table_id" class="vert_mtitle">';
135 echo '<TR><TD class="first">';
136 echo '<a href="#" onclick="document.getElementById(\'acc_report_create_div\').style.display=\'block\'">'
137 ._("Ajout")
138 .'</A></TD></TR>';
139
140 foreach ($lis as $row)
141 {
142 printf('<TR><TD><A HREF="?'.$p_action.$ac.'&action=view&fr_id=%s&%s">%s</A></TD></TR>', $row->id, $str_dossier, $row->name);
143 }
144 echo "</TABLE>";
145 echo '</div>';
146}
148?>
149
html_page_stop()
end tag
Definition: ac_common.php:468
$href
Definition: adm.inc.php:31
$action
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
static build($p_id, $p_form_def_id)
build an object Acc_Report_MTable
Class rapport Create, view, modify and parse report.
static connect()
ORM abstract of the table public.form_definition.
static request_to_hidden(array $array)
transform $_REQUEST data to hidden
static filter_table($p_table_id, $p_col, $start_row)
filter the rows in a table and keep the colored row in alternance
static hidden($p_name, $p_value, $p_id="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
$_POST['ac']
Definition: do.php:310
$gDossier
Definition: report.inc.php:31
$cn
Definition: report.inc.php:39
$menu
Definition: report.inc.php:42
$str_dossier
Definition: report.inc.php:32
global $http
Definition: report.inc.php:29
$ac
Definition: report.inc.php:129
$p_action
Definition: report.inc.php:130
$rap
Definition: report.inc.php:41
$lis
Definition: report.inc.php:128
$rep
Definition: report.inc.php:36