88 lines
3.5 KiB
PHP
Executable File
88 lines
3.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers;
|
|
use App\Models\HomeModel;
|
|
|
|
## Home Controllers only for Dashboards,Report Modules
|
|
class Home extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
// echo "hwllo"
|
|
helper('session');
|
|
$session_role = get_user_role();
|
|
$session_bid = get_business_id();
|
|
|
|
$data['page_name'] = 'Dashboard';
|
|
if (!empty($session_role) && $session_role !== "sadmin") {
|
|
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
|
|
} else if (!empty($session_role) && $session_role !== "admin") {
|
|
$where = ['isactive != ' => NULL];
|
|
} else {
|
|
$where = [];
|
|
}
|
|
$model = new HomeModel();
|
|
$data['customer'] = $model->customers($where);
|
|
$data['customer']['label'] = "Customer";
|
|
$data['invoice'] = $model->invoice_dtls();
|
|
// $data['active_category'] = $model->schemes();
|
|
$data['active_schemes'] = $model->active_schemes();
|
|
$data['expiring_membership'] = $model->expiring_membership_with_notification_list();
|
|
$data['notifications'] = $model->expiring_membership_list();
|
|
// print_r( $data['expiring_membership']);die;
|
|
// $data['active_category'] = array_filter($model->schemes(), function ($element) {
|
|
// return $element['count'] !== '0' ;
|
|
// });
|
|
$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);
|
|
|
|
}
|
|
|
|
// public function check_existing()
|
|
// {
|
|
// $value = $this->request->getPost('value');
|
|
// $table = $this->request->getPost('module');
|
|
// $field = $this->request->getPost('field');
|
|
// $model = new HomeModel();
|
|
// $model->setTable($table);
|
|
// $where = [$field => $value];
|
|
// $check_existing = $model->where($where)->count();
|
|
// $statement_string = ucfirst(str_replace('_', ' ', $field));
|
|
// if($check_existing>0){
|
|
// $data['status'] = true;
|
|
// $data['message'] = $statement_string." Already existing";
|
|
// }
|
|
// else{
|
|
// $data['status'] = false;
|
|
// $data['message'] = "";
|
|
// }
|
|
// return $this->response->setJSON(['data' => $data]);
|
|
// }
|
|
|
|
public function check_existing()
|
|
{
|
|
$value = $this->request->getPost('value');
|
|
$table = $this->request->getPost('module');
|
|
$field = $this->request->getPost('field');
|
|
$model = new HomeModel();
|
|
// $model->setTable('customers');
|
|
$model->setTable((string)$table);
|
|
$where = [$field => $value];
|
|
$check_existing = $model->where($where)->findAll();
|
|
|
|
$statement_string = ucfirst(str_replace('_', ' ', (string)$field));
|
|
$data = ['status' => false, 'message' => '']; // Initialize the data array
|
|
if (!empty($check_existing)) {
|
|
$data['status'] = true;
|
|
$data['message'] = $statement_string." Already existing";
|
|
}
|
|
return $this->response->setJSON(['data' => $data]);
|
|
}
|
|
|
|
}
|