From 8ea1d07d0f1b4991698173c64f42ab79221aeb1c Mon Sep 17 00:00:00 2001 From: heama Date: Wed, 6 Sep 2023 12:14:02 +0530 Subject: [PATCH] heama --- app/Controllers/Customer.php | 1 + app/Controllers/Invoice.php | 56 +++-- app/Controllers/Subscription.php | 2 +- app/Models/CustomerModel.php | 1 + app/Models/EventModel.php | 11 +- app/Models/InvoiceModel.php | 16 ++ app/Views/invoice_form.php | 405 ++++++++++++++++--------------- 7 files changed, 278 insertions(+), 214 deletions(-) create mode 100644 app/Models/InvoiceModel.php diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index c5e0c06e..fd494bd5 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -290,4 +290,5 @@ class Customer extends BaseController echo "
go to list page
"; // return $message; } + } diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 5b9b9ebd..c93211aa 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -1,27 +1,53 @@ (int)$session_bid]; + }else{ $where = ['invoice.business_id != '=>NULL];} + + $InvoiceModel = new InvoiceModel(); + $data['page_name'] = 'Invoice Details'; + // $data['subscriber'] = $SubscriptionModel->where($where)->findAll();; + // $data['invoice'] = $InvoiceModel->getAllSubscribersWithNames($where); + $this->render_page('invoice_list', $data); - + }else { + return redirect()->to('login'); + } } -public function new_invoice() -{ - $data['page_name'] = 'Invoice Details'; - -$this->render_page('invoice_form',$data); + + + public function new_invoice() + { + helper('session'); + $session_bid = get_business_id(); + $data['page_name'] = 'Invoice Details'; + $customerModel = new CustomerModel(); + $eventModel = new EventModel(); + $business_id = get_business_id(); + + // Get customer names for the dropdown + $data['customers'] = $customerModel->getCustomerNamesByBusiness($business_id); +$data['events']= $eventModel->getEventnamesByBusiness($business_id); + // Initialize billing and shipping addresses as empty + $data['billingAddress'] = ''; + $data['shippingAddress'] = ''; + + $this->render_page('invoice_form', $data); + } } -} \ No newline at end of file diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php index aa650965..74dcec30 100644 --- a/app/Controllers/Subscription.php +++ b/app/Controllers/Subscription.php @@ -26,7 +26,7 @@ class Subscription extends BaseController $data['subscriber'] = $SubscriptionModel->getAllSubscribersWithNames($where); $this->render_page('subscribers_list', $data); - }else { + }else { return redirect()->to('login'); } } diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php index f396222f..354e7ba8 100644 --- a/app/Models/CustomerModel.php +++ b/app/Models/CustomerModel.php @@ -90,5 +90,6 @@ class CustomerModel extends Model $dataToUpdate = ['isactive' => 0]; $this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate); } + } ?> diff --git a/app/Models/EventModel.php b/app/Models/EventModel.php index 7098ca43..fdeec050 100644 --- a/app/Models/EventModel.php +++ b/app/Models/EventModel.php @@ -10,7 +10,16 @@ class EventModel extends Model protected $table = 'events'; protected $primaryKey = 'id'; protected $allowedFields = ['id','event_name','next_id','left_pad','id_formating','created_by','created_on','updated_on' ,'updated_by','business_id']; - + + + + public function getEventnamesByBusiness($business_id) + { + $this->builder()->select('id,event_name'); + $this->builder()->where('business_id ', $business_id); // Filter by business_id + $query = $this->builder()->get(); // Use findAll() instead of get() + return ($query->getResult()); + } } ?> \ No newline at end of file diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php new file mode 100644 index 00000000..79051c07 --- /dev/null +++ b/app/Models/InvoiceModel.php @@ -0,0 +1,16 @@ + - - - + } + + .btn btn-primary { + text-align: right; + } + -
-
-
-
-

-

-
-
-
-
- - -
+
+
+
+
+

+

+ +
+
+ +
+ + +
+
Please provide.
- - -
- - -
-
-
- - - -
-
- - -
+ + +
+ + +
+
+
+ + + +
+
+ + +
+ + +
+
+
+ + +
+
+ + +
+
+
+ + + - -
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
- -
+ + +
+
+ + +
- -
- - -
-
Item Details
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Item DetailsQuantityRateTaxAmount Actions
- -
-
- - - -
- -
-
-

Calculation

-
- -
-
- - +
+
+ + +
Please select a customer.
+
-
- - -
-
- - + + + + + +
+ + +
+
Item Details
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Item DetailsQuantityRateTaxAmount Actions
+
-
+ + + +
+ +
+
+

Calculation

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + +
- - + + + +
+ +
+
+ + + + +
- + + + + +
- -
- - - -
- -
+ - + - + - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file