diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 0864bbc5..bb44fadf 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -82,6 +82,25 @@ $routes->get("scheme_list/", "Scheme::index");
$routes->get("new_scheme/(:any)", "Scheme::new_scheme/$1");
$routes->post("insert_scheme/", "Scheme::insert_scheme");
$routes->get("delete_scheme/(:any)", "Scheme::delete_scheme/$1");
+#subscription Routes
+$routes->get("subscribers_list/", "Subscription::index");
+$routes->get("new_subscription/", "Subscription::new_subscription/");
+$routes->post("add_subscription/", "Subscription::add_subscription/");
+#adres priknt
+$routes->get('addressprint/', 'Address::index');
+$routes->post('address/generatePdf', 'Address::generatePdf');
+#evnts
+$routes->get("event_list/", "Event::index");
+$routes->get("new_event/(:any)", "Event::new_event/$1");
+$routes->post("insert_event/", "Event::insert_event");
+#invoices
+$routes->get("invoice_list/", "Invoice::index");
+$routes->get("new_invoice/", "Invoice::new_invoice/");
+
+
+
+
+
# Api integration Routes
$routes->group("api", function ($routes) {
diff --git a/app/Controllers/Address.php b/app/Controllers/Address.php
new file mode 100644
index 00000000..8b0676bf
--- /dev/null
+++ b/app/Controllers/Address.php
@@ -0,0 +1,54 @@
+findAll();
+ return view('address_list', $data);
+ }
+}
+
+
+
+// public function generatePdf()
+// {
+// $customerModel = new CustomerModel();
+
+// $customer_id = $this->request->getPost('customer_id');
+// $customerData = $customerModel->find($customer_id);
+
+// if ($customerData) {
+
+// $options->set('isHtml5ParserEnabled', true);
+// $options->set('isPhpEnabled', true);
+// $dompdf = new Dompdf($options);
+
+
+// $html = view('address_list', ['customerData' => $customerData]);
+
+
+// $dompdf->loadHtml($html);
+
+
+// $dompdf->setPaper('A4', 'portrait');
+
+// $dompdf->render();
+
+
+// $dompdf->stream('customer_information.pdf', ['Attachment' => 0]);
+// } else {
+
+// return redirect()->to('index');
+// }
+// }
+// }
diff --git a/app/Controllers/Event.php b/app/Controllers/Event.php
new file mode 100644
index 00000000..6eb506b7
--- /dev/null
+++ b/app/Controllers/Event.php
@@ -0,0 +1,94 @@
+ (int)$session_bid];
+ } else {
+ $where = ['events.business_id != ' => NULL];
+ }
+
+ $EventModel = new EventModel();
+ $data['page_name'] = 'Event Details';
+ // $events = $EventModel->where($where)->orderBy('id', 'desc')->findAll(); // Retrieve the events
+ $events = $EventModel->where($where)->findAll(); // Retrieve the events
+
+ // Sort the events by ID in descending order (newest first)
+ // usort($events, function ($a, $b) {
+ // return $b['id'] - $a['id'];
+ // });
+
+ $data['event'] = $events; // Assign the sorted array to $data['event']
+
+ $this->render_page('event_list', $data);
+ } else {
+ return redirect()->to('login');
+ }
+}
+
+public function new_event($id)
+{
+ helper('session');
+ $session_bid = get_business_id();
+ if ($id === '0') {
+ $data['page_name'] = 'Add Event';
+ $data['event'] = [];
+ } else if ($id !== '0') {
+ $data['page_name'] = 'Edit Scheme';
+ $model = new EventModel();
+ $model->setTable('events');
+ $edit_event_details = $model->where(['id' => $id])->first();
+
+ $data['event'] = $edit_event_details;
+ }
+
+ $data['session_bid'] = $session_bid;
+
+ $this->render_page('event_form', $data);
+}
+public function insert_event()
+{
+ helper('session');
+ $session_bid = get_business_id();
+ $session_uid = get_logged_user_id();
+
+ $EventModel = new EventModel();
+ $data = [
+ 'event_name' => $this->request->getPost('ename'),
+ 'next_id' => $this->request->getPost('nextid'),
+ 'left_pad' => $this->request->getPost('leftpad'),
+ 'id_formating' => $this->request->getPost('formating'),
+ 'business_id' => $this->request->getPost('business_id')
+
+ ];
+$event_id = $this->request->getPost('id'); // Get the business ID for update
+
+ if (empty($event_id)) {
+ // It's an insert operation
+ $data['created_by'] = $session_uid;
+ $EventModel->insert($data);
+ } else {
+ // It's an update operation
+
+ $data['updated_by'] = $session_uid;
+
+ $EventModel->update($event_id, $data);
+ }
+ return redirect()->route('event_list');
+}
+
+}
\ No newline at end of file
diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php
new file mode 100644
index 00000000..5b9b9ebd
--- /dev/null
+++ b/app/Controllers/Invoice.php
@@ -0,0 +1,27 @@
+render_page('invoice_list', $data);
+
+}
+public function new_invoice()
+{
+ $data['page_name'] = 'Invoice Details';
+
+$this->render_page('invoice_form',$data);
+
+}
+}
\ No newline at end of file
diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php
new file mode 100644
index 00000000..aa650965
--- /dev/null
+++ b/app/Controllers/Subscription.php
@@ -0,0 +1,79 @@
+(int)$session_bid];
+ }else{ $where = ['subscription.business_id != '=>NULL];}
+
+ $SubscriptionModel = new SubscriptionModel();
+ $data['page_name'] = 'Subscription Details';
+ // $data['subscriber'] = $SubscriptionModel->where($where)->findAll();;
+ $data['subscriber'] = $SubscriptionModel->getAllSubscribersWithNames($where);
+
+ $this->render_page('subscribers_list', $data);
+ }else {
+ return redirect()->to('login');
+ }
+}
+ public function new_subscription() {
+
+ helper('session');
+ helper('session');
+ $session_bid = get_business_id();
+ $data['page_name'] = 'Subscription Details';
+ $customerModel = new CustomerModel();
+ $schemeModel = new SchemeModel();
+
+ $business_id = get_business_id();
+
+ // Get scheme names and durations from the SchemeModel
+ $data['customers'] = $customerModel->getCustomerNamesByBusiness($business_id);
+ $data['scheme_names'] = $schemeModel->getSchemeNamesAndDurationsByBusiness($business_id);
+
+ //print_r($data);die();
+ $this->render_page('subscription_form', $data);
+}
+// Subscription Controller (Subscription.php)
+public function add_subscription() {
+ helper('session');
+ $session_bid = get_business_id();
+ $session_uid = get_logged_user_id();
+
+ $SubscriptionModel = new SubscriptionModel();
+ $data = [
+
+ 'scheme_id' =>$this->request->getPost('scheme'),
+ 'customer_id' =>$this->request->getPost('customer'),
+ 'from_subscription' => $this->request->getPost('from_date'),
+ 'to_subscription' => $this->request->getPost('to_date'),
+ 'mode' => $this->request->getPost('mode'),
+ 'business_id'=>$session_bid
+ ];
+
+ $SubscriptionModel->insert($data);
+
+
+ // $data['subscriber'] = $subscriberModel->getAllSubscribersWithNames();
+ // print_r($data);die();
+ return redirect()->to('subscribers_list')->with('data', $data);
+}
+
+
+
+}
+
diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php
index 780986b6..f396222f 100644
--- a/app/Models/CustomerModel.php
+++ b/app/Models/CustomerModel.php
@@ -14,7 +14,44 @@ class CustomerModel extends Model
public function insertCustomer($data)
{
return $this->insert($data);
- }
+ }
+ public function getCustomerNamesByBusiness($business_id)
+ {
+ $this->builder()->select('customer_id,CONCAT(first_name, " ", last_name) as full_name', false);
+ $this->builder()->where('business_id ', $business_id); // Filter by business_id
+ $query = $this->builder()->get(); // Use findAll() instead of get()
+ return ($query->getResult());
+ }
+
+ // $customerNames = [];
+
+ // foreach ($query->getResult() as $row) {
+ // $customerNames[] = [ $row->full_name ];
+ // }
+ // print_r($customerNames);
+ // die();
+
+
+
+// public function getCustomerIdByName($customerName, $businessId)
+// {
+// $customer = $this->builder()
+// ->select('customer_id')
+// ->where('CONCAT(first_name, " ", last_name)', $customerName)
+// ->where('business_id', $businessId)
+// ->get()
+// ->getRow();
+
+// if ($customer) {
+// return $customer->customer_id;
+// }
+
+// return null; // Customer not found
+// }
+
+
+
+
public function insertAddress($addressData) {
$this->db->table('customer_addresses')->insert($addressData);
@@ -44,11 +81,14 @@ class CustomerModel extends Model
$statement[$i] = "address - ".$insertID." Inserted";
}
}
+
return $statement;
}
+
+
public function inactiveMissingAddressDetails($where,$missingValues){
$dataToUpdate = ['isactive' => 0];
$this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
}
}
-?>
\ No newline at end of file
+?>
diff --git a/app/Models/EventModel.php b/app/Models/EventModel.php
new file mode 100644
index 00000000..7098ca43
--- /dev/null
+++ b/app/Models/EventModel.php
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/app/Models/SchemeModel.php b/app/Models/SchemeModel.php
index fc491a88..4c4cfcca 100644
--- a/app/Models/SchemeModel.php
+++ b/app/Models/SchemeModel.php
@@ -15,5 +15,42 @@ class SchemeModel extends Model
{
return $this->insert($data);
}
+
+
+ public function getSchemeNamesAndDurationsByBusiness($business_id)
+ {
+ $builder = $this->builder();
+ $builder->select('scheme_id, scheme_name, duration');
+ $builder->where('business_id', $business_id);
+
+ $query = $builder->get();
+
+ $schemes = [];
+
+ foreach ($query->getResult() as $row) {
+ $schemes[$row->scheme_id] = [
+ 'scheme_name' => $row->scheme_name,
+ 'duration' => $row->duration,
+ ];
+ }
+
+ return $schemes;
+ }
+// public function getSchemeDuration($schemeId)
+// {
+// $query = $this->select('duration')
+// ->where('scheme_id', $schemeId)
+// ->get();
+
+// if ($query->getNumRows() === 1) {
+// $row = $query->getRow();
+// return $row->duration;
+// } else {
+// return null;
+// }
+// }
}
-?>
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/app/Models/SubscriptionModel.php b/app/Models/SubscriptionModel.php
new file mode 100644
index 00000000..fe271023
--- /dev/null
+++ b/app/Models/SubscriptionModel.php
@@ -0,0 +1,25 @@
+db->table('subscription');
+ $builder->select('subscription.*, schemes.scheme_name, CONCAT(customers.first_name, " ", customers.last_name) as customer_name');
+ $builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
+ $builder->join('customers', 'customers.customer_id = subscription.customer_id');
+ $builder->where($where);
+ return $builder->get()->getResultArray();
+}
+}
+
diff --git a/app/Views/address_list.php b/app/Views/address_list.php
new file mode 100644
index 00000000..09e6087d
--- /dev/null
+++ b/app/Views/address_list.php
@@ -0,0 +1,66 @@
+
+ " rel="stylesheet" type="text/css" />
+
+
+ " rel="stylesheet" type="text/css" />
+ " rel="stylesheet" type="text/css" />
+ " rel="stylesheet" type="text/css" />
+ " rel="stylesheet" type="text/css" />
+
+
+
+ " rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
+ " rel="stylesheet" type="text/css" id="app-default-stylesheet" />
+
+ " rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
+ " rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
+
+
+ " rel="stylesheet" type="text/css" />
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/event_list.php b/app/Views/event_list.php
new file mode 100644
index 00000000..08d581b2
--- /dev/null
+++ b/app/Views/event_list.php
@@ -0,0 +1,51 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php
new file mode 100644
index 00000000..151b9b05
--- /dev/null
+++ b/app/Views/invoice_form.php
@@ -0,0 +1,246 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Terms & Conditions
+
+
+
+
+
+
+
+ Submit
+
+
+ Reset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/invoice_list.php b/app/Views/invoice_list.php
new file mode 100644
index 00000000..1916aaf6
--- /dev/null
+++ b/app/Views/invoice_list.php
@@ -0,0 +1,39 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/subscribers_list.php b/app/Views/subscribers_list.php
index a9d658e2..f25b6c62 100644
--- a/app/Views/subscribers_list.php
+++ b/app/Views/subscribers_list.php
@@ -3,7 +3,7 @@