diff --git a/.env b/.env index 13f6ad3..baef502 100644 --- a/.env +++ b/.env @@ -15,13 +15,13 @@ #-------------------------------------------------------------------- # CI_ENVIRONMENT = production -#CI_ENVIRONMENT = development +CI_ENVIRONMENT = development #LOCAL_FOLDER = 'donation' #-------------------------------------------------------------------- # APP #-------------------------------------------------------------------- -# app.baseURL = 'http://localhost/donation/' +app.baseURL = 'http://localhost/donation/' # app.baseURL ='https://venbainfotech.com/donr/' # app.forceGlobalSecureRequests = false @@ -63,6 +63,19 @@ # database.tests.password = root # database.tests.DBDriver = MySQLi + +database.default.hostname = localhost +database.default.database = doner_management +database.default.username = root +database.default.password = '' +database.default.DBDriver = MySQLi + +database.tests.hostname = localhost +database.tests.database = doner_management +database.tests.username = root +database.tests.password = '' +database.tests.DBDriver = MySQLi + #-------------------------------------------------------------------- # CONTENT SECURITY POLICY #-------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index b24d71e..9ce12c6 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ Thumbs.db *.mov *.wmv +writable/session/ +writable/debugbar/ diff --git a/app/Config/Routes.php b/app/Config/Routes.php index aaa888a..579b82a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -71,9 +71,9 @@ $routes->get("new_bussiness/(:any)", "Business::new_bussiness/$1"); $routes->post("insert_business/", "Business::insert_business"); $routes->get("delete_business/(:any)", "Business::delete_business/$1"); -# Doner Routes -$routes->get("doner_list/", "Customer::index"); -$routes->get("new_doner/(:any)", "Customer::new_doner/$1"); +# Donor Routes +$routes->get("Donor_list/", "Customer::index"); +$routes->get("new_Donor/(:any)", "Customer::new_Donor/$1"); $routes->post("insert_customer", "Customer::insert_customer"); $routes->get("delete_customer/(:any)", "Customer::delete_customer/$1"); diff --git a/app/Controllers/Authentication.php b/app/Controllers/Authentication.php index d67b116..37ab968 100644 --- a/app/Controllers/Authentication.php +++ b/app/Controllers/Authentication.php @@ -248,7 +248,9 @@ class Authentication extends BaseController $this->response->setHeader('Pragma', 'no-cache'); $this->response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT'); $data = []; - return view('auth_logout', $data); + + return redirect()->route('login'); + // return view('auth_logout', $data); } ## Lock Screen - holded diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 527ebe3..907d415 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -78,6 +78,8 @@ abstract class BaseController extends Controller $session_uid = get_logged_user_id(); $session_uname = get_logged_name(); + + // echo $session_uname; die; $mergedData = array_merge($data, $this->authData); $mergedData['browser_title']= $mergedData['company_name'] . ' | ' . $mergedData['company_short_name'] . ' ' . $mergedData['page_name']; diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index 82d6471..e5c2fce 100644 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -81,7 +81,7 @@ class Books extends BaseController $causes_id = $BooksModel->insert($data); - if ($BooksModel->insert($data)) { + if ($causes_id) { session()->setFlashdata('success', 'causes successfully created.'); $this->logger->info("Books: has been added successfully. Inserted ID = " . $BooksModel->insertID()); } else { diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php index 0ef06c7..c7c1482 100644 --- a/app/Controllers/Business.php +++ b/app/Controllers/Business.php @@ -22,7 +22,7 @@ class Business extends BaseController } $BusinessModel = new BusinessModel(); $data['page_name'] = 'Organization Details'; - $data['businesses'] = $BusinessModel->where($where)->findAll(); + $data['businesses'] = $BusinessModel->where($where)->where('business_id !=', 0)->findAll(); // $data['lastQuery'] = $BusinessModel->getLastQuery(); // print_r($data);die; $this->render_page('business_list', $data); @@ -33,10 +33,13 @@ class Business extends BaseController ## To Load Business Form (Add/Update) public function new_bussiness($id) - { + { + helper('session'); + $session_role = get_user_role(); if ($id === '0') { $data['page_name'] = 'Add Organization'; + $data['loged_user'] = $session_role; $data['businesses'] = []; } else if ($id !== '0') { $data['page_name'] = 'Edit Organization'; @@ -58,6 +61,7 @@ class Business extends BaseController helper('session'); $session_uid = get_logged_user_id(); $session_role = get_user_role(); + $img = $this->request->getFile('bfile'); $business_id = $this->request->getPost('business_id'); @@ -110,8 +114,13 @@ class Business extends BaseController $data['updated_by'] = $session_uid; $BusinessModel->update($business_id, $data); } - + + if (empty($business_id)) { + return redirect()->route('business_list'); + }else{ return redirect()->route('dashboard'); + } + } ## For delete the business details (Which means inactive the details) diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index e8f6e4c..055572e 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -16,15 +16,15 @@ class Customer extends BaseController $session_role = get_user_role(); $session_bid = get_business_id(); if (!empty($session_role) && $session_role !== "sadmin") { - $this->logger->info("Doner: Listing In admin role . BID = ".$session_bid); + $this->logger->info("Donor: Listing In admin role . BID = ".$session_bid); $where = ['isactive' => 1, 'business_id' => (int)$session_bid]; } else { - $this->logger->info("Doner: Listing In Super-admin role ."); + $this->logger->info("Donor: Listing In Super-admin role ."); $where = ['isactive != ' => NULL]; } $CustomerModel = new CustomerModel(); - $data['page_name'] = 'Doner Details'; + $data['page_name'] = 'Donor Details'; $data['customer'] = $CustomerModel->where($where)->orderBy('doner_id', 'DESC')->findAll(); // print_r($data); die(); @@ -35,22 +35,21 @@ class Customer extends BaseController } } - ## To Load Doner Form (Add/Update) - public function new_doner($id) + ## To Load Donor Form (Add/Update) + public function new_Donor($id) { helper('session'); $session_bid = get_business_id(); if ($id === '0') { - // Add Doner - $data['page_name'] = 'Add Doner Details'; + // Add Donor + $data['page_name'] = 'Add Donor Details'; $data['customer'] = []; } else if ($id !== '0') { - // Edit Doner - $data['page_name'] = 'Edit Doner Details'; - - // Load your Customer Model + + // Edit Donor + $data['page_name'] = 'Edit Donor Details'; $customerModel = new CustomerModel(); // Retrieve customer details by customer ID @@ -74,7 +73,7 @@ class Customer extends BaseController { $requestData = $this->request->getPost(); // print_r($requestData);die; - $this->logger->info("Doner: Inserting/Updating Details"); + $this->logger->info("Donor: Inserting/Updating Details"); try { helper('session'); $session_bid = get_business_id(); @@ -90,7 +89,7 @@ class Customer extends BaseController 'email' => $this->request->getPost('cmail'), 'date_of_birth' => $dob, 'pan_no' => $this->request->getPost('pan_no'), - 'doner_type' => $this->request->getPost('donerType'), + 'doner_type' => $this->request->getPost('DonorType'), 'org_name' => $this->request->getPost('org_name') !== '' || $this->request->getPost('org_name') !== null ? $this->request->getPost('org_name') : NULL, 'address' => $this->request->getPost('address'), 'city' => $this->request->getPost('city'), @@ -110,12 +109,12 @@ class Customer extends BaseController $data['isactive'] = 1; $data['created_by'] = $session_uid; if ($model->insert($data)) { - session()->setFlashdata('success', 'Doner successfully created.'); - $this->logger->info("Doner : has been added successfully. Inserted ID = " . $model->insertID()); - $doner_id_for_addresses = $model->insertID();// for Doner ADDRESS Table + session()->setFlashdata('success', 'Donor successfully created.'); + $this->logger->info("Donor : has been added successfully. Inserted ID = " . $model->insertID()); + $doner_id_for_addresses = $model->insertID();// for Donor ADDRESS Table } else { - session()->setFlashdata('error', 'Doner could not be added. Please try again..'); - $this->logger->error("Doner: Err could not be added. Please try again."); + session()->setFlashdata('error', 'Donor could not be added. Please try again..'); + $this->logger->error("Donor: Err could not be added. Please try again."); $doner_id_for_addresses = ""; } } else { @@ -127,98 +126,31 @@ class Customer extends BaseController $data['updated_by'] = $session_uid; $doner_id_for_addresses = $doner_id; // for Customer ADDRESS Table if ($model->update($doner_id, $data)) { - session()->setFlashdata('success', 'Doner successfully updated'); - $this->logger->info("Doner: has been updated successfully. Updated Doner ID = " . $doner_id_for_addresses); + session()->setFlashdata('success', 'Donor successfully updated'); + $this->logger->info("Donor: has been updated successfully. Updated Donor ID = " . $doner_id_for_addresses); } else { - session()->setFlashdata('error', 'Doner updation failed. Please try again.'); - $this->logger->error("Doner: Err Failed to update ID =" . $doner_id_for_addresses); + session()->setFlashdata('error', 'Donor updation failed. Please try again.'); + $this->logger->error("Donor: Err Failed to update ID =" . $doner_id_for_addresses); } } // if($doner_id_for_addresses != ""){ - // $this->logger->info("Doner: i got Doner id for addresses = " . $doner_id_for_addresses); + // $this->logger->info("Donor: i got Donor id for addresses = " . $doner_id_for_addresses); // $requestData = $this->request->getPost(); // $bill_addr = $this->save_customer_addresses($doner_id_for_addresses, $requestData, 'b'); // $this->logger->info("Customer: bill addr final message = " .implode(" ",$bill_addr)); // $ship_addr = $this->save_customer_addresses($doner_id_for_addresses, $requestData, 's'); - // $this->logger->info("Doner: Ship addr final message = " . implode(" ",$ship_addr)); + // $this->logger->info("Donor: Ship addr final message = " . implode(" ",$ship_addr)); // } } catch (\Exception $e) { - $this->logger->error("Doner : Err Occur =" . $e->getMessage()); + $this->logger->error("Donor : Err Occur =" . $e->getMessage()); session()->setFlashdata('error', 'Message: ' . $e->getMessage()); } - return redirect()->route('doner_list'); + return redirect()->route('Donor_list'); } - ## For Save the customer addresses details (Using Letting Flag and Customer ID) - // public function save_customer_addresses($id, $requestData, $letteringflag) - // { - // try { - // $addressType = ($letteringflag == 'b') ? 1 : 2; - // $this->logger->info("Doner: Addresses Lettering Flag = " . $letteringflag . " Doner address type = " . $addressType); - // $getAddressdetails = $this->get_customer_address($id, $addressType); - // $CAid = $requestData[$letteringflag . 'customer_address_id']; // Available Address IDS in Form Fields. - // $session_uid = get_logged_user_id(); - // $model = new CustomerModel(); - // ## IF Any Missing value Means that values are Inactive here.... - // if(!empty($CAid)){ - // $this->logger->info("Doner: Primary Addresses ID = ".implode(",",$CAid)); - // $filteringAddressIds = []; - // for ($y = 0; $y < count($getAddressdetails); $y++) { - // $filteringAddressIds[$y] = $getAddressdetails[$y]['customer_address_id']; - // } - // if (!empty($filteringAddressIds)) { - // $A = $filteringAddressIds; - // $B = $CAid; - // $missingValues = array_diff($A, $B); - // if (!empty($missingValues)) { - // $where = ['isactive' => 1, 'doner_id' => (int)$id, 'address_type' => $addressType]; - // $model->inactiveMissingAddressDetails($where, $missingValues); - // $this->logger->info("Doner: Inactived Missing Addresses Count = " . count($missingValues)." That Primary Addresses ID = ".implode(",",$CAid)); - // } - // } - // } - - - // $baddress1 = $requestData[$letteringflag . 'address1']; - // $baddress2 = $requestData[$letteringflag . 'address2']; - // $bcountry = $requestData[$letteringflag . 'country']; - // $bcity = $requestData[$letteringflag . 'city']; - // $binputstate = $requestData[$letteringflag . 'istate']; - // $bdropdownstate = $requestData[$letteringflag . 'dstate']; - // $bzip = $requestData[$letteringflag . 'zip']; - // $count = count($CAid); - // $address_array = []; - // if ($count > 0) { - // for ($x = 0; $x < $count; $x++) { - // $address_array[$x]['first_name'] = $requestData['cfname']; - // $address_array[$x]['last_name'] = $requestData['csname']; - // // $address_array[$x]['company'] = ""; - // $address_array[$x]['email'] = $requestData['cmail']; - // $address_array[$x]['mobile_no'] = $requestData['cmobile']; - // $address_array[$x]['address_1'] = $baddress1[$x]; - // $address_array[$x]['address_2'] = $baddress2[$x]; - // $address_array[$x]['city'] = $bcity[$x]; - // $address_array[$x]['state'] = $bcountry[$x] === 'IN' ? $bdropdownstate[$x] : $binputstate[$x] ; - // $address_array[$x]['country'] = $bcountry[$x]; - // $address_array[$x]['postal_code'] = $bzip[$x]; - // $address_array[$x]['doner_id'] = $id; - // $address_array[$x]['address_type'] = $addressType; - // $address_array[$x]['created_by'] = $session_uid; - // $address_array[$x]['updated_by'] = $CAid[$x] ? $session_uid : null; - // $address_array[$x]['customer_address_id'] = $CAid[$x]; - // } - // $statement = !empty($address_array) ? $model->saveAddressDetails($address_array) : ["No data found For addresses"]; - // $this->logger->info("Doner: Address Final message = " . implode(",",$statement)); - // } - // } catch (\Exception $e) { - // $this->logger->error("Doner: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); - // $statement = ['Message: ' . $e->getMessage()]; - // } - // return $statement; - // } ## For delete the customer details (Which means inactive the details) public function delete_customer($id) @@ -228,31 +160,18 @@ class Customer extends BaseController $session_uid = get_logged_user_id(); $CustomerModel = new CustomerModel(); $where = ['doner_id' => (int)$id, 'isactive =' => 1]; + // Check if the business ID exists $existingCustomer = $CustomerModel->where($where)->find($id); if ($existingCustomer) { - $this->logger->Info("Doner: Going to Inactive ID = ".$id); + $this->logger->Info("Donor: Going to Inactive ID = ".$id); $data = ['isactive' => 0 , 'updated_by' => $session_uid]; // Delete the business record if ($CustomerModel->update($id, $data)) { - $billAddressdetails = $this->get_customer_address($id, 1); - if(!empty($billAddressdetails)){ - for ($y = 0; $y < count($billAddressdetails); $y++) { - $billAddressIds[$y] = $billAddressdetails[$y]['customer_address_id']; - } - $CustomerModel->inactiveMissingAddressDetails($where, $billAddressIds); - } - $shipAddressdetails = $this->get_customer_address($id, 2); - if(!empty($shipAddressdetails)){ - for ($z = 0; $z < count($shipAddressdetails); $z++) { - $shipAddressIds[$z] = $shipAddressdetails[$z]['customer_address_id']; - } - $CustomerModel->inactiveMissingAddressDetails($where, $shipAddressIds); - } - session()->setFlashdata('success', 'Doner successfully deleted.'); - $this->logger->info("Doner: has been Inactived successfully. Inactived ID = " . $id); + session()->setFlashdata('success', 'Donor successfully deleted.'); + $this->logger->info("Donor: has been Inactived successfully. Inactived ID = " . $id); } else { - $this->logger->error("Doner: Not able to Inactive ID =" . $id); + $this->logger->error("Donor: Not able to Inactive ID =" . $id); throw new \Exception("Data Not able to Deleted"); } } @@ -260,7 +179,7 @@ class Customer extends BaseController $this->logger->error("Customer: Err Occur = " . $e->getMessage()); session()->setFlashdata('error', 'Message: ' . $e->getMessage()); } - return redirect()->route('doner_list'); + return redirect()->route('Donor_list'); } public function get_customer_address($id,$type){ @@ -288,25 +207,27 @@ class Customer extends BaseController } public function customer_group(){ - $data['page_name'] = 'Doner Group Details'; + + $session_bid = get_business_id(); + $data['page_name'] = 'Donor Group Details'; $model = new CustomerModel(); - $data['customer_group'] = $model->getGroupDetails(); + $data['customer_group'] = $model->getGroupDetails($session_bid); $this->render_page('customer_group', $data); } + + public function view_customer_group($id){ + helper('session'); $session_bid = get_business_id(); $data['field'] = [ - ['value'=>'','fieldflag'=>1,'text'=> 'Choose the Field','disable' => false], - ['value'=>'C.type','fieldflag'=>1,'text'=> 'Type','disable' => false], - ['value'=>'CA.city','fieldflag'=>1,'text'=> 'City','disable' => false], - // ['value'=>'CA.state','fieldflag'=>1,'text'=> 'State','disable' => false], - ['value'=>'CA.postal_code','fieldflag'=>1,'text'=> 'Postal Code','disable' => false], - ['value'=>'C.mode','fieldflag'=>3,'text'=> 'Mode','disable' => false], - ['value'=>'CM.name','fieldflag'=>1,'text'=> 'Category','disable' => false], - ['value'=>'I.invoice_date','fieldflag'=>2,'text'=> 'Invoice Date','disable' => false], - ['value'=>'S.to_subscription','fieldflag'=>2,'text'=> 'Expiry Date','disable' => false]]; + ['value'=>'', 'fieldflag'=>1, 'text'=> 'Choose the Field', 'disable' => false], + ['value'=>'C.doner_type', 'fieldflag'=>1, 'text'=> 'Donor Type', 'disable' => false], + ['value'=>'C.city', 'fieldflag'=>1, 'text'=> 'City', 'disable' => false], + ['value'=>'C.postal_code', 'fieldflag'=>1, 'text'=> 'Postal Code', 'disable' => false], + ['value'=>'I.receipt_date', 'fieldflag'=>2, 'text'=> 'Receipt Date', 'disable' => false], + ]; $data['operator'] = [ '' => 'Choose the operator', @@ -324,12 +245,13 @@ class Customer extends BaseController 'is not null' => 'Is Not NULL', ]; $data['customer_group'] = []; + if ($id === '0') { // Add Customer - $data['page_name'] = 'Add Doner Group'; + $data['page_name'] = 'Add Donor Group'; } else if ($id !== '0') { // Edit Customer - $data['page_name'] = 'Edit Doner Group'; + $data['page_name'] = 'Edit Donor Group'; // Load your Customer Model $model = new CustomerModel(); @@ -348,6 +270,8 @@ class Customer extends BaseController } $this->render_page('customer_group_form', $data); } + + public function preview_customer_group($id){ try { helper('session'); @@ -357,7 +281,7 @@ class Customer extends BaseController $result = $model->where($where)->findAll(); $db = \Config\Database::connect(); $sql = (string)$result[0]['group_query']; - //print_r($sql);die; + if($sql){ $query = $db->query($sql); $results = $query->getResultArray(); @@ -371,7 +295,7 @@ class Customer extends BaseController } } catch (\Exception $e) { - $this->logger->error("Doner Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); + $this->logger->error("Donor Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); session()->setFlashdata('error', 'Message: ' . $e->getMessage()); } } @@ -384,7 +308,7 @@ class Customer extends BaseController $where = ['isactive' => 1,'group_id'=>(int)$id]; $result = $model->where($where)->findAll(); if ($result) { - $this->logger->Info("Doner Group: Going to Inactive ID = ".$id); + $this->logger->Info("Donor Group: Going to Inactive ID = ".$id); $data = ['isactive' => 0 , 'updated_by' => $session_uid,'group_id'=>(int)$id]; $statement = $model->saveGroupDetails($data);// just updating Inactive status only. if ($statement['success']) { @@ -394,34 +318,37 @@ class Customer extends BaseController session()->setFlashdata('error', $statement['error']); $this->logger->error($statement['log']); }else{ - throw new \Exception("Doner Group: Err Occur on data the Doner Group Inactive"); + throw new \Exception("Donor Group: Err Occur on data the Donor Group Inactive"); } } } catch (\Exception $e) { - $this->logger->error("Doner Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); + $this->logger->error("Donor Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); session()->setFlashdata('error', 'Message: ' . $e->getMessage()); } return redirect()->route('customer_group'); } - public function insert_customer_group(){ - + public function insert_customer_group(){ try { - $this->logger->info("Doner Group: Inserting/Updating Details"); + $this->logger->info("Donor Group: Inserting/Updating Details"); helper('session'); $session_uid = get_logged_user_id(); $request_data = $this->request->getPost(); $string_flag = $request_data['string_flag']; // $this->logger->info("Customer Group: Request data = ".json_encode($request_data)); - + + $session_bid = get_business_id(); $model = new CustomerModel(); // Array ( [groupname] => nil [column] => Array ( [0] => city [1] => state ) [operator] => Array ( [0] => not contain [1] => not equal ) [values] => Array ( [0] => 2 [1] => 3 ) ) $data = [ - 'group_name' => $request_data['groupname'], - 'column' => serialize($request_data['column']), - 'operator' => serialize($request_data['operator']), - 'value' => serialize($request_data['values']) + 'group_name' => $request_data['groupname'], + 'column' => serialize($request_data['column']), + 'operator' => serialize($request_data['operator']), + 'value' => serialize($request_data['values']), ]; + + $data['business_id'] = $session_bid; + // Initialize an empty array to store the conditions $conditions = array(); @@ -488,15 +415,15 @@ class Customer extends BaseController // Now you can use $whereCondition in your SQL query $db = \Config\Database::connect(); // $sql = "SELECT doner_id,CONCAT(first_name,'',last_name) as customer_name,email,mobile_no FROM customers WHERE ".$whereCondition; - $sql = "SELECT CA.city,CA.state,I.invoice_date,C.doner_id,CONCAT(C.first_name,'',C.last_name) as customer_name,C.email,C.mobile_no ,S.to_subscription as due_date, C.isactive ,count(I.invoice_id) as invoice_count_raised_by_customer, S.scheme_id , CM.name - FROM customers as C - LEFT JOIN invoice I on I.doner_id = C.doner_id and I.isactive = 1 - LEFT JOIN customer_addresses CA on CA.doner_id = C.doner_id and CA.address_type = 1 and CA.isactive = 1 - LEFT JOIN subscription S on S.doner_id = C.doner_id - LEFT JOIN book_categories BC on BC.book_id = S.scheme_id - LEFT JOIN category CM on CM.id = BC.category_id - WHERE C.isactive = 1 AND ".$whereCondition." GROUP BY C.doner_id"; + $sql = "SELECT C.city, C.state, I.receipt_date, C.doner_id, CONCAT(C.first_name, ' ', C.last_name) as customer_name, C.email, C.mobile_no, C.isactive, COUNT(I.receipt_id) as invoice_count_raised_by_customer FROM customers as C + LEFT JOIN receipt I ON I.doner_id = C.doner_id and I.isactive = 1 + WHERE C.isactive = 1 AND " . $whereCondition . " + GROUP BY C.doner_id"; + $this->logger->info("Customer Group: SQL = ".$sql); + + // echo "$sql"; die; + // Execute the query $query = $db->query($sql); @@ -520,7 +447,7 @@ class Customer extends BaseController session()->setFlashdata('error', $statement['error']); $this->logger->error($statement['log']); }else{ - throw new \Exception("Doner Group: Err Occur on data the Save"); + throw new \Exception("Donor Group: Err Occur on data the Save"); } }else if($string_flag == "preview"){ @@ -529,7 +456,7 @@ class Customer extends BaseController throw new \Exception("Data Not Found"); } } catch (\Exception $e) { - $this->logger->error("Doner Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); + $this->logger->error("Donor Group: Err Occur = ".$e->getMessage()." File = ". $e->getFile() . " Line = " . $e->getLine()); session()->setFlashdata('error', 'Message: ' . $e->getMessage()); } return redirect()->route('customer_group'); diff --git a/app/Controllers/Event.php b/app/Controllers/Event.php index 7c52506..77debcc 100644 --- a/app/Controllers/Event.php +++ b/app/Controllers/Event.php @@ -64,7 +64,7 @@ class Event extends BaseController public function insert_event() { - $this->logger->info("Event: Inserting/Updating Details"); + $this->logger->info("campaign: Inserting/Updating Details"); try { helper('session'); $session_bid = get_business_id(); @@ -87,43 +87,31 @@ class Event extends BaseController if (empty($campaign_id)) { // It's an insert operation $data['created_by'] = $session_uid; - - // echo '
';
-                // print_r($data);
-
-                // $value = $EventModel->insert($data);
-                // $builder = $EventModel;
-
-                // // Get the last run query
-                // $lastQuery = $builder->getLastQuery();
-
-                // // Output or log the last query
-                // echo $lastQuery; die;
 
                 if ($EventModel->insert($data)) {
 
-                    session()->setFlashdata('success', 'Event has been added successfully.');
-                    $this->logger->info("Event : has been added successfully. Inserted ID = " . $EventModel->insertID());
+                    session()->setFlashdata('success', 'campaign has been added successfully.');
+                    $this->logger->info("campaign : has been added successfully. Inserted ID = " . $EventModel->insertID());
                 } else {
-                    session()->setFlashdata('error', 'Event could not be added. Please try again..');
-                    $this->logger->error("Event: Err data could not be added. Please try again.");
+                    session()->setFlashdata('error', 'campaign could not be added. Please try again..');
+                    $this->logger->error("campaign: Err data could not be added. Please try again.");
                 }
             } else {
                 // It's an update operation
                 $data['updated_by'] = $session_uid;
                 if ($EventModel->update($campaign_id, $data)) {
-                    session()->setFlashdata('success', 'Event has been updated successfully.');
-                    $this->logger->info("Event: has been updated successfully. Updated Event ID = " . $campaign_id);
+                    session()->setFlashdata('success', 'campaign has been updated successfully.');
+                    $this->logger->info("campaign: has been updated successfully. Updated campaign ID = " . $campaign_id);
                 } else {
-                    session()->setFlashdata('error', 'Event update failed. Please try again.');
-                    $this->logger->error("Event: Err Failed to update ID =" . $campaign_id);
+                    session()->setFlashdata('error', 'campaign update failed. Please try again.');
+                    $this->logger->error("campaign: Err Failed to update ID =" . $campaign_id);
                 }
             }
         } catch (\Exception $e) {
-            $this->logger->error("Event: Err Occur = " . $e->getMessage() . " Line = " . $e->getLine() . " File = " . $e->getFile());
+            $this->logger->error("campaign: Err Occur = " . $e->getMessage() . " Line = " . $e->getLine() . " File = " . $e->getFile());
             session()->setFlashdata('error', 'Message: ' . $e->getMessage());
         }
