FIX ISSUES IN DASHBOARD,REPORTS

This commit is contained in:
Srinivas-Saravanan 2024-12-13 17:14:51 +05:30
parent 9a1d4d076a
commit 973bc60b44
16 changed files with 61 additions and 56 deletions

View File

@ -123,7 +123,6 @@ $routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoi
$routes->get("download_invoice_pdf/(:any)", 'Invoice::download_invoice_pdf/$1');
$routes->post('update_approval_subscription', 'Invoice::update_approval_subscription');
$routes->post("saveBook", "Invoice::saveBook");
$routes->post("updateInvoiceStatus", "Invoice::updateInvoiceStatus");
$routes->post("updateInvoiceCancelStatus", "Invoice::updateInvoiceCancelStatus");

View File

@ -36,6 +36,9 @@ class Home extends BaseController
$data['financial_year'] = date('m') <= 3 ? (date('Y')-1) . '-' . date('Y') : date('Y') . '-' . (date('Y') + 1);
$data['book_published'] = $model->book_published_dtls();
$data['business_id'] = $session_bid;
// $lastquery = $model->getLastQuery();
// log_message('info','the last executed query - '.$lastquery);
// dd($data);
$this->render_page('dashboard', $data);
}

View File

@ -1219,10 +1219,10 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
if (empty($data['selected_data'])){
//dd($data['selected_data']);
$data['page_name'] = 'Membership Renewals Report (30 days)';
$data['page_name'] = 'Membership Renewal Report (30 days)';
}else{
list($fromDate, $toDate) = explode(" - ", $data['selected_data']);
$data['page_name'] = 'Membership Renewals Report - <br>(From '.$fromDate.' To '.$toDate.')';
$data['page_name'] = 'Membership Renewal Report - <br>(From '.$fromDate.' To '.$toDate.')';
}
$this->render_page('report_expired_customers', $data);
}
@ -1653,4 +1653,6 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
// log_message('error',json_encode($response));die();
return $this->response->setJSON($response);
}
}

View File

