FIX_INVOICE_ORDER_IN_REPORTS
This commit is contained in:
parent
b61e133a6d
commit
a85a43f69c
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Controllers\Books;
|
use App\Controllers\Books;
|
||||||
@ -7,64 +8,67 @@ use CodeIgniter\Model;
|
|||||||
|
|
||||||
class InvoiceModel extends Model
|
class InvoiceModel extends Model
|
||||||
{
|
{
|
||||||
protected $table = 'invoice';
|
protected $table = 'invoice';
|
||||||
protected $primaryKey = 'invoice_id';
|
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','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'];
|
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;
|
$i = 0;
|
||||||
$statement = [];
|
$statement = [];
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
$id = isset($row['invoice_child_id']) ? $row['invoice_child_id'] : '';
|
$id = isset($row['invoice_child_id']) ? $row['invoice_child_id'] : '';
|
||||||
if($id != ''){
|
if ($id != '') {
|
||||||
unset($row['invoice_child_id']); // Remove the id from the data to avoid updating it
|
unset($row['invoice_child_id']); // Remove the id from the data to avoid updating it
|
||||||
unset($row['created_by']); // bcoz here data are Updating here.
|
unset($row['created_by']); // bcoz here data are Updating here.
|
||||||
|
|
||||||
$this->db->table('invoiceitems')->where('invoice_child_id', $id)->update($row);// Update the row with the specified id
|
$this->db->table('invoiceitems')->where('invoice_child_id', $id)->update($row); // Update the row with the specified id
|
||||||
$affectedRows = $this->db->affectedRows();
|
$affectedRows = $this->db->affectedRows();
|
||||||
$statement[$i] = "Invoice Item - ".$id." ".$affectedRows ? " Updated":" Not Updated";
|
$statement[$i] = "Invoice Item - " . $id . " " . $affectedRows ? " Updated" : " Not Updated";
|
||||||
}else{
|
} else {
|
||||||
if (!empty($row['updated_by'])){
|
if (!empty($row['updated_by'])) {
|
||||||
unset($row['updated_by']); // bcoz here data are inserting here.
|
unset($row['updated_by']); // bcoz here data are inserting here.
|
||||||
}
|
}
|
||||||
$this->db->table('invoiceitems')->insert($row);
|
$this->db->table('invoiceitems')->insert($row);
|
||||||
$insertID = $this->db->insertID();
|
$insertID = $this->db->insertID();
|
||||||
$statement[$i] = "Invoice Item - ".$insertID." Inserted";
|
$statement[$i] = "Invoice Item - " . $insertID . " Inserted";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $statement;
|
return $statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function inactiveMissingInvoiceItemDetails($where,$missingValues){
|
public function inactiveMissingInvoiceItemDetails($where, $missingValues)
|
||||||
|
{
|
||||||
$dataToUpdate = ['isactive' => 0];
|
$dataToUpdate = ['isactive' => 0];
|
||||||
$this->db->table('invoiceitems')->where($where)->whereIn('invoice_child_id',$missingValues)->update($dataToUpdate);
|
$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')
|
$this->db->table('invoiceitems')
|
||||||
->where($where)
|
->where($where)
|
||||||
->whereIn('invoice_child_id', $missingValues)
|
->whereIn('invoice_child_id', $missingValues)
|
||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateData($table, $data, $where)
|
public function updateData($table, $data, $where)
|
||||||
{
|
{
|
||||||
$this->db->table($table)->update($data, $where);
|
$this->db->table($table)->update($data, $where);
|
||||||
$affected_rows = $this->db->affectedRows();
|
$affected_rows = $this->db->affectedRows();
|
||||||
return $affected_rows;
|
return $affected_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function InactiveSubscriptionDraftDetails($where,$update_by_id)
|
public function InactiveSubscriptionDraftDetails($where, $update_by_id)
|
||||||
{
|
{
|
||||||
$result = $this->getJoinedData($where);
|
$result = $this->getJoinedData($where);
|
||||||
$inactive_invoice_ids = array();
|
$inactive_invoice_ids = array();
|
||||||
foreach ($result as $item) {
|
foreach ($result as $item) {
|
||||||
$inactive_invoice_ids[] = $item['invoice_id'];
|
$inactive_invoice_ids[] = $item['invoice_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($inactive_invoice_ids)>0){
|
if (count($inactive_invoice_ids) > 0) {
|
||||||
$this->db->table('subscription')
|
$this->db->table('subscription')
|
||||||
->whereIn('invoice_id', $inactive_invoice_ids)
|
->whereIn('invoice_id', $inactive_invoice_ids)
|
||||||
->set('isactive', 0)
|
->set('isactive', 0)
|
||||||
@ -73,35 +77,36 @@ public function InactiveSubscriptionDraftDetails($where,$update_by_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $inactive_invoice_ids;
|
return $inactive_invoice_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteSubscriptionDraftDetails($where,$update_by_id)
|
public function deleteSubscriptionDraftDetails($where, $update_by_id)
|
||||||
{
|
{
|
||||||
$result = $this->getJoinedData($where);
|
$result = $this->getJoinedData($where);
|
||||||
$delete_invoice_ids = array();
|
$delete_invoice_ids = array();
|
||||||
foreach ($result as $item) {
|
foreach ($result as $item) {
|
||||||
$delete_invoice_ids[] = $item['invoice_id'];
|
$delete_invoice_ids[] = $item['invoice_id'];
|
||||||
}
|
}
|
||||||
if(count($delete_invoice_ids)>0){
|
if (count($delete_invoice_ids) > 0) {
|
||||||
$this->db->table('subscription')
|
$this->db->table('subscription')
|
||||||
->whereIn('invoice_id', $delete_invoice_ids)
|
->whereIn('invoice_id', $delete_invoice_ids)
|
||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
return $delete_invoice_ids;
|
return $delete_invoice_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
## check the customer the scheme already Exist
|
## check the customer the scheme already Exist
|
||||||
public function existsSubscriptionDetails($where){
|
public function existsSubscriptionDetails($where)
|
||||||
|
{
|
||||||
$result = $this->getJoinedData($where);
|
$result = $this->getJoinedData($where);
|
||||||
if(count($result)>0){
|
if (count($result) > 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubscriptionInvoiceDetail($where)
|
public function getSubscriptionInvoiceDetail($where)
|
||||||
{
|
{
|
||||||
$result = $this->getJoinedData($where);
|
$result = $this->getJoinedData($where);
|
||||||
// print_r($result);die;
|
// print_r($result);die;
|
||||||
if (!empty($result)) {
|
if (!empty($result)) {
|
||||||
@ -113,7 +118,7 @@ public function getSubscriptionInvoiceDetail($where)
|
|||||||
if (strtolower($child->category_name) == strtolower('Membership')) {
|
if (strtolower($child->category_name) == strtolower('Membership')) {
|
||||||
$schemes[] = [
|
$schemes[] = [
|
||||||
'scheme_name' => $child->title,
|
'scheme_name' => $child->title,
|
||||||
'scheme_code' => !empty($child->short_code)?$child->short_code:$child->title,
|
'scheme_code' => !empty($child->short_code) ? $child->short_code : $child->title,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,12 +129,12 @@ public function getSubscriptionInvoiceDetail($where)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJoinedData($where, $orderby = [])
|
public function getJoinedData($where, $orderby = [])
|
||||||
{
|
{
|
||||||
// dd($where);
|
// dd($where);
|
||||||
$query = $this->db->table($this->table.' as I' )
|
$query = $this->db->table($this->table . ' as I')
|
||||||
->join('customers as C', 'C.customer_id = I.customer_id', 'left')
|
->join('customers as C', 'C.customer_id = I.customer_id', 'left')
|
||||||
->join('subscription as S', 'S.invoice_id = I.invoice_id', 'left')
|
->join('subscription as S', 'S.invoice_id = I.invoice_id', 'left')
|
||||||
->join('events as E', 'E.event_id = I.event_id', 'left')
|
->join('events as E', 'E.event_id = I.event_id', 'left')
|
||||||
@ -153,29 +158,32 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
//echo $this->db->getLastQuery();die;
|
//echo $this->db->getLastQuery();die;
|
||||||
|
|
||||||
return $resultArray;
|
return $resultArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## subscription_inactive
|
## subscription_inactive
|
||||||
public function subscription_inactive(){
|
public function subscription_inactive()
|
||||||
|
{
|
||||||
$now = date('Y-m-d');
|
$now = date('Y-m-d');
|
||||||
$result = $this->db->table('subscription as S')
|
$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')
|
->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')
|
||||||
->where("S.isactive",1)
|
->where("S.isactive", 1)
|
||||||
->where("S.to_subscription < ",$now)
|
->where("S.to_subscription < ", $now)
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
// echo "<pre>";print_r($result);echo "</pre>";die;
|
// echo "<pre>";print_r($result);echo "</pre>";die;
|
||||||
$returnMessages = [];$i = 0 ;$j = 0;
|
$returnMessages = [];
|
||||||
|
$i = 0;
|
||||||
|
$j = 0;
|
||||||
if (!empty($result)) {
|
if (!empty($result)) {
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
// $this->db->table('invoiceitems')->where(['invoice_id' => $row['invoice_id']])->update(['from_subscription' => NULL,'to_subscription' => NULL]);//first child
|
// $this->db->table('invoiceitems')->where(['invoice_id' => $row['invoice_id']])->update(['from_subscription' => NULL,'to_subscription' => NULL]);//first child
|
||||||
$this->db->table('subscription')->where(['sub_id' => $row['sub_id']])->update(['isactive' => 0]);//second child
|
$this->db->table('subscription')->where(['sub_id' => $row['sub_id']])->update(['isactive' => 0]); //second child
|
||||||
$affectedRows = $this->db->affectedRows();
|
$affectedRows = $this->db->affectedRows();
|
||||||
if ($affectedRows) {
|
if ($affectedRows) {
|
||||||
$returnMessages['message'] = "Success for sub_id: " . $row['sub_id'];
|
$returnMessages['message'] = "Success for sub_id: " . $row['sub_id'];
|
||||||
$returnMessages['success_rating'] = $i++;
|
$returnMessages['success_rating'] = $i++;
|
||||||
}else {
|
} else {
|
||||||
$returnMessages['message'] = 'Failed to update subscription with sub_id ' . $row['sub_id'] . '. No rows were affected.';
|
$returnMessages['message'] = 'Failed to update subscription with sub_id ' . $row['sub_id'] . '. No rows were affected.';
|
||||||
$returnMessages['error_rating'] = $j++;
|
$returnMessages['error_rating'] = $j++;
|
||||||
}
|
}
|
||||||
@ -190,12 +198,12 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
public function getDetailForApproveNotifications($where)
|
public function getDetailForApproveNotifications($where)
|
||||||
{
|
{
|
||||||
$result = $this->getJoinedData($where);
|
$result = $this->getJoinedData($where);
|
||||||
if(!empty($result)){
|
if (!empty($result)) {
|
||||||
foreach ($result as $object) {
|
foreach ($result as $object) {
|
||||||
$invoiceId = $object['invoice_id'];
|
$invoiceId = $object['invoice_id'];
|
||||||
$items = $this->getInvoiceItems($invoiceId,'');
|
$items = $this->getInvoiceItems($invoiceId, '');
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$items = [];
|
$items = [];
|
||||||
}
|
}
|
||||||
$data['invoice'] = $result;
|
$data['invoice'] = $result;
|
||||||
@ -240,10 +248,10 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
// Fetch invoice data
|
// Fetch invoice data
|
||||||
return $this->db->table('invoice')
|
return $this->db->table('invoice')
|
||||||
->where('invoice_id', $id)
|
->where('invoice_id', $id)
|
||||||
->join('customers as C','C.customer_id= invoice.customer_id','left')
|
->join('customers as C', 'C.customer_id= invoice.customer_id', 'left')
|
||||||
->join('business as B','B.business_id = invoice.business_id','left')
|
->join('business as B', 'B.business_id = invoice.business_id', 'left')
|
||||||
->join('customer_addresses as A','A.customer_address_id=invoice.billing_address_id AND A.address_type = 1','left')
|
->join('customer_addresses as A', 'A.customer_address_id=invoice.billing_address_id AND A.address_type = 1', 'left')
|
||||||
->join('customer_addresses as S','S.customer_address_id=invoice.shipping_address_id AND S.address_type = 2','left')
|
->join('customer_addresses as S', 'S.customer_address_id=invoice.shipping_address_id AND S.address_type = 2', 'left')
|
||||||
->join('states', 'states.state_short_name = A.state AND A.country = "IN"', 'left')
|
->join('states', 'states.state_short_name = A.state AND A.country = "IN"', 'left')
|
||||||
->join('countries', 'countries.country_short_name = A.country', 'left')
|
->join('countries', 'countries.country_short_name = A.country', 'left')
|
||||||
->select('invoice.*,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date,DATE_FORMAT(invoice.due_date, "%d/%m/%Y") AS formatted_due_date ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name,C.mobile_no,C.email,A.address_1, A.address_2,A.postal_code,A.city, A.state,C.mobile_no as customer_mobile')
|
->select('invoice.*,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date,DATE_FORMAT(invoice.due_date, "%d/%m/%Y") AS formatted_due_date ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name,C.mobile_no,C.email,A.address_1, A.address_2,A.postal_code,A.city, A.state,C.mobile_no as customer_mobile')
|
||||||
@ -254,10 +262,9 @@ 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')
|
->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()
|
->get()
|
||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
}
|
}
|
||||||
// this function Also Used For Approve Notification.
|
// this function Also Used For Approve Notification.
|
||||||
public function getInvoiceItems($id,$stringflag)
|
public function getInvoiceItems($id, $stringflag)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($stringflag == 'groupby') {
|
if ($stringflag == 'groupby') {
|
||||||
@ -308,7 +315,7 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
public function getProductImgs($productId)
|
public function getProductImgs($productId)
|
||||||
{
|
{
|
||||||
$data = $this->db->table('book_images')
|
$data = $this->db->table('book_images')
|
||||||
->where(['book_id' => $productId,'book_images.isactive'=>1])
|
->where(['book_id' => $productId, 'book_images.isactive' => 1])
|
||||||
// ->join('books as B', 'B.book_id = invoiceitems.product', 'left')
|
// ->join('books as B', 'B.book_id = invoiceitems.product', 'left')
|
||||||
// ->join('book_images as BI', 'BI.book_id = invoiceitems.product', 'left')
|
// ->join('book_images as BI', 'BI.book_id = invoiceitems.product', 'left')
|
||||||
->select('book_images.*')
|
->select('book_images.*')
|
||||||
@ -355,13 +362,13 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertupdateSubscriptionData($data,$invoice_status)
|
public function insertupdateSubscriptionData($data, $invoice_status)
|
||||||
{
|
{
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
$invoice_id = $data['invoice_id'];
|
$invoice_id = $data['invoice_id'];
|
||||||
$customer_id = $data['customer_id'];
|
$customer_id = $data['customer_id'];
|
||||||
$scheme_id = $data['scheme_id'];
|
$scheme_id = $data['scheme_id'];
|
||||||
$data['isactive'] = $invoice_status === 'Approved' ? 1 : 0 ;
|
$data['isactive'] = $invoice_status === 'Approved' ? 1 : 0;
|
||||||
$where = ['invoice_id' => $invoice_id]; // invoice id refer with srinivasan // initally invoice id, scheme id and customer id
|
$where = ['invoice_id' => $invoice_id]; // invoice id refer with srinivasan // initally invoice id, scheme id and customer id
|
||||||
$query = $this->db->table('subscription')->select('sub_id')->where($where)->get()->getRow();
|
$query = $this->db->table('subscription')->select('sub_id')->where($where)->get()->getRow();
|
||||||
|
|
||||||
@ -374,12 +381,12 @@ public function insertupdateSubscriptionData($data,$invoice_status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***********************REPORT**********************
|
// ***********************REPORT**********************
|
||||||
|
|
||||||
public function get_general_invoice_data($f_date = null, $t_date = null)
|
public function get_general_invoice_data($f_date = null, $t_date = null)
|
||||||
{
|
{
|
||||||
// Fetch invoice data
|
// Fetch invoice data
|
||||||
$query = $this->db->table('invoice')
|
$query = $this->db->table('invoice')
|
||||||
->select('invoice.*,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date, customers.*, COUNT(invoiceitems.product) as item_count')
|
->select('invoice.*,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date, customers.*, COUNT(invoiceitems.product) as item_count')
|
||||||
@ -402,11 +409,11 @@ public function get_general_invoice_data($f_date = null, $t_date = null)
|
|||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function get_mem_invoice_data($f_date = null, $t_date = null)
|
public function get_mem_invoice_data($f_date = null, $t_date = null)
|
||||||
{
|
{
|
||||||
// Fetch invoice data
|
// Fetch invoice data
|
||||||
$query = $this->db->table('invoice')
|
$query = $this->db->table('invoice')
|
||||||
->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date,subscription.from_subscription,subscription.to_subscription,DATE_FORMAT(subscription.from_subscription, "%d/%m/%Y") AS formatted_from_date,DATE_FORMAT(subscription.to_subscription, "%d/%m/%Y") AS formatted_to_date')
|
->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date,subscription.from_subscription,subscription.to_subscription,DATE_FORMAT(subscription.from_subscription, "%d/%m/%Y") AS formatted_from_date,DATE_FORMAT(subscription.to_subscription, "%d/%m/%Y") AS formatted_to_date')
|
||||||
@ -429,40 +436,39 @@ public function get_mem_invoice_data($f_date = null, $t_date = null)
|
|||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// public function itemwise_report_data($f_date = null, $t_date = null)
|
||||||
|
// {
|
||||||
|
// // Fetch invoice data
|
||||||
|
// $query = $this->db->table('invoice')
|
||||||
|
// ->select('invoice.*, books.* , COUNT(invoiceitems.product) as item_count , sum(invoiceitems.product * invoiceitems.unit_price) as item_cost')
|
||||||
|
// ->where('invoice.isactive', 1)
|
||||||
|
// ->where('books.isactive', 1);
|
||||||
|
|
||||||
// public function itemwise_report_data($f_date = null, $t_date = null)
|
// // Add date range filter if provided
|
||||||
// {
|
// if ($f_date !== null && $t_date !== null) {
|
||||||
// // Fetch invoice data
|
// $query->where('invoice.invoice_date >=', $f_date)
|
||||||
// $query = $this->db->table('invoice')
|
// ->where('invoice.invoice_date <=', $t_date);
|
||||||
// ->select('invoice.*, books.* , COUNT(invoiceitems.product) as item_count , sum(invoiceitems.product * invoiceitems.unit_price) as item_cost')
|
// }
|
||||||
// ->where('invoice.isactive', 1)
|
|
||||||
// ->where('books.isactive', 1);
|
|
||||||
|
|
||||||
// // Add date range filter if provided
|
// $result = $query->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left')
|
||||||
// if ($f_date !== null && $t_date !== null) {
|
// ->join('books', 'books.book_id = invoiceitems.product', 'left')
|
||||||
// $query->where('invoice.invoice_date >=', $f_date)
|
// ->groupBy('books.book_id')
|
||||||
// ->where('invoice.invoice_date <=', $t_date);
|
// ->get()
|
||||||
// }
|
// ->getResult();
|
||||||
|
|
||||||
// $result = $query->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left')
|
// return $result;
|
||||||
// ->join('books', 'books.book_id = invoiceitems.product', 'left')
|
// }
|
||||||
// ->groupBy('books.book_id')
|
public function itemwise_report_data($f_date = null, $t_date = null)
|
||||||
// ->get()
|
{
|
||||||
// ->getResult();
|
|
||||||
|
|
||||||
// return $result;
|
|
||||||
// }
|
|
||||||
public function itemwise_report_data($f_date = null, $t_date = null)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Fetch invoice data
|
// Fetch invoice data
|
||||||
$query = $this->db->table('invoice')
|
$query = $this->db->table('invoice')
|
||||||
->select('books.publishers_code, COUNT(invoiceitems.product) as publisher_item_count, books.title as book_name, COUNT(invoiceitems.product) as item_count, SUM(invoiceitems.quantity * invoiceitems.unit_price) as total_cost ,DATE_FORMAT(books.publication_date, "%d/%m/%Y") AS book_publication_date');
|
->select('books.publishers_code, COUNT(invoiceitems.product) as publisher_item_count, books.title as book_name, COUNT(invoiceitems.product) as item_count, SUM(invoiceitems.quantity * invoiceitems.unit_price) as total_cost ,DATE_FORMAT(books.publication_date, "%d/%m/%Y") AS book_publication_date');
|
||||||
|
|
||||||
$query->where('invoice.isactive', 1)
|
$query->where('invoice.isactive', 1)
|
||||||
->where('invoice.invoice_type',1)
|
->where('invoice.invoice_type', 1)
|
||||||
->where('books.isactive', 1);
|
->where('books.isactive', 1);
|
||||||
|
|
||||||
// Add date range filter if provided
|
// Add date range filter if provided
|
||||||
@ -493,7 +499,7 @@ public function itemwise_report_data($f_date = null, $t_date = null)
|
|||||||
'publisher_item_count' => 0,
|
'publisher_item_count' => 0,
|
||||||
'publisher_total_cost' => 0,
|
'publisher_total_cost' => 0,
|
||||||
'books' => [],
|
'books' => [],
|
||||||
'book_name'=>'',
|
'book_name' => '',
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -505,16 +511,16 @@ public function itemwise_report_data($f_date = null, $t_date = null)
|
|||||||
'book_name' => $row->book_name,
|
'book_name' => $row->book_name,
|
||||||
'item_count' => $row->item_count,
|
'item_count' => $row->item_count,
|
||||||
'total_cost' => $row->total_cost,
|
'total_cost' => $row->total_cost,
|
||||||
'book_publication_date' =>$row->book_publication_date,
|
'book_publication_date' => $row->book_publication_date,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values($groupedResult);
|
return array_values($groupedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getInvoiceIdByMd5($md5Hash)
|
public function getInvoiceIdByMd5($md5Hash)
|
||||||
{
|
{
|
||||||
$result = $this->db->table($this->table)
|
$result = $this->db->table($this->table)
|
||||||
->select('invoice_id')
|
->select('invoice_id')
|
||||||
->get()
|
->get()
|
||||||
@ -527,61 +533,61 @@ public function getInvoiceIdByMd5($md5Hash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// public function getExpiredCustomers($f_date = null, $t_date = null)
|
// public function getExpiredCustomers($f_date = null, $t_date = null)
|
||||||
// {
|
// {
|
||||||
// $now = date('Y-m-d');
|
// $now = date('Y-m-d');
|
||||||
// $futureDate = date('Y-m-d', strtotime($now . ' +30 days'));
|
// $futureDate = date('Y-m-d', strtotime($now . ' +30 days'));
|
||||||
|
|
||||||
// $query = $this->db->table('subscription as S'); // Define $query here
|
// $query = $this->db->table('subscription as S'); // Define $query here
|
||||||
|
|
||||||
// if ($f_date !== null && $t_date !== null) {
|
// if ($f_date !== null && $t_date !== null) {
|
||||||
// $query->where('S.to_subscription >=', $f_date)
|
// $query->where('S.to_subscription >=', $f_date)
|
||||||
// ->where('S.to_subscription <=', $t_date);
|
// ->where('S.to_subscription <=', $t_date);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// $result = $query
|
// $result = $query
|
||||||
// ->select('S.customer_id,S.sub_id, S.from_subscription, S.to_subscription, C.first_name, C.last_name, C.email, C.mobile_no, S.scheme_id,B.short_code')
|
// ->select('S.customer_id,S.sub_id, S.from_subscription, S.to_subscription, C.first_name, C.last_name, C.email, C.mobile_no, S.scheme_id,B.short_code')
|
||||||
// ->join('customers as C', 'C.customer_id = S.customer_id', 'left')
|
// ->join('customers as C', 'C.customer_id = S.customer_id', 'left')
|
||||||
// ->join('books as B', 'B.book_id = S.scheme_id', 'left')
|
// ->join('books as B', 'B.book_id = S.scheme_id', 'left')
|
||||||
// ->where('S.isactive', 1)
|
// ->where('S.isactive', 1)
|
||||||
// ->where('S.to_subscription <', $futureDate)
|
// ->where('S.to_subscription <', $futureDate)
|
||||||
// ->get()
|
// ->get()
|
||||||
// ->getResultArray();
|
// ->getResultArray();
|
||||||
// // print_r($result);
|
// // print_r($result);
|
||||||
// // echo "<pre>";
|
// // echo "<pre>";
|
||||||
// // echo $this->db->getLastQuery();
|
// // echo $this->db->getLastQuery();
|
||||||
// // echo "</pre>";die;
|
// // echo "</pre>";die;
|
||||||
// echo $this->db->getLastQuery();
|
// echo $this->db->getLastQuery();
|
||||||
// die();
|
// die();
|
||||||
|
|
||||||
// return $result;
|
// return $result;
|
||||||
|
|
||||||
// }
|
// }
|
||||||
public function getExpiredCustomers($f_date = null, $t_date = null)
|
public function getExpiredCustomers($f_date = null, $t_date = null)
|
||||||
{
|
{
|
||||||
// Set timezone for accurate date calculation
|
// Set timezone for accurate date calculation
|
||||||
date_default_timezone_set('Asia/Kolkata');
|
date_default_timezone_set('Asia/Kolkata');
|
||||||
|
|
||||||
// Calculate the date 30 days from now
|
// Calculate the date 30 days from now
|
||||||
$futureDate = date('Y-m-d', strtotime('+30 days'));
|
$futureDate = date('Y-m-d', strtotime('+30 days'));
|
||||||
|
|
||||||
$query = $this->db->table('subscription as S');
|
$query = $this->db->table('subscription as S');
|
||||||
|
|
||||||
if (!empty($f_date) && !empty($t_date)) {
|
if (!empty($f_date) && !empty($t_date)) {
|
||||||
$query->where('S.to_subscription >=', $f_date)
|
$query->where('S.to_subscription >=', $f_date)
|
||||||
->where('S.to_subscription <=', $t_date);
|
->where('S.to_subscription <=', $t_date);
|
||||||
} else {
|
} else {
|
||||||
$query->where('S.to_subscription >=', date('Y-m-d'))
|
$query->where('S.to_subscription >=', date('Y-m-d'))
|
||||||
->where('S.to_subscription <=', $futureDate);
|
->where('S.to_subscription <=', $futureDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subquery = $this->db->table('subscription as S2')
|
$subquery = $this->db->table('subscription as S2')
|
||||||
->select('S.sub_id')
|
->select('S.sub_id')
|
||||||
->where('S2.customer_id = S.customer_id')
|
->where('S2.customer_id = S.customer_id')
|
||||||
->where('S.sub_id = S2.is_renew');
|
->where('S.sub_id = S2.is_renew');
|
||||||
|
|
||||||
$result = $query
|
$result = $query
|
||||||
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
|
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
|
||||||
C.first_name, C.last_name, C.email, C.mobile_no,
|
C.first_name, C.last_name, C.email, C.mobile_no,
|
||||||
S.scheme_id, B.short_code, S.membership_id')
|
S.scheme_id, B.short_code, S.membership_id')
|
||||||
@ -599,8 +605,9 @@ $result = $query
|
|||||||
|
|
||||||
// Fetch results as an associative array
|
// Fetch results as an associative array
|
||||||
return $result->getResultArray();
|
return $result->getResultArray();
|
||||||
}
|
}
|
||||||
public function getActiveMembers(){
|
public function getActiveMembers()
|
||||||
|
{
|
||||||
$result =
|
$result =
|
||||||
$this->db->table('subscription as S')
|
$this->db->table('subscription as S')
|
||||||
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
|
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
|
||||||
@ -613,11 +620,10 @@ public function getActiveMembers(){
|
|||||||
->orderBy('S.to_subscription', 'ASC')
|
->orderBy('S.to_subscription', 'ASC')
|
||||||
->get();
|
->get();
|
||||||
return $result->getResultArray();
|
return $result->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function itemwise_report_data_with_publish_code($f_date = null, $t_date = null)
|
||||||
|
{
|
||||||
public function itemwise_report_data_with_publish_code($f_date = null, $t_date = null)
|
|
||||||
{
|
|
||||||
// Fetch invoice data
|
// Fetch invoice data
|
||||||
$query = $this->db->table('invoice')
|
$query = $this->db->table('invoice')
|
||||||
->select('invoice.*, books.* , COUNT(invoiceitems.product) as item_count , sum(invoiceitems.product * invoiceitems.unit_price) as item_cost')
|
->select('invoice.*, books.* , COUNT(invoiceitems.product) as item_count , sum(invoiceitems.product * invoiceitems.unit_price) as item_cost')
|
||||||
@ -639,11 +645,9 @@ public function itemwise_report_data_with_publish_code($f_date = null, $t_date =
|
|||||||
// print_r($result);die;
|
// print_r($result);die;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userwise_eventwise_report($f_date = null, $t_date = null){
|
|
||||||
|
|
||||||
|
|
||||||
|
public function userwise_eventwise_report($f_date = null, $t_date = null) {
|
||||||
$builder = $this->db->table('invoice');
|
$builder = $this->db->table('invoice');
|
||||||
|
|
||||||
$builder->select([
|
$builder->select([
|
||||||
@ -654,6 +658,7 @@ public function userwise_eventwise_report($f_date = null, $t_date = null){
|
|||||||
'COUNT(invoice.created_by) AS books_sold',
|
'COUNT(invoice.created_by) AS books_sold',
|
||||||
'ABS(SUM(invoice.exact_total_amount)) AS total_amount',
|
'ABS(SUM(invoice.exact_total_amount)) AS total_amount',
|
||||||
'invoice.payment_method',
|
'invoice.payment_method',
|
||||||
|
// 'DATE(invoice.invoice_date) AS invoice_date' // Convert to DATE
|
||||||
'invoice.invoice_date'
|
'invoice.invoice_date'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -663,26 +668,31 @@ public function userwise_eventwise_report($f_date = null, $t_date = null){
|
|||||||
$builder->join('books', 'books.book_id = invoiceitems.product');
|
$builder->join('books', 'books.book_id = invoiceitems.product');
|
||||||
|
|
||||||
$builder->where('invoice.event_id <>', 0);
|
$builder->where('invoice.event_id <>', 0);
|
||||||
|
|
||||||
if ($f_date !== null && $t_date !== null) {
|
if ($f_date !== null && $t_date !== null) {
|
||||||
$builder->where('invoice.invoice_date >=', $f_date)
|
$builder->where('invoice.invoice_date >=', $f_date)
|
||||||
->where('invoice.invoice_date <=', $t_date);
|
->where('invoice.invoice_date <=', $t_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->groupBy([
|
$builder->groupBy([
|
||||||
|
'invoice_date',
|
||||||
'users.user_id',
|
'users.user_id',
|
||||||
'users.first_name',
|
'events.event_name'
|
||||||
'events.event_name',
|
|
||||||
'payment_method'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Order by the converted date
|
||||||
|
$builder->orderBy('invoice_date', 'DESC');
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
|
|
||||||
$results = $query->getResultArray();
|
$result = $query->getResultArray();
|
||||||
return $results;
|
// dd($result);
|
||||||
}
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function getPaymentReport($f_date = null, $t_date = null)
|
|
||||||
{
|
public function getPaymentReport($f_date = null, $t_date = null)
|
||||||
|
{
|
||||||
|
|
||||||
$builder = $this->db->table('invoice');
|
$builder = $this->db->table('invoice');
|
||||||
$builder->select('invoice.invoice_number, customers.first_name, invoice.total_amount, invoice.payment_status, invoice.payment_method, invoice.invoice_date');
|
$builder->select('invoice.invoice_number, customers.first_name, invoice.total_amount, invoice.payment_status, invoice.payment_method, invoice.invoice_date');
|
||||||
@ -691,7 +701,7 @@ public function getPaymentReport($f_date = null, $t_date = null)
|
|||||||
$builder->where('invoice.invoice_date >=', $f_date)
|
$builder->where('invoice.invoice_date >=', $f_date)
|
||||||
->where('invoice.invoice_date <=', $t_date);
|
->where('invoice.invoice_date <=', $t_date);
|
||||||
}
|
}
|
||||||
$builder->where('invoice.status','Approved');
|
$builder->where('invoice.status', 'Approved');
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result1 = $query->getResultArray();
|
$result1 = $query->getResultArray();
|
||||||
$builder->select('payment_method, SUM(exact_total_amount) as total_amount');
|
$builder->select('payment_method, SUM(exact_total_amount) as total_amount');
|
||||||
@ -703,20 +713,20 @@ public function getPaymentReport($f_date = null, $t_date = null)
|
|||||||
$query2 = $builder->get();
|
$query2 = $builder->get();
|
||||||
$paymentMethodTotals = $query2->getResultArray();
|
$paymentMethodTotals = $query2->getResultArray();
|
||||||
$paymentMethodMap = [];
|
$paymentMethodMap = [];
|
||||||
foreach ($paymentMethodTotals as $row) {
|
foreach ($paymentMethodTotals as $row) {
|
||||||
$paymentMethodMap[$row['payment_method']] = $row['total_amount'];
|
$paymentMethodMap[$row['payment_method']] = $row['total_amount'];
|
||||||
}
|
}
|
||||||
$result2 = $paymentMethodMap;
|
$result2 = $paymentMethodMap;
|
||||||
// log_message('info',json_encode($results));
|
// log_message('info',json_encode($results));
|
||||||
// dd($results);
|
// dd($results);
|
||||||
$results = [
|
$results = [
|
||||||
'result1'=>$result1,
|
'result1' => $result1,
|
||||||
'result2'=>$result2
|
'result2' => $result2
|
||||||
];
|
];
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
public function itemwise_report_data_with_payment_method($f_date = null, $t_date = null)
|
public function itemwise_report_data_with_payment_method($f_date = null, $t_date = null)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('invoice');
|
$builder = $this->db->table('invoice');
|
||||||
$builder->select('books.publishers_code,
|
$builder->select('books.publishers_code,
|
||||||
COUNT(invoiceitems.product) AS publisher_item_count,
|
COUNT(invoiceitems.product) AS publisher_item_count,
|
||||||
@ -771,11 +781,11 @@ public function itemwise_report_data_with_payment_method($f_date = null, $t_date
|
|||||||
}
|
}
|
||||||
|
|
||||||
return array_values($groupedResult);
|
return array_values($groupedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function updateInvoiceStatus($invoiceId, $voidReason)
|
public function updateInvoiceStatus($invoiceId, $voidReason)
|
||||||
{
|
{
|
||||||
// Assuming 'invoices' is the name of your table
|
// Assuming 'invoices' is the name of your table
|
||||||
$builder = $this->db->table('invoice');
|
$builder = $this->db->table('invoice');
|
||||||
|
|
||||||
@ -793,9 +803,9 @@ public function updateInvoiceStatus($invoiceId, $voidReason)
|
|||||||
$updated = $builder->update($data);
|
$updated = $builder->update($data);
|
||||||
|
|
||||||
return $updated;
|
return $updated;
|
||||||
}
|
}
|
||||||
public function updateInvoiceCancelStatus($invoiceIds, $cancelReason)
|
public function updateInvoiceCancelStatus($invoiceIds, $cancelReason)
|
||||||
{
|
{
|
||||||
// Assuming 'invoices' is the name of your table
|
// Assuming 'invoices' is the name of your table
|
||||||
$builder = $this->db->table('invoice');
|
$builder = $this->db->table('invoice');
|
||||||
|
|
||||||
@ -813,23 +823,19 @@ public function updateInvoiceCancelStatus($invoiceIds, $cancelReason)
|
|||||||
$updated = $builder->update($data);
|
$updated = $builder->update($data);
|
||||||
|
|
||||||
return $updated;
|
return $updated;
|
||||||
}
|
}
|
||||||
public function getActiveSchemes(){
|
public function getActiveSchemes()
|
||||||
$builder = $this->db->table($this->table.' as I' );
|
{
|
||||||
|
$builder = $this->db->table($this->table . ' as I');
|
||||||
$builder->select('books.short_code');
|
$builder->select('books.short_code');
|
||||||
$builder->join('subscription','subscription.invoice_id = I.invoice_id');
|
$builder->join('subscription', 'subscription.invoice_id = I.invoice_id');
|
||||||
$builder->join('invoiceitems','invoiceitems.invoice_id = I.invoice_id');
|
$builder->join('invoiceitems', 'invoiceitems.invoice_id = I.invoice_id');
|
||||||
$builder->join('books','invoiceitems.product = books.book_id');
|
$builder->join('books', 'invoiceitems.product = books.book_id');
|
||||||
$builder->groupBy('short_code');
|
$builder->groupBy('short_code');
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$results = $query->getResultArray();
|
$results = $query->getResultArray();
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<button type="button" id="callajax" class="btn btn-primary" onclick="sendsms()">Send Message</button>
|
<button type="button" id="callajax" class="btn btn-primary" onclick="sendsms()">Send Message</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<input id = 'date_picker' class="form-control input-daterange-datepicker" type="text" name="date" value="<?php echo $selected_data; ?>" />
|
<input id='date_picker' class="form-control input-daterange-datepicker" type="text" name="date" value="<?php echo $selected_data; ?>" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<button type="submit" class="btn btn-primary" onclick="generateData()">Generate Report</button>
|
<button type="submit" class="btn btn-primary" onclick="generateData()">Generate Report</button>
|
||||||
@ -23,8 +23,8 @@
|
|||||||
<br>
|
<br>
|
||||||
<div class="col-md-12" style="margin: 15px;" id="target-div"></div>
|
<div class="col-md-12" style="margin: 15px;" id="target-div"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="modal_table">
|
<div id="modal_table">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="datatable-buttons" class="table table-striped nowrap w-100">
|
<table id="datatable-buttons" class="table table-striped nowrap w-100">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -40,10 +40,13 @@
|
|||||||
<tbody id="table-body">
|
<tbody id="table-body">
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div></div></div></div> <!-- end card body-->
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> <!-- end card body-->
|
||||||
</div> <!-- end card -->
|
</div> <!-- end card -->
|
||||||
</div><!-- end col--><!-- end row-->
|
</div><!-- end col--><!-- end row-->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -53,7 +56,7 @@
|
|||||||
"ordering": false,
|
"ordering": false,
|
||||||
"paging": true,
|
"paging": true,
|
||||||
"searching": true,
|
"searching": true,
|
||||||
"autoWidth":true
|
"autoWidth": true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -77,15 +80,14 @@
|
|||||||
.on('cancel.daterangepicker', function() {
|
.on('cancel.daterangepicker', function() {
|
||||||
$(this).val('');
|
$(this).val('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
|
function sendsms() {
|
||||||
function sendsms(){
|
|
||||||
var params = $("#params").val();
|
var params = $("#params").val();
|
||||||
var params2 = $("#date_picker").val();
|
var params2 = $("#date_picker").val();
|
||||||
console.log("The param passed is "+params2);
|
console.log("The param passed is " + params2);
|
||||||
if(params2){
|
if (params2) {
|
||||||
var dates = params2.split(" - ");
|
var dates = params2.split(" - ");
|
||||||
var from_date = dates[0];
|
var from_date = dates[0];
|
||||||
var to_date = dates[1];
|
var to_date = dates[1];
|
||||||
@ -93,17 +95,17 @@
|
|||||||
if (!params && !(params2)) {
|
if (!params && !(params2)) {
|
||||||
alert("Enter a valid number of days.");
|
alert("Enter a valid number of days.");
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
console.log("param 1 is "+params);
|
console.log("param 1 is " + params);
|
||||||
console.log("params 2 is "+ params2);
|
console.log("params 2 is " + params2);
|
||||||
console.log('<?= base_url() . 'getExpCustomerDetail/' ?>');
|
console.log('<?= base_url() . 'getExpCustomerDetail/' ?>');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: `<?= base_url() . 'getExpCustomerDetail/' ?>${params}/${params2}`,
|
url: `<?= base_url() . 'getExpCustomerDetail/' ?>${params}/${params2}`,
|
||||||
data: {
|
data: {
|
||||||
from_date : from_date,
|
from_date: from_date,
|
||||||
to_date : to_date,
|
to_date: to_date,
|
||||||
params : params
|
params: params
|
||||||
|
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
@ -121,7 +123,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateData(){
|
function generateData() {
|
||||||
var date = $("#date_picker").val();
|
var date = $("#date_picker").val();
|
||||||
console.log(date);
|
console.log(date);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -130,7 +132,7 @@
|
|||||||
data: {
|
data: {
|
||||||
date: date
|
date: date
|
||||||
},
|
},
|
||||||
success: function(response){
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
var data = response.data;
|
var data = response.data;
|
||||||
var table = $('#datatable-buttons').DataTable();
|
var table = $('#datatable-buttons').DataTable();
|
||||||
@ -144,9 +146,14 @@
|
|||||||
var sentDateFormatted = ('0' + sentTime.getDate()).slice(-2) + '/' +
|
var sentDateFormatted = ('0' + sentTime.getDate()).slice(-2) + '/' +
|
||||||
('0' + (sentTime.getMonth() + 1)).slice(-2) + '/' +
|
('0' + (sentTime.getMonth() + 1)).slice(-2) + '/' +
|
||||||
sentTime.getFullYear();
|
sentTime.getFullYear();
|
||||||
var sentTimeFormatted = ('0' + sentTime.getHours()).slice(-2) + ':' +
|
var hours = sentTime.getHours();
|
||||||
('0' + sentTime.getMinutes()).slice(-2) + ':' +
|
var minutes = ('0' + sentTime.getMinutes()).slice(-2);
|
||||||
('0' + sentTime.getSeconds()).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
|
var sentDateTimeFormatted = sentDateFormatted + ' ' + sentTimeFormatted; // Combine date and time
|
||||||
table.row.add([
|
table.row.add([
|
||||||
item.first_name + ' ' + item.last_name,
|
item.first_name + ' ' + item.last_name,
|
||||||
@ -170,12 +177,13 @@
|
|||||||
$('#modal_table').show();
|
$('#modal_table').show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error){
|
error: function(xhr, status, error) {
|
||||||
console.error("Ajax Error: ", error);
|
console.error("Ajax Error: ", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function regenerateFilters(table) {
|
|
||||||
|
function regenerateFilters(table) {
|
||||||
$('#datatable-buttons thead tr:eq(1)').remove();
|
$('#datatable-buttons thead tr:eq(1)').remove();
|
||||||
$('#datatable-buttons thead tr').clone(true).appendTo('#datatable-buttons thead');
|
$('#datatable-buttons thead tr').clone(true).appendTo('#datatable-buttons thead');
|
||||||
|
|
||||||
@ -200,7 +208,5 @@ function regenerateFilters(table) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -6,20 +6,20 @@
|
|||||||
<th><b>SCHEME Name</b></th>
|
<th><b>SCHEME Name</b></th>
|
||||||
<th>Date/Time</th>
|
<th>Date/Time</th>
|
||||||
<th><b>ORDER ID</b></th>
|
<th><b>ORDER ID</b></th>
|
||||||
<th>Payment Status</th>
|
<th style="text-align: left;">Payment Status</th>
|
||||||
<th><b>Amount</b></th>
|
<th><b>Amount</b></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="custom-tbody">
|
<tbody class="custom-tbody">
|
||||||
<?php foreach ($payment_status_data as $row) { ?>
|
<?php foreach ($payment_status_data as $row) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= isset($row['customer_name'])?$row['customer_name']:"-"?></td>
|
<td style="text-align: left;"><?= isset($row['customer_name'])?$row['customer_name']:"-"?></td>
|
||||||
<td><?= isset($row['membership_id'])?$row['membership_id']:"-"?></td>
|
<td style="text-align: left;"><?= isset($row['membership_id'])?$row['membership_id']:"-"?></td>
|
||||||
<td><?= isset($row['scheme_name'])?$row['scheme_name']:"-"?></td>
|
<td style="text-align: left;"><?= 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 style="text-align: left;"><?= isset($row['created_at']) ? date("d/m/Y h:i A", strtotime($row['created_at'])) : '-' ?></td>
|
||||||
<td><?= isset($row['order_id'])?$row['order_id']:"-"?></td>
|
<td style="text-align: left;"><?= isset($row['order_id'])?$row['order_id']:"-"?></td>
|
||||||
<td><?= isset($row['payment_status'])?$row['payment_status']:"-" ?></td>
|
<td style="text-align: left;"><?= isset($row['payment_status'])?$row['payment_status']:"-" ?></td>
|
||||||
<td><?= isset($row['amount'])?$row['amount']:"-"?></td>
|
<td style="text-align: right;"><?= isset($row['amount'])?$row['amount']:"-"?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -156,7 +156,7 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var table = $('#datatable-buttons').DataTable({
|
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',
|
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: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -149,7 +149,7 @@
|
|||||||
|
|
||||||
var table = $('#datatable-buttons').DataTable({
|
var table = $('#datatable-buttons').DataTable({
|
||||||
"order": [
|
"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',
|
"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: [{
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
<th>Event Name</th>
|
<th>Event Name</th>
|
||||||
<th>User Name</th>
|
<th>User Name</th>
|
||||||
<th>Books Sold</th>
|
<th>Books Sold</th>
|
||||||
<th>Payment Method</th>
|
<!-- <th>Payment Method</th> -->
|
||||||
<th>Total Amount</th>
|
<th>Total Amount</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -46,13 +46,15 @@
|
|||||||
<?php foreach ($report_data as $row) { ?>
|
<?php foreach ($report_data as $row) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td hidden><?php echo $row["user_id"]; ?></td>
|
<td hidden><?php echo $row["user_id"]; ?></td>
|
||||||
<?php $unixTime = strtotime($row['invoice_date']);
|
<?php
|
||||||
$invoice_date = date("d/m/Y", $unixTime);?>
|
// 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><?= $invoice_date ?></td>
|
||||||
<td style="text-align: left;"><?= $row['event_name'] ?></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: left;"><?= $row['first_name'] . ' (' . $row['role'] . ')' ?></td>
|
||||||
<td style="text-align: center;"><?= $row['books_sold'] ?></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>
|
<td style="text-align:right;padding-right: 67px;"><?= $row['total_amount'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -67,22 +69,22 @@
|
|||||||
<!-- end row-->
|
<!-- end row-->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function() {
|
||||||
var table = $('#datatable-buttons').DataTable({
|
var table = $('#datatable-buttons').DataTable({
|
||||||
"order": [[0, 'desc']],
|
ordering: false,
|
||||||
|
// "order": [[0, 'desc']],
|
||||||
// "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',
|
"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',
|
extend: 'print',
|
||||||
title: '<?= $page_name.' ' .$selected_data ?>',
|
title: '<?= $page_name . ' ' . $selected_data ?>',
|
||||||
text: 'Print',
|
text: 'Print',
|
||||||
customize: function (win) { }
|
customize: function(win) {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
extend: 'csv',
|
extend: 'csv',
|
||||||
text: 'CSV',
|
text: 'CSV',
|
||||||
title: '<?= $page_name.' ' .$selected_data ?>',
|
title: '<?= $page_name . ' ' . $selected_data ?>',
|
||||||
exportOptions: {}
|
exportOptions: {}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user