-        return redirect()->route('campaign');
+        return redirect()->route('campaign_list');
     }
 
     public function invoice_number_format($id)
@@ -181,7 +169,7 @@ class Event extends BaseController
                 }
             }
         } catch (\Exception $e) {
-            $this->logger->error("Event: Err Occur = " . $e->getMessage() . " Line = " . $e->getLine() . " File = " . $e->getFile());
+            $this->logger->error("campaign: Err Occur = " . $e->getMessage() . " Line = " . $e->getLine() . " File = " . $e->getFile());
             session()->setFlashdata('error', 'Message: ' . $e->getMessage());
         }
         return redirect()->to(base_url("invoice_number_format/1"));
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index 313150a..2107ea2 100644
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -12,13 +12,16 @@ class Home extends BaseController
             helper('session');
             $session_role = get_user_role();
             $session_bid = get_business_id();
+
+            // echo $session_bid, $session_role; die;
             
             $data['page_name']   = 'Dashboard';
-            if (!empty($session_role) && $session_role !== "sadmin") {
-                $where = ['isactive' => 1, 'business_id' => (int)$session_bid];
-            } else if (!empty($session_role) && $session_role !== "admin") {
+            if (!empty($session_role) && $session_role == "sadmin") {
                 $where = ['isactive != ' => NULL];
-            } else {
+            } else if (!empty($session_role) && $session_role == "admin") {
+                $where = ['isactive' => 1, 'business_id' => $session_bid];
+            } 
+            else {
                 $where = [];
             }
             $model = new HomeModel();
@@ -26,7 +29,7 @@ class Home extends BaseController
             $data['customer']['label'] = "Doners";
             
             // echo '
';
-            // print_r($data); die;
+            // print_r($data['customer'] ); die;
 
             // $data['invoice'] = $model->invoice();
             // $data['active_category'] = array_filter($model->schemes(), function ($element) {
diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php
index 1f03c22..792a5fd 100644
--- a/app/Controllers/Invoice.php
+++ b/app/Controllers/Invoice.php
@@ -1,624 +1,600 @@
- (int)get_business_id()];
-            $data['doners'] = $model->getData('customers', $where);
-            $data['page_name'] = 'Receipt  Details';
-            $data['receipt']   = $model->where(["business_id"=>$session_bid])->findAll();
-            
-            // echo '
';
-            // print_r($data); die;
-
-            $this->logger->info("Invoice: Listing Count ." . count($data['receipt']));
-            $this->render_page('invoice_list', $data);
-        } else {
-            return redirect()->to('login');
-        }
-    }
-
-    ## To Load Invoice ADD/EDIT page...
-    public function new_receipt($id = '0')
-    {
-        helper('session');
-        $model = new InvoiceModel();
-        $where = ['business_id' => (int)get_business_id()];
-    
-        // Get customer names for the dropdown, events details, and books details
-        $data['customers'] = $model->getData('customers', $where);
-        $data['causes']    = $model->getData('causes', $where);
-    
-        if ($id === '0') {
-            $this->logger->info("Receipt: In Add Details");
-            $data['page_name']       = 'Add Receipt Details';
-            $data['receipt_details'] = [];
-        } elseif ($id !== '0') {
-            $this->logger->info(" Book Invoice: In Edit Details ID = " . $id);
-            $data['page_name']       = 'Edit Receipt Details';
-            $data['receipt_details'] = $model->where(['receipt_id' => $id, 'isactive' => 1])->first();
-        }
-
-        // echo '
';    
-        // print_r($data);die;
-        $this->render_page('invoice_form', $data);
-    }
-    
-
-    ## 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
-    public function save_invoice()
-    {
-        $this->logger->info("Invoice: Insert/Update Details");
-        try {
-
-            ## Declarions
-            helper('session');
-            $model = new InvoiceModel();
-
-            $receipt_date = $this->request->getVar('receipt_date');
-
-            $receipt_id = (!empty($this->request->getPost('receipt_id'))) ? $this->request->getPost('receipt_id') : "";
-            $customer_id = (int)$this->request->getPost('doner_id');
-
-            $data = [
-                'receipt_number' => $this->request->getPost('receipt_number'),
-                'doner_id' => $customer_id,
-                'notes'=>$this->request->getPost('notes'),
-                'receipt_date' => (!empty($receipt_date)) ? date("Y-m-d", strtotime($receipt_date)) : NULL,
-                'amount' => (int)$this->request->getPost('amount'),
-                'payment_mode' => $this->request->getPost('payment_mode'),
-                'payment_ref_no' => $this->request->getPost('payment_ref_no'),
-                'causes_id' => (int)$this->request->getPost('causes_id'),
-                'business_id' => (int)get_business_id(),
-                'isactive' => 1
-            ];
-            ## Based on the invoice ID, we designated Insert or Update on Details...
-            if (empty($receipt_id)) {
-                $data['created_by'] = (int)get_logged_user_id();
-                if ($model->insert($data, 'invoices')) {
-                    $receipt_id = $model->insertID();
-                    session()->setFlashdata('success', 'Receipt has been added successfully.');
-                    $this->logger->info("Receipt: has been added successfully. Inserted ID = " . $receipt_id);
-                                 
-                } else {
-                    session()->setFlashdata('error', 'Receipt could not be added. Please try again.');
-                    $this->logger->error("Receipt: Err Occur could not be added. Please try again.");
-                }
-            
-            } else {
-                $data['updated_by'] = (int)get_logged_user_id();
-                if ($model->update($receipt_id, $data)) {
-                    session()->setFlashdata('success', 'Receipt has been updated successfully.');
-                    $this->logger->info("Receipt: has been updated successfully. Updated ID = " . $receipt_id);
-                } else {
-                    session()->setFlashdata('error', 'Receipt update failed. Please try again.');
-                    $this->logger->error("Receipt: Err Failed to update ID =" . $receipt_id);
-                }
-            }
-            
-          
-        } catch (\Exception $e) {
-            $this->logger->error("Receipt: Err Occur =" . $e->getMessage());
-            session()->setFlashdata('error', 'Message: ' . $e->getMessage());
-        }
-        return redirect()->route('receipt_list');
-
-      
-    
-
-    }
-
-    ## For Updating Events Details .. 
-    public function update_number_formatting($update_events)
-    {
-        // `id``event_name``business_id``updated_by``updated_on``next_id`
-        $model = new InvoiceModel();
-        $model->setTable('invoice_number_formatting');
-        $where = ['isactive' => 1, 'id' => (int)$update_events['id'], 'business_id' => (int)$update_events['business_id'], 'next_id' => $update_events['next_id']];
-        $details = $model->where($where)->findAll();
-        if (empty($details)) {
-            $update_where = ['id' => (int)$update_events['id'], 'business_id' => (int)$update_events['business_id']];
-            $update_data = ['next_id' => $update_events['next_id'], 'updated_by' => $update_events['updated_by']];
-            $model->updateData('invoice_number_formatting', $update_data, $update_where);
-        }
-    }
-
-    ## 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 "
...................."; - $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'); - } - - ## To Approve Invoice details based on invoice ID - public function approve_invoice($id) - { - - try { - if (!$id) { - throw new \Exception("Invoice can't able to Approved. Because ID can't Found"); - } - $model = new InvoiceModel(); - helper('session'); - $where = ['isactive' => 1, 'status' => 'Approved', 'receipt_id' => (int)$id]; - $details = $model->where($where)->findAll(); - if (empty($details)) { // Array Empty Means allow to Approve. - $data = ['status' => 'Approved', 'updated_by' => get_logged_user_id()]; - if ($model->update($id, $data)) { - $this->approve_notifications((int)$id); - session()->setFlashdata('success', 'Invoice has been Approved Successfully.'); - $this->logger->info("Invoice: has been Approved successfully. ID = " . $id); - } else { - $this->logger->error("Invoice: Does Not Exist To Approved"); - throw new \Exception("Invoice can't Approved"); - } - } else { - $this->logger->error("Invoice: already Approved ID = " . $id); - throw new \Exception("Invoice already Approved"); - } - } catch (\Exception $e) { - $this->logger->error("Invoice: Err Occur = " . $e->getMessage()); - session()->setFlashdata('error', 'Message: ' . $e->getMessage()); - } - // Redirect back to the invoice list - return redirect()->route('receipt_list'); - } - - 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'] = "VBP Approve Information -