@ -175,7 +175,8 @@ public function payment_success() {
$bookModel = new BooksModel();
$model = new InvoiceModel();
$db = \Config\Database::connect();
$address = $db->table('customer_addresses')->select('address_1','customer_address_id')->where('customer_id',$customer_id)->get()->getRowArray();
$baddress = $db->table('customer_addresses')->select('address_1,customer_address_id')->where('customer_id',$customer_id)->where('address_type',1)->get()->getRowArray();
$saddress = $db->table('customer_addresses')->select('address_1,customer_address_id')->where('customer_id',$customer_id)->where('address_type',2)->get()->getRowArray();
$next_id_row = $db->table('invoice_number_formatting')->select('next_id, left_pad')->get()->getRowArray();
$filtered_data = [
@ -204,8 +205,10 @@ public function payment_success() {
'grand_total' => $amount,
'total_amount' => $amount,
'invoice_date' => $currentDate,
'billing_address'=> $address['address_1'],
'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : '',
'shipping_address'=> $saddress['address_1'],
'shipping_address_id' => isset($saddress['customer_address_id']) ? $saddress['customer_address_id'] : '',
'billing_address'=> $baddress['address_1'],
'billing_address_id' => isset($baddress['customer_address_id']) ? $baddress['customer_address_id'] : '',
'payment_method' => $payment_method,
'business_id' =>2
];

View File

@ -21,10 +21,10 @@ class Subscription extends BaseController
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Invoice: Listing In Admin BID = " . $session_bid);
$where = ['I.business_id' => (int)$session_bid, 'I.isactive' => 1,'I.invoice_type'=>2,'S.invoice_id !='=>"",'S.sub_id !='=>""];
$where = ['I.business_id' => (int)$session_bid, 'I.isactive' => 1,'S.invoice_id !='=>"",'S.sub_id !='=>""];
} else {
$this->logger->info("Invoice: Listing In the Super-Admin ");
$where = ['I.business_id != ' => NULL, 'I.isactive != ' => NULL,'I.invoice_type'=>2,'S.invoice_id !='=>"",'S.sub_id !='=>""];
$where = ['I.business_id != ' => NULL, 'I.isactive != ' => NULL,'S.invoice_id !='=>"",'S.sub_id !='=>""];
}
$model = new InvoiceModel();
@ -271,6 +271,7 @@ public function download_details()
$subscriptionModel = new SubscriptionModel();
$customerDetails = $subscriptionModel->getSubscriptionDetailsBySchemeName($mergedBookids, $downloadType);
// dd($customerDetails);
if (!empty($customerDetails)) {
$html = view('print_addresses_form', ['customerDetails' => $customerDetails, 'action' => $action, 'pdf' => $pdf]);

View File

@ -60,7 +60,7 @@ class HomeModel extends Model
// Today
$date_where = ['DATE(created_on)' => date('Y-m-d'), 'invoice_type' => 1, 'isactive' => 1];
$date_query = $this->db->table('invoice')->where($date_where)->countAllResults();
$date_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($date_where)->get()->getRowArray();
$date_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($date_where)->where('status','Approved')->get()->getRowArray();
$invoice['today'] = [
'count' => $date_query,
'total_amount' => $date_amount_query['total_amount'] ?? 0,
@ -101,21 +101,24 @@ class HomeModel extends Model
public function active_schemes()
{
$query = $this->db->table('subscription AS S')
->select('S.business_id, BK.title as name, BK.short_code, BK.book_id as id, S.scheme_id, LEFT(BK.title, 1) AS first_letter, COUNT(S.customer_id) AS count, BI.wp_img_url')
->select('COUNT(S.customer_id) AS overall, COUNT(IF(S.isactive = 1, S.customer_id, NULL)) AS activeoverall, COUNT(IF(S.is_renew = 0 AND S.isactive = 1, S.customer_id, NULL)) AS nonrenewal, COUNT(IF(S.is_renew = 1 AND S.isactive = 1, S.customer_id, NULL)) AS renewal, SUM(CASE WHEN S.created_on >= NOW() - INTERVAL 30 DAY THEN 1 ELSE 0 END) AS new_subscribers')
->select('COUNT(IF(S.status = 1 and S.is_renew =0 ,S.customer_id, NULL)) AS active,COUNT(IF(S.status = 0, S.customer_id, NULL)) AS expired,COUNT(IF(S.is_renew > 0 AND S.status = 1, S.customer_id, NULL)) AS renew')
->join('customers AS C', 'C.customer_id = S.customer_id AND C.isactive = 1', 'left')
->join('books AS BK', 'BK.book_id = S.scheme_id', 'left')
->join('book_categories AS BC', 'BC.book_id = S.scheme_id AND BC.isactive = 1', 'left')
->join('category AS CM', 'CM.id = BC.category_id AND C.isactive = 1', 'left')
->join('book_images AS BI', 'BI.book_id = S.scheme_id AND BI.isactive = 1', 'left')
->where(['S.business_id' => 2, 'BK.isactive' => 1])
->groupBy('S.scheme_id');
$query = $this->db->table('subscription')
// ->select('S.business_id, BK.title as name, BK.short_code, BK.book_id as id, S.scheme_id, LEFT(BK.title, 1) AS first_letter, COUNT(S.customer_id) AS count, BI.wp_img_url')
// ->select('COUNT(S.customer_id) AS overall, COUNT(IF(S.isactive = 1, S.customer_id, NULL)) AS activeoverall, COUNT(IF(S.is_renew = 0 AND S.isactive = 1, S.customer_id, NULL)) AS nonrenewal, COUNT(IF(S.is_renew = 1 AND S.isactive = 1, S.customer_id, NULL)) AS renewal, SUM(CASE WHEN S.created_on >= NOW() - INTERVAL 30 DAY THEN 1 ELSE 0 END) AS new_subscribers')
// ->select('COUNT(IF(S.status = 1 and S.is_renew =0 ,S.customer_id, NULL)) AS active,COUNT(IF(S.status = 0, S.customer_id, NULL)) AS expired,COUNT(IF(S.is_renew > 0 AND S.status = 1, S.customer_id, NULL)) AS renew')
// ->join('customers AS C', 'C.customer_id = S.customer_id AND C.isactive = 1', 'left')
// ->join('books AS BK', 'BK.book_id = S.scheme_id', 'left')
// ->join('book_categories AS BC', 'BC.book_id = S.scheme_id AND BC.isactive = 1', 'left')
// ->join('category AS CM', 'CM.id = BC.category_id AND C.isactive = 1', 'left')
// ->join('book_images AS BI', 'BI.book_id = S.scheme_id AND BI.isactive = 1', 'left')
// ->where(['S.business_id' => 2, 'BK.isactive' => 1])
// ->groupBy('S.scheme_id');
// print_r($query);die;
// echo $this->db->getLastQuery(); die;
->select('books.business_id,books.title as name ,scheme_id, books.short_code, count(*) as overall')
->join('books','books.book_id = subscription.scheme_id')
->where('to_subscription>now()')
->groupBy('scheme_id');
$results = $query->get()->getResultArray();
// print_r($results);die;
return $results;
}
@ -156,7 +159,7 @@ class HomeModel extends Model
->groupBy('S.sub_id')
->get()
->getResultArray();
// print_r($membershipList);
// print_r($membershipList);
// echo $this->db->getLastQuery(); die;
foreach ($membershipList as &$membership) {
$notifications = $this->getNotifications($membership['customer_id']);
@ -204,6 +207,7 @@ class HomeModel extends Model
->groupBy('S.sub_id')
->get()
->getResultArray();
// echo($this->db->getLastQuery());die();
return $membershipList;
}

View File

@ -144,7 +144,7 @@ public function getJoinedData($where, $orderby = [])
// }
$query->orderBy('I.invoice_date', 'DESC');
$query->orderBy('I.invoice_id', 'DESC');
$query->groupBy('I.invoice_id');
// $query->groupBy('I.invoice_id');
$resultArray = $query->get()->getResultArray();
@ -646,6 +646,7 @@ public function userwise_eventwise_report($f_date = null, $t_date = null){
$builder->select([
'users.user_id',
'users.first_name',
'users.role',
'events.event_name',
'COUNT(invoice.created_by) AS books_sold',
'ABS(SUM(invoice.exact_total_amount)) AS total_amount',

View File

@ -250,7 +250,7 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
$result = $query->getResultArray();
$lastQuery = $this->db->getLastQuery();
$finalQueryString = $lastQuery->getQuery();
// echo $finalQueryString;die;
// echo(count($result));die;
return $result;
}
public function getSubscriptionDetailsBySchemeName($selectedScheme, $downloadType){

View File

@ -84,7 +84,7 @@
<div class="mt-3">
<div class="media">
<div dir="ltr">
<!-- <h3 class="my-2 py-1"><span data-plugin="counterup"><?= $a['activeoverall']; ?></span></h3> -->
<!-- <h3 class="my-2 py-1"><span data-plugin="counterup"><?php // $a['activeoverall']; ?></span></h3> -->
<!-- <input data-plugin="knob" data-width="64" data-height="64" data-fgColor="#675db7"
data-bgColor="#e8e7f4" value=""
data-skin="tron" data-angleOffset="" data-readOnly=true
@ -96,7 +96,6 @@
<img src="<?= $a['wp_img_url']; ?>" alt="table-user" class="mr-3 rounded avatar-md">
<?php } else { ?>
<div class="avatar-title bg-light rounded text-body font-20 font-weight-semibold">
<?= $a['first_letter']; ?>
</div>
<?php } ?>
</div>
@ -113,17 +112,7 @@
</div>
</div>
<br>
<div class="row text-center mt-0">
<div class="col-md-4">
<p class="text-muted mb-0"><span class="text-success" data-toggle="tooltip" data-placement="bottom" data-original-title="New Subscriber"> New : <?= $a['active']; ?></span> </p>
</div>
<div class="col-md-4">
<p class="text-muted mb-0"><span class="text-warning" data-toggle="tooltip" data-placement="bottom" data-original-title="Expired Subscriber"> Expired : <?= $a['expired']; ?></span> </p>
</div>
<div class="col-md-4">
<p class="text-muted mb-0"><span class="text-primary" data-toggle="tooltip" data-placement="bottom" data-original-title="Re-Newed Subscriber"> Renewed : <?= $a['renew']; ?></span> </p>
</div>
</div>
</div>
</div>
</div>

View File

@ -688,8 +688,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-group col-md-6">
<label for="bcountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<select class="form-control" id="bcountry" name="bcountry[]"placeholder="Choose Your Country" required>
<option value="">Choose your Country</option>
<?php
<option selected value="India">India</option> <?php
if(!empty($country_details)){
foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_short_name']; ?>">
@ -700,7 +699,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
<div class="form-group col-md-6">
<label for="bstate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bstate" name="bstate" placeholder="State" />
<input type="text" class="form-control" id="bstate" name="bstate" value="Tamil Nadu" />
</div>
<div class="form-group col-md-6">
@ -739,8 +738,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-group col-md-6">
<label for="scountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<select class="form-control" id="scountry" name="scountry[]"placeholder="Choose Your Country" required>
<option value="">Choose your Country</option>
<?php
<option selected value="India">India</option> <?php
if(!empty($country_details)){
foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_short_name']; ?>">
@ -752,7 +750,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<!-- State -->
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">State</label>
<input type="text" class="form-control" id="sstate" name="sstate" placeholder="State" />
<input type="text" class="form-control" id="sstate" name="sstate" value="Tamil Nadu" />
</div>
<div class="form-group col-md-6">
@ -858,14 +856,14 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-group">
<label for="quick_billing_country"> Country<span class="text-danger"> *</span></label>
<select class="form-control" id="quick_billing_country">
<option value="">Select Country</option>
<option selected value="India">India</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="quick_billing_state"> State<span class="text-danger"> *</span></label>
<input class="form-control" type="text" id="quick_billing_state" required placeholder="State">
<input class="form-control" type="text" id="quick_billing_state" required value="Tamil Nadu">
</div>
</div>
<div class="col-md-4">
@ -900,14 +898,14 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-group">
<label for="quick_shipping_country"> Country<span class="text-danger"> *</span></label>
<select class="form-control" id="quick_shipping_country">
<option value="">Select Country</option>
<option selected value="India">India</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="quick_shipping_state"> State<span class="text-danger"> *</span></label>
<input class="form-control" type="text" id="quick_shipping_state" required placeholder="State">
<input class="form-control" type="text" id="quick_shipping_state" required value="Tamil Nadu">
</div>
</div>
<div class="col-md-4">

View File

@ -82,7 +82,7 @@
<th>Invoice Date</th>
<th>Customer Name</th>
<th>Status</th>
<th>Total</th>
<th>Total ()</th>
<th align="center" id="action-column">Action</th>
</tr>
</thead>
@ -99,7 +99,7 @@
<td class="preview-pdf" data-order="<?= strtotime($row['invoice_date']); ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $invoice_date; ?></td>
<td class="preview-pdf" data-order="<?= $row['customer_name']; ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['customer_name']; ?></td>
<td class="preview-pdf" data-order="<?= $row['status']; ?>;" id="status-column" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['status']; ?></td>
<td class="preview-pdf" data-order="<?= $row['total_amount']; ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= "" . $row['total_amount']; ?></td>
<td style="text-align: right;" class="preview-pdf" data-order="<?= $row['total_amount']; ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= "" . $row['total_amount']; ?></td>
<td>
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>&nbsp;
<a style="display: none;" href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>

View File

@ -373,6 +373,7 @@
<h4>Bank Details</h4>
<?php echo nl2br($business['terms']); ?>
<?php endif?>
</div>
</td>

View File

@ -111,7 +111,7 @@
<th>Invoice Date</th>
<th>Customer Name</th>
<th>Status</th>
<th>Total</th>
<th>Total ()</th>
<th align="center" id="action-column">Action</th>
</tr>
</thead>
@ -128,7 +128,7 @@
<td class="preview-pdf" data-order="<?= strtotime($row['invoice_date']); ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $invoice_date; ?></td>
<td class="preview-pdf" data-order="<?= $row['customer_name']; ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['customer_name']; ?></td>
<td class="preview-pdf" data-order="<?= $row['status']; ?>;" id="status-column" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['status']; ?></td>
<td class="preview-pdf" data-order="<?= $row['total_amount']; ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= "" . $row['total_amount']; ?></td>
<td style="text-align:right" class="preview-pdf" data-order="<?= $row['total_amount']; ?>" data-invoice-id="<?= $row['invoice_id']; ?>"><?= "" . $row['total_amount']; ?></td>
<td>
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>&nbsp;
<a style="display: none;" href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>

View File

@ -46,11 +46,11 @@
<tbody>
<?php foreach ($expired_customers as $row) { ?>
<tr>
<td hidden><?= isset($row['sub_id'])?$row['sub_id']: " " ?></td>
<td style="text-align: left;"><?= $row['first_name'] . ' ' . (isset($row['last_name']) ? $row['last_name'] : "") ?></td>
<td style="text-align: center;"><?= $row['membership_id'] ?></td>
<td style="text-align: center;"><?= date("d/m/Y", strtotime($row['from_subscription'])); ?></td>
<td style="text-align: center;"><?= date("d/m/Y", strtotime($row['to_subscription'])); ?></td>
<td hidden><?php echo $row["sub_id"]; ?></td>
<td><?= $row['mobile_no'] ?></td>
<td style="text-align: left;"><?= $row['email'] ?></td>
<td><?= $row['short_code'] ?></td>
@ -102,8 +102,10 @@ Sri Kasi, 12, M.V. Naidu Street, Chetpet,Chennai -
{
type: 'date',
targets: [1, 2, 3, 4, 5, 6],
orderable: false
orderable: false,
}
]
});

View File

@ -50,7 +50,7 @@
$invoice_date = date("d/m/Y", $unixTime);?>
<td><?= $invoice_date ?></td>
<td style="text-align: left;"><?= $row['event_name'] ?></td>
<td style="text-align: left;"><?= $row['first_name']?></td>
<td style="text-align: left;"><?= $row['first_name'].' ('.$row['role'].')'?></td>
<td style="text-align: center;"><?= $row['books_sold'] ?></td>
<td style="text-align: center;"><?= strtoupper($row['payment_method'])?></td>
<td style="text-align: right;"><?= $row['total_amount'] ?></td>

View File

@ -178,6 +178,9 @@
<li>
<a href="<?= base_url()."offline_invoice"; ?>">Offline Sales</a>
</li>
<li>
<a href="<?= base_url()."walkin_customer"; ?>">Walkin Customers</a>
</li>
</ul>
</div>
@ -198,7 +201,6 @@
<li>
<a href="<?= base_url()."notify_the_expiry_subscribers"; ?>">Send Expiry message</a>
</li>
</ul>
</div>
</li>