-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
51 lines (50 loc) · 1.92 KB
/
api.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
<?php
require_once 'Controller/SaleController.php';
require_once 'Controller/ProductController.php';
require_once 'Controller/TypeProductController.php';
switch ($_REQUEST['endpoint']) {
case 'selectTypeProduct':
$return = TypeProductController::selectTypeProductAll();
echo json_encode($return);
break;
case 'insertTypeProduct':
$return = TypeProductController::insert($_REQUEST['nameType'], $_REQUEST['percent']);
echo json_encode($return);
break;
case 'delTypeProduct':
$return = TypeProductController::deleteTypeProduct($_REQUEST['idItem']);
echo json_encode($return);
break;
case 'listProducts':
$return = ProductController::selectProductAll();
echo json_encode($return);
break;
case 'addProduct':
$return = ProductController::insert($_REQUEST['nameProduct'], $_REQUEST['typeProduct'],$_REQUEST['price']);
echo json_encode($return);
break;
case 'getProductbyId':
$return = ProductController::getProductId($_REQUEST['cdProduct'], $_REQUEST['amountProduct']);
echo json_encode($return);
break;
case 'delProduct':
$return = ProductController::deleteProduct($_REQUEST['idItem']);
echo json_encode($return);
break;
case 'listProductSale':
$return = SaleController::getSaleProducts();
echo json_encode($return);
break;
case 'saveSale':
$return = SaleController::saveSale();
echo json_encode($return);
break;
case 'clearProductsSale':
$return = SaleController::clearProducts();
echo json_encode($return);
break;
default:
return json_encode(array('error' => 'Invalid action'));
break;
}
?>