Code Merge branch 'uat' : ps
This commit is contained in:
commit
f60a847d9e
@ -86,7 +86,8 @@ $routes->get("delete_scheme/(:any)", "Scheme::delete_scheme/$1");
|
||||
$routes->get("subscribers_list/", "Subscription::index");
|
||||
$routes->get("new_subscription/", "Subscription::new_subscription/");
|
||||
$routes->post("add_subscription/", "Subscription::add_subscription/");
|
||||
$routes->get('subscription/generate_pdf', 'Subscription::generate_pdf');
|
||||
$routes->post('subscription/download_details', 'Subscription::download_details');
|
||||
|
||||
|
||||
|
||||
#adres priknt
|
||||
|
||||
@ -48,6 +48,7 @@ class Subscription extends BaseController
|
||||
//print_r($data);die();
|
||||
$this->render_page('subscription_form', $data);
|
||||
}
|
||||
|
||||
// Subscription Controller (Subscription.php)
|
||||
public function add_subscription() {
|
||||
helper('session');
|
||||
@ -75,34 +76,64 @@ public function add_subscription() {
|
||||
|
||||
// Subscription.php (Controller)
|
||||
|
||||
public function generate_pdf()
|
||||
// public function download_details()
|
||||
// {
|
||||
// $selectedScheme = $this->request->getPost('selected_scheme');
|
||||
|
||||
// // Call the model method to get customer details for the selected scheme
|
||||
// $subscriptionModel = new SubscriptionModel();
|
||||
// $business = $subscriptionModel->getCustomerAddressesBySchemeName($selectedScheme);
|
||||
|
||||
// $shippingInfo = $subscriptionModel->getCustomerAddressesBySchemeName($selectedScheme, 2);
|
||||
// $customerName = $subscriptionModel->getCustomerNameBySchemeName($selectedScheme);
|
||||
|
||||
// // Create an HTML content string using the view file (similar to print_addresses.php)
|
||||
// if ($customerName !== 'Customer not found') {
|
||||
// $html = view('print_addresses_form', ['customerName' => $customerName, 'shippingInfo' => $shippingInfo, 'business' => $business]);
|
||||
|
||||
// // Generate a PDF from the HTML content
|
||||
// $pdf = new Mpdf();
|
||||
|
||||
// $pdf->WriteHTML($html);
|
||||
|
||||
// // Set the PDF filename
|
||||
// $filename = 'CustomerDetails_' . date('YmdHis') . '.pdf';
|
||||
|
||||
// // Output the PDF for download
|
||||
// $pdf->Output($filename, 'D');
|
||||
// } else {
|
||||
// // Handle the case where the customer is not found
|
||||
// echo 'Customer not found';
|
||||
// }
|
||||
// }
|
||||
public function download_details()
|
||||
{
|
||||
$schemeName = $this->request->getGet('scheme_name');
|
||||
$selectedScheme = $this->request->getPost('selected_scheme');
|
||||
|
||||
// Call the model method to get customer addresses
|
||||
// Call the model method to get all customer details for the selected scheme
|
||||
$subscriptionModel = new SubscriptionModel();
|
||||
$addresses = $subscriptionModel->getCustomerAddressesBySchemeName($schemeName);
|
||||
$billingInfo = $subscriptionModel->getCustomerAddressesBySchemeName($schemeName, 1);
|
||||
$shippingInfo = $subscriptionModel->getCustomerAddressesBySchemeName($schemeName, 2);
|
||||
$customerName = $subscriptionModel->getCustomerNameBySchemeName($schemeName);
|
||||
$customerDetails = $subscriptionModel->getAllCustomerDetailsBySchemeName($selectedScheme);
|
||||
|
||||
// Create an HTML content string using the view file (similar to print_addresses.php)
|
||||
if (!empty($customerDetails)) {
|
||||
$html = view('print_addresses_form', ['customerDetails' => $customerDetails]);
|
||||
|
||||
// Create an HTML content string using the view file
|
||||
if ($customerName !== 'Customer not found') {
|
||||
// Create an HTML content string using the view file
|
||||
$html = view('print_addresses_form', ['customerName' => $customerName, 'billingInfo' => $billingInfo, 'shippingInfo' => $shippingInfo]);
|
||||
|
||||
// Generate a PDF from the HTML content
|
||||
$pdf = new Mpdf();
|
||||
|
||||
|
||||
$pdf->WriteHTML($html);
|
||||
|
||||
// Output the PDF to the browser in a new tab
|
||||
$pdf->Output('CustomerAddress.pdf', 'D');
|
||||
// Set the PDF filename
|
||||
$filename = 'CustomerDetails_' . date('YmdHis') . '.pdf';
|
||||
|
||||
// Output the PDF for download
|
||||
$pdf->Output($filename, 'D');
|
||||
} else {
|
||||
// Handle the case where the customer is not found
|
||||
echo 'Customer not found';
|
||||
// Handle the case where no customer details are found for the selected scheme
|
||||
echo 'No customer details found for the selected scheme.';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// public function generate_pdf()
|
||||
// {
|
||||
|
||||
@ -81,10 +81,28 @@ public function getSchemeNames()
|
||||
print_r($schemes);die();
|
||||
}
|
||||
|
||||
public function getSchemeNameById($schemeId)
|
||||
{
|
||||
// Query the database to retrieve the scheme name by ID
|
||||
$builder = $this->db->table('schemes');
|
||||
$builder->select('scheme_name');
|
||||
$builder->where('scheme_id', $schemeId);
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
// Check if a record was found
|
||||
if ($query->getNumRows() > 0) {
|
||||
$row = $query->getRow();
|
||||
return $row->scheme_name;
|
||||
} else {
|
||||
return null; // Return null if no scheme with the given ID is found
|
||||
}
|
||||
}
|
||||
public function getAllSchemes()
|
||||
{
|
||||
return $this->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -86,8 +86,69 @@ public function getCustomerAddressesBySchemeName($schemeName)
|
||||
|
||||
return $addresses;
|
||||
}
|
||||
public function getAllCustomerDetailsBySchemeName($schemeName)
|
||||
{
|
||||
$builder = $this->db->table('subscription');
|
||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title,business.address,business.city,business.state,business.postal_code,schemes.scheme_name,from_subscription,to_subscription');
|
||||
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
||||
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
|
||||
$builder->join('business', 'business.business_id = subscription.business_id');
|
||||
$builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
|
||||
$builder->where('schemes.scheme_name', $schemeName);
|
||||
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
||||
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
||||
|
||||
// Fetch the query result
|
||||
$query = $builder->get();
|
||||
|
||||
$customerDetails = [];
|
||||
|
||||
if ($query->getNumRows() > 0) {
|
||||
$currentCustomerID = null;
|
||||
$shippingAddress = [];
|
||||
|
||||
foreach ($query->getResultArray() as $row) {
|
||||
$customerID = $row['customer_id'];
|
||||
|
||||
if ($currentCustomerID !== $customerID) {
|
||||
// New customer, add the previous customer's details (if any)
|
||||
if (!empty($shippingAddress)) {
|
||||
$customerDetails[] = $shippingAddress;
|
||||
}
|
||||
|
||||
// Start a new customer's details
|
||||
$shippingAddress = [
|
||||
'customer_name' => $row['customer_name'],
|
||||
'address_1' => $row['address_1'],
|
||||
'address_2' => $row['address_2'],
|
||||
'mobile_no'=>$row['mobile_no'],
|
||||
|
||||
'city' => $row['city'],
|
||||
'state' => $row['state'],
|
||||
'postal_code' => $row['postal_code'],
|
||||
'address' => $row['address'],
|
||||
'city' => $row['city'],
|
||||
'state' => $row['state'],
|
||||
'postal_code' => $row['postal_code'],
|
||||
'title' => $row['title'],
|
||||
'to_subscription'=>$row['to_subscription'],
|
||||
'scheme_name'=>$row['scheme_name'],
|
||||
];
|
||||
|
||||
$currentCustomerID = $customerID;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last customer's details (if any)
|
||||
if (!empty($shippingAddress)) {
|
||||
$customerDetails[] = $shippingAddress;
|
||||
}
|
||||
}
|
||||
|
||||
return $customerDetails;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -12,21 +12,22 @@
|
||||
}
|
||||
|
||||
.shipping-label {
|
||||
width: 250px; /* Reduced width for courier cover */
|
||||
margin: 20px auto;
|
||||
width: 400px; /* Set the width */
|
||||
height: 140px; /* Set the height to match the width for a square shape */
|
||||
margin: 10px;
|
||||
border: 1px solid #000;
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.label-title {
|
||||
font-size: 14px; /* Reduced font size for title */
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.address {
|
||||
font-size: 12px; /* Reduced font size for address */
|
||||
font-size: 16px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@ -40,29 +41,26 @@
|
||||
}
|
||||
|
||||
.footer {
|
||||
font-size: 10px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.business-logo {
|
||||
max-width: 150px; /* Adjust the logo size */
|
||||
max-width: 150px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php foreach ($invoiceData as $value) : ?>
|
||||
<div class="shipping-label">
|
||||
<div class="label-title">
|
||||
<img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo">
|
||||
</div>
|
||||
<?php foreach ($invoiceData as $value) : ?>
|
||||
<div class="address">
|
||||
<p><?= $value->address ?>,<br><?= $value->city ?>, <?= $value->state ?>,</p>
|
||||
<p><?= $value->postal_code ?></p>
|
||||
<p><?= $value->email ?></p>
|
||||
<p><?= $value->mobile_no ?></p>
|
||||
<img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"><br>
|
||||
<?= $value->address ?>,<br><?= $value->city ?>, <?= $value->state ?>,
|
||||
<?= $value->postal_code ?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="address">
|
||||
<p>To:</p>
|
||||
<p><?= $value->customer_name ?></p>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
font-family: 'Times New Roman', Times, sans-serif;
|
||||
|
||||
font-size: 14px; /* Change this value to your desired font size */
|
||||
font-size: 12px; /* Change this value to your desired font size */
|
||||
}
|
||||
|
||||
/* Style for the main table with border */
|
||||
@ -155,15 +155,14 @@ td.invoice-number {
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table class="invoice-info-table">
|
||||
<table class="invoice-info-table">
|
||||
<?php foreach ($data as $value) : ?>
|
||||
<tr>
|
||||
<th>Invoice #</th>
|
||||
<td class="invoice-number"><?= $value->invoice_number ?></td>
|
||||
<th>Invoice # <?= $value->invoice_number ?></th>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Invoice Date</th>
|
||||
<?php
|
||||
<?php
|
||||
// Assuming $value->invoice_date is in yyyy-mm-dd format
|
||||
$invoiceDateParts = explode('-', $value->invoice_date);
|
||||
if (count($invoiceDateParts) === 3) {
|
||||
@ -172,25 +171,28 @@ if (count($invoiceDateParts) === 3) {
|
||||
$formattedInvoiceDate = 'Invalid Date'; // Handle invalid dates gracefully
|
||||
}
|
||||
?>
|
||||
<th>Invoice Date : <?= $formattedInvoiceDate ?></th>
|
||||
|
||||
|
||||
<!-- Display the formatted invoice date -->
|
||||
<td><?= $formattedInvoiceDate ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Order Number</th>
|
||||
<td><?= $value->order_number ?></td>
|
||||
<th>Order Number : <?= $value->order_number ?></th>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Due Date</th>
|
||||
<?php $invoiceDateParts = explode('-', $value->due_date);
|
||||
<?php $invoiceDateParts = explode('-', $value->due_date);
|
||||
if (count($invoiceDateParts) === 3) {
|
||||
$formattedDueDate = $invoiceDateParts[2] . '/' . $invoiceDateParts[1] . '/' . $invoiceDateParts[0];
|
||||
} else {
|
||||
$formattedDueDate = 'Invalid Date'; // Handle invalid dates gracefully
|
||||
}
|
||||
?>
|
||||
<th>Due Date : <?= $formattedDueDate ?></th>
|
||||
|
||||
<!-- Display the formatted invoice date -->
|
||||
<td><?= $formattedDueDate ?></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -12,21 +12,22 @@
|
||||
}
|
||||
|
||||
.shipping-label {
|
||||
width: 250px; /* Reduced width for courier cover */
|
||||
margin: 20px auto;
|
||||
width: 600px; /* Set the width */
|
||||
height: 140px; /* Set the height to match the width for a square shape */
|
||||
margin: 10px;
|
||||
border: 1px solid #000;
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.label-title {
|
||||
font-size: 14px; /* Reduced font size for title */
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.address {
|
||||
font-size: 12px; /* Reduced font size for address */
|
||||
font-size: 16px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@ -40,40 +41,48 @@
|
||||
}
|
||||
|
||||
.footer {
|
||||
font-size: 10px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.business-logo {
|
||||
max-width: 150px; /* Adjust the logo size */
|
||||
max-width: 150px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php foreach ($customerDetails as $customer) : ?>
|
||||
<div class="shipping-label">
|
||||
<div class="label-title">
|
||||
<img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo">
|
||||
<img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"><br>
|
||||
|
||||
<?= $customer['address'] ?>
|
||||
<?= $customer['city'] ?>- <?= $customer['postal_code'] ?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="address">
|
||||
<?php foreach ($addresses as $value) : ?>
|
||||
<p><?= $value['postal_code'] ?></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
<div class="address">
|
||||
<p>To:</p>
|
||||
<p><?= $customerName?></p>
|
||||
<?php foreach ($shippingInfo as $row) : ?>
|
||||
<p><?= $row['address_1'] ?><?= $row['address_2'] ?></p>
|
||||
<p><?= $row['city'] ?> <?= $row['state'] ?></p>
|
||||
<p><?= $row['postal_code'] ?></p>
|
||||
<?= $customer['customer_name'] ?><br>
|
||||
<?= $customer['address_1'] ?>
|
||||
<?= $customer['address_2'] ?><br>
|
||||
<?= $customer['postal_code'] ?><br>
|
||||
<?= $customer['city'] ?><br>
|
||||
<?= $customer['state'] ?> <br>
|
||||
<?= $customer['mobile_no'] ?></p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="barcode">
|
||||
<img src="barcode.png" alt="Barcode">
|
||||
</div>
|
||||
<div class="footer">Thank you for choosing our service</div>
|
||||
|
||||
<div class="footer">"<?= $customer['scheme_name'] ?>" Expires on "<?= date('d-m-Y', strtotime($customer['to_subscription'])) ?>" </div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</body>
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
|
||||
<a href="#" class="btn btn-secondary" id="openSchemeListModal"><i class="ri-printer-line"></i> Print Address</a>
|
||||
<!-- Add a "Print Addresses" button -->
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#printAddressesModal">Print Addresses</button>
|
||||
|
||||
<a href="new_subscription" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add New </a>
|
||||
|
||||
@ -44,34 +44,41 @@
|
||||
|
||||
|
||||
<!-- Scheme List Modal -->
|
||||
<div class="modal fade" id="schemeListModal" tabindex="-1" role="dialog" aria-labelledby="schemeListModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<!-- Create a modal for scheme selection -->
|
||||
<!-- Create a modal for scheme selection -->
|
||||
<div class="modal fade" id="printAddressesModal" tabindex="-1" role="dialog" aria-labelledby="printAddressesModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="schemeListModalLabel">Select Schemes</h5>
|
||||
<h5 class="modal-title" id="printAddressesModalLabel">Select Schemes to Print Addresses</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul>
|
||||
<?php foreach ($subscriber as $scheme) : ?>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" class="scheme-checkbox" value="<?= $scheme['scheme_name']; ?>">
|
||||
<?= $scheme['scheme_name']; ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<div class="modal-body">
|
||||
<!-- Create a form to select schemes and download details -->
|
||||
<!-- ... Inside the modal in subscriber_list.php ... -->
|
||||
<form action="<?= base_url('subscription/download_details'); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<?php
|
||||
$uniqueSchemes = []; // Array to track unique scheme names
|
||||
foreach ($subscriber as $scheme) :
|
||||
// Check if the scheme name is already in the unique list
|
||||
if (!in_array($scheme['scheme_name'], $uniqueSchemes)) {
|
||||
$uniqueSchemes[] = $scheme['scheme_name']; // Add to unique list
|
||||
?>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="selected_scheme" value="<?= $scheme['scheme_name']; ?>">
|
||||
<label class="form-check-label"><?= $scheme['scheme_name']; ?></label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="printAddress">Print Address</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Download Details</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -82,24 +89,4 @@
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
// Open the Scheme List Modal when "Print Address" button is clicked
|
||||
$("#openSchemeListModal").click(function () {
|
||||
$("#schemeListModal").modal("show");
|
||||
});
|
||||
|
||||
// Handle the "Print Address" button click inside the modal
|
||||
$("#printAddress").click(function () {
|
||||
const selectedScheme = $(".scheme-checkbox:checked").val();
|
||||
|
||||
if (!selectedScheme) {
|
||||
alert("Please select a scheme.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect to a URL that generates the PDF with the selected customer name
|
||||
window.location.href = '<?= base_url('subscription/generate_pdf'); ?>?scheme_name=' + encodeURIComponent(selectedScheme);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -178,12 +178,7 @@
|
||||
<span>Subscription </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."addressprint"; ?>">
|
||||
<i class="bx bx-file"></i>
|
||||
<span>Address Print </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url()."mail_custom_notifications"; ?>">
|
||||
<i class="ri-notification-3-fill"></i>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user