-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_transferencia.php
78 lines (60 loc) · 2.27 KB
/
ajax_transferencia.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
<?php
require_once('includes/load.php');
// Check if user is logged in
if(!$session->isUserLoggedIn(true)) { redirect('dashboard.php', false);}
// Auto sugestão
$html = '';
if(isset($_POST['asset_tombo']) && strlen($_POST['asset_tombo']))
{
$assets = find_asset_by_tombo($_POST['asset_tombo']);
if($assets){
foreach ($assets as $asset):
$html .= "<li class=\"list-group-item\">";
$html .= $asset['tombo'];
$html .= "</li>";
endforeach;
} else {
$html .= '<li onClick=\"fill(\''.addslashes().'\')\" class=\"list-group-item\">';
$html .= 'Tombo não encontrado ou este bem já foi transferido.';
$html .= "</li>";
}
echo json_encode($html);
}
// Usuário responsável
$user = current_user();
// Encontrar todos os bens
if(isset($_POST['a_tombo']) && strlen($_POST['a_tombo']))
{
$asset_tombo = remove_junk($db->escape($_POST['a_tombo']));
if($results = find_all_asset_info_by_tombo($asset_tombo)){
$all_sector = find_all('sectors');
foreach ($results as $result) {
$html .= "<tr>";
$html .= "<input type=\"hidden\" name=\"a_id\" value=\"{$result['id']}\">";
$html .= "<td class=\"text-center\" id=\"a_tombo\">".$result['tombo']."</td>";
$html .= "<td>".$result['descrip_asset']."</td>";
$html .= "<td>";
$html .= "<input type=\"text\" class=\"form-control\" value=\"{$user['name']}\" name=\"responsible_user\" disabled>";
$html .= "</td>";
$html .= "<td>";
$html .= "<select class=\"form-control\" name=\"sector\" required>";
$html .= "<option selected value=\"\">Selecione</option>";
foreach ($all_sector as $sec):
$html .= "<option value=\"{$sec['id']}\">{$sec['name']}</option>";
endforeach;
$html .= "</select>";
$html .= "</td>";
$html .= "<td>";
$html .= "<input type=\"date\" class=\"form-control\" name=\"transfer_date\" required>";
$html .= "</td>";
$html .= "<td class=\"text-center\">";
$html .= "<button type=\"submit\" name=\"add_transfer\" class=\"btn btn-warning\">Registrar Transferência</button>";
$html .= "</td>";
$html .= "</tr>";
}
} else {
$html ='<tr><td>Tombo não encontrado ou o bem já foi transferido.</td></tr>';
}
echo json_encode($html);
}
?>