FIX_INVOICE_ORDER_IN_REPORTS
This commit is contained in:
parent
b61e133a6d
commit
a85a43f69c
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Controllers\Books;
|
||||
@ -12,7 +13,8 @@ protected $primaryKey = 'invoice_id';
|
||||
// protected $allowedFields = ['invoice_id','invoice_number','customer_id','invoice_date','event_id','business_id','created_on','business_id'];
|
||||
protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id', 'notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'dis_type', 'discount', 'shipping_charge', 'shipping_label', 'total_amount', 'payment_status', 'order_number', 'invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by', 'category', 'isactive', 'billing_address', 'shipping_address', 'status', 'payment_note', 'exact_total_amount'];
|
||||
|
||||
public function saveInvoiceItemDetails($data){
|
||||
public function saveInvoiceItemDetails($data)
|
||||
{
|
||||
$i = 0;
|
||||
$statement = [];
|
||||
foreach ($data as $row) {
|
||||
@ -37,12 +39,14 @@ public function saveInvoiceItemDetails($data){
|
||||
}
|
||||
|
||||
|
||||
public function inactiveMissingInvoiceItemDetails($where,$missingValues){
|
||||
public function inactiveMissingInvoiceItemDetails($where, $missingValues)
|
||||
{
|
||||
$dataToUpdate = ['isactive' => 0];
|
||||
$this->db->table('invoiceitems')->where($where)->whereIn('invoice_child_id', $missingValues)->update($dataToUpdate);
|
||||
}
|
||||
|
||||
public function deleteMissingInvoiceItemDetails($where, $missingValues) {
|
||||
public function deleteMissingInvoiceItemDetails($where, $missingValues)
|
||||
{
|
||||
$this->db->table('invoiceitems')
|
||||
->where($where)
|
||||
->whereIn('invoice_child_id', $missingValues)
|
||||
@ -91,7 +95,8 @@ public function deleteSubscriptionDraftDetails($where,$update_by_id)
|
||||
}
|
||||
|
||||
## check the customer the scheme already Exist
|
||||
public function existsSubscriptionDetails($where){
|
||||
public function existsSubscriptionDetails($where)
|
||||
{
|
||||
$result = $this->getJoinedData($where);
|
||||
if (count($result) > 0) {
|
||||
return 1;
|
||||
@ -157,7 +162,8 @@ public function getJoinedData($where, $orderby = [])
|
||||
|
||||
|
||||
## subscription_inactive
|
||||
public function subscription_inactive(){
|
||||
public function subscription_inactive()
|
||||
{
|
||||
$now = date('Y-m-d');
|
||||
$result = $this->db->table('subscription as S')
|
||||
->select('S.sub_id, S.scheme_id, S.customer_id, S.business_id,S.invoice_id,S.mode,S.from_subscription, S.to_subscription, S.is_renew, S.isactive')
|
||||
@ -166,7 +172,9 @@ public function getJoinedData($where, $orderby = [])
|
||||
->get()
|
||||
->getResultArray();
|
||||
// echo "<pre>";print_r($result);echo "</pre>";die;
|
||||
$returnMessages = [];$i = 0 ;$j = 0;
|
||||
$returnMessages = [];
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $row) {
|
||||
// $this->db->table('invoiceitems')->where(['invoice_id' => $row['invoice_id']])->update(['from_subscription' => NULL,'to_subscription' => NULL]);//first child
|
||||
@ -254,7 +262,6 @@ public function getJoinedData($where, $orderby = [])
|
||||
->select('CONCAT_WS(" ", S.first_name, S.last_name) as customer_shipper_name,concat(S.address_1," ", S.address_2) as customer_ship_address,S.postal_code as customer_ship_postal_code ,S.city as customer_ship_city, countries.country_name as customer_ship_country,S.country as scountry,S.state as sstate,S.customer_address_id as saddr_id,S.email as semail,S.mobile_no as smobile')
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
}
|
||||
// this function Also Used For Approve Notification.
|
||||
public function getInvoiceItems($id, $stringflag)
|
||||
@ -429,7 +436,6 @@ public function get_mem_invoice_data($f_date = null, $t_date = null)
|
||||
->getResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
// public function itemwise_report_data($f_date = null, $t_date = null)
|
||||
@ -600,7 +606,8 @@ $result = $query
|
||||
// Fetch results as an associative array
|
||||
return $result->getResultArray();
|
||||
}
|
||||
public function getActiveMembers(){
|
||||
public function getActiveMembers()
|
||||
{
|
||||
$result =
|
||||
$this->db->table('subscription as S')
|
||||
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
|
||||
@ -613,7 +620,6 @@ public function getActiveMembers(){
|
||||
->orderBy('S.to_subscription', 'ASC')
|
||||
->get();
|
||||
return $result->getResultArray();
|
||||
|
||||
}
|
||||
|
||||
public function itemwise_report_data_with_publish_code($f_date = null, $t_date = null)
|
||||
@ -642,8 +648,6 @@ public function itemwise_report_data_with_publish_code($f_date = null, $t_date =
|
||||
}
|
||||
|
||||
public function userwise_eventwise_report($f_date = null, $t_date = null) {
|
||||
|
||||
|
||||
$builder = $this->db->table('invoice');
|
||||
|
||||
$builder->select([
|
||||
@ -654,6 +658,7 @@ public function userwise_eventwise_report($f_date = null, $t_date = null){
|
||||
'COUNT(invoice.created_by) AS books_sold',
|
||||
'ABS(SUM(invoice.exact_total_amount)) AS total_amount',
|
||||
'invoice.payment_method',
|
||||
// 'DATE(invoice.invoice_date) AS invoice_date' // Convert to DATE
|
||||
'invoice.invoice_date'
|
||||
]);
|
||||
|
||||
@ -663,24 +668,29 @@ public function userwise_eventwise_report($f_date = null, $t_date = null){
|
||||
$builder->join('books', 'books.book_id = invoiceitems.product');
|
||||
|
||||
$builder->where('invoice.event_id <>', 0);
|
||||
|
||||
if ($f_date !== null && $t_date !== null) {
|
||||
$builder->where('invoice.invoice_date >=', $f_date)
|
||||
->where('invoice.invoice_date <=', $t_date);
|
||||
}
|
||||
|
||||
$builder->groupBy([
|
||||
'invoice_date',
|
||||
'users.user_id',
|
||||
'users.first_name',
|
||||
'events.event_name',
|
||||
'payment_method'
|
||||
'events.event_name'
|
||||
]);
|
||||
|
||||
// Order by the converted date
|
||||
$builder->orderBy('invoice_date', 'DESC');
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
$results = $query->getResultArray();
|
||||
return $results;
|
||||
$result = $query->getResultArray();
|
||||
// dd($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getPaymentReport($f_date = null, $t_date = null)
|
||||
{
|
||||
|
||||
@ -814,7 +824,8 @@ public function updateInvoiceCancelStatus($invoiceIds, $cancelReason)
|
||||
|
||||
return $updated;
|
||||
}
|
||||
public function getActiveSchemes(){
|
||||
public function getActiveSchemes()
|
||||
{
|
||||
$builder = $this->db->table($this->table . ' as I');
|
||||
$builder->select('books.short_code');
|
||||
$builder->join('subscription', 'subscription.invoice_id = I.invoice_id');
|
||||
@ -827,9 +838,4 @@ public function getActiveSchemes(){
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,10 @@
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div></div></div></div> <!-- end card body-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col--><!-- end row-->
|
||||
|
||||
@ -80,7 +83,6 @@
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function sendsms() {
|
||||
var params = $("#params").val();
|
||||
var params2 = $("#date_picker").val();
|
||||
@ -144,9 +146,14 @@
|
||||
var sentDateFormatted = ('0' + sentTime.getDate()).slice(-2) + '/' +
|
||||
('0' + (sentTime.getMonth() + 1)).slice(-2) + '/' +
|
||||
sentTime.getFullYear();
|
||||
var sentTimeFormatted = ('0' + sentTime.getHours()).slice(-2) + ':' +
|
||||
('0' + sentTime.getMinutes()).slice(-2) + ':' +
|
||||
('0' + sentTime.getSeconds()).slice(-2);
|
||||
var hours = sentTime.getHours();
|
||||
var minutes = ('0' + sentTime.getMinutes()).slice(-2);
|
||||
var ampm = hours >= 12 ? 'PM' : 'AM';
|
||||
hours = hours % 12 || 12; // Convert 0 (midnight) and 12 (noon) properly
|
||||
|
||||
var sentTimeFormatted = ('0' + hours).slice(-2) + ':' + minutes + ' ' + ampm;
|
||||
var sentDateTimeFormatted = sentDateFormatted + ' ' + sentTimeFormatted; // Combine date and time
|
||||
|
||||
var sentDateTimeFormatted = sentDateFormatted + ' ' + sentTimeFormatted; // Combine date and time
|
||||
table.row.add([
|
||||
item.first_name + ' ' + item.last_name,
|
||||
@ -175,6 +182,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function regenerateFilters(table) {
|
||||
$('#datatable-buttons thead tr:eq(1)').remove();
|
||||
$('#datatable-buttons thead tr').clone(true).appendTo('#datatable-buttons thead');
|
||||
@ -201,6 +209,4 @@ function regenerateFilters(table) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -6,20 +6,20 @@
|
||||
<th><b>SCHEME Name</b></th>
|
||||
<th>Date/Time</th>
|
||||
<th><b>ORDER ID</b></th>
|
||||
<th>Payment Status</th>
|
||||
<th style="text-align: left;">Payment Status</th>
|
||||
<th><b>Amount</b></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="custom-tbody">
|
||||
<?php foreach ($payment_status_data as $row) { ?>
|
||||
<tr>
|
||||
<td><?= isset($row['customer_name'])?$row['customer_name']:"-"?></td>
|
||||
<td><?= isset($row['membership_id'])?$row['membership_id']:"-"?></td>
|
||||
<td><?= isset($row['scheme_name'])?$row['scheme_name']:"-"?></td>
|
||||
<td><?= isset($row['created_at'])? date("d/m/Y H:i:s", strtotime($row['created_at'])) : '-' ?></td>
|
||||
<td><?= isset($row['order_id'])?$row['order_id']:"-"?></td>
|
||||
<td><?= isset($row['payment_status'])?$row['payment_status']:"-" ?></td>
|
||||
<td><?= isset($row['amount'])?$row['amount']:"-"?></td>
|
||||
<td style="text-align: left;"><?= isset($row['customer_name'])?$row['customer_name']:"-"?></td>
|
||||
<td style="text-align: left;"><?= isset($row['membership_id'])?$row['membership_id']:"-"?></td>
|
||||
<td style="text-align: left;"><?= isset($row['scheme_name'])?$row['scheme_name']:"-"?></td>
|
||||
<td style="text-align: left;"><?= isset($row['created_at']) ? date("d/m/Y h:i A", strtotime($row['created_at'])) : '-' ?></td>
|
||||
<td style="text-align: left;"><?= isset($row['order_id'])?$row['order_id']:"-"?></td>
|
||||
<td style="text-align: left;"><?= isset($row['payment_status'])?$row['payment_status']:"-" ?></td>
|
||||
<td style="text-align: right;"><?= isset($row['amount'])?$row['amount']:"-"?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
@ -156,7 +156,7 @@
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
var table = $('#datatable-buttons').DataTable({
|
||||
"order": [[1, 'desc']],
|
||||
"order": [[0, 'desc']],
|
||||
dom: '<"row mb-3"<"col-md-6 d-flex align-items-center"B><"col-md-6 d-flex justify-content-end"f>>rtip',
|
||||
buttons: [
|
||||
{
|
||||
|
||||
@ -149,7 +149,7 @@
|
||||
|
||||
var table = $('#datatable-buttons').DataTable({
|
||||
"order": [
|
||||
[1, 'desc']
|
||||
// [0, 'desc']
|
||||
],
|
||||
"dom": '<"row mb-3"<"col-md-6 d-flex align-items-center"B><"col-md-6 d-flex justify-content-end"f>>rtip',
|
||||
buttons: [{
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<th>Event Name</th>
|
||||
<th>User Name</th>
|
||||
<th>Books Sold</th>
|
||||
<th>Payment Method</th>
|
||||
<!-- <th>Payment Method</th> -->
|
||||
<th>Total Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -46,13 +46,15 @@
|
||||
<?php foreach ($report_data as $row) { ?>
|
||||
<tr>
|
||||
<td hidden><?php echo $row["user_id"]; ?></td>
|
||||
<?php $unixTime = strtotime($row['invoice_date']);
|
||||
$invoice_date = date("d/m/Y", $unixTime);?>
|
||||
<?php
|
||||
// Since invoice_date is now a proper date, we can format it directly
|
||||
$invoice_date = date("d/m/Y", strtotime($row['invoice_date']));
|
||||
?>
|
||||
<td><?= $invoice_date ?></td>
|
||||
<td style="text-align: left;"><?= $row['event_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: left;"><?= strtoupper($row['payment_method'])?></td>
|
||||
<!-- <td style="text-align: left;"><?= strtoupper($row['payment_method']) ?></td> -->
|
||||
<td style="text-align:right;padding-right: 67px;"><?= $row['total_amount'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -69,11 +71,11 @@
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table = $('#datatable-buttons').DataTable({
|
||||
"order": [[0, 'desc']],
|
||||
ordering: false,
|
||||
// "order": [[0, 'desc']],
|
||||
// "order": [[0, 'desc']],
|
||||
"dom": '<"row mb-3"<"col-md-6 d-flex align-items-center"B><"col-md-6 d-flex justify-content-end"f>>rtip',
|
||||
buttons: [
|
||||
{
|
||||
buttons: [{
|
||||
extend: 'print',
|
||||
title: '<?= $page_name . ' ' . $selected_data ?>',
|
||||
text: 'Print',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user