User , buiness , Recepit Fixes : ps

This commit is contained in:
VE10-Sanjeev 2024-03-21 12:02:15 +05:30
parent 7cdda4a7ef
commit 5f6573b4d8
19 changed files with 1341 additions and 1617 deletions

View File

@ -49,7 +49,7 @@ $routes->get('dashboard/', 'Home::index');
# Users Routes # Users Routes
$routes->get("user_list/", "Users::index"); $routes->get("user_list/", "Users::index");
$routes->get("user_page/(:any)", "Users::user_page/$1"); $routes->get("user_page/(:any)/(:any)", "Users::user_page/$1/$2");
$routes->post("insert_users", "Users::insert_users"); $routes->post("insert_users", "Users::insert_users");
$routes->get("delete_user/(:any)", "Users::delete_user/$1"); $routes->get("delete_user/(:any)", "Users::delete_user/$1");
$routes->get("activateUser/(:any)", "Users::activateUser/$1"); $routes->get("activateUser/(:any)", "Users::activateUser/$1");
@ -70,7 +70,7 @@ $routes->get("delete_sitesetting/(:any)", "Books::delete_sitesetting/$1");
# App Site-Setting Routes(SuperAdmin) # App Site-Setting Routes(SuperAdmin)
// $routes->get("appsetting/", "AppSettings::index"); // $routes->get("appsetting/", "AppSettings::index");
$routes->get("appsetting_page/(:any)", "AppSettings::appsetting_page/$1"); $routes->get("appsetting_page", "AppSettings::appsetting_page");
$routes->post("appsetting_synchronization", "AppSettings::appsetting_synchronization"); $routes->post("appsetting_synchronization", "AppSettings::appsetting_synchronization");
// $routes->get("delete_sitesetting/(:any)", "Books::delete_sitesetting/$1"); // $routes->get("delete_sitesetting/(:any)", "Books::delete_sitesetting/$1");
@ -88,14 +88,15 @@ $routes->get('Customer/getReceiptDetails/(:num)', 'Customer::getReceiptDetails/$
$routes->post("insert_donor", "Customer::insert_donor"); $routes->post("insert_donor", "Customer::insert_donor");
$routes->post("insert_ajaxdonor", "Customer::insert_ajaxdonor");
$routes->get("delete_donor/(:any)", "Customer::delete_donor/$1"); $routes->get("delete_donor/(:any)", "Customer::delete_donor/$1");
#Routes for donor group #Routes for donor group (renamed as contributor group : 20/03/2024)
$routes->get('donor_group/', 'Customer::donor_group'); $routes->get('contributor_group/', 'Customer::donor_group');
$routes->get('view_donor_group/(:any)', 'Customer::view_donor_group/$1'); $routes->get('view_contributor_group/(:any)', 'Customer::view_donor_group/$1');
$routes->get('preview_donor_group/(:any)', 'Customer::preview_donor_group/$1'); $routes->get('preview_contributor_group/(:any)', 'Customer::preview_donor_group/$1');
$routes->get('delete_donor_group/(:any)', 'Customer::delete_donor_group/$1'); $routes->get('delete_contributor_group/(:any)', 'Customer::delete_donor_group/$1');
$routes->post("insert_donor_group", "Customer::insert_donor_group"); $routes->post("insert_contributor_group", "Customer::insert_donor_group");
@ -124,10 +125,8 @@ $routes->get('generate-pdf/(:num)', 'Invoice::generatePdf/$1');
$routes->get('Invoice/showInvoiceModal', 'Invoice::showInvoiceModal'); $routes->get('Invoice/showInvoiceModal', 'Invoice::showInvoiceModal');
$routes->post("load_details1/", "Invoice::load_details1/"); $routes->post("get_donor_details", "Invoice::get_donor_details");
$routes->post("load_details2/", "Invoice::load_details2/");
$routes->post("save_invoice/", "Invoice::save_invoice/"); $routes->post("save_invoice/", "Invoice::save_invoice/");
$routes->get("delete_invoice/(:any)", "Invoice::delete_invoice/$1");
$routes->add('approve_invoice/(:num)', 'Invoice::approve_invoice/$1'); $routes->add('approve_invoice/(:num)', 'Invoice::approve_invoice/$1');
$routes->get('generate_invoice_pdf/(:num)', 'Invoice::generate_invoice_pdf/$1'); $routes->get('generate_invoice_pdf/(:num)', 'Invoice::generate_invoice_pdf/$1');
$routes->get('print_address/(:num)', 'Invoice::print_address/$1'); $routes->get('print_address/(:num)', 'Invoice::print_address/$1');

View File

@ -3,7 +3,6 @@
namespace App\Controllers; namespace App\Controllers;
use App\Models\BusinessModel; use App\Models\BusinessModel;
use App\Models\SettingsModel;
class Business extends BaseController class Business extends BaseController
{ {
@ -32,7 +31,7 @@ class Business extends BaseController
} }
} }
## To Load Business Form (Add/Update) ## For Organization Form (Add/Update)
public function new_org($id) public function new_org($id)
{ {
helper('session'); helper('session');
@ -46,44 +45,29 @@ class Business extends BaseController
$data['businesses'] = []; $data['businesses'] = [];
$data['branches'] = []; $data['branches'] = [];
$data['donation']=[]; $data['donation']=[];
// -----------
$data['details'] = [];
} else if ($id !== '0') { } else if ($id !== '0') {
$data['page_name'] = 'Edit Organization'; $data['page_name'] = 'Edit Organization';
$data['loged_user'] = $session_role; $data['loged_user'] = $session_role;
$model = new BusinessModel(); $model = new BusinessModel();
$model->setTable('business'); $model->setTable('business');
// Fetch business details ## Fetch business details (particular business)
$edit_user_details = $model->where(['business_id ' => $id])->first(); $edit_business_details = $model->where(['business_id ' => $id , 'isactive' => 1])->first();
$data['businesses'] = $edit_user_details; $data['businesses'] = $edit_business_details;
## Fetch branch details
$branch_details = $model->getBranchesByBusinessId($id);
$data['branches'] = $branch_details;
## Fetch donation details
if ($session_role !== 'sadmin') { if ($session_role !== 'sadmin') {
$donation_accepted=$model->getDonationBusinessData($id);
$donationaccepted=$model->getDonationBusinessData($id); $data['donation']=$donation_accepted;
$data['donation']=$donationaccepted;
// dd($data['donation']);die;
} }
// Fetch branch details
$branchData = $model->getBranchesByBusinessId($id);
$data['branches'] = $branchData;
// ============================
$smodel = new SettingsModel();
$smodel->setTable('settings');
if($session_role === 'sadmin'){
$details = $smodel->where(['setting_id' => $id, 'isactive' => 1])->first();
}
else{
$details = $smodel->where(['business_id' => $session_bid, 'isactive' => 1])->first();
// print_r($session_bid);die;
}
// echo json_decode($details);die;
$data['details'] = $details;
// echo json_encode($data);die;
} }
$data['business_details']=$this->business_details();
$data['master_business_details']=$this->business_details();
$data['session_bid']=$session_bid; $data['session_bid']=$session_bid;
$this->render_page('business_form', $data); $this->render_page('business_form', $data);
} }
@ -110,30 +94,40 @@ class Business extends BaseController
## For inserting/updating details of business ## For inserting/updating details of business
public function insert_org() public function insert_org()
{ {
helper('session'); helper('session');
$session_uid = get_logged_user_id(); $session_uid = get_logged_user_id();
$session_role = get_user_role(); $session_role = get_user_role();
$img = $this->request->getFile('slogo'); ## logo
$filePath = 'public/uploads/' . $this->request->getPost('slogo'); $img = $this->request->getFile('business_logo');
$filePath = 'public/uploads/' . $this->request->getPost('business_logo');
$fileName = $img->getName(); $fileName = $img->getName();
if ($fileName !== "") { if ($fileName !== "") {
if ($img->isValid() && !$img->hasMoved()) { if ($img->isValid() && !$img->hasMoved()) {
$img->move(ROOTPATH . 'public/uploads', $fileName); $img->move(ROOTPATH . 'public/uploads', $fileName);
} }
} }
## favicon
$favicon = $this->request->getFile('favicon');
$faviconFileName = $favicon->getName();
if ($faviconFileName !== "") {
if ($favicon->isValid() && !$favicon->hasMoved()) {
$favicon->move(ROOTPATH . 'public/uploads', $faviconFileName);
}
}
## signature
$sign = $this->request->getFile('signature'); $sign = $this->request->getFile('signature');
$signFileName = $sign->getName(); $signFileName = $sign->getName();
if ($signFileName !== "") { if ($signFileName !== "") {
if ($sign->isValid() && !$sign->hasMoved()) { if ($sign->isValid() && !$sign->hasMoved()) {
$sign->move(ROOTPATH . 'public/uploads', $signFileName); $sign->move(ROOTPATH . 'public/uploads', $signFileName);
} }
} }
## Business Data
$BusinessModel = new BusinessModel(); $BusinessModel = new BusinessModel();
$data = [ $data = [
'title' => $this->request->getPost('bname'), 'title' => $this->request->getPost('bname'),
@ -147,11 +141,24 @@ class Business extends BaseController
'org_reg_no' => $this->request->getPost('org_reg_no'), 'org_reg_no' => $this->request->getPost('org_reg_no'),
'terms' => $this->request->getPost('bterms'), 'terms' => $this->request->getPost('bterms'),
'80G' => $this->request->getPost('80G'), '80G' => $this->request->getPost('80G'),
'site_name' => $this->request->getPost('site_name'),
'site_title' => $this->request->getPost('site_title'),
'admin_email' => $this->request->getPost('admin_email'),
'site_mobile'=> $this->request->getPost('site_mobile'),
'copyright'=> $this->request->getPost('copyright'),
'currency'=> $this->request->getPost('currency'),
'country'=> $this->request->getPost('country'),
'start_no'=> $this->request->getPost('start_no'),
'left_pad'=> $this->request->getPost('left_pad'),
'prefix_format'=> $this->request->getPost('prefix_format'),
]; ];
if ($fileName !== "") { if ($fileName !== "") {
$data['business_logo'] = $fileName; $data['business_logo'] = $fileName;
} }
if ($faviconFileName !== "") {
$data['favicon'] = $faviconFileName;
}
if ($signFileName !== "") { if ($signFileName !== "") {
$data['signature'] = $signFileName; $data['signature'] = $signFileName;
} }
@ -160,180 +167,106 @@ class Business extends BaseController
if (empty($business_id)) { if (empty($business_id)) {
// It's an insert operation // It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid; $data['created_by'] = $session_uid;
$businessId = $BusinessModel->insert($data); $businessId = $BusinessModel->insert($data);
$BusinessModel->insertDonationBusiness($businessId);
// $this->insert_branch($businessId);
} else { } else {
// It's an update operation // It's an update operation
if ($session_role === 'sadmin') { $businessId = $business_id;
$data['isactive'] = 1;
$data['updated_by'] = $session_uid; $data['updated_by'] = $session_uid;
$BusinessModel->update($business_id, $data); $BusinessModel->update($business_id, $data);
$businessId = $business_id; }
## Donation Business Data (Note: not a super-admin means)
if ($session_role !== 'sadmin') {
if (empty($business_id)) {
$BusinessModel->insertDonationBusiness($businessId);
}else{
$selectedDonations = $this->request->getPost('name'); $selectedDonations = $this->request->getPost('name');
$BusinessModel->updateDonationData($businessId, $selectedDonations); $BusinessModel->updateDonationData($businessId, $selectedDonations);
}
}
// ... 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);
} }
} }
}
//SITE SETTINGS ## Buiness Branch Data
helper('session'); if(!empty($_POST['branch_name'])){
$session_bid = get_business_id(); $requestData = $this->request->getPost();
$session_uid = get_logged_user_id(); $bb_result = $this->save_business_branch($requestData, $businessId);
$session_role = get_user_role(); $this->logger->info("business branch: final message = " .implode(" ",$bb_result));
$img = $this->request->getFile('slogo');
// print_r($img);
$business_id = $this->request->getPost('business_id');
$app_setting_id = $this->request->getPost('app_setting_id');
$filePath = 'public/uploads/' . $this->request->getPost('slogo');
$fileName = $img->getName();
// var_dump($fileName);
// echo $fileName;
// echo $fileName !== "" && $fileName !== null ? "Yes":"No";
// die();
if($fileName !== ""){
if ($img->isValid() && !$img->hasMoved()) {
$img->move(ROOTPATH . 'public/uploads', $fileName);
} }
} if ($session_role === 'sadmin') {
session()->setFlashdata('success', 'organization details has been updated successfully.');
$favicon = $this->request->getFile('favicon');
$faviconName = $favicon->getName();
if($faviconName !== ""){
if ($favicon->isValid() && !$favicon->hasMoved()) {
$favicon->move(ROOTPATH . 'public/uploads', $faviconName);
}
}
$SettingsModel = new SettingsModel();
$data = [
'site_name' => $this->request->getPost('site_name'),
'site_title' => $this->request->getPost('site_title'),
'terms_service' => $this->request->getPost('terms_service'),
'footer_about' => $this->request->getPost('footer_about'),
'admin_email' => $this->request->getPost('admin_email'),
'mobile'=> $this->request->getPost('mobile'),
'copyright'=> $this->request->getPost('copyright'),
'pagination_limit'=> $this->request->getPost('pagination_limit'),
'site_info'=> $this->request->getPost('site_info'),
'about_info'=> $this->request->getPost('about_info'),
'mail_protocol'=> $this->request->getPost('mail_protocol'),
'mail_title'=> $this->request->getPost('mail_title'),
'mail_host'=> $this->request->getPost('mail_host'),
'mail_port'=> $this->request->getPost('mail_port'),
'mail_encryption'=> $this->request->getPost('mail_encryption'),
'mail_username'=> $this->request->getPost('mail_username'),
'mail_password'=> $this->request->getPost('mail_password'),
'currency'=> $this->request->getPost('currency'),
'country'=> $this->request->getPost('country'),
'business_id'=> $this->request->getPost('business_id'),
'start_no'=> $this->request->getPost('start_no'),
'left_pad'=> $this->request->getPost('left_pad'),
'prefix_format'=> $this->request->getPost('prefix_format'),
];
if($fileName !== "" && $fileName !== null)
{
$data['logo'] = $fileName;
}
if($faviconName !== "" && $faviconName !== null)
{
$data['favicon'] = $faviconName;
}
// echo '<pre>';
// print_r($data); die;
$setting_id = $this->request->getPost('setting_id'); // Get the business ID for update
if (empty($setting_id)) {
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$SettingsModel->insert($data);
// print_r($data);die;
} else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
$data['updated_by'] = $session_uid;
$SettingsModel->update($setting_id, $data);
}
// ... exis
// ... existing code ...
// Redirect based on user role
// ... existing code ...
// Redirect based on user role
if ($session_role === 'sadmin') {
return redirect()->route('org_list'); return redirect()->route('org_list');
}else{
session()->setFlashdata('success', 'organization details has been updated successfully.');
return redirect()->to(base_url("new_org/{$business_id}"));
}
}
public function save_business_branch($requestData, $bid)
{
try {
$getBuinessBranchdetails = $this->get_business_branch($bid);
$BBprimaryid = $requestData['id'] ; // Available Buiness Branch Primary IDS in Form Fields.
$model = new BusinessModel();
## IF Any Missing value Means that values are Inactive here....
if(!empty($BBprimaryid)){
$this->logger->info("BuinessBranch: Primary ID = ".implode(",",$BBprimaryid));
$filteringIds = [];
for ($y = 0; $y < count($getBuinessBranchdetails); $y++) {
$filteringIds[$y] = $getBuinessBranchdetails[$y]['id'];
} }
// Redirect based on user role if (!empty($filteringIds)) {
if ($session_role !== 'sadmin') { $A = $filteringIds;
$B = $BBprimaryid;
session()->setFlashdata('success', 'User has been updated successfully.'); $missingValues = array_diff($A, $B);
// Assuming 'index' is the route name for your index page if (!empty($missingValues)) {
return redirect()->to(base_url("new_org/{$business_id}")); $where = ['isactive' => 1, 'business_id'=>$bid];
$model->inactiveMissingBuinessBranchDetails($where, $missingValues);
echo
$this->logger->info("BuinessBranch: Inactived Missing Count = " . count($missingValues)." That Primary ID = ".implode(",",$BBprimaryid));
}
}
}
} $count = count($BBprimaryid);
} $branchData = [];
if ($count > 0) {
for ($x = 0; $x < $count; $x++) {
$branchData[$x]['id'] = $requestData['id'][$x];
$branchData[$x]['branch_name'] = $requestData['branch_name'][$x];
$branchData[$x]['business_id'] = $bid;
$branchData[$x]['email'] = $requestData['email'][$x];
$branchData[$x]['mobile_no'] = $requestData['mobile_no'][$x];
$branchData[$x]['address'] = $requestData['branchaddress'][$x];
}
$statement = !empty($branchData) ? $model->saveBuinessBranchDetails($branchData) : ["No data found For buisness branch"];
$this->logger->info("BuinessBranch: Final message = " . implode(",",$statement));
}
} catch (\Exception $e) {
$this->logger->error("BuinessBranch: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine());
$statement = ['Message: ' . $e->getMessage()];
}
return $statement;
}
public function get_business_branch($bid){
$model = new BusinessModel();
$model->setTable('business_branches');
$where = ['business_id'=> (int)$bid , 'isactive' => 1];
$details = $model->where($where)->findAll();
return $details;
}
## For delete the business details (Which means inactive the details) ## For delete the business details (Which means inactive the details)
public function delete_org($id) public function delete_org($id)
@ -357,7 +290,8 @@ if ($session_role !== 'sadmin') {
} }
public function insertDonationBusiness($businessId) public function insertDonationBusiness($businessId)
{ {
$donationData = $this->db->table('donation_accepted') $db = \Config\Database::connect();
$donationData = $db->table('donation_accepted')
->get() ->get()
->getResultArray(); ->getResultArray();
@ -368,7 +302,7 @@ if ($session_role !== 'sadmin') {
} }
// Insert data into donation_business table // Insert data into donation_business table
$this->db->table('donation_business')->insertBatch($donationData); $db->table('donation_business')->insertBatch($donationData);
} }
} }
} }

