55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class PaymentStatusModel extends Model
|
|
{
|
|
protected $DBGroup = 'default';
|
|
protected $table = 'payment_status';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = 'array';
|
|
protected $useSoftDeletes = false;
|
|
protected $protectFields = true;
|
|
protected $allowedFields = [
|
|
'id',
|
|
'customer_id',
|
|
'membership_id',
|
|
'scheme_id',
|
|
'amount',
|
|
'device',
|
|
'status',
|
|
'is_active',
|
|
'order_id',
|
|
'payment_status'
|
|
];
|
|
|
|
|
|
public function getPaymentData($fromDate, $toDate, $status)
|
|
{
|
|
|
|
$builder = $this->db->table('payment_status')->select('payment_status.*,CONCAT(COALESCE(customers.first_name, ""), " ", COALESCE(customers.last_name, "")) AS customer_name,books.short_code as scheme_name')
|
|
->join('customers','customers.customer_id = payment_status.customer_id and customers.isactive = 1')
|
|
->join('books','books.book_id = payment_status.scheme_id and books.isactive = 1');
|
|
|
|
if (!empty($fromDate) && !empty($toDate)) {
|
|
$builder->where('payment_status.created_at >=', $fromDate.' 00:00:00')
|
|
->where('payment_status.created_at <=', $toDate. ' 23:59:59');
|
|
}
|
|
|
|
if ($status == 1) {
|
|
$builder->where('payment_status.status >', 0); // Correct usage of where() for status
|
|
}else{
|
|
$builder->where('payment_status.status', null);
|
|
}
|
|
|
|
$builder->where('payment_status.is_active',1);
|
|
$builder->orderBy('payment_status.created_at','desc');
|
|
$data = $builder->get()->getResultArray();
|
|
// log_message('error',json_encode($this->db->getLastQuery()->getQuery()));
|
|
return $data; // Fetch and return as an array
|
|
}
|
|
}
|