Dear $recipient_name,

-

   We are pleased to inform you that your Invoice has been approved.

-

Details:

-
  • Approval Date:" . $approval_date . "
  • -
  • Approved By:" . $approved_by . "
  • -
  • Reference ID:" . $reference_number . "
  • -

-

Best regards,

-
    -
  • ".$business_name.",
  • -
  • ".$business_address." ".$business_city." ".$business_state." - ".$business_postal_code."
  • -
  • Call Us: +91 ".$business_mobile_no."
  • -
  • Email Us: ".$business_email."
  • "; - - $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)); - } - - ## To Generate receipt PDF based on receipt ID - public function generate_invoice_pdf($id) - { - // Fetch the receipt data based on $receipt_id - $model = new InvoiceModel(); - $data = $model->getInvoiceData($id); - - - // Create an mPDF object - $mpdf = new Mpdf(); - $mpdf->autoLangToFont = true; - $mpdf->autoScriptToLang = true; - - // Set PDF properties - $mpdf->SetTitle('Receipt'); - $mpdf->SetAuthor('ORG'); - $mpdf->SetCreator(''); - - - // Set the page size to letter - // Add a page with letter size (8.5 x 11 inches) - $mpdf->AddPage('L', 'LETTER'); - - // Generate the PDF content (HTML) with data - $html = view('invoice_pdf_template', ['data' => $data]); - - // echo $html; die; - - // Load HTML into the mPDF instance - $mpdf->WriteHTML($html); - - // Output the PDF to the browser for download - $mpdf->Output('Receipt' . date('Y-m-d H-i-s') . '.pdf', 'D'); - - } - public function print_address($id) - { - // Fetch the invoice data based on $id - $model = new InvoiceModel(); - $invoiceData = $model->getInvoiceData($id); - // print_r($invoiceData);die(); - // Initialize an empty PDF with custom paper size (4x6 inches) - $config = [ - 'mode' => 'utf-8', - 'format' => [101.6, 152.4], - 'default_font_size' => 12, - 'default_font' => 'Arial', - 'margin_left' => 0, - 'margin_right' => 0, - 'margin_top' => 0, - 'margin_bottom' => 0, - 'margin_header' => 0, - 'margin_footer' => 0, - 'orientation' => 'P', // Portrait - ]; - $mpdf = new Mpdf($config); - $mpdf->SetTitle('Doner Address'); - $mpdf->SetAuthor('Venba'); - $mpdf->SetCreator(''); - - // Generate the PDF content (HTML) with customer and address data - $html = view('address_pdf_template', ['invoiceData' => $invoiceData]); - - - // Load the mPDF library - - - // Set PDF properties - - - // Load HTML content into mPDF - $mpdf->WriteHTML($html); - - // Output the PDF for download - - $pdfFileName = 'customer_address_' . date('Y-m-d H-i-s') . '.pdf'; - $mpdf->Output($pdfFileName, 'D'); - } - - 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); - } - - } -} - -// public function generate_invoice_pdf($id) -// { -// // Load the mPDF library -// $mpdf = new \Mpdf\Mpdf(); - -// // Fetch invoice data -// $invoice = $this->find($id); - -// if ($invoice) { -// // Fetch related invoice items -// $invoiceItems = $this->getInvoiceItems($id); - -// // Create the HTML content for the PDF -// $html = view('pdf/invoice_template', ['invoice' => $invoice, 'invoiceItems' => $invoiceItems]); - -// // Load HTML content into mPDF -// $mpdf->WriteHTML($html); - -// // Set PDF filename -// $pdfFileName = 'invoice_' . $invoice->invoice_number . '.pdf'; - -// // Output the PDF for download -// $mpdf->Output($pdfFileName, 'D'); -// } -// } - -// public function getInvoiceItems($invoiceId) -// { -// // Fetch invoice items related to the given invoice ID -// return $this->db->table('invoice_items')->where('receipt_id', $invoiceId)->get()->getResult(); -// } - - - + (int)get_business_id()]; + $data['Donors'] = $model->getData('customers', $where); + $data['page_name'] = 'Receipt Details'; + $data['receipt'] = $model->where(["business_id"=>$session_bid])->findAll(); + + // echo '
    ';
    +            // print_r($data); die;
    +
    +            $this->logger->info("Invoice: Listing Count ." . count($data['receipt']));
    +            $this->render_page('invoice_list', $data);
    +        } else {
    +            return redirect()->to('login');
    +        }
    +    }
    +
    +    ## To Load Invoice ADD/EDIT page...
    +    public function new_receipt($id = '0')
    +    {
    +        helper('session');
    +        $model = new InvoiceModel();
    +        $where = ['business_id' => (int)get_business_id()];
    +    
    +        // Get customer names for the dropdown, events details, and books details
    +        $data['customers'] = $model->getData('customers', $where);
    +        $data['causes']    = $model->getData('causes', $where);
    +        $data['invoice_number_formatting'] = $model->getData('invoice_number_formatting', $where);
    +
    +        if ($id === '0') {
    +            $this->logger->info("Receipt: In Add Details");
    +            $data['page_name']       = 'Add Receipt Details';
    +            $data['receipt_details'] = [];
    +        } elseif ($id !== '0') {
    +            $this->logger->info(" Book Invoice: In Edit Details ID = " . $id);
    +            $data['page_name']       = 'Edit Receipt Details';
    +            $data['receipt_details'] = $model->where(['receipt_id' => $id, 'isactive' => 1])->first();
    +        }
    +
    +        // echo '
    ';    
    +        // print_r($data['invoice_number_formatting']);die;
    +        $this->render_page('invoice_form', $data);
    +    }
    +    
    +
    +    ## 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
    +    public function save_invoice()
    +    {
    +        $this->logger->info("Invoice: Insert/Update Details");
    +        try {
    +
    +            ## Declarions
    +            helper('session');
    +            $model = new InvoiceModel();
    +
    +            $receipt_date = $this->request->getVar('receipt_date');
    +
    +            $receipt_id = (!empty($this->request->getPost('receipt_id'))) ? $this->request->getPost('receipt_id') : "";
    +            $customer_id = (int)$this->request->getPost('doner_id');
    +
    +            $data = [
    +                'receipt_number' => $this->request->getPost('receipt_number'),
    +                'doner_id' => $customer_id,
    +                'notes'=>$this->request->getPost('notes'),
    +                'receipt_date' => (!empty($receipt_date)) ? date("Y-m-d", strtotime($receipt_date)) : NULL,
    +                'amount' => (int)$this->request->getPost('amount'),
    +                'payment_mode' => $this->request->getPost('payment_mode'),
    +                'payment_ref_no' => $this->request->getPost('payment_ref_no'),
    +                'causes_id' => (int)$this->request->getPost('causes_id'),
    +                'business_id' => (int)get_business_id(),
    +                'isactive' => 1
    +            ];
    +            ## Based on the invoice ID, we designated Insert or Update on Details...
    +            if (empty($receipt_id)) {
    +                $data['created_by'] = (int)get_logged_user_id();
    +                if ($model->insert($data, 'invoices')) {
    +                    $receipt_id = $model->insertID();
    +                    session()->setFlashdata('success', 'Receipt has been added successfully.');
    +                    $this->logger->info("Receipt: has been added successfully. Inserted ID = " . $receipt_id);
    +                                 
    +                } else {
    +                    session()->setFlashdata('error', 'Receipt could not be added. Please try again.');
    +                    $this->logger->error("Receipt: Err Occur could not be added. Please try again.");
    +                }
    +            
    +            } else {
    +                $data['updated_by'] = (int)get_logged_user_id();
    +                if ($model->update($receipt_id, $data)) {
    +                    session()->setFlashdata('success', 'Receipt has been updated successfully.');
    +                    $this->logger->info("Receipt: has been updated successfully. Updated ID = " . $receipt_id);
    +                } else {
    +                    session()->setFlashdata('error', 'Receipt update failed. Please try again.');
    +                    $this->logger->error("Receipt: Err Failed to update ID =" . $receipt_id);
    +                }
    +            }
    +
    +            if($this->request->getPost('next_id')){
    +                ## Array Formation For Events Details And Updating Events also Here.. 
    +                $update_events = [
    +                    'id' => 1,
    +                    'next_id' => (int)$this->request->getPost('next_id'),
    +                    'business_id' => (int)get_business_id(),
    +                    'updated_by' => get_logged_user_id()
    +                ];
    +                $this->update_number_formatting($update_events);}
    +            
    +          
    +        } catch (\Exception $e) {
    +            $this->logger->error("Receipt: Err Occur =" . $e->getMessage());
    +            session()->setFlashdata('error', 'Message: ' . $e->getMessage());
    +        }
    +        return redirect()->route('receipt_list');
    +
    +      
    +    
    +
    +    }
    +
    +    ## For Updating Events Details .. 
    +    public function update_number_formatting($update_events)
    +    {
    +        // `id``event_name``business_id``updated_by``updated_on``next_id`
    +        $model = new InvoiceModel();
    +        $model->setTable('invoice_number_formatting');
    +        $where = ['isactive' => 1, 'id' => (int)$update_events['id'], 'business_id' => (int)$update_events['business_id'], 'next_id' => $update_events['next_id']];
    +        $details = $model->where($where)->findAll();
    +        if (empty($details)) {
    +            $update_where = ['id' => (int)$update_events['id'], 'business_id' => (int)$update_events['business_id']];
    +            $update_data = ['next_id' => $update_events['next_id'], 'updated_by' => $update_events['updated_by']];
    +            $model->updateData('invoice_number_formatting', $update_data, $update_where);
    +        }
    +    }
    +
    +    ## 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 "
    ...................."; + $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'); + } + + ## To Approve Invoice details based on invoice ID + public function approve_invoice($id) + { + + try { + if (!$id) { + throw new \Exception("Invoice can't able to Approved. Because ID can't Found"); + } + $model = new InvoiceModel(); + helper('session'); + $where = ['isactive' => 1, 'status' => 'Approved', 'receipt_id' => (int)$id]; + $details = $model->where($where)->findAll(); + if (empty($details)) { // Array Empty Means allow to Approve. + $data = ['status' => 'Approved', 'updated_by' => get_logged_user_id()]; + if ($model->update($id, $data)) { + $this->approve_notifications((int)$id); + session()->setFlashdata('success', 'Invoice has been Approved Successfully.'); + $this->logger->info("Invoice: has been Approved successfully. ID = " . $id); + } else { + $this->logger->error("Invoice: Does Not Exist To Approved"); + throw new \Exception("Invoice can't Approved"); + } + } else { + $this->logger->error("Invoice: already Approved ID = " . $id); + throw new \Exception("Invoice already Approved"); + } + } catch (\Exception $e) { + $this->logger->error("Invoice: Err Occur = " . $e->getMessage()); + session()->setFlashdata('error', 'Message: ' . $e->getMessage()); + } + // Redirect back to the invoice list + return redirect()->route('receipt_list'); + } + + 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'] = "VBP Approve Information +

    Dear $recipient_name,

    +

       We are pleased to inform you that your Invoice has been approved.

    +

    Details:

    +
    • Approval Date:" . $approval_date . "
    • +
    • Approved By:" . $approved_by . "
    • +
    • Reference ID:" . $reference_number . "
    • +

    +

    Best regards,

    +
      +
    • ".$business_name.",
    • +
    • ".$business_address." ".$business_city." ".$business_state." - ".$business_postal_code."
    • +
    • Call Us: +91 ".$business_mobile_no."
    • +
    • Email Us: ".$business_email."
    • "; + + $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)); + } + + ## To Generate receipt PDF based on receipt ID + public function generate_invoice_pdf($id) + { + // Fetch the receipt data based on $receipt_id + $model = new InvoiceModel(); + $data = $model->getInvoiceData($id); + // print_r($data);die; + + // Create an mPDF object + $mpdf = new Mpdf(); + $mpdf->autoLangToFont = true; + $mpdf->autoScriptToLang = true; + + // Set PDF properties + $mpdf->SetTitle('Receipt'); + $mpdf->SetAuthor('ORG'); + $mpdf->SetCreator(''); + + $mpdf->AddPage('L', 'LETTER'); + + // Generate the PDF content (HTML) with data + $html = view('invoice_pdf_template', ['data' => $data[0]]); + + // Load HTML into the mPDF instance + $mpdf->WriteHTML($html); + + // Output the PDF to the browser for download + $mpdf->Output('Receipt' . date('Y-m-d H-i-s') . '.pdf', 'D'); + + } + public function print_address($id) + { + // Fetch the invoice data based on $id + $model = new InvoiceModel(); + $invoiceData = $model->getInvoiceData($id); + // print_r($invoiceData);die(); + // Initialize an empty PDF with custom paper size (4x6 inches) + $config = [ + 'mode' => 'utf-8', + 'format' => [101.6, 152.4], + 'default_font_size' => 12, + 'default_font' => 'Arial', + 'margin_left' => 0, + 'margin_right' => 0, + 'margin_top' => 0, + 'margin_bottom' => 0, + 'margin_header' => 0, + 'margin_footer' => 0, + 'orientation' => 'P', // Portrait + ]; + $mpdf = new Mpdf($config); + $mpdf->SetTitle('Donor Address'); + $mpdf->SetAuthor('Venba'); + $mpdf->SetCreator(''); + + // Generate the PDF content (HTML) with customer and address data + $html = view('address_pdf_template', ['invoiceData' => $invoiceData]); + + + // Load the mPDF library + + + // Set PDF properties + + + // Load HTML content into mPDF + $mpdf->WriteHTML($html); + + // Output the PDF for download + + $pdfFileName = 'customer_address_' . date('Y-m-d H-i-s') . '.pdf'; + $mpdf->Output($pdfFileName, 'D'); + } + + 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); + } + + } +} + + + + + diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index de90232..2be93c6 100644 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -15,6 +15,7 @@ class Users extends BaseController $session_role = get_user_role(); $session_bid = get_business_id(); + $session_role = get_user_role(); if (!empty($session_role) && $session_role !== "sadmin") { $this->logger->info("Users: Listing In admin role . BID = ".$session_bid); @@ -25,10 +26,18 @@ class Users extends BaseController } $model = new UsersModel(); $model->setTable('users'); - $user_details = $model->where($where)->orderBy('user_id', 'DESC')->findAll(); + // $user_details = $model->where($where)->orderBy('user_id', 'DESC')->findAll(); + $user_details = $model->select('users.*, business.title as org_name') + ->join('business', 'business.business_id = users.business_id') + ->where($where)->orderBy('user_id', 'DESC')->findAll(); + $this->logger->info("Users: Listing Count .".count($user_details)); $data['page_name'] = 'User Details'; + $data['loged_user'] = $session_role; $data['details'] = $user_details; + + // echo '
      ';
      +        // print_r($data); die;
               $this->render_page('user_list', $data);
           }
       
      diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php
      index d7924be..4cc7809 100644
      --- a/app/Models/CustomerModel.php
      +++ b/app/Models/CustomerModel.php
      @@ -146,13 +146,14 @@ public function saveGroupDetails($data){
       return $statement;
       }
       
      -public function getGroupDetails()
      +public function getGroupDetails($business_id)
       {
       return $this->db->table('customer_groups as CG' )
       ->join('users as U1', 'U1.user_id = CG.created_by', 'left')
       ->join('users as U2', 'U2.user_id = CG.updated_by', 'left')
       ->select('CG.group_id,CG.group_name,CG.created_on,CG.created_by,CG.updated_on,CG.updated_by,DATE_FORMAT(CG.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,CG.isactive')
       ->where(['CG.group_name != ' => 'EXPIRYDATE'])
      +->where('CG.business_id', $business_id)
       // ->where(['CG.isactive' => 1])
       ->get()
       ->getResultArray();
      diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php
      index e18b97b..6893a5f 100644
      --- a/app/Models/HomeModel.php
      +++ b/app/Models/HomeModel.php
      @@ -5,6 +5,7 @@ class HomeModel extends Model
       {
       
           public function customers($where) {
      +        
               $query = $this->db->table('customers');
       
               $totalCustomers = $query->where($where)->countAll();
      diff --git a/app/Views/auth_login.php b/app/Views/auth_login.php
      index 9a45727..96e8be7 100644
      --- a/app/Views/auth_login.php
      +++ b/app/Views/auth_login.php
      @@ -3,7 +3,7 @@
       
       
           
      -    BigBambooBookPublish | BBBP 
      +    BigBamboo Donation
           
           
           
      @@ -46,7 +46,7 @@
                                               
                                           
                                       
      -                                

      Enter your email address and password to access admin panel.

      +

      Enter your email address and password.

      " method="post"> @@ -110,7 +110,7 @@
      -

      © .

      +

      © .

      diff --git a/app/Views/business_form.php b/app/Views/business_form.php index aa3f0e8..6537359 100644 --- a/app/Views/business_form.php +++ b/app/Views/business_form.php @@ -31,7 +31,7 @@
      - +
      Please provide.
      @@ -55,7 +55,7 @@
      - +
      Please provide.
      @@ -63,10 +63,13 @@
      Please provide.
      + +
      - +
      +
      @@ -84,26 +87,29 @@
      Please provide.
      + +
      +
      - - Business Logo + + Organization Logo
      - +
      - +
      diff --git a/app/Views/business_list.php b/app/Views/business_list.php index e1c1789..c2c0d84 100644 --- a/app/Views/business_list.php +++ b/app/Views/business_list.php @@ -14,7 +14,7 @@ - Business Name + Organization Name Email Mobile Number Address diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index 8e4d72b..340571b 100644 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -27,8 +27,8 @@
      - - @@ -54,13 +54,7 @@
      Please provide.
      -
      - - - -
      -
      -
      +
      @@ -71,19 +65,27 @@
      Please provide.
      -
      - - +
      + +
      +
      + + +
      + +
      - - -
      Please provide.
      + +
      - +
      @@ -94,56 +96,40 @@
      - - -
      Please provide.
      + +
      - - + -
      Please provide.
      - -
      - +
      - - + +
      Please provide.
      - - -
      Please provide.
      + +
      -

      @@ -158,12 +144,10 @@ -
      @@ -173,199 +157,7 @@
      - \ No newline at end of file diff --git a/app/Views/customer_group.php b/app/Views/customer_group.php index b710826..1fdf891 100644 --- a/app/Views/customer_group.php +++ b/app/Views/customer_group.php @@ -3,7 +3,7 @@

      diff --git a/app/Views/customer_list.php b/app/Views/customer_list.php index 6ee0fa5..8679ecc 100644 --- a/app/Views/customer_list.php +++ b/app/Views/customer_list.php @@ -3,7 +3,7 @@

      @@ -39,11 +39,15 @@ - + + + + + - " class="edit-button"> + " class="edit-button"> " class="delete-button"> diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index f5e3243..78c0aa1 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -13,9 +13,9 @@
      - + + + + + + +
      + + +
      -
      +
      @@ -80,36 +94,26 @@
      - -
      -
      - Business Logo -
      -
      Existing Profile Picture
      -

      - -
      -
      -
      - +
      - -
      - - + +
      +
      + Business Logo +
      + + + +
      +
      +
      diff --git a/app/Views/user_list.php b/app/Views/user_list.php index 55e0a6d..4f17c16 100644 --- a/app/Views/user_list.php +++ b/app/Views/user_list.php @@ -33,6 +33,9 @@ Name + + Org Name + Email Mobile Number Role @@ -63,6 +66,9 @@ + + + diff --git a/db/doner_management.sql b/db/doner_management.sql index da8d4ef..d2d6874 100644 --- a/db/doner_management.sql +++ b/db/doner_management.sql @@ -18,7 +18,7 @@ SET time_zone = "+00:00"; /*!40101 SET NAMES utf8mb4 */; -- --- Database: `doner_management` +-- Database: `Donor_management` -- -- -------------------------------------------------------- @@ -1051,9 +1051,9 @@ CREATE TABLE `settings` ( -- INSERT INTO `settings` (`business_id`, `setting_id`, `site_name`, `site_title`, `favicon`, `logo`, `terms_service`, `footer_about`, `admin_email`, `mobile`, `copyright`, `pagination_limit`, `site_info`, `about_info`, `mail_protocol`, `mail_title`, `mail_host`, `mail_port`, `mail_encryption`, `mail_username`, `mail_password`, `currency`, `country`, `created_on`, `created_by`, `updated_on`, `updated_by`, `isactive`) VALUES -(0, 1, 'Bigbamboo Doner Management', 'BB Books', NULL, NULL, 'Term and Service', 'BBBP.COM', 'sadmin@bbbp.com', '1010101010', '2023', 1, 1, 'nil', 'nil', 'nil', 'nil', 'nil', 'ssl', 'nil', 'nil', 'USD', 1, '2023-09-06 15:22:18', 1, '2023-12-12 15:46:24', NULL, 1), -(1, 2, 'Doner Management', 'DM', 'Vijayabharatham.ico', 'Vijayabharatham_withname_1.png', 'Vijayabharatham Publishing Terms', 'https://vijayabharathambooks.com/', 'admin@vbp.com', NULL, '2023', NULL, 1, NULL, NULL, NULL, NULL, NULL, 'ssl', NULL, NULL, 'nil', 1, '2023-09-06 15:16:58', 1, '2023-12-12 15:35:35', NULL, 1), -(2, 3, 'Doner Management', 'DM', 'JerryCharlesMiculekPublishing.ico', 'JerryCharlesMiculekPublishing.png', '', '', 'admin@hcc.com', NULL, NULL, NULL, 1, '', NULL, NULL, NULL, NULL, 'ssl', NULL, NULL, 'USD', 178, '2023-09-11 12:43:11', NULL, '2023-12-12 15:35:43', NULL, 1); +(0, 1, 'Bigbamboo Donor Management', 'BB Books', NULL, NULL, 'Term and Service', 'BBBP.COM', 'sadmin@bbbp.com', '1010101010', '2023', 1, 1, 'nil', 'nil', 'nil', 'nil', 'nil', 'ssl', 'nil', 'nil', 'USD', 1, '2023-09-06 15:22:18', 1, '2023-12-12 15:46:24', NULL, 1), +(1, 2, 'Donor Management', 'DM', 'Vijayabharatham.ico', 'Vijayabharatham_withname_1.png', 'Vijayabharatham Publishing Terms', 'https://vijayabharathambooks.com/', 'admin@vbp.com', NULL, '2023', NULL, 1, NULL, NULL, NULL, NULL, NULL, 'ssl', NULL, NULL, 'nil', 1, '2023-09-06 15:16:58', 1, '2023-12-12 15:35:35', NULL, 1), +(2, 3, 'Donor Management', 'DM', 'JerryCharlesMiculekPublishing.ico', 'JerryCharlesMiculekPublishing.png', '', '', 'admin@hcc.com', NULL, NULL, NULL, 1, '', NULL, NULL, NULL, NULL, 'ssl', NULL, NULL, 'USD', 178, '2023-09-11 12:43:11', NULL, '2023-12-12 15:35:43', NULL, 1); -- -------------------------------------------------------- @@ -1260,14 +1260,14 @@ CREATE TABLE `users` ( INSERT INTO `users` (`business_id`, `user_id`, `email`, `first_name`, `last_name`, `password`, `mobile_no`, `date_of_birth`, `address`, `gender`, `profile_picture`, `city`, `state`, `postal_code`, `country`, `role`, `reset_link`, `created_on`, `created_by`, `updated_on`, `updated_by`, `isactive`) VALUES (0, 1, 'sadmin@bbbp.com', 'BBBP', 'SA', '$2y$10$JymR48XU0h5ukLpCWIy0V.9uwTPXiS6LhQihT18pkidkwoxA.ZQpa', '7128122050', '2023-08-21', 'www', 'male', '', 'Trichy', 'Tamil Nadu', '620122', NULL, 'sadmin', NULL, '2023-08-18 12:31:39', 1, '2023-10-12 16:08:31', 1, 1), -(1, 2, 'admin@vbp.com', 'Donermanagement', 'A1', '$2y$10$JymR48XU0h5ukLpCWIy0V.9uwTPXiS6LhQihT18pkidkwoxA.ZQpa', '2266778899', NULL, '1/8', 'male', 'dummy.jpeg', 'nanganallur', 'tamilnadu', '630345', NULL, 'admin', 'f901031dfaaf15d4734fb405d24f9421afb2e1ccf175db85181056def6c08c9e', '2023-08-19 16:05:22', 1, '2023-12-12 15:38:54', 2, 1), +(1, 2, 'admin@vbp.com', 'Donormanagement', 'A1', '$2y$10$JymR48XU0h5ukLpCWIy0V.9uwTPXiS6LhQihT18pkidkwoxA.ZQpa', '2266778899', NULL, '1/8', 'male', 'dummy.jpeg', 'nanganallur', 'tamilnadu', '630345', NULL, 'admin', 'f901031dfaaf15d4734fb405d24f9421afb2e1ccf175db85181056def6c08c9e', '2023-08-19 16:05:22', 1, '2023-12-12 15:38:54', 2, 1), (2, 3, 'admin@hcc.com', 'HCC', 'A1', '$2y$10$7NW11LCIjRiAYHE9wBsituMuqleV/ItTxcRZ9NrqAmqAbAy9Ph2Bq', '12344321', '2003-08-11', 'address001', 'female', '', 'Chennai', 'TN', '600001', NULL, 'admin', NULL, '2023-09-11 12:33:01', NULL, '2023-09-29 10:10:05', NULL, 1), (1, 4, 'vbptest@gmail.com', 'VBP', 'TEST', '$2y$10$ky2TxMj6LaBEqPma7VDC5Os9NxmgNlDgyUWzJUOrewdBdBOWaOgBq', '9090909090', NULL, 'No.123', 'male', 'dummy-prod-1.jpg', 'Banglore', 'Karnataka', '600051', NULL, 'admin', NULL, '2023-10-17 17:34:13', 2, '2023-11-06 16:05:05', 2, 1), (1, 5, 'online@vbp.com', 'Vijayabharatham', 'O1', '$2y$10$K8lwOXryrQZsp0QVMKdeXeAepYBLImxPgr5Ze4jDcik53ByLQYw6a', '8122050331', NULL, 'Chennai', NULL, 'nameboard2.jpeg', 'Nanganallur', 'Tamil nadu', '600009', NULL, 'online', NULL, '2023-10-11 15:17:51', 2, '2023-10-12 18:21:46', NULL, 0), (1, 6, 'manager@vbp.com', 'Vijayabharatham', 'M1', '$2y$10$K8lwOXryrQZsp0QVMKdeXeAepYBLImxPgr5Ze4jDcik53ByLQYw6a', '9812205034', NULL, 'Chennai', '', NULL, 'Nanganallur.', 'Tamil nadu', '600011', NULL, 'manager', NULL, '2023-10-11 15:17:51', 2, '2023-10-12 18:35:05', NULL, 1), (1, 7, 'kavitha123@gmail.com', 'Kavitha', 'L', '$2y$10$MQKj999N0XCgMvTT162jQ.pADLijrdbucdBivoYgCAAKzxhWGRQju', '8541236589', NULL, '', '', NULL, '', '', '', NULL, 'admin', NULL, '2023-11-08 09:18:26', 2, NULL, NULL, 1), (1, 8, 'nithiya123@gmail.com', 'Nithiya', 'K', '$2y$10$Cbj4.AJKYvSD1iSum34/E./ugnXYJVvDud/QuGBhGkHkK6hDE30ha', '8541236589', NULL, '', '', NULL, '', '', '', NULL, 'admin', NULL, '2023-11-08 09:19:10', 2, '2023-11-10 17:19:11', 2, 0), -(1, 9, 'raman@gmail.com', 'Donermanagement', 'VENKATESHRAMAN', '$2y$10$k5es.HKc0qOk2QtBE2gLP.MNeG7mg5KEpdiK4bLnTnW7MVibLk2mS', '8976543098', NULL, 'annappanpettain ', 'male', NULL, 'sirkali', 'tamilnadu', '908765', NULL, 'admin', NULL, '2023-12-12 18:36:22', 2, NULL, NULL, 1); +(1, 9, 'raman@gmail.com', 'Donormanagement', 'VENKATESHRAMAN', '$2y$10$k5es.HKc0qOk2QtBE2gLP.MNeG7mg5KEpdiK4bLnTnW7MVibLk2mS', '8976543098', NULL, 'annappanpettain ', 'male', NULL, 'sirkali', 'tamilnadu', '908765', NULL, 'admin', NULL, '2023-12-12 18:36:22', 2, NULL, NULL, 1); -- -- Indexes for dumped tables diff --git a/public/assets/libs/custombox/custombox.legacy.min.js b/public/assets/libs/custombox/custombox.legacy.min.js index 9d85983..31e9748 100644 --- a/public/assets/libs/custombox/custombox.legacy.min.js +++ b/public/assets/libs/custombox/custombox.legacy.min.js @@ -12,4 +12,4 @@ * * Under MIT License - http://opensource.org/licenses/MIT */ -!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!u&&c)return c(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var a=n[o]={exports:{}};t[o][0].call(a.exports,function(n){var r=t[o][1][n];return s(r||n)},a,a.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o2?arguments[2]:void 0,s=Math.min((void 0===a?u:i(a,u))-f,u-c),l=1;for(f0;)f in r?r[c]=r[f]:delete r[c],c+=l,f+=l;return r}},{105:105,108:108,109:109}],9:[function(t,n,r){"use strict";var e=t(109),i=t(105),o=t(108);n.exports=function(t){for(var n=e(this),r=o(n.length),u=arguments.length,c=i(u>1?arguments[1]:void 0,r),f=u>2?arguments[2]:void 0,a=void 0===f?r:i(f,r);a>c;)n[c++]=t;return n}},{105:105,108:108,109:109}],10:[function(t,n,r){var e=t(37);n.exports=function(t,n){var r=[];return e(t,!1,r.push,r,n),r}},{37:37}],11:[function(t,n,r){var e=t(107),i=t(108),o=t(105);n.exports=function(t){return function(n,r,u){var c,f=e(n),a=i(f.length),s=o(u,a);if(t&&r!=r){for(;a>s;)if((c=f[s++])!=c)return!0}else for(;a>s;s++)if((t||s in f)&&f[s]===r)return t||s||0;return!t&&-1}}},{105:105,107:107,108:108}],12:[function(t,n,r){var e=t(25),i=t(45),o=t(109),u=t(108),c=t(15);n.exports=function(t,n){var r=1==t,f=2==t,a=3==t,s=4==t,l=6==t,h=5==t||l,v=n||c;return function(n,c,p){for(var d,y,g=o(n),b=i(g),x=e(c,p,3),m=u(b.length),w=0,S=r?v(n,m):f?v(n,0):void 0;m>w;w++)if((h||w in b)&&(d=b[w],y=x(d,w,g),t))if(r)S[w]=y;else if(y)switch(t){case 3:return!0;case 5:return d;case 6:return w;case 2:S.push(d)}else if(s)return!1;return l?-1:a||s?s:S}}},{108:108,109:109,15:15,25:25,45:45}],13:[function(t,n,r){var e=t(3),i=t(109),o=t(45),u=t(108);n.exports=function(t,n,r,c,f){e(n);var a=i(t),s=o(a),l=u(a.length),h=f?l-1:0,v=f?-1:1;if(r<2)for(;;){if(h in s){c=s[h],h+=v;break}if(h+=v,f?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;f?h>=0:l>h;h+=v)h in s&&(c=n(c,s[h],h,a));return c}},{108:108,109:109,3:3,45:45}],14:[function(t,n,r){var e=t(49),i=t(47),o=t(117)("species");n.exports=function(t){var n;return i(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!i(n.prototype)||(n=void 0),e(n)&&null===(n=n[o])&&(n=void 0)),void 0===n?Array:n}},{117:117,47:47,49:49}],15:[function(t,n,r){var e=t(14);n.exports=function(t,n){return new(e(t))(n)}},{14:14}],16:[function(t,n,r){"use strict";var e=t(3),i=t(49),o=t(44),u=[].slice,c={},f=function(t,n,r){if(!(n in c)){for(var e=[],i=0;i1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!y(this,t)}}),v&&e(l.prototype,"size",{get:function(){return f(this[d])}}),l},def:function(t,n,r){var e,i,o=y(t,n);return o?o.v=r:(t._l=o={i:i=p(n,!0),k:n,v:r,p:e=t._l,n:void 0,r:!1},t._f||(t._f=o),e&&(e.n=o),t[d]++,"F"!==i&&(t._i[i]=o)),t},getEntry:y,setStrong:function(t,n,r){s(t,n,function(t,n){this._t=t,this._k=n,this._l=void 0},function(){for(var t=this,n=t._k,r=t._l;r&&r.r;)r=r.p;return t._t&&(t._l=r=r?r.n:t._t._f)?"keys"==n?l(0,r.k):"values"==n?l(0,r.v):l(0,[r.k,r.v]):(t._t=void 0,l(1))},r?"entries":"values",!r,!0),h(n)}}},{25:25,27:27,28:28,37:37,53:53,55:55,6:6,62:62,66:66,67:67,86:86,91:91}],20:[function(t,n,r){var e=t(17),i=t(10);n.exports=function(t){return function(){if(e(this)!=t)throw TypeError(t+"#toJSON isn't generic");return i(this)}}},{10:10,17:17}],21:[function(t,n,r){"use strict";var e=t(86),i=t(62).getWeak,o=t(7),u=t(49),c=t(6),f=t(37),a=t(12),s=t(39),l=a(5),h=a(6),v=0,p=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},y=function(t,n){return l(t.a,function(t){return t[0]===n})};d.prototype={get:function(t){var n=y(this,t);if(n)return n[1]},has:function(t){return!!y(this,t)},set:function(t,n){var r=y(this,t);r?r[1]=n:this.a.push([t,n])},delete:function(t){var n=h(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},n.exports={getConstructor:function(t,n,r,o){var a=t(function(t,e){c(t,a,n,"_i"),t._i=v++,t._l=void 0,void 0!=e&&f(e,r,t[o],t)});return e(a.prototype,{delete:function(t){if(!u(t))return!1;var n=i(t);return!0===n?p(this).delete(t):n&&s(n,this._i)&&delete n[this._i]},has:function(t){if(!u(t))return!1;var n=i(t);return!0===n?p(this).has(t):n&&s(n,this._i)}}),a},def:function(t,n,r){var e=i(o(n),!0);return!0===e?p(t).set(n,r):e[t._i]=r,t},ufstore:p}},{12:12,37:37,39:39,49:49,6:6,62:62,7:7,86:86}],22:[function(t,n,r){"use strict";var e=t(38),i=t(32),o=t(87),u=t(86),c=t(62),f=t(37),a=t(6),s=t(49),l=t(34),h=t(54),v=t(92),p=t(43);n.exports=function(t,n,r,d,y,g){var b=e[t],x=b,m=y?"set":"add",w=x&&x.prototype,S={},_=function(t){var n=w[t];o(w,t,"delete"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return g&&!s(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof x&&(g||w.forEach&&!l(function(){(new x).entries().next()}))){var E=new x,O=E[m](g?{}:-0,1)!=E,F=l(function(){E.has(1)}),P=h(function(t){new x(t)}),M=!g&&l(function(){for(var t=new x,n=5;n--;)t[m](n,n);return!t.has(-0)});P||(x=n(function(n,r){a(n,x,t);var e=p(new b,n,x);return void 0!=r&&f(r,y,e[m],e),e}),x.prototype=w,w.constructor=x),(F||M)&&(_("delete"),_("has"),y&&_("get")),(M||O)&&_(m),g&&w.clear&&delete w.clear}else x=d.getConstructor(n,t,y,m),u(x.prototype,r),c.NEED=!0;return v(x,t),S[t]=x,i(i.G+i.W+i.F*(x!=b),S),g||d.setStrong(x,t,y),x}},{32:32,34:34,37:37,38:38,43:43,49:49,54:54,6:6,62:62,86:86,87:87,92:92}],23:[function(t,n,r){var e=n.exports={version:"2.4.0"};"number"==typeof __e&&(__e=e)},{}],24:[function(t,n,r){"use strict";var e=t(67),i=t(85);n.exports=function(t,n,r){n in t?e.f(t,n,i(0,r)):t[n]=r}},{67:67,85:85}],25:[function(t,n,r){var e=t(3);n.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},{3:3}],26:[function(t,n,r){"use strict";var e=t(7),i=t(110),o="number";n.exports=function(t){if("string"!==t&&t!==o&&"default"!==t)throw TypeError("Incorrect hint");return i(e(this),t!=o)}},{110:110,7:7}],27:[function(t,n,r){n.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},{}],28:[function(t,n,r){n.exports=!t(34)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{34:34}],29:[function(t,n,r){var e=t(49),i=t(38).document,o=e(i)&&e(i.createElement);n.exports=function(t){return o?i.createElement(t):{}}},{38:38,49:49}],30:[function(t,n,r){n.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},{}],31:[function(t,n,r){var e=t(76),i=t(73),o=t(77);n.exports=function(t){var n=e(t),r=i.f;if(r)for(var u,c=r(t),f=o.f,a=0;c.length>a;)f.call(t,u=c[a++])&&n.push(u);return n}},{73:73,76:76,77:77}],32:[function(t,n,r){var e=t(38),i=t(23),o=t(40),u=t(87),c=t(25),f="prototype",a=function(t,n,r){var s,l,h,v,p=t&a.F,d=t&a.G,y=t&a.S,g=t&a.P,b=t&a.B,x=d?e:y?e[n]||(e[n]={}):(e[n]||{})[f],m=d?i:i[n]||(i[n]={}),w=m[f]||(m[f]={});d&&(r=n);for(s in r)l=!p&&x&&void 0!==x[s],h=(l?x:r)[s],v=b&&l?c(h,e):g&&"function"==typeof h?c(Function.call,h):h,x&&u(x,s,h,t&a.U),m[s]!=h&&o(m,s,v),g&&w[s]!=h&&(w[s]=h)};e.core=i,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,n.exports=a},{23:23,25:25,38:38,40:40,87:87}],33:[function(t,n,r){var e=t(117)("match");n.exports=function(t){var n=/./;try{"/./"[t](n)}catch(r){try{return n[e]=!1,!"/./"[t](n)}catch(t){}}return!0}},{117:117}],34:[function(t,n,r){n.exports=function(t){try{return!!t()}catch(t){return!0}}},{}],35:[function(t,n,r){"use strict";var e=t(40),i=t(87),o=t(34),u=t(27),c=t(117);n.exports=function(t,n,r){var f=c(t),a=r(u,f,""[t]),s=a[0],l=a[1];o(function(){var n={};return n[f]=function(){return 7},7!=""[t](n)})&&(i(String.prototype,t,s),e(RegExp.prototype,f,2==n?function(t,n){return l.call(t,this,n)}:function(t){return l.call(t,this)}))}},{117:117,27:27,34:34,40:40,87:87}],36:[function(t,n,r){"use strict";var e=t(7);n.exports=function(){var t=e(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},{7:7}],37:[function(t,n,r){var e=t(25),i=t(51),o=t(46),u=t(7),c=t(108),f=t(118),a={},s={};(r=n.exports=function(t,n,r,l,h){var v,p,d,y,g=h?function(){return t}:f(t),b=e(r,l,n?2:1),x=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(o(g)){for(v=c(t.length);v>x;x++)if((y=n?b(u(p=t[x])[0],p[1]):b(t[x]))===a||y===s)return y}else for(d=g.call(t);!(p=d.next()).done;)if((y=i(d,b,p.value,n))===a||y===s)return y}).BREAK=a,r.RETURN=s},{108:108,118:118,25:25,46:46,51:51,7:7}],38:[function(t,n,r){var e=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},{}],39:[function(t,n,r){var e={}.hasOwnProperty;n.exports=function(t,n){return e.call(t,n)}},{}],40:[function(t,n,r){var e=t(67),i=t(85);n.exports=t(28)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},{28:28,67:67,85:85}],41:[function(t,n,r){n.exports=t(38).document&&document.documentElement},{38:38}],42:[function(t,n,r){n.exports=!t(28)&&!t(34)(function(){return 7!=Object.defineProperty(t(29)("div"),"a",{get:function(){return 7}}).a})},{28:28,29:29,34:34}],43:[function(t,n,r){var e=t(49),i=t(90).set;n.exports=function(t,n,r){var o,u=n.constructor;return u!==r&&"function"==typeof u&&(o=u.prototype)!==r.prototype&&e(o)&&i&&i(t,o),t}},{49:49,90:90}],44:[function(t,n,r){n.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},{}],45:[function(t,n,r){var e=t(18);n.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},{18:18}],46:[function(t,n,r){var e=t(56),i=t(117)("iterator"),o=Array.prototype;n.exports=function(t){return void 0!==t&&(e.Array===t||o[i]===t)}},{117:117,56:56}],47:[function(t,n,r){var e=t(18);n.exports=Array.isArray||function(t){return"Array"==e(t)}},{18:18}],48:[function(t,n,r){var e=t(49),i=Math.floor;n.exports=function(t){return!e(t)&&isFinite(t)&&i(t)===t}},{49:49}],49:[function(t,n,r){n.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},{}],50:[function(t,n,r){var e=t(49),i=t(18),o=t(117)("match");n.exports=function(t){var n;return e(t)&&(void 0!==(n=t[o])?!!n:"RegExp"==i(t))}},{117:117,18:18,49:49}],51:[function(t,n,r){var e=t(7);n.exports=function(t,n,r,i){try{return i?n(e(r)[0],r[1]):n(r)}catch(n){var o=t.return;throw void 0!==o&&e(o.call(t)),n}}},{7:7}],52:[function(t,n,r){"use strict";var e=t(66),i=t(85),o=t(92),u={};t(40)(u,t(117)("iterator"),function(){return this}),n.exports=function(t,n,r){t.prototype=e(u,{next:i(1,r)}),o(t,n+" Iterator")}},{117:117,40:40,66:66,85:85,92:92}],53:[function(t,n,r){"use strict";var e=t(58),i=t(32),o=t(87),u=t(40),c=t(39),f=t(56),a=t(52),s=t(92),l=t(74),h=t(117)("iterator"),v=!([].keys&&"next"in[].keys()),d="keys",y="values",g=function(){return this};n.exports=function(t,n,r,b,x,m,w){a(r,n,b);var S,_,E,O=function(t){if(!v&&t in A)return A[t];switch(t){case d:case y:return function(){return new r(this,t)}}return function(){return new r(this,t)}},F=n+" Iterator",P=x==y,M=!1,A=t.prototype,I=A[h]||A["@@iterator"]||x&&A[x],j=I||O(x),N=x?P?O("entries"):j:void 0,k="Array"==n?A.entries||I:I;if(k&&(E=l(k.call(new t)))!==Object.prototype&&(s(E,F,!0),e||c(E,h)||u(E,h,g)),P&&I&&I.name!==y&&(M=!0,j=function(){return I.call(this)}),e&&!w||!v&&!M&&A[h]||u(A,h,j),f[n]=j,f[F]=g,x)if(S={values:P?j:O(y),keys:m?j:O(d),entries:N},w)for(_ in S)_ in A||o(A,_,S[_]);else i(i.P+i.F*(v||M),n,S);return S}},{117:117,32:32,39:39,40:40,52:52,56:56,58:58,74:74,87:87,92:92}],54:[function(t,n,r){var e=t(117)("iterator"),i=!1;try{var o=[7][e]();o.return=function(){i=!0},Array.from(o,function(){throw 2})}catch(t){}n.exports=function(t,n){if(!n&&!i)return!1;var r=!1;try{var o=[7],u=o[e]();u.next=function(){return{done:r=!0}},o[e]=function(){return u},t(o)}catch(t){}return r}},{117:117}],55:[function(t,n,r){n.exports=function(t,n){return{value:n,done:!!t}}},{}],56:[function(t,n,r){n.exports={}},{}],57:[function(t,n,r){var e=t(76),i=t(107);n.exports=function(t,n){for(var r,o=i(t),u=e(o),c=u.length,f=0;c>f;)if(o[r=u[f++]]===n)return r}},{107:107,76:76}],58:[function(t,n,r){n.exports=!1},{}],59:[function(t,n,r){var e=Math.expm1;n.exports=!e||e(10)>22025.465794806718||e(10)<22025.465794806718||-2e-17!=e(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:e},{}],60:[function(t,n,r){n.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},{}],61:[function(t,n,r){n.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},{}],62:[function(t,n,r){var e=t(114)("meta"),i=t(49),o=t(39),u=t(67).f,c=0,f=Object.isExtensible||function(){return!0},a=!t(34)(function(){return f(Object.preventExtensions({}))}),s=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,e)){if(!f(t))return"F";if(!n)return"E";s(t)}return t[e].i},h=function(t,n){if(!o(t,e)){if(!f(t))return!0;if(!n)return!1;s(t)}return t[e].w},v=function(t){return a&&p.NEED&&f(t)&&!o(t,e)&&s(t),t},p=n.exports={KEY:e,NEED:!1,fastKey:l,getWeak:h,onFreeze:v}},{114:114,34:34,39:39,49:49,67:67}],63:[function(t,n,r){var e=t(149),i=t(32),o=t(94)("metadata"),u=o.store||(o.store=new(t(255))),c=function(t,n,r){var i=u.get(t);if(!i){if(!r)return;u.set(t,i=new e)}var o=i.get(n);if(!o){if(!r)return;i.set(n,o=new e)}return o},f=function(t,n,r){var e=c(n,r,!1);return void 0!==e&&e.has(t)},a=function(t,n,r){var e=c(n,r,!1);return void 0===e?void 0:e.get(t)},s=function(t,n,r,e){c(r,e,!0).set(t,n)},l=function(t,n){var r=c(t,n,!1),e=[];return r&&r.forEach(function(t,n){e.push(n)}),e},h=function(t){return void 0===t||"symbol"==typeof t?t:String(t)},v=function(t){i(i.S,"Reflect",t)};n.exports={store:u,map:c,has:f,get:a,set:s,keys:l,key:h,exp:v}},{149:149,255:255,32:32,94:94}],64:[function(t,n,r){var e=t(38),i=t(104).set,o=e.MutationObserver||e.WebKitMutationObserver,u=e.process,c=e.Promise,f="process"==t(18)(u);n.exports=function(){var t,n,r,a=function(){var e,i;for(f&&(e=u.domain)&&e.exit();t;){i=t.fn,t=t.next;try{i()}catch(e){throw t?r():n=void 0,e}}n=void 0,e&&e.enter()};if(f)r=function(){u.nextTick(a)};else if(o){var s=!0,l=document.createTextNode("");new o(a).observe(l,{characterData:!0}),r=function(){l.data=s=!s}}else if(c&&c.resolve){var h=c.resolve();r=function(){h.then(a)}}else r=function(){i.call(e,a)};return function(e){var i={fn:e,next:void 0};n&&(n.next=i),t||(t=i,r()),n=i}}},{104:104,18:18,38:38}],65:[function(t,n,r){"use strict";var e=t(76),i=t(73),o=t(77),u=t(109),c=t(45),f=Object.assign;n.exports=!f||t(34)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=f({},t)[r]||Object.keys(f({},n)).join("")!=e})?function(t,n){for(var r=u(t),f=arguments.length,a=1,s=i.f,l=o.f;f>a;)for(var h,v=c(arguments[a++]),p=s?e(v).concat(s(v)):e(v),d=p.length,y=0;d>y;)l.call(v,h=p[y++])&&(r[h]=v[h]);return r}:f},{109:109,34:34,45:45,73:73,76:76,77:77}],66:[function(t,n,r){var e=t(7),i=t(68),o=t(30),u=t(93)("IE_PROTO"),c=function(){},f="prototype",a=function(){var n,r=t(29)("iframe"),e=o.length;for(r.style.display="none",t(41).appendChild(r),r.src="javascript:",(n=r.contentWindow.document).open(),n.write("