-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_totales.php
More file actions
66 lines (41 loc) · 1.54 KB
/
fetch_totales.php
File metadata and controls
66 lines (41 loc) · 1.54 KB
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
<?php
require_once("funciones.php");
if(!permiso($perfil,"totales_usuario")){
echo "Permisos insuficientes";
exit;
}
$data = Array();
if(isset($_REQUEST["id"]))
{
$id = validar($_REQUEST["id"]);
$sql = "select id,nombre from insumos";
$Result = mysqli_query($mysqli_link,$sql);
$data['entrada'] = "<div class='row'>";
$data['salida'] = "<div class='row'>";
while ($row = mysqli_fetch_row($Result)) {
// ENTRADA
$sql2 = "SELECT if(sum(cantidad) is NULL, 0, sum(cantidad)) from movimientos
where confirmado is not null AND
insumo_id = '".$row[0]."' AND
user_entrada = '$id'; ";
$Result2 = mysqli_query($mysqli_link,$sql2);
$row2 = mysqli_fetch_row($Result2);
if ($row2[0] != 0) {
$data['entrada'] .= "<div class='col-6'>".$row[1].":</div><div class='col-6'>".($row2[0] * 1)."</div>";
}
// SALIDA
$sql2 = "SELECT if(sum(cantidad) is NULL, 0, sum(cantidad)) from movimientos
where confirmado is not null AND
insumo_id = '".$row[0]."' AND
user_salida = '$id'; ";
$Result2 = mysqli_query($mysqli_link,$sql2);
$row2 = mysqli_fetch_row($Result2);
if ($row2[0] != 0) {
$data['salida'] .= "<div class='col-6'>".$row[1].":</div><div class='col-6'>".($row2[0] * 1)."</div>";
}
}
$data['entrada'] .= "</div>";
$data['salida'] .= "</div>";
echo json_encode($data);
}
?>