View File

@ -69,7 +69,40 @@ class Customer extends BaseController
} }
## For inserting/updating details of customer
public function insert_ajaxdonor(){
helper('session');
$model = new CustomerModel();
$session_uid = get_logged_user_id();
$session_bid = get_business_id();
$pan = ($this->request->getPost('pan_no') == '') ? $this->request->getPost('o_pan_no') : $this->request->getPost('pan_no');
$data = [
'first_name' => $this->request->getPost('cfname'),
'mobile_no' => $this->request->getPost('mobile'),
'email' => $this->request->getPost('cmail'),
'pan_no' => $pan,
'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'),
'business_id' => $session_bid,
'isactive' => 1,
'created_by' => $session_uid
];
if ($model->insert($data)) {
$results = ['status' => true, 'message' => 'added successfully','donor_id' => $model->insertID()];
}else {
$results = ['status' => false, 'message' => 'could not be added','donor_id' => ''];
}
$donor_where = ['business_id' => (int)get_business_id() , 'isactive' => 1, 'donor_type'=>$this->request->getPost('DonorType')];
$results['donor'] = $model->getData('donor', $donor_where);
return $this->response->setJSON(['data' => $results]);
}
public function insert_donor() public function insert_donor()
{ {
$requestData = $this->request->getPost(); $requestData = $this->request->getPost();

View File

@ -20,13 +20,15 @@ use Dompdf\Options;
class Invoice extends BaseController class Invoice extends BaseController
{ {
protected $AuditHistoryModel;
protected $UserModel;
protected $BusinessModel;
public function __construct() public function __construct()
{ {
$this->AuditHistoryModel = new AuditHistoryModel(); $this->AuditHistoryModel = new AuditHistoryModel();
$this->UserModel = new UsersModel(); $this->UserModel = new UsersModel();
$this->Business_Model = new BusinessModel(); $this->BusinessModel = new BusinessModel();
} }
## For Invoice Listing.. ## For Invoice Listing..
@ -48,11 +50,6 @@ class Invoice extends BaseController
$data['receipt'][$key]['created_name'] = $this->UserModel->where('user_id', $value['created_by'])->get()->getRow()->first_name; $data['receipt'][$key]['created_name'] = $this->UserModel->where('user_id', $value['created_by'])->get()->getRow()->first_name;
} }
// echo json_encode($data['receipt']);die;
// echo '<pre>';
// print_r($data); die;
$this->logger->info("Invoice: Listing Count ." . count($data['receipt'])); $this->logger->info("Invoice: Listing Count ." . count($data['receipt']));
$this->render_page('invoice_list', $data); $this->render_page('invoice_list', $data);
} else { } else {
@ -116,20 +113,19 @@ class Invoice extends BaseController
} }
} }
## To Load Invoice ADD/EDIT page... ## To Save/Update the Recepit Details
public function new_receipt($id = '0') public function new_receipt($id = '0')
{ {
helper('session'); helper('session');
$model = new InvoiceModel(); $model = new InvoiceModel();
$bmodel = new BooksModel(); $bmodel = new BooksModel();
$setting_model = new SettingsModel();
$where = ['business_id' => (int)get_business_id() ]; $where = ['business_id' => (int)get_business_id() ];
$cus_where = ['business_id' => (int)get_business_id() , 'isactive' => 1];
$rec_where = ['business_id' => (int)get_business_id(), 'YEAR(created_on)' => date('Y')]; $rec_where = ['business_id' => (int)get_business_id(), 'YEAR(created_on)' => date('Y')];
$receipt = $model->getData('receipt', $rec_where); $receipt = $model->getData('receipt', $rec_where);
// receipt number // receipt number
$settingData = $setting_model->select('*')->where($where)->findAll(); $settingData = $this->BusinessModel->select('*')->where($where)->findAll();
$count_receipt_no = (count($receipt) > 0) ? count($receipt) + $settingData[0]['start_no'] + 1 : $settingData[0]['start_no'] + 1; $count_receipt_no = (count($receipt) > 0) ? count($receipt) + $settingData[0]['start_no'] + 1 : $settingData[0]['start_no'] + 1;
// Calculate padding based on the count of digits in count_receipt_no // Calculate padding based on the count of digits in count_receipt_no
@ -139,12 +135,12 @@ class Invoice extends BaseController
$data['count_receipt_no'] = $settingData[0]['prefix_format'] . $padding . $count_receipt_no; $data['count_receipt_no'] = $settingData[0]['prefix_format'] . $padding . $count_receipt_no;
// Get customer names for the dropdown, events details, and books details // Get customer names for the dropdown, events details, and books details
$data['currency'] = $setting_model->select('currency')->where($where)->findAll(); $data['currency'] = $this->BusinessModel->select('currency')->where($where)->findAll();
$data['customers'] = $model->getData('donor', $cus_where);
$data['causes'] = $bmodel->select('*')->where('business_id', (int)get_business_id())->where('isactive',1)->get()->getResult(); $data['causes'] = $bmodel->select('*')->where('business_id', (int)get_business_id())->where('isactive',1)->get()->getResult();
$data['campaign'] = $model->getData('campaign', $where); $data['campaign'] = $model->getData('campaign', $where);
$data['invoice_number_formatting'] = $model->getData('settings', $where); $data['invoice_number_formatting'] = $model->getData('settings', $where);
$data['receipt_type'] = "option1";
if ($id === '0') { if ($id === '0') {
$this->logger->info("Receipt: In Add Details"); $this->logger->info("Receipt: In Add Details");
$data['page_name'] = 'Add Receipt Details'; $data['page_name'] = 'Add Receipt Details';
@ -160,7 +156,21 @@ class Invoice extends BaseController
{ {
$data['receipt_details'] = $model->where(['receipt_id' => $id, 'isactive' => 1])->first(); $data['receipt_details'] = $model->where(['receipt_id' => $id, 'isactive' => 1])->first();
} }
$get_receipt_type_where = [
'business_id' => (int)get_business_id(),
'isactive' => 1,
'donor_id' => $data['receipt_details']['donor_id']
];
$get_receipt_type = $model->getData('donor', $get_receipt_type_where);
if (!empty($get_receipt_type)) {
$firstItem = reset($get_receipt_type);
$data['receipt_type'] = $firstItem->donor_type;
} }
}
$cus_where = ['business_id' => (int)get_business_id() , 'isactive' => 1, 'donor_type'=>$data['receipt_type']];
$data['typebaseddonors'] = $model->getData('donor', $cus_where);
$data['alldonors'] = $model->getData('donor', ['business_id' => (int)get_business_id() , 'isactive' => 1]);
$this->render_page('invoice_form', $data); $this->render_page('invoice_form', $data);
} }
@ -234,50 +244,6 @@ class Invoice extends BaseController
return redirect()->route('receipt_list'); return redirect()->route('receipt_list');
} }
## For Ajax Call To Fetch/Retrive All Address Details Based On Customer...
public function load_details1()
{
$id = $this->request->getPost('selectedValue');
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$id];
$where['address_type'] = 1;
$data['customer_billing'] = $this->get_customer_address($where, []);
$select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"];
$where['address_type'] = 2;
$data['customer_shipping'] = $this->get_customer_address($where, $select);
$data['customer_membership'] = $this->get_customer_membership("membership",(int)$id);
return $this->response->setJSON(['data' => $data]);
}
## For Ajax Call To Fetch/Retrive Shipping Address Details Only Based On Customer...
public function load_details2()
{
$customer_id = $this->request->getPost('customerValue');
$address_id = $this->request->getPost('selectedValue');
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$customer_id, 'address_type' => 2, 'customer_address_id' => (int)$address_id];
$data['customer_shipping'] = $this->get_customer_address($where, []);
return $this->response->setJSON(['data' => $data]);
}
// public function generate_serial_no(){}
## For Gethering Address Details...
public function get_customer_address($where, $select)
{
$model = new CustomerModel();
$model->setTable('customer_addresses');
if (empty($select)) {
$select = ["customer_addresses.customer_id","customer_addresses.customer_address_id","customer_addresses.first_name","customer_addresses.last_name ","customer_addresses.company","customer_addresses.email","customer_addresses.mobile_no","customer_addresses.address_type","customer_addresses.address_1","customer_addresses.address_2","customer_addresses.city","customer_addresses.state","customer_addresses.postal_code","customer_addresses.country","states.state_name","countries.country_name"];
}
$address_details = $model->select($select)->join('states', 'states.state_short_name = customer_addresses.state AND customer_addresses.country = "IN"', 'left')->join('countries', 'countries.country_short_name = customer_addresses.country', 'left')->where($where)->findAll();
return $address_details;
}
public function get_customer_membership($category,$id){
$model = new InvoiceModel();
$result = $model->getMembershipListForCustomer($category,$id);
return $result;
}
## To insert or update the details of the invoice ## To insert or update the details of the invoice
public function save_invoice() public function save_invoice()
{ {
@ -290,11 +256,12 @@ class Invoice extends BaseController
$receipt_date = $this->request->getVar('receipt_date'); $receipt_date = $this->request->getVar('receipt_date');
$receipt_id = (!empty($this->request->getPost('receipt_id'))) ? $this->request->getPost('receipt_id') : ""; $receipt_id = (!empty($this->request->getPost('receipt_id'))) ? $this->request->getPost('receipt_id') : "";
$customer_id = (int)$this->request->getPost('donor_id'); $donor_id = (int)$this->request->getPost('donor_id');
$data = [ $data = [
'receipt_type' => $this->request->getPost('receipt_type'),
'receipt_number' => $this->request->getPost('receipt_number'), 'receipt_number' => $this->request->getPost('receipt_number'),
'donor_id' => $customer_id, 'donor_id' => $donor_id,
'campaign_id' => (int)$this->request->getPost('campaign_id'), 'campaign_id' => (int)$this->request->getPost('campaign_id'),
'notes'=>$this->request->getPost('notes'), 'notes'=>$this->request->getPost('notes'),
'receipt_date' => (!empty($receipt_date)) ? date("Y-m-d", strtotime($receipt_date)) : NULL, 'receipt_date' => (!empty($receipt_date)) ? date("Y-m-d", strtotime($receipt_date)) : NULL,
@ -395,8 +362,8 @@ class Invoice extends BaseController
$donormodel = new CustomerModel(); $donormodel = new CustomerModel();
$template_data = $notificationModel->select('*')->where('template_id',7)->findAll(); $template_data = $notificationModel->select('*')->where('template_id',7)->findAll();
$cause = $bmodel->select('name')->where('causes_id',(int)$this->request->getPost('causes_id'))->findAll(); $cause = $bmodel->select('name')->where('causes_id',(int)$this->request->getPost('causes_id'))->findAll();
$d_name = $donormodel->select('first_name')->where('donor_id',$customer_id)->findAll(); $d_name = $donormodel->select('first_name')->where('donor_id',$donor_id)->findAll();
$business = $this->Business_Model->select('*')->where('business_id',(int)get_business_id())->findAll(); $business = $this->BusinessModel->select('*')->where('business_id',(int)get_business_id())->findAll();
$donor_name = $d_name[0]['first_name']; $donor_name = $d_name[0]['first_name'];
$currency_amount = $this->request->getPost('amount'); $currency_amount = $this->request->getPost('amount');
@ -450,7 +417,6 @@ class Invoice extends BaseController
{ {
helper('session'); helper('session');
$model = new InvoiceModel(); $model = new InvoiceModel();
$usermodel = new UsersModel();
$where = ['business_id' => (int)get_business_id()]; $where = ['business_id' => (int)get_business_id()];
$data = $model->getData('audit_history', $where); $data = $model->getData('audit_history', $where);
// echo $data[0]->current_data;die; // echo $data[0]->current_data;die;
@ -466,7 +432,7 @@ class Invoice extends BaseController
foreach ($arr1[0] as $key => $value) { foreach ($arr1[0] as $key => $value) {
$con = $key != 'created_on' && $key != 'created_by' && $key != 'updated_on' && $key != 'updated_by'; $con = $key != 'created_on' && $key != 'created_by' && $key != 'updated_on' && $key != 'updated_by';
if ($audit_data->is_edit == 1 && $arr2[0][$key] !== $value) { if ($audit_data->is_edit == 1 && $arr2[0][$key] !== $value) {
$user = $usermodel->select('first_name,last_name')->where('user_id',$audit_data->updated_by)->findAll(); $user = $this->UserModel->select('first_name,last_name')->where('user_id',$audit_data->updated_by)->findAll();
if($con){ if($con){
$temp_diff[] = (object) [ $temp_diff[] = (object) [
'id' => $audit_data->id, 'id' => $audit_data->id,
@ -482,7 +448,7 @@ class Invoice extends BaseController
} }
else if($con && $audit_data->is_add == 1){ else if($con && $audit_data->is_add == 1){
// echo $key;die; // echo $key;die;
$user = $usermodel->select('first_name,last_name')->where('user_id',$audit_data->created_by)->findAll(); $user = $this->UserModel->select('first_name,last_name')->where('user_id',$audit_data->created_by)->findAll();
$temp_diff[] = (object) [ $temp_diff[] = (object) [
'id' => $audit_data->id, 'id' => $audit_data->id,
'key' => '-', 'key' => '-',
@ -497,7 +463,7 @@ class Invoice extends BaseController
} }
else if($con && $audit_data->is_delete == 1){ else if($con && $audit_data->is_delete == 1){
// echo $key;die; // echo $key;die;
$user = $usermodel->select('first_name,last_name')->where('user_id',$audit_data->updated_by)->findAll(); $user = $this->UserModel->select('first_name,last_name')->where('user_id',$audit_data->updated_by)->findAll();
$temp_diff[] = (object) [ $temp_diff[] = (object) [
'id' => $audit_data->id, 'id' => $audit_data->id,
'key' => '-', 'key' => '-',
@ -539,132 +505,21 @@ class Invoice extends BaseController
} }
} }
## To insert or update invoice item details based on invoice ID
public function save_invoice_item($id, $requestData)
{
## Get Invoice item details (to checking purpose exist or not based on invoice ID)
$getInvoiceItemDetails = $this->get_invoice_item($id);
## Declaration
$statement = "";
$model = new InvoiceModel();
$itemid = $requestData['invoice_child_id'];
## IF Any Missing value Means that values are Inactive here....
if (!empty($itemid)) {
$filteringInvoiceItemIds = [];
for ($y = 0; $y < count($getInvoiceItemDetails); $y++) {
$filteringInvoiceItemIds[$y] = $getInvoiceItemDetails[$y]['invoice_child_id'];
}
if (!empty($filteringInvoiceItemIds)) {
$A = $filteringInvoiceItemIds;
$B = $itemid;
$missingValues = array_diff($A, $B);
if (!empty($missingValues)) {
$where = ['isactive' => 1, 'receipt_id' => (int)$id];
$model->inactiveMissingInvoiceItemDetails($where, $missingValues);
}
}
}
// echo "<br/>....................";
$count = count($itemid);
$invoiceitem_arr = [];
if ($count > 0) {
for ($x = 0; $x < $count; $x++) {
if(!empty($requestData['item_details'][$x])){
$invoiceitem_arr[$x]['receipt_id'] = $id;
$invoiceitem_arr[$x]['product'] = (int)$requestData['item_details'][$x];
$invoiceitem_arr[$x]['quantity'] = (int)$requestData['quantity'][$x];
$invoiceitem_arr[$x]['tax'] = (int)$requestData['tax'][$x];
$invoiceitem_arr[$x]['unit_price'] = (int)$requestData['rate'][$x];
$invoiceitem_arr[$x]['subtotal'] = (int)$requestData['amount'][$x];
$invoiceitem_arr[$x]['discount_amount'] = (int)$requestData['discount_amount'][$x];
$invoiceitem_arr[$x]['discount_type'] =$requestData['discount_type'][$x];
if (!empty($requestData['from_subscription'])) {
$invoiceitem_arr[0]['from_subscription'] = $requestData['from_subscription'];
}
if (!empty($requestData['to_subscription'])) {
$invoiceitem_arr[0]['to_subscription'] = $requestData['to_subscription'];
}
$invoiceitem_arr[$x]['created_by'] = (int)get_logged_user_id();
$invoiceitem_arr[$x]['updated_by'] = (int)get_logged_user_id();
$invoiceitem_arr[$x]['isactive'] = 1;
$invoiceitem_arr[$x]['invoice_child_id'] = $itemid[$x];
}
}
$statement = $model->saveInvoiceItemDetails($invoiceitem_arr);
}
return $statement;
}
## To Retrive Invoice item details based on invoice ID
public function get_invoice_item($id)
{
$model = new InvoiceModel();
$model->setTable('invoiceitems');
$where = ['isactive' => 1, 'receipt_id' => (int)$id];
$details = $model->where($where)->findAll();
return $details;
}
## To Inactive Invoice details based on invoice ID Including Invoice Item Details also
public function delete_invoice($id)
{
helper('session');
$session_uid = get_logged_user_id();
try {
$model = new InvoiceModel();
$where = ['isactive' => 1, 'business_id' => (int)get_business_id(), 'receipt_id' => (int)$id];
$existed = $model->where($where)->findAll();
$this->logger->Info("Invoice : Going to Inactive ID = " . $id);
if ($existed) {
$data['isactive'] = 0;
$data['updated_by'] = get_logged_user_id();
if ($model->update($id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Invoice: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("Invoice: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
$getInvoiceItemDetails = $this->get_invoice_item($id);
if ($getInvoiceItemDetails) {
$update_where = ['receipt_id' => (int)$id];
$model->updateData('invoiceitems', $data, $update_where);
}
} else {
$this->logger->error("Invoice: Does Not Exist To Inactive, ID = " . $id);
throw new \Exception("Invoice Already Deleted");
}
} catch (\Exception $e) {
$this->logger->error("Invoice: Err Occur = " . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('receipt_list');
}
public function generate_invoice_pdf($id, $dest = null) public function generate_invoice_pdf($id, $dest = null)
{ {
try { try {
// Fetch the receipt data based on $receipt_id // Fetch the receipt data based on $receipt_id
$model = new InvoiceModel(); $model = new InvoiceModel();
$usermodel = new UsersModel();
$setting_model = new SettingsModel(); $setting_model = new SettingsModel();
$business_model = new BusinessModel();
$where = ['business_id' => (int)get_business_id()]; $where = ['business_id' => (int)get_business_id()];
$currency_data = $setting_model->select('currency')->where($where)->findAll(); $currency_data = $setting_model->select('currency')->where($where)->findAll();
$terms_data = $business_model->select('terms,signature')->where($where)->findAll(); $terms_data = $this->BusinessModel->select('terms,signature')->where($where)->findAll();
$data = $model->getInvoiceData($id); $data = $model->getInvoiceData($id);
// Check if data is empty // Check if data is empty
if (!$data || !$currency_data) { if (!$data || !$currency_data) {
throw new Exception('Data not found or empty'); throw new \Exception('Data not found or empty');
} }
$options = new Options(); $options = new Options();
@ -680,7 +535,7 @@ class Invoice extends BaseController
$dompdf = new Dompdf($options); $dompdf = new Dompdf($options);
define("DOMPDF_UNICODE_ENABLED", true); define("DOMPDF_UNICODE_ENABLED", true);
$user = $usermodel->select('first_name')->where('user_id',$data[0]->created_by)->findAll(); $user = $this->UserModel->select('first_name')->where('user_id',$data[0]->created_by)->findAll();
$logoPath = base_url()."public/uploads/".$data[0]->business_logo; $logoPath = base_url()."public/uploads/".$data[0]->business_logo;
if ($data[0]->business_logo && file_exists($logoPath)) { if ($data[0]->business_logo && file_exists($logoPath)) {
@ -689,11 +544,13 @@ class Invoice extends BaseController
// Logo does not exist, handle this case accordingly // Logo does not exist, handle this case accordingly
$baseurl = base_url()."public/uploads/default.png"; $baseurl = base_url()."public/uploads/default.png";
} }
$digits = strlen((string)$data[0]->amount);
$amount_in_words = $digits <= 9 ? $this->convertNumberToWords($data[0]->amount) : $data[0]->amount;
$html = view('invoice_pdf_template', [ $html = view('invoice_pdf_template', [
'data' => $data[0], 'data' => $data[0],
'currency' => $data[0]->currency, 'currency' => $data[0]->currency,
'currency_in_words' => $this->convertNumberToWords($data[0]->amount) , 'currency_in_words' => $amount_in_words ,
'baseurl' => $baseurl, 'baseurl' => $baseurl,
'signature' => $terms_data[0]['signature'], 'signature' => $terms_data[0]['signature'],
'staff_name' => $user[0]['first_name'], 'staff_name' => $user[0]['first_name'],
@ -720,7 +577,7 @@ class Invoice extends BaseController
return $html; return $html;
} }
$dompdf->stream('Receipt.pdf', ['Attachment' => 1]); $dompdf->stream('Receipt.pdf', ['Attachment' => 1]);
} catch (Exception $e) { } catch (\Exception $e) {
// Handle the exception // Handle the exception
// For example, log the error, display a user-friendly message, or return an error response // For example, log the error, display a user-friendly message, or return an error response
echo 'Error: ' . $e->getMessage(); echo 'Error: ' . $e->getMessage();
@ -767,10 +624,24 @@ class Invoice extends BaseController
$num = (int)$number; $num = (int)$number;
$result = ''; $result = '';
// Handle numbers greater than 1000 // Handle numbers greater than 10 million (crores)
if ($num >= 10000000) {
$crores = floor($num / 10000000);
$result .= $this->convertNumberToWords($crores) . ' Crore ';
$num %= 10000000;
}
// Handle numbers between 1 million and 9 million (lakhs)
if ($num >= 100000) {
$lakhs = floor($num / 100000);
$result .= $this->convertNumberToWords($lakhs) . ' Lakh ';
$num %= 100000;
}
// Handle numbers between 1000 and 99999
if ($num >= 1000) { if ($num >= 1000) {
$thousands = floor($num / 1000); $thousands = floor($num / 1000);
$result .= $words[$thousands] . ' Thousand '; $result .= $this->convertNumberToWords($thousands) . ' Thousand ';
$num %= 1000; $num %= 1000;
} }
@ -796,196 +667,18 @@ class Invoice extends BaseController
return $result; return $result;
} }
## For Ajax Call To Retrive Donor Details Based On Donor type...
public function get_donor_details()
{
helper('session');
$model = new InvoiceModel();
$value = $this->request->getPost('donor_type');
//For Donor Name And Donor Mobile Number Dropdown..
$where = ['business_id' => (int)get_business_id() , 'donor_type'=>$value, 'isactive' => 1];
$data['donor_details'] = $model->getData('donor', $where);
return $this->response->setJSON(['data' => $data]);
}
// public function approve_notifications($receipt_id)
// {
// $model = new InvoiceModel();
// $where = ['I.business_id' => (int)get_business_id(), 'I.receipt_id' => $receipt_id, 'I.isactive' => 1];
// $details = $model->getDetailForApproveNotifications($where);
// $records = [];
// $reference_number = "";
// $invoice_serial_number = "";
// $recipient_name = "";
// $approval_date = "";
// $approved_by = "";
// $recipient_email = "";
// $recipient_mobile = "";
// $subtotal = "";
// $tax = "";
// $total_amount = "";
// $payment_method = "";
// $business_name= "";
// $business_address= "";
// $business_city= "";
// $business_state= "";
// $business_postal_code= "";
// $business_email= "";
// $business_mobile_no= "";
// if (isset($details)) {
// $this->logger->info("Invoice: approve notification Request data type = ".gettype($details));
// }
// helper('notification');
// $notification = new NotificationHelper();
// foreach ($details['invoice'] as $rec) {
// $reference_number = $rec['order_number'];
// $invoice_serial_number = $rec['invoice_number'];
// $recipient_name = $rec['customer_name'];
// $approval_date = $rec['updated_on'];
// $approved_by = $rec['updated_by_name'];
// $recipient_email = $rec['customer_email'];
// $recipient_mobile = $rec['customer_mobile'];
// $subtotal = $rec['subtotal'];
// $tax = $rec['tax'];
// $total_amount = $rec['total_amount'];
// $payment_method = $rec['payment_method'];
// $business_name= $rec['business_name'];
// $business_address= $rec['business_address'];
// $business_city= $rec['business_city'];
// $business_state= $rec['business_state'];
// $business_postal_code= $rec['business_postal_code'];
// $business_email= $rec['business_email'];
// $business_mobile_no= $rec['business_mobile_no'];
// }
// $records['invoice_order_number'] = $reference_number;
// $records['invoice_serial_number'] = $invoice_serial_number;
// $records['recipient_name'] = $recipient_name;
// $records['recipient_email'] = $recipient_email ? $recipient_email : "sanjeev.p@venbainfotech.com";
// $records['subtotal'] = $subtotal;
// $records['tax'] = $tax;
// $records['total_amount'] = $total_amount;
// $records['payment_method'] = $payment_method;
// $records['favicon'] = base_url("public/uploads/default.ico");
// $records['browser_title'] = "bbb-bp | Approve Template";
// $records['page_name'] = 'Approve Template';
// // view('approve_template',$records);
// // $this->logger->info("Approve : Request data = ".json_encode($records));
// // view('approve_template',$records);
// $records['template_name'] = 'approve_template';
// $records['item'] = $details['item'];
// $records['subject'] = $invoice_serial_number . " - Approval Notification";
// $records['description'] = "<html><head><title>VBP Approve Information</title></head><body>
// <p>Dear $recipient_name,</p>
// <p> &ensp;&ensp; We are pleased to inform you that your Invoice has been approved.</p>
// <p><strong>Details:</strong></p>
// <ul><li>Approval Date:" . $approval_date . "</li>
// <li>Approved By:" . $approved_by . "</li>
// <li>Reference ID:" . $reference_number . "</li>
// </ul><br>
// <p>Best regards,</p>
// <ul style='list-style: none;'>
// <li>".$business_name.",</li>
// <li>".$business_address." ".$business_city." ".$business_state." - ".$business_postal_code."</li>
// <li>Call Us: +91 ".$business_mobile_no."</li>
// <li>Email Us: ".$business_email."</li></body></html>";
// $template = "Dear " . $recipient_name . ",\r\r\n\nYour Invoice has been approved.\n\nDetails:\r\n- Approval Date: " . $approval_date . "\r\n- Approved By: " . $approved_by . "\r\n- Reference ID: " . $reference_number . "\r\n\nBest regards,\n".$business_name.",\n".$business_address." ".$business_city." ".$business_state." - ".$business_postal_code.".\nCall Us: +91 ".$business_mobile_no."\nEmail Us:".$business_email;
// $params = (object) Null;
// $params->number = (int)'91' . $recipient_mobile;
// $params->type = "text";
// $params->message = $template;
// $params->instance_id = WAAI_INSTANCE;
// $params->access_token = WAAI_TOKEN;
// $this->logger->info("receipt: approve notification Email Request data = ".json_encode($records));
// $email_result = $notification->sendEmail($records);
// $this->logger->info("receipt: approve notification Email Response = " . json_encode($email_result));
// $this->logger->info("receipt: approve notification Whatsapp Request data = ".json_encode($params));
// $whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
// $this->logger->info("receipt: approve notification Whatsapp Response = " . json_encode($whatsapp_result));
// }
// public function general_inv_rp()
// {
// if($this->request->getmethod() == 'get')
// {
// $model = new InvoiceModel();
// $data['report_data'] = $model->get_general_invoice_data();
// $this->logger->info("Invoice Report ");
// $data['page_name'] = 'General Invoice Report';
// $this->render_page('report_general_invoice', $data);
// }
// else
// {
// $dateParts = explode(' - ', $this->request->getVar('date') );
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('m/d/Y', $fromDate);
// $dateTime1 = \DateTime::createFromFormat('m/d/Y', $toDate);
// $model = new InvoiceModel();
// $data['report_data'] = $model->get_general_invoice_data( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') );
// $this->logger->info("Invoice Report ");
// $data['page_name'] = 'General Invoice Report';
// $data['selected_data'] = $this->request->getVar('date');
// $this->render_page('report_general_invoice', $data);
// }
// }
// public function general_membership_inv_rp()
// {
// if($this->request->getmethod() == 'get')
// {
// $model = new InvoiceModel();
// $data['report_data'] = $model->get_mem_invoice_data();
// $this->logger->info("Membership Invoice Report ");
// $data['page_name'] = 'Membership Invoice Report';
// $this->render_page('report_mem_invoice', $data);
// }
// else
// {
// $dateParts = explode(' - ', $this->request->getVar('date') );
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('m/d/Y', $fromDate);
// $dateTime1 = \DateTime::createFromFormat('m/d/Y', $toDate);
// $model = new InvoiceModel();
// $data['report_data'] = $model->get_mem_invoice_data( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') );
// $this->logger->info("Membership Invoice Report ");
// $data['page_name'] = 'Membership Invoice Report';
// $data['selected_data'] = $this->request->getVar('date');
// $this->render_page('report_mem_invoice', $data);
// }
// }
// public function itemwise_report()
// {
// if($this->request->getmethod() == 'get')
// {
// $model = new InvoiceModel();
// $data['report_data'] = $model->itemwise_report_data();
// $this->logger->info("Itemwise Report ");
// $data['page_name'] = 'Itemwise Report';
// $this->render_page('report_itemwise', $data);
// }
// else
// {
// $dateParts = explode(' - ', $this->request->getVar('date') );
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('m/d/Y', $fromDate);
// $dateTime1 = \DateTime::createFromFormat('m/d/Y', $toDate);
// $model = new InvoiceModel();
// $data['report_data'] = $model->itemwise_report_data( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') );
// $this->logger->info("Itemwise Report ");
// $data['page_name'] = 'Itemwise Report';
// $data['selected_data'] = $this->request->getVar('date');
// $this->render_page('report_itemwise', $data);
// }
// }
} }

View File

@ -42,14 +42,15 @@ class Users extends BaseController
} }
## To Load User Add/Update page ## To Load User Add/Update page
public function user_page($id) public function user_page($id,$flag)
{ {
helper('session'); helper('session');
$session_role = get_user_role(); $session_role = get_user_role();
$session_bid = get_business_id(); $session_bid = get_business_id();
$session_uid = get_logged_user_id(); $session_uid = get_logged_user_id();
$data['business_details'] = $this->business_details(); $data['business_details'] = $this->business_details();
$data['dummy_flag'] = $flag; // for redirect purpose.
if ($id === '0') { if ($id === '0') {
$this->logger->info("Users: In Add page"); $this->logger->info("Users: In Add page");
$data['page_name'] = 'Add User'; $data['page_name'] = 'Add User';
@ -300,7 +301,11 @@ class Users extends BaseController
} }
// Redirect back to the user_page function or any other appropriate page // Redirect back to the user_page function or any other appropriate page
return redirect()->to(base_url("user_page/{$user_id}")); if($this->request->getPost('dummy_flag') == 1){
return redirect()->to(base_url("user_page/{$user_id}/1"));
}else{
return redirect()->route('user_list');
}
} }

View File

@ -9,7 +9,7 @@ class BusinessModel extends Model
{ {
protected $table = 'business'; protected $table = 'business';
protected $primaryKey = 'business_id'; protected $primaryKey = 'business_id';
protected $allowedFields = ['business_id','title','email','mobile_no','terms','address','city','state','postal_code' ,'business_logo','isactive', 'pan_no', 'org_reg_no', '80G', 'signature']; protected $allowedFields = ['business_id','title','email','mobile_no','terms','address','city','state','postal_code' ,'business_logo','isactive', 'pan_no', 'org_reg_no', '80G', 'signature','favicon','start_no','left_pad','prefix_format','site_name','site_title','site_mobile','site_info','admin_email','terms_service','footer_about','copyright','pagination_limit','about_info','currency'];
public function insertBusiness($data) public function insertBusiness($data)
{ {
@ -19,6 +19,7 @@ class BusinessModel extends Model
{ {
return $this->db->table('business_branches') return $this->db->table('business_branches')
->where('business_id', $businessId) ->where('business_id', $businessId)
->where('isactive', 1)
->get() ->get()
->getResultArray(); ->getResultArray();
} }
@ -75,5 +76,32 @@ public function updateDonationData($businessId, $selectedDonations)
} }
} }
public function inactiveMissingBuinessBranchDetails($where,$missingValues){
$dataToUpdate = ['isactive' => 0];
$this->db->table('business_branches')->where($where)->whereIn('id',$missingValues)->update($dataToUpdate);
}
public function saveBuinessBranchDetails($data){
$i = 0;
$statement = [];
foreach ($data as $row) {
$id = $row['id'];
if($id != ''){
unset($row['id']); // Remove the id from the data to avoid updating it
$this->db->table('business_branches')->where('id', $id)->update($row);// Update the row with the specified id
$affectedRows = $this->db->affectedRows();
$statement[$i] = "business branches id - ".$id." ". ($affectedRows ? " Updated":" Nothing to Updated");
}else{
$this->db->table('business_branches')->insert($row);
$insertID = $this->db->insertID();
$statement[$i] = "business branches id - ".$insertID." Inserted";
}
$i++;
}
return $statement;
}
} }
?> ?>

View File

@ -168,6 +168,15 @@ public function getReceiptDetailsByDonorId($donorId)
->getResult(); ->getResult();
} }
public function getData($table, $where = null)
{
$query = $this->db->table($table);
if ($where) {
$query->where($where);
}
return $query->get()->getResult();
}
} }

View File

@ -1,4 +1,3 @@
<html> <html>
<head> <head>
@ -17,12 +16,14 @@
margin-top: 10px; margin-top: 10px;
/* Add a top margin for spacing */ /* Add a top margin for spacing */
} }
.toggle-icon { .toggle-icon {
cursor: pointer; cursor: pointer;
margin-left: 5px; margin-left: 5px;
} }
#error-message{
color:red; #error-message {
color: red;
} }
</style> </style>
@ -114,7 +115,7 @@
</div> </div>
</div> </div>
<!-- Existing form fields above this section --> <!-- Existing form fields above this section -->
<!-- ################################################################################################# --> <!-- ################################################################################################# -->
<hr /> <hr />
<h4 class="header-title" id="site-settings-title"> <h4 class="header-title" id="site-settings-title">
Site Settings Site Settings
@ -126,10 +127,11 @@
<div class="form-group col-md-12" style="display:none;"> <div class="form-group col-md-12" style="display:none;">
<label for="postal_code" class="col-form-label">Organization</label> <label for="postal_code" class="col-form-label">Organization</label>
<select id="business_id" name="business_id" class="form-control"> <select id="business_id" name="business_id" class="form-control">
<option value="null"><?php if(!isset($details['business_id'])){ echo 'Choose Organization'; } ?></option> <option value="null"><?php if (!isset($details['business_id'])) {
<?php foreach ($business_details as $value) { ?> echo 'Choose Organization';
<option value="<?php echo $value['business_id']; ?>" } ?></option>
<?php if (isset($details['business_id']) && ($details['business_id'] === $value['business_id'])) echo "selected"; ?>> <?php foreach ($master_business_details as $value) { ?>
<option value="<?php echo $value['business_id']; ?>" <?php if (isset($details['business_id']) && ($details['business_id'] === $value['business_id'])) echo "selected"; ?>>
<?php echo $value['title']; ?></option> <?php echo $value['title']; ?></option>
<?php } ?> <?php } ?>
</select> </select>
@ -139,43 +141,31 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="site_name" class="col-form-label">Site Name</label> <label for="site_name" class="col-form-label">Site Name</label>
<input type="text" class="form-control" id="site_name" name="site_name" <input type="text" class="form-control" id="site_name" name="site_name" value="<?= isset($businesses['site_name']) ? $businesses['site_name'] : '' ?>" placeholder="Site Name" />
value="<?= isset($details['site_name']) ? $details['site_name'] : '' ?>"
placeholder="Site Name" />
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="site_title" class="col-form-label">Site Title</label> <label for="site_title" class="col-form-label">Site Title</label>
<input type="text" class="form-control" id="site_title" name="site_title" <input type="text" class="form-control" id="site_title" name="site_title" placeholder="Site Title" value="<?= isset($businesses['site_title']) ? $businesses['site_title'] : '' ?>" />
placeholder="Site Title"
value="<?= isset($details['site_title']) ? $details['site_title'] : '' ?>" />
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="admin_email" class="col-form-label">Admin Email</label> <label for="admin_email" class="col-form-label">Admin Email</label>
<input type="email" class="form-control" id="admin_email" name="admin_email" <input type="email" class="form-control" id="admin_email" name="admin_email" placeholder="Admin Email" value="<?= isset($businesses['admin_email']) ? $businesses['admin_email'] : '' ?>" />
placeholder="Admin Email"
value="<?= isset($details['admin_email']) ? $details['admin_email'] : '' ?>" />
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="mobile" class="col-form-label">Mobile Number</label> <label for="site_mobile" class="col-form-label">Mobile Number</label>
<input type="text" class="form-control" id="mobile" name="mobile" <input type="text" class="form-control" id="site_mobile" name="site_mobile" placeholder="Mobile Number (Enter only numbers)" data-parsley-type="number" value="<?= isset($businesses['site_mobile']) ? $businesses['site_mobile'] : '' ?>" pattern="\d{10}" title="Please enter a 10-digit mobile number" maxlength="10" />
placeholder="Mobile Number (Enter only numbers)" data-parsley-type="number"
value="<?= isset($details['mobile']) ? $details['mobile'] : '' ?>" pattern="\d{10}" title="Please enter a 10-digit mobile number" maxlength="10" />
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="copyright" class="col-form-label">Copyright</label> <label for="copyright" class="col-form-label">Copyright</label>
<input type="text" class="form-control" id="copyright" name="copyright" <input type="text" class="form-control" id="copyright" name="copyright" placeholder="Copy Right" value="<?= isset($businesses['copyright']) ? $businesses['copyright'] : '' ?>" />
placeholder="Copy Right"
value="<?= isset($details['copyright']) ? $details['copyright'] : '' ?>" />
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="currency" class="col-form-label">Currency</label> <label for="currency" class="col-form-label">Currency</label>
<input type="text" class="form-control" id="currency" name="currency" <input type="text" class="form-control" id="currency" name="currency" placeholder="currency (eg : Rupees,Dollar,Euro)" value="<?= isset($businesses['currency']) ? $businesses['currency'] : '' ?>" />
placeholder="currency (eg : Rupees,Dollar,Euro)"
value="<?= isset($details['currency']) ? $details['currency'] : '' ?>" />
</div> </div>
</div> </div>
@ -183,17 +173,15 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="country" class="col-form-label">Country</label> <label for="country" class="col-form-label">Country</label>
<input type="text" class="form-control" id="country" name="country" <input type="text" class="form-control" id="country" name="country" placeholder="Country" value="<?= isset($businesses['country']) ? $businesses['country'] : '' ?>" />
placeholder="Country"
value="<?= isset($details['country']) ? $details['country'] : '' ?>" />
</div> </div>
</div> </div>
</div> </div>
<!-- ################################################################################################# --> <!-- ################################################################################################# -->
<?php if ($loged_user !== 'sadmin') : ?> <?php if ($loged_user !== 'sadmin') : ?>
<hr /> <hr />
<!-- --> <!-- -->
<h4 class="header-title" id="donaton-accepted-title"> <h4 class="header-title" id="donaton-accepted-title">
Accepted Contribution Accepted Contribution
<span class="toggle-icon" onclick="toggleSettings('donaton-accepted')"></span> <span class="toggle-icon" onclick="toggleSettings('donaton-accepted')"></span>
@ -204,10 +192,10 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="title" class="col-form-label">Name<span class="text-danger">*</span></label> <label for="title" class="col-form-label">Name<span class="text-danger">*</span></label>
<select class="form-control" placeholder="PAN Number" id="name" name="name[]" required data-toggle="select2" multiple > <select class="form-control" placeholder="PAN Number" id="name" name="name[]" required data-toggle="select2" multiple>
<option value="0" disabled>--Select--</option> <option value="0" disabled>--Select--</option>
<?php foreach ($donation as $val) : ?> <?php foreach ($donation as $val) : ?>
<option value="<?= $val["id"] ?>" <?php if ($val["is_active"] == 1) echo "selected"; ?> > <?= $val["name"] ?> </option> <option value="<?= $val["id"] ?>" <?php if ($val["is_active"] == 1) echo "selected"; ?>> <?= $val["name"] ?> </option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
@ -220,138 +208,87 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
<!--#################################################################### --> <!--#################################################################### -->
<hr /> <hr />
<h4 class="header-title" id="branch-settings-title"> <h4 class="header-title" id="branch-settings-title">
Branch Settings Branch Settings
<span class="toggle-icon" onclick="toggleSettings('branch-settings')"></span> <span class="toggle-icon" onclick="toggleSettings('branch-settings')"></span>
</h4> </h4>
<br> <br>
<div id="branchesContainer"> <div id="branch-settings" style="display: none;">
<div class="after-shipping-addr-add-more" id="branch-settings" style="display: none;"> <div class="after-busi-branch-add-more">
<?php if (empty($branches)) : ?>
<!-- Display at least one set of branch fields when the array is empty -->
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="branchname" class="col-form-label">Branch Name<span class="text-danger"> </span></label> <label for="branchname" class="col-form-label">Branch Name<span class="text-danger"> </span></label>
<input type="text" class="form-control" id="branchname" name="branchname[]" placeholder="Branch Name"required /> <input type="text" class="form-control" id="branchname" name="branch_name[]" placeholder="Branch Name" required />
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="branchaddress" class="col-form-label">Branch Address<span class="text-danger"></span></label> <label for="branchaddress" class="col-form-label">Branch Address<span class="text-danger"></span></label>
<input type="text" class="form-control" id="branchaddress" name="branchaddress[]" placeholder="Address (eg : 1234 Main St)"required /> <input type="text" class="form-control" id="branchaddress" name="branchaddress[]" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="mobile_no" class="col-form-label">Contact Person<span class="text-danger"></span></label> <label for="mobile_no" class="col-form-label">Contact Person Mobile Number<span class="text-danger"></span></label>
<input type="number" class="form-control" id="mobile_no" name="mobile_no[]" placeholder="Contact Person"required data-parsley-type="number" maxlength="10" /> <input type="number" class="form-control" id="mobile_no" name="mobile_no[]" placeholder="Contact Person Mobile Number" required data-parsley-type="number" maxlength="10" />
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="email" class="col-form-label">Email<span class="text-danger"></span></label> <label for="email" class="col-form-label">Email<span class="text-danger"></span></label>
<input type="text" class="form-control" id="email" name="email[]" placeholder="Email" required/> <input type="text" class="form-control" id="email" name="email[]" placeholder="Email" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<!-- Add hidden input for branch id -->
<input type="hidden" name="id[]" />
</div>
<?php else : ?>
<!-- Display branch fields for each branch in the $branches array -->
<?php foreach ($branches as $branch) : ?>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="branchname" class="col-form-label">Branch Name<span class="text-danger"></span></label>
<input type="text" class="form-control" id="branchname" name="branchname[]" value="<?= isset($branch['branch_name']) ? $branch['branch_name'] : '' ?>" placeholder="Branch Name"required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="branchaddress" class="col-form-label">Branch Address<span class="text-danger"> </span></label>
<input type="text" class="form-control" id="branchaddress" name="branchaddress[]" value="<?= isset($branch['address']) ? $branch['address'] : '' ?>" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-3">
<label for="mobile_no" class="col-form-label">Contact Person<span class="text-danger"> </span></label>
<input type="text" class="form-control" id="mobile_no" name="mobile_no[]" value="<?= isset($branch['mobile_no']) ? $branch['mobile_no'] : '' ?>" placeholder="Contact Person" required data-parsley-type="number" maxlength="10" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="email" class="col-form-label">Email<span class="text-danger"></span></label>
<input type="email" class="form-control" id="email" name="email[]" value="<?= isset($branch['email']) ? $branch['email'] : '' ?>" placeholder="Email"required/>
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<!-- Add hidden input for branch id --> <!-- Add hidden input for branch id -->
<input type="hidden" name="id[]" value="<?= isset($branch['id']) ? $branch['id'] : '' ?>" /> <input type="hidden" id="buiness_branch_id" name="id[]" placeholder="hidden for buisness branch id" />
<input type="hidden" id="counter" value=<?= 0; ?> readonly />
</div> </div>
<div class="form-group col-md-9 busi-branch-div-change text-right m-b-0">
<a class="btn btn-success waves-effect waves-light mr-1 busi-branch-add-more">+ Add More </a>
<a class="btn btn-danger waves-effect waves-light mr-1 busi-branch-remove">- Remove </a>
</div>
</div>
</div>
</div>
</div>
<!-- ############################################################################################### -->
<hr /> <hr />
<?php endforeach; ?> <h4 class="header-title" id="logo-settings-title">
<?php endif; ?>
<!-- Add more branches when clicking the "Add More Branches" button -->
<div class="form-group col-md-12 text-right m-b-0">
<a class="btn btn-success waves-effect waves-light mr-1 add-brnach-details"id="addBranchButton">+ Add More Branches </a>
<!-- <a class="btn btn-danger waves-effect waves-light mr-1 remove-brnach-details">- Remove </a> -->
</div>
</div>
<!-- Remaining form fields below this section -->
<!-- Add more branches when clicking the "Add More Branches" button -->
<!-- <div class="form-group col-md-12 text-right m-b-0">
<a class="btn btn-success waves-effect waves-light mr-1 add-brnach-details">+ Add More Branches </a>
<a class="btn btn-danger waves-effect waves-light mr-1 remove-brnach-details">- Remove </a>
</div>
</div> -->
</div>
<!-- ############################################################################################### -->
<hr />
<h4 class="header-title" id="logo-settings-title">
Logo Settings Logo Settings
<span class="toggle-icon" onclick="toggleSettings('logo-settings')"></span> <span class="toggle-icon" onclick="toggleSettings('logo-settings')"></span>
</h4> </h4>
<br> <br>
<div class="form-group" id="logo-settings" style="display: none;"> <div class="form-group" id="logo-settings" style="display: none;">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="logo" class="col-form-label">Logo</label> <label for="logo" class="col-form-label">Logo</label>
<input type="file" class="form-control" style="border: 0px !important; " id="logo" <input type="file" class="form-control" style="border: 0px !important; " id="logo" name="business_logo" placeholder="Logo Name" accept=".png, .jpg, .jpeg" value="<?= isset($businesses['business_logo']) ? $businesses['business_logo'] : '' ?>" />
name="slogo" placeholder="Logo Name" accept=".png, .jpg, .jpeg"
value="<?= isset($details['logo']) ? $details['logo'] : '' ?>" />
<p id="logo-error-message" style="color: red;"></p> <p id="logo-error-message" style="color: red;"></p>
</div> </div>
<?php if (!empty($details['logo'])) { ?> <?php if (!empty($businesses['business_logo'])) { ?>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="slogo" class="col-form-label"> Logo</label> <label for="business_logo" class="col-form-label"> Logo</label>
<img src="<?= base_url('public/uploads/'. $details['logo']) ?>" alt="Logo" <img src="<?= base_url('public/uploads/' . $businesses['business_logo']) ?>" alt="Logo" class="preview-image" />
class="preview-image" />
</div> </div>
<?php } ?> <?php } ?>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="favicon" class="col-form-label">Favicon</label> <label for="favicon" class="col-form-label">Favicon</label>
<input type="file" class="form-control" style="border: 0px !important; " id="favic" <input type="file" class="form-control" style="border: 0px !important; " id="favic" name="favicon" placeholder="Fav-icon Name" accept=".png, .jpg, .jpeg" value="<?= isset($businesses['favicon']) ? $businesses['favicon'] : '' ?>" />
name="favicon" placeholder="Fav-icon Name" accept=".png, .jpg, .jpeg"
value="<?= isset($details['favicon']) ? $details['favicon'] : '' ?>" />
<p id="favic-error-message" style="color: red;"></p> <p id="favic-error-message" style="color: red;"></p>
</div> </div>
<?php if (!empty($details['favicon'])) { ?> <?php if (!empty($businesses['favicon'])) { ?>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="favicon" class="col-form-label">Favicon</label> <label for="favicon" class="col-form-label">Favicon</label>
<img src="<?= base_url('public/uploads/'. $details['favicon']) ?>" alt="Icon" <img src="<?= base_url('public/uploads/' . $businesses['favicon']) ?>" alt="Icon" class="preview-image" />
class="preview-image" />
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
@ -374,37 +311,29 @@
</div> </div>
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for Organization id" value="<?= isset($businesses['business_id']) ? $businesses['business_id'] : '' ?>" /> <input type="hidden" id="business_id" name="business_id" placeholder="hidden for Organization id" value="<?= isset($businesses['business_id']) ? $businesses['business_id'] : '' ?>" />
<?php if (!empty($businesses) && ($loggedin_person_role === 'sadmin')) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="checkbox" id="bcheckbox" name="bcheckbox" class="form-control" <?= isset($businesses) && $businesses['isactive'] == 1 ? 'checked' : '' ?>>
<label for="bcheckbox"> Is Active</label>
</div>
<br>
<?php } ?>
</div> </div>
<div class="after-add-more"> <div class="after-add-more">
<hr /> <hr />
<h4 class="header-title" id="receipt-settings-title"> <h4 class="header-title" id="receipt-settings-title">
Receipt Settings Receipt Settings
<span class="toggle-icon" onclick="toggleSettings('receipt-settings')"></span> <span class="toggle-icon" onclick="toggleSettings('receipt-settings')"></span>
</h4> </h4>
<br> <br>
<div class="form-group" id="receipt-settings" style="display: none;"> <div class="form-group" id="receipt-settings" style="display: none;">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<div> <div>
<label for="bistate" class="col-form-label">Prefix</label> <label for="prefix_format" class="col-form-label">Prefix</label>
<input type="text" class="form-control" id="bistate" name="prefix_format" placeholder="Receipt Number Format" value="<?= isset($details['prefix_format']) ? $details['prefix_format'] : ''?>"/> <input type="text" class="form-control" id="prefix_format" name="prefix_format" placeholder="Receipt Number Format" value="<?= isset($businesses['prefix_format']) ? $businesses['prefix_format'] : '' ?>" />
</div> </div>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="baddress1" class="col-form-label">Left Padding</label> <label for="left_pad" class="col-form-label">Left Padding</label>
<input type="text" class="form-control" id="baddress1" name="left_pad" placeholder="Left Padding Number" value="<?= isset($details['left_pad']) ? $details['left_pad'] : '' ?>"/> <input type="text" class="form-control" id="left_pad" name="left_pad" placeholder="Left Padding Number" value="<?= isset($businesses['left_pad']) ? $businesses['left_pad'] : '' ?>" />
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="bcity" class="col-form-label">Start Number</label> <label for="start_no" class="col-form-label">Start Number</label>
<input type="text" class="form-control" id="bcity" name="start_no" value="<?= isset($details['start_no']) ? $details['start_no'] : '1' ?>" placeholder="Start Number" /> <input type="text" class="form-control" id="start_no" name="start_no" value="<?= isset($businesses['start_no']) ? $businesses['start_no'] : '1' ?>" placeholder="Start Number" />
</div> </div>
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="bterms" class="col-form-label">Receipt Note</label> <label for="bterms" class="col-form-label">Receipt Note</label>
@ -413,7 +342,7 @@ Receipt Settings
</div> </div>
</div> </div>
</div> </div>
<?php if(!empty($details)){ ?> <?php if (!empty($details)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple"> <div class="form-group text-right m-b-0 checkbox checkbox-purple">
</div> </div>
@ -423,12 +352,18 @@ Receipt Settings
<input type="hidden" id="setting_id" name="setting_id" placeholder="hidden for setting id" value="<?= isset($details['setting_id']) ? $details['setting_id'] : '' ?>" /> <input type="hidden" id="setting_id" name="setting_id" placeholder="hidden for setting id" value="<?= isset($details['setting_id']) ? $details['setting_id'] : '' ?>" />
<?php if (!empty($businesses) && ($loggedin_person_role === 'sadmin')) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple" style="display: none;">
<input type="checkbox" id="bcheckbox" name="bcheckbox" class="form-control" <?= isset($businesses) && $businesses['isactive'] == 1 ? 'checked' : '' ?>>
<label for="bcheckbox"> Is Active</label>
</div>
<br>
<?php } ?>
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">Save</button> <button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">Save</button>
<?php <?php
// $business_id=$businesses['business_id']; // $business_id=$businesses['business_id'];
$business_id = isset($businesses['business_id']) ? $businesses['business_id']: null; $business_id = isset($businesses['business_id']) ? $businesses['business_id'] : null;
// Check if the logged-in user's ID matches the user's ID // Check if the logged-in user's ID matches the user's ID
if ($session_bid == $business_id) { if ($session_bid == $business_id) {
@ -438,9 +373,9 @@ Receipt Settings
// Redirect to the user list // Redirect to the user list
$redirect_url = base_url() . "org_list"; $redirect_url = base_url() . "org_list";
} }
?> ?>
<!-- --> <!-- -->
<a href="<?= $redirect_url; ?>" class="btn btn-secondary waves-effect">Cancel</a> <a href="<?= $redirect_url; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div> </div>
</div> </div>
@ -464,7 +399,7 @@ Receipt Settings
} }
}); });
function validateImage(input) { function validateImage(input) {
const errorMessageElement = document.getElementById('error-message'); const errorMessageElement = document.getElementById('error-message');
errorMessageElement.textContent = ''; errorMessageElement.textContent = '';
@ -483,106 +418,19 @@ function validateImage(input) {
const maxHeight = 100; const maxHeight = 100;
const img = new Image(); const img = new Image();
img.onload = function () { img.onload = function() {
if (img.width > maxWidth || img.height > maxHeight) { if (img.width > maxWidth || img.height > maxHeight) {
errorMessageElement.textContent = `Image dimensions should not exceed ${maxWidth}x${maxHeight}.`; errorMessageElement.textContent = `Image dimensions should not exceed ${maxWidth}x${maxHeight}.`;
} }
}; };
img.src = URL.createObjectURL(image); img.src = URL.createObjectURL(image);
} }
</script> </script>
<script> <script>
document.addEventListener('DOMContentLoaded', function () { function toggleSettings(id) {
document.getElementById('addBranchButton').addEventListener('click', function () {
addBranch();
});
});
function addBranch(branchData) {
var html = '';
var i = document.querySelectorAll('.after-shipping-addr-add-more').length + 1; // Get the count of existing branches and increment
html += '<div class="after-shipping-addr-add-more" id="branch-settings-' + i + '">';
html += '<div class="form-group">';
html += '<div class="form-row">';
html += '<div class="form-group col-md-6">';
html += '<label for="branchname' + i + '" class="col-form-label">Branch Name<span class="text-danger"> </span></label>';
html += '<input type="text" class="form-control" id="branchname' + i + '" name="branchname[]" placeholder="Branch Name" required value="' + (branchData && branchData.branch_name ? branchData.branch_name : '') + '" />';
html += '<div class="invalid-feedback"> Please provide. </div>';
html += '</div>';
html += '<div class="form-group col-md-6">';
html += '<label for="branchaddress' + i + '" class="col-form-label">Branch Address<span class="text-danger"></span></label>';
html += '<input type="text" class="form-control" id="branchaddress' + i + '" name="branchaddress[]" placeholder="Address (eg: 1234 Main St)" required value="' + (branchData && branchData.address ? branchData.address : '') + '" />';
html += '<div class="invalid-feedback"> Please provide. </div>';
html += '</div>';
html += '</div>';
html += '<div class="form-row">';
html += '<div class="form-group col-md-6">';
html += '<label for="mobile_no' + i + '" class="col-form-label">Contact Person<span class="text-danger"></span></label>';
html += '<input type="number" class="form-control" id="mobile_no' + i + '" name="mobile_no[]" placeholder="Contact Person" required data-parsley-type="number" maxlength="10" value="' + (branchData && branchData.mobile_no ? branchData.mobile_no : '') + '" />';
html += '<div class="invalid-feedback"> Please provide. </div>';
html += '</div>';
html += '<div class="form-group col-md-6">';
html += '<label for="email' + i + '" class="col-form-label">Email<span class="text-danger"></span></label>';
html += '<input type="email" class="form-control" id="email' + i + '" name="email[]" placeholder="Email" required value="' + (branchData && branchData.email ? branchData.email : '') + '" />';
html += '<div class="invalid-feedback"> Please provide. </div>';
html += '</div>';
html += '</div>';
html += '<input type="hidden" name="id[]" />';
html += '<div class="form-group col-md-12 text-right m-b-0">'
html += '<button class="btn btn-success waves-effect waves-light mr-1 add-branch-button">+ Add More Branches </button>';
html += '<button class="btn btn-danger waves-effect waves-light mr-1 remove-branch-button" data-branch-id="' + i + '">Remove Branch</button>';
html += '</div>';
html += '</div>';
// Append the generated HTML to the container
document.getElementById('branchesContainer').insertAdjacentHTML('beforeend', html);
// Attach event handler to the newly added remove button
var removeButton = document.querySelector('#branch-settings-' + i + ' .remove-branch-button[data-branch-id="' + i + '"]');
removeButton.addEventListener('click', function() {
var branchId = this.getAttribute('data-branch-id');
var branchElement = document.getElementById('branch-settings-' + branchId);
if (branchElement) {
branchElement.remove();
}
});
// Attach event handler to the newly added add button
var addButton = document.querySelector('#branch-settings-' + i + ' .add-branch-button');
addButton.addEventListener('click', function() {
addBranch();
});
}
// Usage example:
<?php foreach ($branches as $branch) : ?>
addBranch(<?php echo json_encode($branch); ?>);
<?php endforeach; ?>
// Event delegation to handle removing branches
// Event delegation to handle adding and removing branches
// Event delegation to handle removing branches
// document.getElementById('branchesContainer').addEventListener('click', function (event) {
// if (event.target.classList.contains('remove-branch-button')) {
// var branchId = event.target.getAttribute('data-branch-id');
// var branchElement = document.getElementById('branch-settings-' + branchId);
// if (branchElement) {
// branchElement.remove();
// }
// }
// });
function toggleSettings(id) {
var settingsDiv = document.getElementById(id); var settingsDiv = document.getElementById(id);
var titleIcon = document.querySelector("#"+id+"-title .toggle-icon"); var titleIcon = document.querySelector("#" + id + "-title .toggle-icon");
if (settingsDiv.style.display === "none") { if (settingsDiv.style.display === "none") {
settingsDiv.style.display = "block"; settingsDiv.style.display = "block";
titleIcon.textContent = ""; // Change icon to up arrow titleIcon.textContent = ""; // Change icon to up arrow
@ -590,9 +438,7 @@ function toggleSettings(id) {
settingsDiv.style.display = "none"; settingsDiv.style.display = "none";
titleIcon.textContent = ""; // Change icon to down arrow titleIcon.textContent = ""; // Change icon to down arrow
} }
} }
</script> </script>
<script> <script>
document.getElementById('logo').addEventListener('change', function() { document.getElementById('logo').addEventListener('change', function() {
@ -652,8 +498,67 @@ function toggleSettings(id) {
} }
}); });
</script> </script>
<script>
$(document).ready(function() {
var busiBranchArray = <?php echo json_encode($branches); ?>;
if (busiBranchArray.length > 0) {
j = 0;
for (var i = 0; i < busiBranchArray.length; i++) {
if (i == 0) {
var html = $(".after-busi-branch-add-more").first();
} else {
var html = $(".after-busi-branch-add-more").first().clone();
}
html.find('input#buiness_branch_id').val(busiBranchArray[i]['id']);
html.find('input#mobile_no').val(busiBranchArray[i]['mobile_no']);
html.find('input#email').val(busiBranchArray[i]['email']);
html.find('input#branchaddress').val(busiBranchArray[i]['address']);
html.find('input#branchname').val(busiBranchArray[i]['branch_name']);
if (i !== 0) {
html.find(".busi-branch-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 busi-branch-add-more'>+ Add More </a><a class='btn btn-danger waves-effect waves-light mr-1 busi-branch-remove'>- Remove </a>");
html.insertAfter(".after-busi-branch-add-more:last");
}
j++;
swapButtons();
}
} else {
swapButtons();
}
$("body").on("click", ".busi-branch-add-more", function() {
var html = $(".after-busi-branch-add-more").first().clone();
var count = $(".after-busi-branch-add-more").length;
html.find('input').val(''); // Clear input values in the cloned element
html.find('input#counter').val(count).prop("readonly", true);
html.find(".busi-branch-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 busi-branch-add-more'>+ Add More </a><a class='btn btn-danger waves-effect waves-light mr-1 busi-branch-remove'>- Remove </a>");
html.insertAfter(".after-busi-branch-add-more:last");
swapButtons();
});
$("body").on("click", ".busi-branch-remove", function() {
var rows = $(".after-busi-branch-add-more");
if (rows.length > 1) {
$(this).parents(".after-busi-branch-add-more").remove();
} else {
alert("At least one Shipping Address must be displayed.");
}
swapButtons();
});
function swapButtons() {
var elementCount = $(".after-busi-branch-add-more").length;
if (elementCount > 1) {
$(".busi-branch-remove").show(); // Show the "busi-branch-remove" buttons
} else {
$(".busi-branch-remove").hide(); // Hide the "busi-branch-remove" buttons
}
$(".after-busi-branch-add-more .busi-branch-add-more").hide();
$(".after-busi-branch-add-more:last .busi-branch-add-more").show();
}
});
</script>

View File

@ -71,7 +71,7 @@
<input type="hidden" id="campaign_id" name="campaign_id" placeholder="hidden for template id" value="<?= isset($campaign_details['campaign_id']) ? $campaign_details['campaign_id'] : '' ?>" /> <input type="hidden" id="campaign_id" name="campaign_id" placeholder="hidden for template id" value="<?= isset($campaign_details['campaign_id']) ? $campaign_details['campaign_id'] : '' ?>" />
<?php if (!empty($campaign_details)) { ?> <?php if (!empty($campaign_details)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple"> <div class="form-group text-right m-b-0 checkbox checkbox-purple" style="display: none;">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($campaign_details) && $campaign_details['isactive'] == 1 ? 'checked' : '' ?>> <input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($campaign_details) && $campaign_details['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label> <label for="isactive"> Is Active</label>
</div> </div>

View File

@ -34,7 +34,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="DonorType" class="col-form-label">Contributor Type<span class="text-danger"> *</span></label> <label for="DonorType" class="col-form-label">Contributor Type<span class="text-danger"> *</span></label>
<select class="form-control" id="DonorType" name="DonorType" required disabled> <select class="form-control" id="DonorType" name="DonorType" required disabled>
<option value="" disabled>Select Contributor Type</option> <option value="" disabled>--Select--</option>
<option value="option1" <?= isset($customer['donor_type']) && $customer['donor_type'] === 'option1' ? 'selected' : '' ?>>Individual</option> <option value="option1" <?= isset($customer['donor_type']) && $customer['donor_type'] === 'option1' ? 'selected' : '' ?>>Individual</option>
<option value="option2" <?= isset($customer['donor_type']) && $customer['donor_type'] === 'option2' ? 'selected' : '' ?>>Organization</option> <option value="option2" <?= isset($customer['donor_type']) && $customer['donor_type'] === 'option2' ? 'selected' : '' ?>>Organization</option>
@ -125,7 +125,7 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="bcountry" class="col-form-label">Country</label> <label for="bcountry" class="col-form-label">Country</label>
<select class="form-control" id="bcountry" name="country"> <select class="form-control" id="bcountry" name="country">
<option value="<?= isset($customer['country']) ? $customer['country'] : '';?>"><?= isset($customer['country']) ? $customer['country'] : 'Choose your Country';?></option> <option value="<?= isset($customer['country']) ? $customer['country'] : '';?>"><?= isset($customer['country']) ? $customer['country'] : '--Select--';?></option>
<?php foreach ($country_details as $value) { ?> <?php foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_name']; ?>"> <option value="<?php echo $value['country_name']; ?>">
<?php <?php

View File

@ -3,7 +3,7 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="float-right"> <div class="float-right">
<a href="<?= base_url()."view_donor_group/0"; ?>" class="btn btn-primary"><i class="ri-team-line"></i> Add Contributor Group </a> <a href="<?= base_url()."view_contributor_group/0"; ?>" class="btn btn-primary"><i class="ri-team-line"></i> Add Contributor Group </a>
</div><!-- end col--> </div><!-- end col-->
<br> <br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4> <h4 class="header-title mb-3"><?= $page_name; ?></h4>
@ -52,10 +52,10 @@
<td><?= $group['created_by_name']; ?></td> <td><?= $group['created_by_name']; ?></td>
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td> <td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
<td> <td>
<a href="<?= base_url() . "view_donor_group/" . $group['group_id']; ?>" class="edit-button" title="Edit" ><i class="ri-pencil-line"></i></a> <a href="<?= base_url() . "view_contributor_group/" . $group['group_id']; ?>" class="edit-button" title="Edit" ><i class="ri-pencil-line"></i></a>
<a class="preview-button" title="Customer list" data-toggle="modal" data-target="#scrollable-modal" data-primary-key="<?php echo $group['group_id']; ?>" data-group-name="<?php echo $group['group_name']; ?>"><i class="ri-pages-line"></i></a> <a class="preview-button" title="preview" data-toggle="modal" data-target="#scrollable-modal" data-primary-key="<?php echo $group['group_id']; ?>" data-group-name="<?php echo $group['group_name']; ?>"><i class="ri-pages-line"></i></a>
<?php if(get_user_role() != 'auditor') { ?> <?php if(get_user_role() != 'auditor') { ?>
<?php if ($group['isactive']) { ?> <a href="<?= base_url() . "delete_donor_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?> <?php if ($group['isactive']) { ?> <a href="<?= base_url() . "delete_contributor_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
<?php } ?> <?php } ?>
</td> </td>
</tr> </tr>
@ -118,7 +118,7 @@ $(document).ready(function() {
// Get the table reference // Get the table reference
var table = $("#data-table tbody"); var table = $("#data-table tbody");
var route = "<?= base_url().'preview_donor_group/'?>"+primaryKey; var route = "<?= base_url().'preview_contributor_group/'?>"+primaryKey;
$.ajax({ $.ajax({
method: 'GET', method: 'GET',

View File

@ -4,7 +4,7 @@
<div class="card-body"> <div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4> <h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"></p> <p class="sub-header"></p>
<form id="myForm" class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_donor_group"; ?>" > <form id="myForm" class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_contributor_group"; ?>" >
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="groupname" class="col-form-label">Group Name<span class="text-danger"> *</span></label> <label for="groupname" class="col-form-label">Group Name<span class="text-danger"> *</span></label>
@ -115,7 +115,7 @@
<button type="button" id="addItem" class="btn btn-soft-dark btn-rounded waves-effect waves-light mr-3 add-item"> + Add New Criteria</button> <button type="button" id="addItem" class="btn btn-soft-dark btn-rounded waves-effect waves-light mr-3 add-item"> + Add New Criteria</button>
</div> </div>
<?php if (!empty($donor_group)) { ?> <?php if (!empty($donor_group)) { ?>
<div class="form-group text-right checkbox checkbox-purple mr-3"> <div class="form-group text-right checkbox checkbox-purple mr-3" style="display: none;">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($donor_group) && $donor_group['isactive'] == 1 ? 'checked' : '' ?>> <input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($donor_group) && $donor_group['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label> <label for="isactive"> Is Active</label>
</div> </div>
@ -456,7 +456,7 @@ document.getElementById("addItem").addEventListener("click", function() {
var table = $("#data-table tbody"); var table = $("#data-table tbody");
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<?= base_url() . 'insert_donor_group' ?>", url: "<?= base_url() . 'insert_contributor_group' ?>",
data: formData, data: formData,
dataType: "json", // Expect JSON response dataType: "json", // Expect JSON response
success: function(response) { success: function(response) {

View File

@ -1,68 +1,96 @@
<style> <style>
td .select2-container{ td .select2-container {
width: 249px !important; width: 249px !important;
} }
.fe-plus-circle:hover { .fe-plus-circle:hover {
color: #ff0000; /* Change to the desired hover color */ color: #ff0000;
} /* Change to the desired hover color */
}
</style> </style>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col-lg-6"><h4 class="header-title"><?= $page_name; ?></h4></div> <div class="col-lg-6">
<h4 class="header-title"><?= $page_name; ?></h4>
</div>
</div> </div>
<br> <br>
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>" class="main-form" id="myForm"> <form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>" class="main-form" id="myForm">
<div class="form-group"> <div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="receipt_type" class="col-form-label">Type</label>
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" class="receipt_type" name="receipt_type" value="option1" <?php if ($receipt_type == "option1") echo "checked"; ?> onchange="get_donor_details(this.value);">
Individual
&nbsp;
<input type="radio" class="receipt_type" name="receipt_type" value="option2" <?php if ($receipt_type == "option2") echo "checked"; ?> onchange="get_donor_details(this.value);">
Organization
<!-- <select class="form-control" id="receipt_type" onchange="get_donor_details(this.value);">
<option value="option1" <?php if ($receipt_type == "option1") {
echo "selected";
} ?> >Individual</option>
<option value="option2" <?php if ($receipt_type == "option2") {
echo "selected";
} ?> >Organization</option>
</select> -->
</div>
</div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="customerMobile" class="col-form-label">Donor Mobile<span class="text-danger"> *</span></label> <label for="customerMobile" class="col-form-label">Donor Mobile<span class="text-danger"> *</span></label>
<?php if(get_user_role() != 'accounts') { ?> <!-- <?php if (get_user_role() != 'accounts') { ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<i type="button" class="fe-plus-circle" id="add-quk-donar" style="font-size: 24px;" data-toggle="modal" data-target="#standard-modal" title="Add Donor"></i> <i type="button" class="fe-plus-circle" id="add-quk-donar" style="font-size: 24px;" data-toggle="modal" data-target="#standard-modal" title="Add Donor"></i>
<?php } ?> <?php } ?> -->
<select class="form-control" id="donor_mobile" name="donor_mobile" required data-toggle="select2"> <select class="form-control" id="donor_mobile" name="donor_mobile" required data-toggle="select2">
<option value="">--Select--</option> <option value="">--Select--</option>
<?php foreach ($customers as $customer) : ?> <?php if (get_user_role() != 'accounts') { ?> <option class="blueText" value="0"> + Add a donor</option> <?php } ?>
<option value="<?= $customer->mobile_no ?>" <?php if (isset($receipt_details['donor_id']) && ($receipt_details['donor_id'] == $customer->donor_id)) echo "selected"; ?> > <?= $customer->mobile_no ?> </option> <?php foreach ($typebaseddonors as $customer) : ?>
<option value="<?= $customer->mobile_no ?>" <?php if (isset($receipt_details['donor_id']) && ($receipt_details['donor_id'] == $customer->donor_id)) echo "selected"; ?>> <?= $customer->mobile_no ?> </option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="customerName" class="col-form-label">Donor Name<span class="text-danger"> *</span></label> <label for="donor_first_name" class="col-form-label">Donor Name<span class="text-danger"> *</span></label>
<select class="form-control" id="customerName" name="donor_id" required data-toggle="select2"> <select class="form-control" id="donor_first_name" name="donor_id" required data-toggle="select2">
<option value="">--Select--</option> <option value="">--Select--</option>
<?php foreach ($customers as $customer) : ?> <?php if (get_user_role() != 'accounts') { ?> <option class="blueText" value="0"> + Add a donor</option><?php } ?>
<option value="<?= $customer->donor_id ?>" <?php if (isset($receipt_details['donor_id']) && ($receipt_details['donor_id'] == $customer->donor_id)) echo "selected"; ?> > <?= $customer->first_name ?> </option> <?php foreach ($typebaseddonors as $customer) : ?>
<option value="<?= $customer->donor_id ?>" <?php if (isset($receipt_details['donor_id']) && ($receipt_details['donor_id'] == $customer->donor_id)) echo "selected"; ?>> <?= $customer->first_name ?> </option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="event" class="col-form-label">Causes<span class="text-danger"> *</span></label> <label for="event" class="col-form-label">Causes<span class="text-danger"> *</span></label>
<select class="form-control" id="event" name="causes_id" required > <select class="form-control" id="event" name="causes_id" required>
<option value="">Select the Causes</option> <option value="">--Select--</option>
<?php foreach ($causes as $causesData) : if(date("Y-m-d") >= $causesData->from_date && date("Y-m-d") <= $causesData->to_date || $causesData->from_date == '' && $causesData->to_date == ''){?> <?php foreach ($causes as $causesData) : if (date("Y-m-d") >= $causesData->from_date && date("Y-m-d") <= $causesData->to_date || $causesData->from_date == '' && $causesData->to_date == '') { ?>
<option value="<?= $causesData->causes_id ?>" <?php if (isset($receipt_details['causes_id']) && ($receipt_details['causes_id'] === $causesData->causes_id)) echo "selected"; ?> ><?= $causesData->name ?> <?= ($causesData->from_date != '') ? '('. date("d-m-Y", strtotime($causesData->from_date)) .' - '. date("d-m-Y", strtotime($causesData->to_date)).' )' : ''; ?> </option> <option value="<?= $causesData->causes_id ?>" <?php if (isset($receipt_details['causes_id']) && ($receipt_details['causes_id'] === $causesData->causes_id)) echo "selected"; ?>><?= $causesData->name ?> <?= ($causesData->from_date != '') ? '(' . date("d-m-Y", strtotime($causesData->from_date)) . ' - ' . date("d-m-Y", strtotime($causesData->to_date)) . ' )' : ''; ?> </option>
<?php } else { <?php } else {
if(isset($receipt_details['causes_id']) && ($receipt_details['causes_id'] === $causesData->causes_id)) { ?> if (isset($receipt_details['causes_id']) && ($receipt_details['causes_id'] === $causesData->causes_id)) { ?>
<option value="<?= $causesData->causes_id ?>" <?php if (isset($receipt_details['causes_id']) && ($receipt_details['causes_id'] === $causesData->causes_id)) echo "selected disabled"; ?>><?= $causesData->name ?> ( <?= date("d-m-Y", strtotime($causesData->from_date)) ?> - <?= date("d-m-Y", strtotime($causesData->to_date)) ?> )</option> <option value="<?= $causesData->causes_id ?>" <?php if (isset($receipt_details['causes_id']) && ($receipt_details['causes_id'] === $causesData->causes_id)) echo "selected disabled"; ?>><?= $causesData->name ?> ( <?= date("d-m-Y", strtotime($causesData->from_date)) ?> - <?= date("d-m-Y", strtotime($causesData->to_date)) ?> )</option>
<?php } <?php }
} endforeach; ?> }
endforeach; ?>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="event" class="col-form-label">Campaign</label> <label for="event" class="col-form-label">Campaign</label>
<select class="form-control" id="campaign" name="campaign_id" data-toggle="select2" > <select class="form-control" id="campaign" name="campaign_id" data-toggle="select2">
<option value="">Select the Campaign</option> <option value="">--Select--</option>
<?php foreach ($campaign as $cam) : if(date("Y-m-d") >= $cam->start_date && date("Y-m-d") <= $cam->end_date || $cam->start_date == '' && $cam->end_date == ''){?> <?php foreach ($campaign as $cam) : if (date("Y-m-d") >= $cam->start_date && date("Y-m-d") <= $cam->end_date || $cam->start_date == '' && $cam->end_date == '') { ?>
<option value="<?= $cam->campaign_id ?>" <?php if (isset($receipt_details['campaign_id']) && ($receipt_details['campaign_id'] === $cam->campaign_id)) echo "selected"; ?>><?= $cam->name ?> ( <?= date("d-m-Y", strtotime($cam->start_date)) ?> - <?= date("d-m-Y", strtotime($cam->end_date)) ?> )</option> <option value="<?= $cam->campaign_id ?>" <?php if (isset($receipt_details['campaign_id']) && ($receipt_details['campaign_id'] === $cam->campaign_id)) echo "selected"; ?>><?= $cam->name ?> ( <?= date("d-m-Y", strtotime($cam->start_date)) ?> - <?= date("d-m-Y", strtotime($cam->end_date)) ?> )</option>
<?php } endforeach; ?> <?php }
endforeach; ?>
</select> </select>
</div> </div>
@ -98,17 +126,29 @@
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<label for="csname" class="col-form-label">Amount<span class="text-danger"> *</span></label> <label for="csname" class="col-form-label">Amount<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="org_name_field" name="amount" value="<?= isset($receipt_details['amount']) ? $receipt_details['amount'] : '' ?>" placeholder="Amount" oninput="this.value = this.value.replace(/[^0-9]/g, '')" required /> <input type="text" class="form-control" id="org_name_field" name="amount" value="<?= isset($receipt_details['amount']) ? $receipt_details['amount'] : '' ?>" placeholder="Amount" oninput="this.value = this.value.replace(/[^0-9]/g, '')" required maxlength="9" />
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="invoiceDate" class="col-form-label">Payment Mode<span class="text-danger"> *</span></label> <label for="invoiceDate" class="col-form-label">Payment Mode<span class="text-danger"> *</span></label>
<select class="form-control" id="paymentMode" name="payment_mode" required> <select class="form-control" id="paymentMode" name="payment_mode" required>
<option value="" <?php if( isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == '' ) { echo 'selected'; } ?> >Select Payment Mode</option> <option value="" <?php if (isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == '') {
<option value="credit" <?php if( isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'credit' ) { echo 'selected'; } ?>>Credit Card</option> echo 'selected';
<option value="debit" <?php if( isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'debit' ) { echo 'selected'; } ?>>Debit Card</option> } ?>>--Select--</option>
<option value="cash" <?php if( isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'cash' ) { echo 'selected'; } ?>>Cash</option> <option value="credit" <?php if (isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'credit') {
<option value="upi" <?php if( isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'upi' ) { echo 'selected'; } ?>>UPI</option> echo 'selected';
<option value="banktransfer" <?php if( isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'banktransfer' ) { echo 'selected'; } ?>>Bank Transfer</option> } ?>>Credit Card</option>
<option value="debit" <?php if (isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'debit') {
echo 'selected';
} ?>>Debit Card</option>
<option value="cash" <?php if (isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'cash') {
echo 'selected';
} ?>>Cash</option>
<option value="upi" <?php if (isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'upi') {
echo 'selected';
} ?>>UPI</option>
<option value="banktransfer" <?php if (isset($receipt_details['payment_mode']) && $receipt_details['payment_mode'] == 'banktransfer') {
echo 'selected';
} ?>>Bank Transfer</option>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
@ -126,7 +166,7 @@
</div> </div>
<input type="hidden" id="hiddenInvoiceId" name="receipt_id" placeholder="hidden for invoice id" value="<?= isset($receipt_details['receipt_id']) ? $receipt_details['receipt_id'] : '' ?>" /> <input type="hidden" id="hiddenInvoiceId" name="receipt_id" placeholder="hidden for invoice id" value="<?= isset($receipt_details['receipt_id']) ? $receipt_details['receipt_id'] : '' ?>" />
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<?php if(get_user_role() != 'accounts') { ?> <?php if (get_user_role() != 'accounts') { ?>
<button type="submit" class="btn btn-primary waves-effect mr-1" name="saveas" value="Draft" id="saveDraftButton"><?= isset($receipt_details['receipt_id']) ? 'Update' : 'Save' ?></button> <button type="submit" class="btn btn-primary waves-effect mr-1" name="saveas" value="Draft" id="saveDraftButton"><?= isset($receipt_details['receipt_id']) ? 'Update' : 'Save' ?></button>
<?php } ?> <?php } ?>
</div> </div>
@ -159,15 +199,15 @@
<!-- Your existing JavaScript code --> <!-- Your existing JavaScript code -->
<script> <script>
$(document).ready(function () { $(document).ready(function() {
$('#myForm').submit(function (e) { $('#myForm').submit(function(e) {
e.preventDefault(); e.preventDefault();
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '<?= base_url("save_invoice"); ?>', url: '<?= base_url("save_invoice"); ?>',
data: $(this).serialize(), data: $(this).serialize(),
success: function (response) { success: function(response) {
if (response.success) { if (response.success) {
$('#successModal').modal('show'); $('#successModal').modal('show');
$('#downloadButton').attr('href', "<?= base_url('generate_invoice_pdf/'); ?>" + response.invoice_id); $('#downloadButton').attr('href', "<?= base_url('generate_invoice_pdf/'); ?>" + response.invoice_id);
@ -177,7 +217,7 @@
console.log(response.message); console.log(response.message);
} }
}, },
error: function (error) { error: function(error) {
console.log('AJAX Error:', error); console.log('AJAX Error:', error);
} }
}); });
@ -186,94 +226,144 @@
</script> </script>
<script> <script>
var data = <?php echo json_encode($customers); ?>; var data = <?php echo json_encode($typebaseddonors); ?>;
var editdata = <?php echo json_encode($receipt_details); ?>; var alldonors = <?php echo json_encode($alldonors); ?>;
console.log(editdata,'data'); var editdata = <?php echo json_encode($receipt_details); ?>;
$(function() {
$(function() { $('#donor_mobile').on('change', function() {
// onload function if ($(this).val()) {
// if(editdata) { if ($(this).val() == '0') {
// var selectedMobile = $('#donor_mobile').val(); $('#standard-modal').modal('show');
// console.log(selectedMobile,'selectedMobiledsf'); } else {
// var options = '<option value="">Select a Donor</option>'; $('#standard-modal').modal('hide');
$('#donor-form-submit').prop('disabled', false);
// // Assuming `data` is an array of objects containing donor information }
// for (const donor of data) { if ($(this).val() != '0') {
// if(selectedMobile == donor.mobile_no) {
// options += `<option value="${donor.donor_id}" ${editdata && editdata.donor_id == donor.donor_id ? 'selected' : ''}>${donor.first_name} ${donor.last_name}</option>`;
// }
// }
// // Assuming you have a select element with the id `#donor_select`
// $('#customerName').html(options);
// }
$('#donor_mobile').on('change', function(){
console.log($(this).val());
if($(this).val())
{
var selectedMobile = $(this).val(); var selectedMobile = $(this).val();
var options = '<option value="">Select a Donor</option>'; var options = '<option value="">--Select--</option>';
// Assuming `data` is an array of objects containing donor information // Assuming `data` is an array of objects containing donor information
for (const donor of data) { for (const donor of data) {
if(selectedMobile == donor.mobile_no) { if (selectedMobile == donor.mobile_no) {
options += `<option value="${donor.donor_id}" ${editdata && editdata.donor_id == donor.donor_id ? 'selected' : ''}>${donor.first_name}</option>`; options += `<option value="${donor.donor_id}" ${editdata && editdata.donor_id == donor.donor_id ? 'selected' : ''}>${donor.first_name}</option>`;
} }
} }
// Assuming you have a select element with the id `#donor_select` // Assuming you have a select element with the id `#donor_select`
$('#customerName').html(options); $('#donor_first_name').html(options);
} }
else } else {
{
var selectedMobile = $(this).val(); var selectedMobile = $(this).val();
var options = '<option value="">Select a Donor</option>'; var options = '<option value="">--Select--</option>';
options += '<option value="0">+ Add a donor</option>';
// Assuming `data` is an array of objects containing donor information // Assuming `data` is an array of objects containing donor information
for (const donor of data) { for (const donor of data) {
options += `<option value="${donor.donor_id}">${donor.first_name}</option>`; options += `<option value="${donor.donor_id}">${donor.first_name}</option>`;
} }
// Assuming you have a select element with the id `#donor_select` // Assuming you have a select element with the id `#donor_select`
$('#customerName').html(options); $('#donor_first_name').html(options);
} }
}); });
});
$(function() {
$('#donor_mobile').on('change', function(){
var selectedMobile = $(this).val();
// Find the donor with the selected mobile number $('#donor_first_name').on('change', function() {
var matchingDonor = data.find(donor => donor.mobile_no == selectedMobile); var type = $('.receipt_type:checked').val();
if ($(this).val() == '0') {
// Set the donor name directly if there's a matching donor $('#standard-modal').modal('show');
if (matchingDonor) {
$('#customerName').val(matchingDonor.donor_id).trigger('change');
} else { } else {
// If there's no matching donor or multiple donors, reset the donor name input $('#standard-modal').modal('hide');
$('#customerName').val('').trigger('change'); $('#donor-form-submit').prop('disabled', false);
if (type == "option2") {
var selectedID = $(this).val();
var options = '<option value="">--Select--</option>';
options += '<option value="0">+ Add a donor</option>';
// Filter the donors array based on the selectedID
var filter_array = alldonors.filter(function(d) {
return d.donor_id === selectedID;
});
if (filter_array.length > 0) {
var donor = filter_array[0];
options += `<option value="${donor.mobile_no}" selected>${donor.mobile_no}</option>`;
}
// Set the options to the donor_mobile select element
$('#donor_mobile').html(options);
}
} }
}); });
});
});
$(function() { $(function() {
$('#form-submit').on('click', function(){ $('#donor-form-submit').on('click', function() {
console.log('edakfibsefui');
// Disable the button to prevent multiple clicks // Disable the button to prevent multiple clicks
if ($('.myForm')[0].checkValidity()) { if ($('.donorForm')[0].checkValidity()) {
this.disabled = true; this.disabled = true;
} }
$('#submitBtn').click(); // $('#submitBtn').click();
// Perform any other actions (e.g., form submission) $.ajax({
// For example, you can use AJAX to submit the form data type: "POST",
url: "<?= base_url() . 'insert_ajaxdonor' ?>",
data: $('#donorForm').serialize(),
success: function(response) {
console.log(response);
if (response['data']['status']) {
dropdown = response['data']['donor'];
alert(response['data']['message']);
if (dropdown.length > 0) {
$('#donor_mobile').empty().append($('<option>', {
value: "",
text: "--Select--"
}));
$('#donor_mobile').append($('<option>', {
value: "0",
text: "+ Add a donor"
}));
$('#donor_first_name').empty().append($('<option>', {
value: "",
text: "--Select--"
}));
$('#donor_first_name').append($('<option>', {
value: "0",
text: "+ Add a donor"
}));
$.each(dropdown, function(k, v) {
$('#donor_mobile').append($('<option>', {
value: v.mobile_no,
text: v.mobile_no,
selected: (v.donor_id == response['data']['donor_id']) ? true : false
}));
$('#donor_first_name').append($('<option>', {
value: v.donor_id,
text: v.first_name,
selected: (v.donor_id == response['data']['donor_id']) ? true : false
}));
});
}
} else {
alert(response['data']['message']);
}
$('#standard-modal').modal('hide');
// Reset the form
$('#donorForm').get(0).reset();
$('#donor-form-submit').prop('disabled', false);
},
error: function() {
alert("Error occur.");
$('#donor-form-submit').prop('disabled', false);
}
}); });
});
});
});
$(function() { $(function() {
$('#saveDraftButton').on('click', function(){ $('#saveDraftButton').on('click', function() {
// Check if the form is valid // Check if the form is valid
if ($('.main-form')[0].checkValidity()) { if ($('.main-form')[0].checkValidity()) {
// Disable the button to prevent multiple clicks // Disable the button to prevent multiple clicks
@ -282,16 +372,14 @@ $(function() {
// Submit the form // Submit the form
$('.main-form').submit(); $('.main-form').submit();
} }
}); });
});
}); // hide all fields for account login
$(function() {
// hide all fields for account login
$(function() {
role = "<?php echo get_user_role() ?>"; role = "<?php echo get_user_role() ?>";
console.log(role); console.log(role);
if(role == "accounts" || role == "auditor") if (role == "accounts" || role == "auditor") {
{
// for input // for input
var formElements = document.querySelectorAll('#myForm input, #myForm textarea'); var formElements = document.querySelectorAll('#myForm input, #myForm textarea');
formElements.forEach(function(element) { formElements.forEach(function(element) {
@ -304,9 +392,7 @@ $(function() {
}); });
$('#add-quk-donar').attr('disabled', true); $('#add-quk-donar').attr('disabled', true);
} } else {
else
{
// for input // for input
// var formElements = document.querySelectorAll('#myForm input, #myForm textarea'); // var formElements = document.querySelectorAll('#myForm input, #myForm textarea');
// formElements.forEach(function(element) { // formElements.forEach(function(element) {
@ -318,8 +404,9 @@ $(function() {
// element.setAttribute('disabled', false); // element.setAttribute('disabled', false);
// }); // });
} }
}); });
function restriction(event) {
function restriction(event) {
var charCode = event.which || event.keyCode; var charCode = event.which || event.keyCode;
if ((charCode >= 48 && charCode <= 57)) { if ((charCode >= 48 && charCode <= 57)) {
return true; return true;
@ -327,26 +414,24 @@ function restriction(event) {
event.preventDefault(); // Prevent the character from being entered event.preventDefault(); // Prevent the character from being entered
return false; return false;
} }
} }
$(document).ready(function(){ $(document).ready(function() {
$('#org_details_form').hide(); $('#org_details_form').hide();
$('#DonorType').on('change', function() {
$('#DonorType').on('change', function(){
let DonorType = $(this).val(); let DonorType = $(this).val();
if(DonorType === 'option2'){ if (DonorType === 'option2') {
$('#org_details_form').show(); $('#org_details_form').show();
$('#org_name_fie').prop('required', true); $('#org_name_fie').prop('required', true);
$('#pan_no_org').prop('required', true); $('#pan_no_org').prop('required', true);
$('#org_reg_details').prop('required', true); $('#org_reg_details').prop('required', true);
$('#pan_no').prop('required', false); $('#pan_no').prop('required', false);
$('#ind_pan').hide(); $('#ind_pan').hide();
} } else {
else{
$('#org_details_form').hide(); $('#org_details_form').hide();
$('#org_name_fie').prop('required', false); $('#org_name_fie').prop('required', false);
$('#pan_no_org').prop('required', false); $('#pan_no_org').prop('required', false);
@ -357,7 +442,6 @@ $(document).ready(function(){
}) })
}); });
</script> </script>
<!-- Standard modal content --> <!-- Standard modal content -->
@ -369,16 +453,16 @@ $(document).ready(function(){
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form class="needs-validation myForm" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_donor"; ?>" id="myForm" name="myForm"> <form class="needs-validation donorForm" novalidate method="POST" enctype="multipart/form-data" id="donorForm" name="donorForm">
<input type="hidden" name="new_receipt" value="new_receipt"/> <input type="hidden" name="new_receipt" value="new_receipt" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?php echo get_business_id() ?>" /> <input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?php echo get_business_id() ?>" />
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="DonorType" class="col-form-label">Donor Type<span class="text-danger"> *</span></label> <label for="DonorType" class="col-form-label">Donor Type<span class="text-danger"> *</span></label>
<select class="form-control" id="DonorType" name="DonorType" required> <select class="form-control" id="DonorType" name="DonorType" required>
<option value="<?= isset($receipt_details['donor_type']) ? $receipt_details['donor_type'] : '' ?>"><?= isset($receipt_details['donor_type']) ? ($receipt_details['donor_type'] === 'option1' ? 'Individual' : ($receipt_details['donor_type'] === 'option2' ? 'Organization' : 'Select Donor Type')) : 'Select Donor Type'; ?></option> <option value="<?= isset($receipt_details['donor_type']) ? $receipt_details['donor_type'] : '' ?>"><?= isset($receipt_details['donor_type']) ? ($receipt_details['donor_type'] === 'option1' ? 'Individual' : ($receipt_details['donor_type'] === 'option2' ? 'Organization' : '--Select--')) : '--Select--'; ?></option>
<option value="option1">Individual</option> <option value="option1">Individual</option>
<option value="option2">Organization</option> <option value="option2">Organization</option>
</select> </select>
@ -389,15 +473,15 @@ $(document).ready(function(){
<div id="org_details_form"> <div id="org_details_form">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="csname" class="col-form-label">Organization Name<span class="text-danger"> *</span></label> <label for="org_name" class="col-form-label">Organization Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="org_name_fie" name="org_name" value="" placeholder="Organization Name" > <input type="text" class="form-control" id="org_name_fie" name="org_name" value="" placeholder="Organization Name">
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="csname" class="col-form-label"><span class="contactPerson">Organization PAN Number<span class="text-danger"> *</span></label> <label for="o_pan_no" class="col-form-label"><span class="contactPerson">Organization PAN Number<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="pan_no_org" name="o_pan_no" value="" placeholder="PAN Number" oninput="validatePANFormatOrg(this)" /> <input type="text" class="form-control" id="pan_no_org" name="o_pan_no" value="" placeholder="PAN Number" oninput="validatePANFormatOrg(this)" />
<div id="panNoErrors" style="display: none; color: red;">Invalid PAN format</div> <div id="panNoErrors" style="display: none; color: red;">Invalid PAN format</div>
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
@ -406,8 +490,8 @@ $(document).ready(function(){
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="csname" class="col-form-label">Organization Reg Details<span class="text-danger"> *</span></label> <label for="org_reg_Details" class="col-form-label">Organization Reg Details<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="org_reg_details" name="org_reg_Details" value="" placeholder="Organization Reg details"/> <input type="text" class="form-control" id="org_reg_details" name="org_reg_Details" value="" placeholder="Organization Reg details" />
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
@ -424,7 +508,7 @@ $(document).ready(function(){
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="cfname" class="col-form-label"><span class="contactPerson">Contact Person </span>Email<span class="text-danger"> *</span></label> <label for="cmail" class="col-form-label"><span class="contactPerson">Contact Person </span>Email<span class="text-danger"> *</span></label>
<input type="email" class="form-control" id="cmail" name="cmail" value="<?= isset($receipt_details['email']) ? $receipt_details['email'] : '' ?>" placeholder="Email" required /> <input type="email" class="form-control" id="cmail" name="cmail" value="<?= isset($receipt_details['email']) ? $receipt_details['email'] : '' ?>" placeholder="Email" required />
<div class="invalid-feedback"> Please provide a valid email address. </div> <div class="invalid-feedback"> Please provide a valid email address. </div>
</div> </div>
@ -432,7 +516,7 @@ $(document).ready(function(){
<div class="form-row" id="ind_pan"> <div class="form-row" id="ind_pan">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="csname" class="col-form-label">PAN Number<span class="text-danger"> *</span></label> <label for="pan_no" class="col-form-label">PAN Number<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="pan_no" name="pan_no" value="<?= isset($receipt_details['pan_no']) ? $receipt_details['pan_no'] : '' ?>" placeholder="PAN Number" oninput="validatePANFormat(this)" required /> <input type="text" class="form-control" id="pan_no" name="pan_no" value="<?= isset($receipt_details['pan_no']) ? $receipt_details['pan_no'] : '' ?>" placeholder="PAN Number" oninput="validatePANFormat(this)" required />
<div id="panNoError" style="display: none; color: red;">Invalid PAN format</div> <div id="panNoError" style="display: none; color: red;">Invalid PAN format</div>
@ -451,27 +535,27 @@ $(document).ready(function(){
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
</div> </div>
<button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit" hidden></button> <!-- <button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit" hidden></button> -->
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
<button type="button" id="form-submit" class="btn btn-primary">Save changes</button> <button type="button" id="donor-form-submit" class="btn btn-primary">Save changes</button>
</div> </div>
</div><!-- /.modal-content --> </div><!-- /.modal-content -->
</div><!-- /.modal-dialog --> </div><!-- /.modal-dialog -->
</div><!-- /.modal --> </div><!-- /.modal -->
<script> <script>
function validateEmailFormat(email) { function validateEmailFormat(email) {
var emailPattern = /^(.+)@(gmail\.com|yahoo\.com|hotmail\.com|[^@]+\.com\.org)$/i; var emailPattern = /^(.+)@(gmail\.com|yahoo\.com|hotmail\.com|[^@]+\.com\.org)$/i;
if (!emailPattern.test(email)) { if (!emailPattern.test(email)) {
alert("Please provide a valid email addres"); alert("Please provide a valid email addres");
// You can also update the UI to indicate the error, e.g., by adding a class to the input field. // You can also update the UI to indicate the error, e.g., by adding a class to the input field.
// Example: $('#cmail').addClass('is-invalid'); // Example: $('#cmail').addClass('is-invalid');
} }
} }
</script> </script>
<script> <script>
function validatePANFormat(input) { function validatePANFormat(input) {
@ -489,8 +573,8 @@ if (!emailPattern.test(email)) {
</script> </script>
<script> <script>
$(document).ready(function () { $(document).ready(function() {
$('#invoiceDate').on('change', function () { $('#invoiceDate').on('change', function() {
var selectedDate = new Date($(this).val()); var selectedDate = new Date($(this).val());
var currentDate = new Date(); var currentDate = new Date();
@ -500,9 +584,52 @@ if (!emailPattern.test(email)) {
} }
}); });
}); });
function get_donor_details(option) {
$('#donor_mobile').val("");
$('#donor_first_name').val("");
$.ajax({
type: "POST",
url: "<?= base_url() . 'get_donor_details' ?>",
data: {
donor_type: option
},
success: function(response) {
donor = response['data']['donor_details'];
if (donor.length > 0) {
$('#donor_mobile').empty().append($('<option>', {
value: "",
text: "--Select--"
}));
$('#donor_mobile').append($('<option>', {
value: "0",
text: "+ Add a donor"
}));
$('#donor_first_name').empty().append($('<option>', {
value: "",
text: "--Select--"
}));
$('#donor_first_name').append($('<option>', {
value: "0",
text: "+ Add a donor"
}));
$.each(donor, function(k, v) {
$('#donor_mobile').append($('<option>', {
value: v.mobile_no,
text: v.mobile_no
}));
$('#donor_first_name').append($('<option>', {
value: v.donor_id,
text: v.first_name
}));
});
}
},
error: function() {
alert("Error Occur.");
}
});
}
</script> </script>

View File

@ -208,7 +208,7 @@
<input type="hidden" id="setting_id" name="setting_id" placeholder="hidden for setting id" value="<?= isset($details['setting_id']) ? $details['setting_id'] : '' ?>" /> <input type="hidden" id="setting_id" name="setting_id" placeholder="hidden for setting id" value="<?= isset($details['setting_id']) ? $details['setting_id'] : '' ?>" />
<?php if(!empty($details)){ ?> <?php if(!empty($details)){ ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple"> <div class="form-group text-right m-b-0 checkbox checkbox-purple" style="display: none;">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <input type="checkbox" id="isactive" name="isactive" class="form-control"
<?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>> <?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label> <label for="isactive"> Is Active</label>

View File

@ -124,18 +124,22 @@
<span> Dashboard </span> <span> Dashboard </span>
</a> </a>
</li> </li>
<?php if ($loggedin_person_role !== 'sadmin') : ?>
<li> <li>
<a href="<?= base_url()."receipt_list"; ?>"> <a href="<?= base_url()."receipt_list"; ?>">
<i class="fe-file-text"></i> <i class="fe-file-text"></i>
<span> Receipts </span> <span> Receipts </span>
</a> </a>
</li> </li>
<?php endif; ?>
<?php if ($loggedin_person_role !== 'sadmin') : ?>
<li> <li>
<a href="<?= base_url()."Contributor_list"; ?>"> <a href="<?= base_url()."Contributor_list"; ?>">
<i class="ri-map-pin-user-fill"></i> <i class="ri-map-pin-user-fill"></i>
<span> Contributor </span> <span> Contributor </span>
</a> </a>
</li> </li>
<?php endif; ?>
<?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?> <?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?>
<li> <li>
<a href="<?= base_url()."audit_history"; ?>"> <a href="<?= base_url()."audit_history"; ?>">
@ -144,9 +148,6 @@
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?> <?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?>
<li> <li>
<a href="<?= base_url()."causes_list"; ?>"> <a href="<?= base_url()."causes_list"; ?>">
@ -178,15 +179,15 @@
<span> Org Settings </span> <span> Org Settings </span>
</a> </a>
</li> </li>
<?php endif; ?> --> <?php endif; ?>
<?php if ($loggedin_person_role === 'sadmin' && $loggedin_person_role !== 'accounts') : ?> <?php if ($loggedin_person_role === 'sadmin' && $loggedin_person_role !== 'accounts') : ?>
<li> <li>
<a href="<?= base_url()."appsetting_page/1"; ?>"> <a href="<?= base_url()."appsetting_page"; ?>">
<i class="ri-list-settings-line"></i> <i class="ri-list-settings-line"></i>
<span> App Settings </span> <span> App Settings </span>
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?> -->
<?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?> <?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?>
<li> <li>
<a href="<?= base_url()."campaign_list"; ?>"> <a href="<?= base_url()."campaign_list"; ?>">
@ -239,7 +240,7 @@
<ul class="nav-second-level"> <ul class="nav-second-level">
<?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?> <?php if ($loggedin_person_role !== 'volunteer' && $loggedin_person_role !== 'sadmin' && $loggedin_person_role !== 'accounts') : ?>
<li> <li>
<a href="<?= base_url()."donor_group"; ?>"> <a href="<?= base_url()."contributor_group"; ?>">
<i class="ri-team-line"></i> <i class="ri-team-line"></i>
<span> Contributor Groups </span> <span> Contributor Groups </span>
</a> </a>

View File

@ -70,7 +70,7 @@
</div> </div>
<!-- item--> <!-- item-->
<a href="<?= base_url()."user_page/".$loggedin_person_id; ?>" class="dropdown-item notify-item"> <a href="<?= base_url()."user_page/".$loggedin_person_id."/1"; ?>" class="dropdown-item notify-item">
<i class="ri-account-circle-line"></i> <i class="ri-account-circle-line"></i>
<span>My Account</span> <span>My Account</span>
</a> </a>

View File

@ -65,7 +65,7 @@
</div> </div>
<input type="hidden" id="template_id" name="template_id" placeholder="hidden for template id" value="<?= isset($template_details['template_id']) ? $template_details['template_id'] : '' ?>" /> <input type="hidden" id="template_id" name="template_id" placeholder="hidden for template id" value="<?= isset($template_details['template_id']) ? $template_details['template_id'] : '' ?>" />
<?php if (!empty($template_details)) { ?> <?php if (!empty($template_details)) { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple"> <div class="form-group text-right m-b-0 checkbox checkbox-purple" style="display: none;">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($template_details) && $template_details['isactive'] == 1 ? 'checked' : '' ?>> <input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($template_details) && $template_details['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label> <label for="isactive"> Is Active</label>
</div> </div>

View File

@ -25,7 +25,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="role" class="col-form-label">Role<span class="text-danger">*</span></label> <label for="role" class="col-form-label">Role<span class="text-danger">*</span></label>
<select id="role" name="role" class="form-control" required> <select id="role" name="role" class="form-control" required>
<option value="">Select Role</option> <option value="">--Select--</option>
<option value="admin" <?= isset($details['role']) && $details['role'] === 'admin' ? 'selected' : '' ?>>Admin</option> <option value="admin" <?= isset($details['role']) && $details['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
<option value="volunteer" <?= isset($details['role']) && $details['role'] === 'volunteer' ? 'selected' : '' ?>>Volunteer</option> <option value="volunteer" <?= isset($details['role']) && $details['role'] === 'volunteer' ? 'selected' : '' ?>>Volunteer</option>
<option value="accounts" <?= isset($details['role']) && $details['role'] === 'accounts' ? 'selected' : '' ?>>Accounts Staff</option> <option value="accounts" <?= isset($details['role']) && $details['role'] === 'accounts' ? 'selected' : '' ?>>Accounts Staff</option>
@ -33,9 +33,9 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-row">
<?php if ($loggedin_person_role === 'sadmin') { ?> <?php if ($loggedin_person_role === 'sadmin') { ?>
<div class="form-group col-md-3"> <div class="form-row">
<div class="form-group col-md-6">
<label for="business_id" class="col-form-label">Organization<span class="text-danger">*</span></label> <label for="business_id" class="col-form-label">Organization<span class="text-danger">*</span></label>
<select id="business_id" name="business_id" class="form-control" required> <select id="business_id" name="business_id" class="form-control" required>
<?php foreach ($business_details as $business) { ?> <?php foreach ($business_details as $business) { ?>
@ -45,7 +45,7 @@
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-6">
<label for="F" class="col-form-label">Organization Branches<span class="text-danger">*</span></label> <label for="F" class="col-form-label">Organization Branches<span class="text-danger">*</span></label>
<select id="branch_id" name="branch_id" class="form-control" required> <select id="branch_id" name="branch_id" class="form-control" required>
<?php if (!empty($branches)) { ?> <?php if (!empty($branches)) { ?>
@ -59,7 +59,9 @@
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
</div>
<?php } ?> <?php } ?>
<div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="email" class="col-form-label">Email<span class="text-danger">*</span></label> <label for="email" class="col-form-label">Email<span class="text-danger">*</span></label>
<input type="email" class="form-control" id="email" name="email" placeholder="Email" value="<?= isset($details['email']) ? $details['email'] : '' ?>" required /> <input type="email" class="form-control" id="email" name="email" placeholder="Email" value="<?= isset($details['email']) ? $details['email'] : '' ?>" required />
@ -70,51 +72,41 @@
<input type="text" class="form-control" id="password" name="password" placeholder="Password" value="<?= isset($details['password']) ? $details['password'] : '' ?>" required /> <input type="text" class="form-control" id="password" name="password" placeholder="Password" value="<?= isset($details['password']) ? $details['password'] : '' ?>" required />
</div> </div>
<?php } ?> <?php } ?>
<?php if ($loggedin_person_role !== 'sadmin') : ?>
<div class="form-group col-md-4">
<label for="branch" class="col-form-label">Branch<span class="text-danger"></span></label>
<select id="branch" name="branch" class="form-control">
<option value="">--Select--</option>
<?php if (!empty($branches)) {
foreach ($branches as $branch) { ?>
<option data-business-id="<?= $branch['business_id']; ?>" value="<?= $branch['id']; ?>" <?= isset($details['branch_id']) && ($details['branch_id'] == $branch['id']) ? 'selected' : '' ?>>
<?= $branch['branch_name']; ?>
</option>
<?php }
} ?>
</select>
</div>
<?php endif; ?>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="address" class="col-form-label">Address<span class="text-danger"></span></label> <label for="address" class="col-form-label">Address<span class="text-danger"></span></label>
<input type="text" class="form-control" id="address" name="address" placeholder="Address (eg : 1234 Main St)" value="<?= isset($details['address']) ? $details['address'] : '' ?>" /> <input type="text" class="form-control" id="address" name="address" placeholder="Address (eg : 1234 Main St)" value="<?= isset($details['address']) ? $details['address'] : '' ?>" />
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-3">
<label for="city" class="col-form-label">City<span class="text-danger"></span></label> <label for="city" class="col-form-label">City<span class="text-danger"></span></label>
<input type="text" class="form-control" id="city" name="city" placeholder="City" value="<?= isset($details['city']) ? $details['city'] : '' ?>" /> <input type="text" class="form-control" id="city" name="city" placeholder="City" value="<?= isset($details['city']) ? $details['city'] : '' ?>" />
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-3">
<label for="state" class="col-form-label">State<span class="text-danger"></span></label> <label for="state" class="col-form-label">State<span class="text-danger"></span></label>
<input type="text" class="form-control" id="state" name="state" placeholder="State" value="<?= isset($details['state']) ? $details['state'] : '' ?>" /> <input type="text" class="form-control" id="state" name="state" placeholder="State" value="<?= isset($details['state']) ? $details['state'] : '' ?>" />
</div> </div>
</div> <div class="form-group col-md-2">
<div class="form-row">
<div class="form-group col-md-4">
<label for="postal_code" class="col-form-label">Postal Code<span class="text-danger"></span></label> <label for="postal_code" class="col-form-label">Postal Code<span class="text-danger"></span></label>
<input data-parsley-type="number" type="text" class="form-control" id="postal_code" name="postal_code" placeholder="Postal Code (PIN)" value="<?= isset($details['postal_code']) ? $details['postal_code'] : '' ?>" pattern="[0-9]{6}" maxlength="6" /> <input data-parsley-type="number" type="text" class="form-control" id="postal_code" name="postal_code" placeholder="Postal Code (PIN)" value="<?= isset($details['postal_code']) ? $details['postal_code'] : '' ?>" pattern="[0-9]{6}" maxlength="6" />
</div> </div>
<!-- <div class="form-group col-md-4">
<label for="profile_picture" class="col-form-label">Profile Picture</label>
<input type="file" name="profile_picture" value="" accept="image/*" onchange="validateFile(this)" />
<div id="error_message" style="color: red;"></div>
</div> -->
<?php if ($loggedin_person_role !== 'sadmin') : ?>
<div class="form-group col-md-4">
<label for="branch" class="col-form-label">Branch<span class="text-danger"></span></label>
<select id="branch" name="branch" class="form-control">
<option value="">Select Branch</option>
<?php
// Check if branches are available
if (!empty($branches)) {
foreach ($branches as $branch) {
?>
<option data-business-id="<?= $branch['business_id']; ?>" value="<?= $branch['id']; ?>" <?= isset($details['branch_id']) && ($details['branch_id'] == $branch['id']) ? 'selected' : '' ?>>
<?= $branch['branch_name']; ?>
</option>
<?php
}
}
?>
</select>
</div> </div>
<?php endif; ?> <div class="form-row">
<?php if (!empty($details['profile_picture'])) { ?> <?php if (!empty($details['profile_picture'])) { ?>
<div class="form-group col-md-4 mt-3"> <div class="form-group col-md-4 mt-3">
<div class="media"> <div class="media">
@ -129,23 +121,22 @@
<?php } ?> <?php } ?>
</div> </div>
<input type="hidden" id="user_id" name="user_id" placeholder="hidden for user id" value="<?= isset($details['user_id']) ? $details['user_id'] : '' ?>" /> <input type="hidden" id="user_id" name="user_id" placeholder="hidden for user id" value="<?= isset($details['user_id']) ? $details['user_id'] : '' ?>" />
<input type="hidden" id="dummy_flag" name="dummy_flag" placeholder="hidden for dummy flag redirect purpose" value="<?= isset($dummy_flag) ? $dummy_flag : '' ?>" />
<?php if (!empty($details) && $loggedin_person_role !== 'volunteer') { ?> <?php if (!empty($details) && $loggedin_person_role !== 'volunteer') { ?>
<div class="form-group text-right m-b-0 checkbox checkbox-purple"> <div class="form-group text-right m-b-0 checkbox checkbox-purple" style="display: none;">
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>> <input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>>
<label for="isactive"> Is Active</label> <label for="isactive"> Is Active</label>
</div> </div>
<br> <br>
<?php } ?> <?php } ?>
<!-- ... (existing code) -->
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn"> <button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">
Save <?= isset($details['user_id']) ? 'Update' : 'Save' ?>
</button> </button>
<?php if (isset($success_message)) : ?> <?php if (isset($success_message)) : ?>
<div class="alert alert-success"><?= esc($success_message) ?></div> <div class="alert alert-success"><?= esc($success_message) ?></div>
<?php endif; ?> <?php endif; ?>
<?php if ($loggedin_person_role !== 'volunteer') : ?> <?php if ($loggedin_person_role !== 'volunteer') : ?>
@ -162,10 +153,10 @@
// Redirect to the user list // Redirect to the user list
$redirect_url = base_url() . "user_list"; $redirect_url = base_url() . "user_list";
} }
?> ?>
<a href="<?= $redirect_url; ?>" class="btn btn-secondary waves-effect">Cancel</a> <a href="<?= $redirect_url; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<!-- --> <!-- -->
<?php endif; ?> <?php endif; ?>
@ -184,8 +175,7 @@
$(function() { $(function() {
role = "<?php echo get_user_role() ?>"; role = "<?php echo get_user_role() ?>";
console.log(role); console.log(role);
if(role == "auditor") if (role == "auditor") {
{
// for input // for input
var formElements = document.querySelectorAll('#myForm input, #myForm textarea'); var formElements = document.querySelectorAll('#myForm input, #myForm textarea');
formElements.forEach(function(element) { formElements.forEach(function(element) {
@ -254,26 +244,26 @@
}); });
</script> </script>
<script> <script>
$(document).ready(function () { $(document).ready(function() {
// Function to fetch branches based on selected organization // Function to fetch branches based on selected organization
function fetchBranches(selectedBusinessId, preSelectedBranchId) { function fetchBranches(selectedBusinessId, preSelectedBranchId) {
var businessBranchDropdown = $('#branch_id'); var businessBranchDropdown = $('#branch_id');
// Clear existing options // Clear existing options
businessBranchDropdown.empty().append('<option value="">Choose Organization Branch</option>'); businessBranchDropdown.empty().append('<option value="">--Select--</option>');
// Fetch branches via AJAX // Fetch branches via AJAX
$.ajax({ $.ajax({
url: '<?= base_url('users/get_branches') ?>/' + selectedBusinessId, url: '<?= base_url('users/get_branches') ?>/' + selectedBusinessId,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
success: function (response) { success: function(response) {
console.log('Response from server:', response); // Log the response for debugging console.log('Response from server:', response); // Log the response for debugging
if (response && response.length > 0) { if (response && response.length > 0) {
console.log('Number of branches:', response.length); // Log the number of branches console.log('Number of branches:', response.length); // Log the number of branches
$.each(response, function (index, branch) { $.each(response, function(index, branch) {
console.log('Appending option:', branch); // Log each branch before appending console.log('Appending option:', branch); // Log each branch before appending
var option = $('<option></option>').attr('value', branch.id).text(branch.branch_name); var option = $('<option></option>').attr('value', branch.id).text(branch.branch_name);
@ -290,14 +280,14 @@
businessBranchDropdown.append('<option value="">No branches available</option>'); businessBranchDropdown.append('<option value="">No branches available</option>');
} }
}, },
error: function (error) { error: function(error) {
console.error('Error fetching branches:', error); console.error('Error fetching branches:', error);
} }
}); });
} }
// Change event handler for the organization dropdown // Change event handler for the organization dropdown
$('#business_id').change(function () { $('#business_id').change(function() {
var selectedBusinessId = $(this).val(); var selectedBusinessId = $(this).val();
console.log('Selected Business ID:', selectedBusinessId); // Log the selected business ID console.log('Selected Business ID:', selectedBusinessId); // Log the selected business ID
@ -315,7 +305,7 @@
}); });
</script> </script>
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function() {
// Get the form group element // Get the form group element
var formGroup = document.querySelector('.form-group.text-right.checkbox.checkbox-purple'); var formGroup = document.querySelector('.form-group.text-right.checkbox.checkbox-purple');

View File

@ -3,7 +3,7 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="float-right"> <div class="float-right">
<a href="<?= base_url()."user_page/0"; ?>" class="btn btn-primary"><i class="ri-user-add-line"></i> Add User </a> <a href="<?= base_url()."user_page/0/0"; ?>" class="btn btn-primary"><i class="ri-user-add-line"></i> Add User </a>
</div><!-- end col--> </div><!-- end col-->
<br> <br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4> <h4 class="header-title mb-3"><?= $page_name; ?></h4>
@ -54,7 +54,7 @@
$class = 'badge badge-soft-danger'; $class = 'badge badge-soft-danger';
$message = 'In-Active'; $message = 'In-Active';
} }
$edit_page_route = base_url()."user_page/".$row['user_id']; $edit_page_route = base_url()."user_page/".$row['user_id']."/0";
$addressParts = array( $addressParts = array(
$row['address'], $row['address'],
$row['city'], $row['city'],