-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathreports.php
222 lines (194 loc) · 11.3 KB
/
reports.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
$title ="Reportes | ";
include "head.php";
include "sidebar.php";
$projects = mysqli_query($con, "select * from project");
$priorities = mysqli_query($con, "select * from priority");
$statuses = mysqli_query($con, "select * from status");
$kinds = mysqli_query($con, "select * from kind");
?>
<div class="right_col" role="main"><!-- page content -->
<div class="">
<div class="page-title">
<div class="clearfix"></div>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Reportes</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<!-- form search -->
<form class="form-horizontal" role="form">
<input type="hidden" name="view" value="reports">
<div class="form-group">
<div class="col-lg-3">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-male"></i></span>
<select name="project_id" class="form-control">
<option value="">PROJECTO</option>
<?php foreach($projects as $p):?>
<option value="<?php echo $p['id']; ?>" <?php if(isset($_GET["project_id"]) && $_GET["project_id"]==$p['id']){ echo "selected"; } ?>><?php echo $p['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-lg-3">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-support"></i></span>
<select name="priority_id" class="form-control">
<option value="">PRIORIDAD</option>
<?php foreach($priorities as $p):?>
<option value="<?php echo $p['id']; ?>" <?php if(isset($_GET["priority_id"]) && $_GET["priority_id"]==$p['id']){ echo "selected"; } ?>><?php echo $p['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-lg-3">
<div class="input-group">
<span class="input-group-addon">INICIO</span>
<input type="date" name="start_at" value="<?php if(isset($_GET["start_at"]) && $_GET["start_at"]!=""){ echo $_GET["start_at"]; } ?>" class="form-control" placeholder="Palabra clave">
</div>
</div>
<div class="col-lg-3">
<div class="input-group">
<span class="input-group-addon">FIN</span>
<input type="date" name="finish_at" value="<?php if(isset($_GET["finish_at"]) && $_GET["finish_at"]!=""){ echo $_GET["finish_at"]; } ?>" class="form-control" placeholder="Palabra clave">
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-3">
<div class="input-group">
<span class="input-group-addon">ESTADO</span>
<select name="status_id" class="form-control">
<?php foreach($statuses as $p):?>
<option value="<?php echo $p['id']; ?>" <?php if(isset($_GET["status_id"]) && $_GET["status_id"]==$p['id']){ echo "selected"; } ?>><?php echo $p['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-lg-3">
<div class="input-group">
<span class="input-group-addon">TIPO</span>
<select name="kind_id" class="form-control">
<?php foreach($kinds as $p):?>
<option value="<?php echo $p['id']; ?>" <?php if(isset($_GET["kind_id"]) && $_GET["kind_id"]==$p['id']){ echo "selected"; } ?>><?php echo $p['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-lg-6">
<button class="btn btn-primary btn-block">Procesar</button>
</div>
</div>
</form>
<!-- end form search -->
<?php
$users= array();
if((isset($_GET["status_id"]) && isset($_GET["kind_id"]) && isset($_GET["project_id"]) && isset($_GET["priority_id"]) && isset($_GET["start_at"]) && isset($_GET["finish_at"]) ) && ($_GET["status_id"]!="" ||$_GET["kind_id"]!="" || $_GET["project_id"]!="" || $_GET["priority_id"]!="" || ($_GET["start_at"]!="" && $_GET["finish_at"]!="") ) ) {
$sql = "select * from ticket where ";
if($_GET["status_id"]!=""){
$sql .= " status_id = ".$_GET["status_id"];
}
if($_GET["kind_id"]!=""){
if($_GET["status_id"]!=""){
$sql .= " and ";
}
$sql .= " kind_id = ".$_GET["kind_id"];
}
if($_GET["project_id"]!=""){
if($_GET["status_id"]!=""||$_GET["kind_id"]!=""){
$sql .= " and ";
}
$sql .= " project_id = ".$_GET["project_id"];
}
if($_GET["priority_id"]!=""){
if($_GET["status_id"]!=""||$_GET["project_id"]!=""||$_GET["kind_id"]!=""){
$sql .= " and ";
}
$sql .= " priority_id = ".$_GET["priority_id"];
}
if($_GET["start_at"]!="" && $_GET["finish_at"]){
if($_GET["status_id"]!=""||$_GET["project_id"]!="" ||$_GET["priority_id"]!="" ||$_GET["kind_id"]!="" ){
$sql .= " and ";
}
$sql .= " ( date_at >= \"".$_GET["start_at"]."\" and date_at <= \"".$_GET["finish_at"]."\" ) ";
}
$users = mysqli_query($con, $sql);
}else{
$users = mysqli_query($con, "select * from ticket order by created_at desc");
}
if(@mysqli_num_rows($users)>0){
// si hay reportes
$_SESSION["report_data"] = $users;
?>
<div class="x_content">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<th>Asunto</th>
<th>Proyecto</th>
<th>Tipo</th>
<th>Categoria</th>
<th>Prioridad</th>
<th>Estado</th>
<th>Fecha</th>
<th>Ultima Actualizacion</th>
</thead>
<?php
$total = 0;
foreach($users as $user){
$project_id=$user['project_id'];
$priority_id=$user['priority_id'];
$kind_id=$user['kind_id'];
$category_id=$user['category_id'];
$status_id=$user['status_id'];
$status=mysqli_query($con, "select * from status where id=$status_id");
$category=mysqli_query($con, "select * from category where id=$category_id");
$kinds = mysqli_query($con,"select * from kind where id=$kind_id");
$project = mysqli_query($con, "select * from project where id=$project_id");
$medic = mysqli_query($con,"select * from priority where id=$priority_id");
?>
<tr>
<td><?php echo $user['title'] ?></td>
<?php foreach($project as $pro){?>
<td><?php echo $pro['name'] ?></td>
<?php } ?>
<?php foreach($kinds as $kind){?>
<td><?php echo $kind['name'] ?></td>
<?php } ?>
<?php foreach($category as $cat){?>
<td><?php echo $cat['name']; ?></td>
<?php } ?>
<?php foreach($medic as $medics){?>
<td><?php echo $medics['name']; ?></td>
<?php } ?>
<?php foreach($status as $stat){?>
<td><?php echo $stat['name']; ?></td>
<?php } ?>
<td><?php echo $user['created_at']; ?></td>
<td><?php echo $user['updated_at']; ?></td>
</tr>
<?php
}
?>
<?php
}else{
echo "<p class='alert alert-danger'>No hay tickets</p>";
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- /page content -->
<?php include "footer.php" ?>