-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddCustomerBackEnd.php
More file actions
73 lines (58 loc) · 2.31 KB
/
addCustomerBackEnd.php
File metadata and controls
73 lines (58 loc) · 2.31 KB
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
<?php
session_start();
if ($_POST) {
include_once 'config/database.php';
include_once 'object/Customer.php';
// Connect Databace
$database = new Database();
$db = $database->getConnection();
// Create customer
$user = new User();
$user->mobileNo = $_POST['mobileNumber'];
if ($user->mobileExists()) {
// alert code here
$_SESSION['userWithMobileAlreadyExists'] = "User with same mobile number already exists ";
} else {
$user->customerName = $_POST['customerName'];
$user->mobileNo = $_POST['mobileNumber'];
$user->mobileNO2 = $_POST['mobileNumber2'];
if ($_POST['area'] != "areaNotInTheList") {
$user->area = $_POST['area'];
} else {
$user->area = $_POST['notInTheList'];
// add area into area Table
$user->addArea($user->area);
}
$user->city = $_POST['city'];
$user->status = $_POST['status'];
$user->conn_date = $_POST['con_date'];
$user->paid_date = $_POST['con_date'];
if ($_POST['area'] == "areaNotInTheList" && empty($_POST['notInTheList'])) {
$_SESSION['AreaError'] = "Please Select Area";
} else {
if ($user->create()) {
$_SESSION['RecordCreated'] = "Success";
// INSERT Record into customer Detail Table
$customer_id = $user->getLastInsertedResult();
if (!empty($customer_id)) {
foreach ($customer_id as $ID) {
$cid = $ID['Customer_ID'];
}
}
$user->fee_paid = $_POST['recivedPayment'];
$user->totalFee = $_POST['totalPayment'];
if (empty($_POST['recivedPayment'])) {
$user->arrears = $user->totalFee - $user->fee_paid;
} else {
$user->arrears = $user->totalFee - $user->fee_paid;
}
$user->insertIntoCustomerDetails($cid);
} else {
$_SESSION['RecordFailed'] = "There is some error Please Check";
}
}
// End of outer if
}
}
header('location:addCustomersFront.php');
?>