customer subscription tab

This commit is contained in:
heama 2023-10-05 10:12:37 +05:30
parent dc1aba9e3b
commit eaf7692215
7 changed files with 54 additions and 21 deletions

View File

@ -38,9 +38,10 @@ class Customer extends BaseController
{
helper('session');
$session_bid = get_business_id();
if ($id === '0') {
// Add Customer
$data['page_name'] = 'Add Customer';
$data['page_name'] = 'Add Customer';
$data['customer'] = [];
$data['customer_billing'] = [];
$data['customer_shipping'] = [];
@ -48,22 +49,27 @@ class Customer extends BaseController
$data['invoices'] = [];
} else if ($id !== '0') {
// Edit Customer
$data['page_name'] = 'Edit Customer';
$subscriptionModel = new SubscriptionModel();
$subscriptionData = $subscriptionModel->getSubscriptionsByCustomerId($id);
$model = new CustomerModel();
$model->setTable('customers');
$edit_user_details = $model->where(['customer_id' => $id])->first();
$data['page_name'] = 'Edit Customer';
// Load your Customer Model
$customerModel = new CustomerModel();
// Retrieve customer details by customer ID
$edit_user_details = $customerModel->where(['customer_id' => $id])->first();
$data['customer'] = $edit_user_details;
$data['customer_billing'] = $this->get_customer_address($id, 1);
$data['customer_shipping'] = $this->get_customer_address($id, 2);
$data['subscriptionData'] = $subscriptionData;
// Retrieve subscriber data based on the customer ID
$subscriberData = $customerModel->getSubscriberDataByCustomerId($id);
$data['subscriptionData'] = $subscriberData;
// Fetch invoice data for the customer
$CustomerModel = new CustomerModel();
$invoices = $CustomerModel->getInvoicesByCustomerId($id);
$data['invoices'] = $invoices;
}
$data['session_bid'] = $session_bid;
$this->render_page('customer_form', $data);
}

View File

@ -98,5 +98,22 @@ class CustomerModel extends Model
->get()
->getResult();
}
public function getSubscriberDataByCustomerId($customerId)
{
// Assuming 'subscription' is the table name where subscriber data is stored.
$builder = $this->db->table('subscription');
$builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
// Define the columns you want to select from the subscription table.
$builder->select('sub_id, to_subscription, from_subscription,schemes.scheme_name');
// Add a where condition to filter results based on customer ID.
$builder->where('customer_id', $customerId);
// Execute the query and return the result as an array of objects.
return $builder->get()->getResult();
}
}
?>

View File

@ -147,14 +147,7 @@ public function getAllCustomerDetailsBySchemeName($schemeName)
return $customerDetails;
}
public function getSubscriptionsByCustomerId($customerId)
{
$builder = $this->db->table('subscription');
$builder->select('schemes.scheme_name,from_subscription,to_subscription');
$builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
// Query to retrieve subscription records for a specific customer
return $builder->get()->getResultArray();
}
}

View File

@ -328,9 +328,9 @@
<tbody>
<?php foreach ($subscriptionData as $subscription): ?>
<tr>
<td><?= $subscription['scheme_name']; ?></td>
<td><?= $subscription['from_subscription']; ?></td>
<td><?= $subscription['to_subscription']; ?></td>
<td><?= $subscription->scheme_name ?></td>
<td><?= $subscription->from_subscription ?></td>
<td><?= $subscription->to_subscription ?></td>
</tr>
<?php endforeach; ?>
</tbody>

View File

@ -740,5 +740,22 @@ invoiceDateInput.setAttribute("min", minDate);
// Optional: Set the default value to today's date
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Get the Due Date input element by its ID
const dueDateInput = document.getElementById("dueDate");
// Get the current date
const currentDate = new Date();
// Set the minimum date attribute to today's date (YYYY-MM-DD format)
const minDate = currentDate.toISOString().split("T")[0];
dueDateInput.setAttribute("min", minDate);
// Optional: Set the default value to today's date
});
</script>
</body>
</html>

View File

@ -272,7 +272,7 @@ if (count($invoiceDateParts) === 3) {
</table>
<div class="business-stamp">
<img src="https://static.vecteezy.com/system/resources/thumbnails/004/853/320/small/book-read-library-study-line-icon-illustration-logo-template-suitable-for-many-purposes-free-vector.jpg" alt="Business Logo" class="business-logo">
</div>
<div class="terms">

View File

@ -142,7 +142,7 @@
</li>
<li>
<a href="<?= base_url()."book_list"; ?>">
<i class=" ri-book-open-line"></i>
<i class="ri-book-open-line"></i>
<span> Products </span>
</a>
</li>