-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajax.php
72 lines (66 loc) · 2.43 KB
/
ajax.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
<?php
require_once('include/load.php');
if (!$session->isUserLoggedIn(true)) { redirect(SITE_URL.'index.php', false);}
//print_r( $_POST );
//exit( );
?>
<?php
// Auto suggestion
$html = '';
if(isset($_POST['product_name']) && strlen($_POST['product_name']))
{
//echo display_msg( array('info', "Buscando " . $_POST['product_name'] ) );
//echo display_msg( );
$products = find_product_by_title($_POST['product_name']);
if($products){
$i=0;
foreach ($products as $product):
$i++;
$html .= "<li id=\"product_list_item_${i}\" class=\"list-group-item\">";
$html .= $product['name'];
$html .= "</li>";
endforeach;
} else {
//$html .= '<li onClick=\"fill(\''.addslashes().'\')\" class=\"list-group-item\">';
$html .= '<li class=\"list-group-item\">';
$html .= 'No encontrado';
$html .= "</li>";
}
//echo json_encode($html);
echo $html;
}
?>
<?php
// find all product
if(isset($_POST['p_name']) && strlen($_POST['p_name']))
{
$product_title = remove_junk($db->escape($_POST['p_name']));
if($results = find_all_product_info_by_title($product_title)){
foreach ($results as $result) {
$html .= "<tr>";
$html .= "<td id=\"s_name\">".$result['name']."</td>";
$html .= "<input type=\"hidden\" name=\"s_id\" value=\"{$result['id']}\">";
$html .= "<td>";
$html .= "<input type=\"text\" class=\"form-control\" name=\"price\" value=\"{$result['sale_price']}\">";
$html .= "</td>";
$html .= "<td id=\"s_qty\">";
$html .= "<input type=\"text\" class=\"form-control\" name=\"quantity\" value=\"1\">";
$html .= "</td>";
$html .= "<td>";
$html .= "<input type=\"text\" class=\"form-control\" name=\"total\" value=\"{$result['sale_price']}\">";
$html .= "</td>";
$html .= "<td>";
$html .= "<input type=\"date\" class=\"form-control datePicker\" name=\"date\" data-date data-date-format=\"yyyy-mm-dd\">";
$html .= "</td>";
$html .= "<td>";
$html .= "<button type=\"submit\" name=\"add_sale\" class=\"btn btn-primary\">Agregar</button>";
$html .= "</td>";
$html .= "</tr>";
}
} else {
$html ='<tr><td>El producto no se encuentra registrado en la base de datos</td></tr>';
}
//echo json_encode($html);
echo $html;
}
?>