-
Notifications
You must be signed in to change notification settings - Fork 0
/
productInServiceFunctions.php
87 lines (72 loc) · 3.34 KB
/
productInServiceFunctions.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
<?php
include 'productInService.php';
//include 'DatabaseConnection.php';
class productInServiceFunctions{
function insertProductInService(productInService $newProductInService){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$serialNo = $newProductInService->serialNo;
$modelCode = $newProductInService->modelCode;
$status = $newProductInService->status;
$ownerAddress = $newProductInService->ownerEmail;
$ownerEmail = $newProductInService->ownerEmail;
$ownerPhone = $newProductInService->ownerPhone;
$result = $conn->query("CALL `insertProductInService`('$serialNo', '$modelCode', '$status', '$ownerAddress', '$ownerEmail', '$ownerPhone');");
}
function updateProductInService(productInService $newProductInService){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$serialNo = $newProductInService->serialNo;
$status = $newProductInService->status;
$ownerAddress = $newProductInService->ownerAddress;
$ownerEmail = $newProductInService->ownerEmail;
$ownerPhone = $newProductInService->ownerPhone;
$dateOfReturn=$newProductInService->dateOfReturn;
$result = $conn->query("CALL `updateProductInService`('$serialNo', '$status', '$dateOfReturn', '$ownerAddress', '$ownerEmail', '$ownerPhone');");
}
function selectProductInService(){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$sql= $conn->query("CALL `selectProductInService`();");
while($rs = $sql->fetch_array(MYSQLI_ASSOC)) {
$newProductInService = new productInService();
$newProductInService->id=$rs['id'];
$newProductInService->serialNo=$rs['serial_no'];
$newProductInService->status=$rs['status'];
$newProductInService->modelCode=$rs['model_code'];
$newProductInService->dateOfArrival=$rs['date_of_arrival'];
$newProductInService->dateOfReturn=$rs['date_of_return'];
$newProductInService->ownerAddress=$rs['owner_address'];
$newProductInService->ownerEmail=$rs['owner_email'];
$newProductInService->ownerPhone=$rs['owner_phone'];
$productsInService[]=$newProductInService;
}
$conn->close();
return json_encode($productsInService,JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
}
function searchProductInService($serialNo){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$sql= $conn->query("CALL `searchProductInService`('$serialNo');");
while($rs = $sql->fetch_array(MYSQLI_ASSOC)) {
$newProductInService = new productInService();
$newProductInService->id=$rs['id'];
$newProductInService->serialNo=$rs['serial_no'];
$newProductInService->status=$rs['status'];
$newProductInService->modelCode=$rs['model_code'];
$newProductInService->dateOfArrival=$rs['date_of_arrival'];
$newProductInService->dateOfReturn=$rs['date_of_return'];
$newProductInService->ownerAddress=$rs['owner_address'];
$newProductInService->ownerEmail=$rs['owner_email'];
$newProductInService->ownerPhone=$rs['owner_phone'];
$productsInService[]=$newProductInService;
}
$conn->close();
echo json_encode($productsInService,JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
}
}
?>