diff --git a/.env b/.env index 1ca79b5..dcda61f 100644 --- a/.env +++ b/.env @@ -64,16 +64,16 @@ app.baseURL = 'http://localhost/donation/' # database.tests.DBDriver = MySQLi -database.default.hostname = localhost -database.default.database = donor_management -database.default.username = root -database.default.password = '' +database.default.hostname = 119.18.54.85 +database.default.database =venbaehn_donation +database.default.username = venbaehn_donor_be_usr1 +database.default.password = 'e0jZ1BaWZT2V' database.default.DBDriver = MySQLi -database.tests.hostname = localhost -database.tests.database = donor_management -database.tests.username = root -database.tests.password = '' +database.tests.hostname = l119.18.54.85 +database.tests.database = venbaehn_donation +database.tests.username = enbaehn_donor_be_usr1 +database.tests.password = 'e0jZ1BaWZT2V' database.tests.DBDriver = MySQLi #-------------------------------------------------------------------- diff --git a/app/Config/Database.php b/app/Config/Database.php index 2c09212..a0e72b6 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -50,10 +50,10 @@ class Database extends Config */ public array $tests = [ 'DSN' => '', - 'hostname' => '127.0.0.1', - 'username' => '', - 'password' => '', - 'database' => ':memory:', + 'hostname' => '119.18.54.85', + 'username' => 'venbaehn_donor_be_usr1', + 'password' => 'e0jZ1BaWZT2V', + 'database' => 'venbaehn_donation', 'DBDriver' => 'SQLite3', 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS 'pConnect' => false, diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2d546b1..1960d08 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -53,6 +53,8 @@ $routes->get("user_page/(:any)", "Users::user_page/$1"); $routes->post("insert_users", "Users::insert_users"); $routes->get("delete_user/(:any)", "Users::delete_user/$1"); $routes->get("activateUser/(:any)", "Users::activateUser/$1"); +$routes->get('users/get_branches/(:num)', 'Users::get_branches/$1'); + # Causes Routes $routes->get("causes_list/", "Books::index"); diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php index 9a437af..4287168 100644 --- a/app/Controllers/Business.php +++ b/app/Controllers/Business.php @@ -36,112 +36,145 @@ class Business extends BaseController { helper('session'); $session_role = get_user_role(); - + if ($id === '0') { - $data['page_name'] = 'Add Organization'; - $data['loged_user'] = $session_role; + $data['page_name'] = 'Add Organization'; + $data['loged_user'] = $session_role; $data['businesses'] = []; + $data['branches'] = []; } else if ($id !== '0') { - $data['page_name'] = 'Edit Organization'; - + $data['page_name'] = 'Edit Organization'; + $model = new BusinessModel(); $model->setTable('business'); + + // Fetch business details $edit_user_details = $model->where(['business_id ' => $id])->first(); - $data['businesses'] = $edit_user_details; + + // Fetch branch details + $branchData = $model->getBranchesByBusinessId($id); + $data['branches'] = $branchData; } - // echo '
';
- // print_r($data); die();
+
$this->render_page('business_form', $data);
}
+
## For inserting/updating details of business
- public function insert_org()
- {
- helper('session');
- $session_uid = get_logged_user_id();
- $session_role = get_user_role();
-
-
- $img = $this->request->getFile('bfile');
- $business_id = $this->request->getPost('business_id');
- $filePath = 'public/uploads/' . $this->request->getPost('bfile');
- $fileName = $img->getName();
+ public function insert_org()
+{
+ helper('session');
+ $session_uid = get_logged_user_id();
+ $session_role = get_user_role();
- if($fileName !== ""){
+ $img = $this->request->getFile('bfile');
+ $filePath = 'public/uploads/' . $this->request->getPost('bfile');
+ $fileName = $img->getName();
- if ($img->isValid() && !$img->hasMoved()) {
-
- $img->move(ROOTPATH . 'public/uploads', $fileName);
- }
-
+ if ($fileName !== "") {
+ if ($img->isValid() && !$img->hasMoved()) {
+ $img->move(ROOTPATH . 'public/uploads', $fileName);
}
-
- $sign = $this->request->getFile('signature');
- $business_id = $this->request->getPost('business_id');
- $filePath = 'public/uploads/' . $this->request->getPost('signature');
- $signFileName = $sign->getName();
-
- if($signFileName !== ""){
-
- if ($sign->isValid() && !$sign->hasMoved()) {
-
- $sign->move(ROOTPATH . 'public/uploads', $signFileName);
- }
-
- }
-
-
- $BusinessModel = new BusinessModel();
- $data = [
- 'title' => $this->request->getPost('bname'),
- 'email' => $this->request->getPost('bmail'),
- 'mobile_no' => $this->request->getPost('bmobile'),
- 'address' => $this->request->getPost('baddress'),
- 'city' => $this->request->getPost('bcity'),
- 'state' => $this->request->getPost('bstate'),
- 'postal_code' => $this->request->getPost('bzip'),
- 'pan_no'=>$this->request->getPost('pan_no'),
- 'org_reg_no'=>$this->request->getPost('org_reg_no'),
- 'terms'=>$this->request->getPost('bterms'),
- '80G'=>$this->request->getPost('80G'),
-
- ];
- if($fileName !== "")
- {
- $data['business_logo'] = $fileName;
- }
- if($signFileName !== "")
- {
- $data['signature'] = $signFileName;
- }
-
-
- $business_id = $this->request->getPost('business_id'); // Get the business ID for update
-
- if (empty($business_id)) {
- // It's an insert operation
- $data['isactive'] = 1;
- $data['created_by'] = $session_uid;
- $BusinessModel->insert($data);
- } else {
- // It's an update operation
- if($session_role === 'sadmin'){
- $isactive = $this->request->getPost('bcheckbox');
- $data['isactive'] = ($isactive == 'on') ? 1 : 0; }
- $data['updated_by'] = $session_uid;
- $BusinessModel->update($business_id, $data);
- }
-
- if ($session_role === 'sadmin') {
- return redirect()->route('org_list');
- }else{
- return redirect()->route('dashboard');
- }
-
}
- ## For delete the business details (Which means inactive the details)
+ $sign = $this->request->getFile('signature');
+ $signFileName = $sign->getName();
+
+ if ($signFileName !== "") {
+ if ($sign->isValid() && !$sign->hasMoved()) {
+ $sign->move(ROOTPATH . 'public/uploads', $signFileName);
+ }
+ }
+
+ $BusinessModel = new BusinessModel();
+ $data = [
+ 'title' => $this->request->getPost('bname'),
+ 'email' => $this->request->getPost('bmail'),
+ 'mobile_no' => $this->request->getPost('bmobile'),
+ 'address' => $this->request->getPost('baddress'),
+ 'city' => $this->request->getPost('bcity'),
+ 'state' => $this->request->getPost('bstate'),
+ 'postal_code' => $this->request->getPost('bzip'),
+ 'pan_no' => $this->request->getPost('pan_no'),
+ 'org_reg_no' => $this->request->getPost('org_reg_no'),
+ 'terms' => $this->request->getPost('bterms'),
+ '80G' => $this->request->getPost('80G'),
+ ];
+
+ if ($fileName !== "") {
+ $data['business_logo'] = $fileName;
+ }
+ if ($signFileName !== "") {
+ $data['signature'] = $signFileName;
+ }
+
+ $business_id = $this->request->getPost('business_id'); // Get the business ID for update
+
+ if (empty($business_id)) {
+ // It's an insert operation
+ $data['isactive'] = 1;
+ $data['created_by'] = $session_uid;
+ $businessId = $BusinessModel->insert($data);
+ // $this->insert_branch($businessId);
+ } else {
+ // It's an update operation
+ if ($session_role === 'sadmin') {
+ $isactive = $this->request->getPost('bcheckbox');
+ $data['isactive'] = ($isactive == 'on') ? 1 : 0;
+ }
+ $data['updated_by'] = $session_uid;
+ $BusinessModel->update($business_id, $data);
+ $businessId = $business_id;
+ }
+
+ // ... existing code ...
+
+ if (!empty($_POST['branchname'])) {
+ $branchNames = $_POST['branchname'];
+ $branchMobile = $_POST['mobile_no'];
+ $branchMail = $_POST['email'];
+ $branchAddress = $_POST['branchaddress'];
+ $branchIds = isset($_POST['id']) ? $_POST['id'] : [];
+
+ foreach ($branchNames as $key => $branchName) {
+ $branchId = isset($branchIds[$key]) ? $branchIds[$key] : null;
+
+ $branchData = [
+ 'business_id' => $businessId,
+ 'branch_name' => $branchName,
+ 'mobile_no' => $branchMobile[$key],
+ 'email' => $branchMail[$key],
+ 'address' => $branchAddress[$key],
+ ];
+
+ if (!empty($branchId)) {
+ // Update the existing branch
+ $db = \Config\Database::connect();
+ $db->table('business_branches')
+ ->where('id', $branchId)
+ ->update($branchData);
+ } else {
+ // Insert new branch
+ $db = \Config\Database::connect();
+ $db->table('business_branches')->insert($branchData);
+ }
+ }
+}
+
+
+// ... exis
+ // ... existing code ...
+
+ // Redirect based on user role
+ if ($session_role === 'sadmin') {
+ return redirect()->route('org_list');
+ } else {
+ return redirect()->route('dashboard');
+ }
+}
+
+ ## For delete the business details (Which means inactive the details)
public function delete_org($id)
{
helper('session');
diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php
index 35dff70..836ce5b 100644
--- a/app/Controllers/Customer.php
+++ b/app/Controllers/Customer.php
@@ -90,8 +90,11 @@ class Customer extends BaseController
'email' => $this->request->getPost('cmail'),
'date_of_birth' => $dob,
'pan_no' => $this->request->getPost('pan_no'),
+ 'adhar_no' => $this->request->getPost('adhar_no'),
+
'donor_type' => $this->request->getPost('DonorType'),
'org_name' => $this->request->getPost('org_name') !== '' || $this->request->getPost('org_name') !== null ? $this->request->getPost('org_name') : NULL,
+ 'org_reg_details'=> $this->request->getPost('org_reg_Details'),
'address' => $this->request->getPost('address'),
'city' => $this->request->getPost('city'),
'state' => $this->request->getPost('state') ? $this->request->getPost('state') : $this->request->getPost('state_text'),
@@ -101,8 +104,8 @@ class Customer extends BaseController
];
- // print_r($data); die();
-
+ print_r($data);
+ // echo $this->db->getLastQuery();die();
$donor_id = $this->request->getPost('donor_id'); // Get the business ID for update
if (empty($donor_id)) {
diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php
index f1496c4..d5fdc53 100644
--- a/app/Controllers/Users.php
+++ b/app/Controllers/Users.php
@@ -48,64 +48,103 @@ class Users extends BaseController
$session_role = get_user_role();
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
+ $data['business_details'] = $this->business_details();
+
if ($id === '0') {
$this->logger->info("Users: In Add page");
- $data['page_name'] = 'Add User';
- $business_details = $this->business_details();
+ $data['page_name'] = 'Add User';
$render_page_name = 'user_form';
$data['details'] = [];
- } else if ($id !== '0') {
+ $data['branches'] = $this->getOrganizationBranches($session_bid);
+ // print_r($data);
+ } else {
$this->logger->info("Users: In Edit page");
$model = new UsersModel();
$model->setTable('users');
- if (!empty($session_role)){
+
+ if (!empty($session_role)) {
switch ($session_role) {
- case "sadmin":
+ case "sadmin":
$where = ['users.user_id' => $id, 'users.isactive !=' => NULL];
$edit_user_details = $model->where($where)->first();
- $business_details = $this->business_details();
$render_page_name = 'user_form';
- $data['page_name'] = 'Edit User';
+ $data['page_name'] = 'Edit User';
+ // Fetch organization branches for the selected organization
+ $data['branches'] = $this->getOrganizationBranches($edit_user_details['business_id']);
+ // print_r($data);die;
break;
- case "admin":
+
+ case "admin":
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
$edit_user_details = $model->where($where)->first();
- $business_details = [];
$render_page_name = 'user_form';
- $data['page_name'] = 'Edit User';
- break;
- case "manager":
+ $data['page_name'] = 'Edit User';
+ $data['branches'] = $this->getOrganizationBranches($edit_user_details['business_id']);
+ // print_r($branches);die;
+ break;
+
+ case "manager":
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
- $edit_user_details = $model->where($where)->first();
- $business_details = [];
- if($session_uid === $id && $session_role === "manager"){
- $data['page_name'] = 'Edit User';
+ $edit_user_details = $model->where($where)->first();
+ if ($session_uid === $id && $session_role === "manager") {
+ $data['page_name'] = 'Edit User';
+ $data['branches'] = $this->getOrganizationBranches($edit_user_details['business_id']);
+ print_r($branches);die;
$render_page_name = 'user_form';
- }else{
- $data['page_name'] = 'Page Not Found';
+
+ } else {
+ $data['page_name'] = 'Page Not Found';
$render_page_name = 'pages_404';
}
break;
+
default:
- $data['page_name'] = 'Page Not Found';
- $render_page_name = 'pages_404';
+ $data['page_name'] = 'Page Not Found';
+ $render_page_name = 'pages_404';
}
}
+
$data['details'] = $edit_user_details;
}
- $data['business_details'] = $business_details;
+
$data['session_bid'] = $session_bid;
$this->render_page($render_page_name, $data);
}
-
+
+ // Add the getOrganizationBranches method
+ public function getOrganizationBranches($businessId)
+ {
+ $db = db_connect();
+ $builder = $db->table('business_branches');
+
+ $branches = $builder->where('business_id', $businessId)->get()->getResultArray();
+
+ return $branches;
+ }
+
+
## For SuperAdmin Role business Dropdown displayed on Userpage.otherwise Hidden fields
public function business_details()
{
$model = new BusinessModel();
$model->setTable('business');
$business_details = $model->orderBy('business_id', 'DESC')->findAll();
+
+ // Fetch branches for all organizations
+ $branchModel = new BusinessModel();
+ $branchModel->setTable('business_branches');
+ $branches = $branchModel->findAll();
+
+ // Add branches to each business
+ foreach ($business_details as &$business) {
+ $business['branches'] = array_filter($branches, function ($branch) use ($business) {
+ return $branch['business_id'] == $business['business_id'];
+ });
+ }
+
return $business_details;
}
+
## For inserting/updating details of user
public function insert_users()
@@ -181,8 +220,11 @@ class Users extends BaseController
$final_img_name = $existing_img_name;
//throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice");
}
-
+ // $branch_id = $this->request->getPost('branch_id');
+ // $business_id = $this->request->getPost('business_id');
$data = [
+
+
'profile_picture' => $final_img_name,
'city' => $this->request->getPost('city'),
'state' => $this->request->getPost('state'),
@@ -196,8 +238,11 @@ class Users extends BaseController
'date_of_birth' => NULL,
'address' => $this->request->getPost('address'),
'gender' => $this->request->getPost('gender'),
- 'business_id' => $business_id
+ 'business_id' => $business_id,
+ 'branch_id' => $this->request->getPost('branch_id') ?? $this->request->getPost('branch'),
+
];
+ // print_r($data);die;
if (empty($user_id)) {
// It's an insert operation
@@ -318,5 +363,16 @@ class Users extends BaseController
return redirect()->route('user_list');
}
+ // Add a method to fetch organization branches based on the selected organization
+public function get_branches($business_id)
+{
+ $model = new BusinessModel();
+ $model->setTable('business_branches');
+
+ $branches = $model->where('business_id', $business_id)->findAll();
+
+ return json_encode($branches);
+}
+
}
diff --git a/app/Models/BusinessModel.php b/app/Models/BusinessModel.php
index b787e50..6efdaf6 100644
--- a/app/Models/BusinessModel.php
+++ b/app/Models/BusinessModel.php
@@ -15,5 +15,14 @@ class BusinessModel extends Model
{
return $this->insert($data);
}
+ public function getBranchesByBusinessId($businessId)
+{
+ return $this->db->table('business_branches')
+ ->where('business_id', $businessId)
+ ->get()
+ ->getResultArray();
+}
+
+
}
?>
\ No newline at end of file
diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php
index a7d7456..e361d5f 100644
--- a/app/Models/CustomerModel.php
+++ b/app/Models/CustomerModel.php
@@ -10,7 +10,7 @@ class CustomerModel extends Model
protected $table = 'donor';
protected $primaryKey = 'donor_id ';
// protected $allowedFields = ['donor_id ','first_name','city','last_name','email','mobile_no','country','state','postal_code' ,'address','profile_picture','date_of_birth','gender','mode','isactive','business_id'];
- protected $allowedFields = ['donor_id ','first_name','city','last_name','email','mobile_no','country','state','postal_code' ,'address','org_name','date_of_birth','pan_no','donor_type','isactive','business_id','created_by','updated_by'];
+ protected $allowedFields = ['donor_id ','first_name','city','last_name','email','mobile_no','country','state','postal_code' ,'address','org_name','date_of_birth','pan_no','adhar_no','org_reg_details','donor_type','isactive','business_id','created_by','updated_by'];
public function insertCustomer($data)
{
diff --git a/app/Models/UsersModel.php b/app/Models/UsersModel.php
index 6c46727..4430d6e 100644
--- a/app/Models/UsersModel.php
+++ b/app/Models/UsersModel.php
@@ -5,7 +5,7 @@ class UsersModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'user_id';
- protected $allowedFields = ['user_id','user_name','email','first_name','last_name','password','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','created_by','updated_by'];
+ protected $allowedFields = ['user_id','user_name','email','first_name','last_name','password','branch_id','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','created_by','updated_by'];
public function saveData($data, $id = null)
{
@@ -17,6 +17,15 @@ class UsersModel extends Model
return $this->update($id, $data);
}
}
-
-}
+ public function getOrganizationBranches($businessId)
+ {
+ // Assuming your branches table is named 'branches'
+ $db = db_connect();
+ $builder = $db->table('business_branches');
+ $branches = $builder->where('business_id', $businessId)->get()->getResultArray();
+
+ return $branches;
+ }
+
+}
\ No newline at end of file
diff --git a/app/Views/business_form.php b/app/Views/business_form.php
index 0db4b88..333fce6 100644
--- a/app/Views/business_form.php
+++ b/app/Views/business_form.php
@@ -1,3 +1,4 @@
+
@@ -96,6 +97,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Please provide.
+
+
+
+
+ Please provide.
+
+
+
+
+
+
+ Please provide.
+
+
+
+
+ Please provide.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Please provide.
+
+
+
+
+ Please provide.
+
+
+
+
+
+ />
+ Please provide.
+
+
+
+
+ Please provide.
+
+
+
+
+
+
+
+
+
+ + Add More Branches
+ - Remove
+
+
+
+
+
+
+
+
+
@@ -134,6 +221,7 @@
+
" class="btn btn-secondary waves-effect">Cancel
@@ -186,4 +274,38 @@ function validateImage(input) {
img.src = URL.createObjectURL(image);
}
-
\ No newline at end of file
+
+
+
+
+
diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php
index 9836ed6..e745293 100644
--- a/app/Views/customer_form.php
+++ b/app/Views/customer_form.php
@@ -36,11 +36,17 @@
Please provide.
-
+
Please provide.
+
+
+
+ Please provide.
+
+
@@ -81,8 +87,13 @@
-
+
+
+
+
+
+
@@ -97,13 +108,13 @@
-
+
-
@@ -141,6 +152,7 @@
+
@@ -174,22 +186,23 @@
});
-
\ No newline at end of file
diff --git a/app/Views/donation.code-workspace b/app/Views/donation.code-workspace
new file mode 100644
index 0000000..112dd85
--- /dev/null
+++ b/app/Views/donation.code-workspace
@@ -0,0 +1,11 @@
+{
+ "folders": [
+ {
+ "path": "../.."
+ },
+ {
+ "path": "../../../vb_book"
+ }
+ ],
+ "settings": {}
+}
\ No newline at end of file
diff --git a/app/Views/setting_form.php b/app/Views/setting_form.php
index fcf4983..c083df5 100644
--- a/app/Views/setting_form.php
+++ b/app/Views/setting_form.php
@@ -126,7 +126,7 @@
@@ -139,7 +139,7 @@
@@ -273,4 +273,36 @@ document.getElementById('myForm').addEventListener('submit', function(event) {
$('#submitBtn').prop('disabled', true);
}
});
+
+
+
\ No newline at end of file
diff --git a/app/Views/user_form.php b/app/Views/user_form.php
index 137e7c2..dc53467 100644
--- a/app/Views/user_form.php
+++ b/app/Views/user_form.php
@@ -1,3 +1,11 @@
+
+
+
+
+
+
+
+
@@ -11,25 +19,44 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -100,6 +127,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -194,4 +243,136 @@
$('#submitBtn').prop('disabled', true);
}
});
-
\ No newline at end of file
+
+
+
+
+