63 lines
2.2 KiB
PHP
63 lines
2.2 KiB
PHP
<?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();
|
|
|
|
// echo $session_bid, $session_role; die;
|
|
|
|
$data['page_name'] = 'Dashboard';
|
|
if (!empty($session_role) && $session_role == "sadmin") {
|
|
$where = ['isactive != ' => NULL];
|
|
} else if (!empty($session_role) && $session_role == "admin") {
|
|
$where = ['isactive' => 1, 'business_id' => $session_bid];
|
|
}
|
|
else {
|
|
$where = [];
|
|
}
|
|
$model = new HomeModel();
|
|
$data['customer'] = $model->customers($where);
|
|
$data['customer']['label'] = "donors";
|
|
|
|
// echo '<pre>';
|
|
// print_r($data['customer'] ); die;
|
|
|
|
// $data['invoice'] = $model->invoice();
|
|
// $data['active_category'] = array_filter($model->schemes(), function ($element) {
|
|
// return $element['count'] !== '0' ;
|
|
// });
|
|
// $data['book_published'] = $model->book_published_list();
|
|
$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('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]);
|
|
}
|
|
}
|