File: //var/www/html/pmw24/app/application/controllers/admin/Dashboard.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends MY_Controller {
public function __construct() {
parent::__construct();
$this->redirect_guest();
$this->load->model('admin/mdashboard');
$this->load->model('admin/mjob');
}
public function index() {
$data=array();
$this->_load_dashboard_view($data);
}
private function _load_dashboard_view($dashboard) {
$data['content'] = 'admin/dashboard';
$total_car = $this->mdashboard->total_car();
$data['total_car'] = $total_car;
$mechanic_condition = array("role_id"=>14,"status"=>1);
$mechanics = $this->mjob->getRows('admins',$mechanic_condition);
$date = date('Y-m-d');
$condition = array('available_date'=>$date);
$off_mechanics = $this->mjob->getRows('user_roaster',$condition);
$new_off_mechanic = array();
foreach($off_mechanics as $off_mechanic)
{
$new_off_mechanic[] = $off_mechanic['mechanic_id'];
}
$new_mechanic = array();
foreach($mechanics as $mechanic)
{
$new_mechanic[] = $mechanic['admin_id'];
}
$roasted_mechanic_list = array_diff($new_mechanic,$new_off_mechanic);
$new_mechanic_list = array();
foreach($roasted_mechanic_list as $key_m=>$roasted_mechanic)
{
$reassign_mechanic_condition = array("admin_id"=>$roasted_mechanic);
$reassign_mechanic = $this->mjob->getRow('admins',$reassign_mechanic_condition);
$new_mechanic_list[$key_m] = $reassign_mechanic;
}
$total_mechanic = count($new_mechanic_list);;
$data['total_mechanic'] = $total_mechanic;
$total_service = $this->mdashboard->total_service();
$data['total_service'] = $total_service;
$data['list']=$dashboard;
$this->load->view('admin/layouts/index', $data);
}
private function sendMail($data){
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.hostinger.com'; //'ssl://smtp.gmail.com';
$config['smtp_port'] = '587';
$config['smtp_user'] = 'info@pmw24.com.au'; //'joysz2018@gmail'
$config['smtp_pass'] = 'Kzlsdsxnsoevymxi@1';//'poker#2018';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html';
$config['validation'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_crlf( "\r\n" );
$this->email->from('info@pmw24.com.au', 'Punjab Motor Work Shop');
//$data['to']
$this->email->to($data['to']);
//$this->email->bcc('ishani.banerjee@met-technologies.com', 'Dev');
$this->email->subject($data['subject']);
$this->email->message($data['message']);
if($this->email->send()){
echo "mail Send.";
} else {
echo $this->email->print_debugger();
}
//return true;
}
public function test_email(){
$data['to']='ZAFAR.DNK@GMAIL.COM';
$data['name']='PUNJAB MOTOR WORKSHOP';
$data['subject']='Approved By Admin';
$data['message']='This is Test <strong>Email</strong>';
$this->sendMail($data);
}
}