-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
53 lines (47 loc) · 1.62 KB
/
index.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
<?php
require_once('config/db_config.php');
require_once('app/model/Buyer.php');
require_once('app/Validation.php');
$action = "";
if(! empty($_GET["action"])){
$action = $_GET["action"];
}
switch($action){
case "buyer-add":
if (isset($_POST['add'])) {
$validation = new Validation();
$validity = $validation->validator($_POST);
if($validity['resp_code'] == 1){
require_once('view/buyer/create.php');
}else{
$buyer = new Buyer();
if($_COOKIE['buyer_creation'] != 110105){
$buyerId = $buyer->create($_POST);
if($buyerId){
setcookie('buyer_creation', 110105, time() + 86400);
$result = $buyer->index();
require_once('view/buyer/index.php');
break;
}
}else{
$validity['resp_code'] = 1;
$validity['message'] = 'you can not create another one within 24 hours.';
require_once('view/buyer/create.php');
break;
}
}
}
require_once("view/buyer/create.php");
break;
default:
$buyer = new Buyer();
if(isset($_GET['search'])){
$validation = new Validation();
$validity = $validation->searchValidator($_GET);
$result = $buyer->search($_GET);
}else{
$result = $buyer->index();
}
require_once('view/buyer/index.php');
break;
}