1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
class Dashboard_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function getBookingCount(){
$result = $this->db->get_where('bookings')->result();
return count($result);
}
public function getMechShpCount(){
$result = $this->db->get_where('mechanic_shop',array('status'=>'1'))->result();
return count($result);
}
public function getCompletedBookingCount(){
$result = $this->db->get_where('bookings',array('status'=>'3'))->result();
return count($result);
}
public function getPendingBookingCount(){
$result = $this->db->get_where('bookings',array('status'=>'1'))->result();
return count($result);
}
public function getMbleVndrsCount(){
$result = $this->db->get_where('mechanic',array('shop_id'=>'1'))->result();
return count($result);
}
public function getMbleMchnsCount(){
$result = $this->db->get_where('mechanic',array('shop_id'=>'0'))->result();
return count($result);
}
public function getCustomerCount(){
$result = $this->db->get_where('customers',array('status'=>'1'))->result();
return count($result);
}
public function getProductCount(){
$result = $this->db->get_where('products',array('status'=>'1'))->result();
return count($result);
}
public function getProductSoldCount(){
$result = $this->db->query("SELECT SUM(`quantity`) as count FROM `orders` WHERE status IN('2,3,4,5')")->row();
return $result->count;
}
public function getSalesReportCount(){
$query = $this->db->query("
SELECT COUNT(ORDS.order_id) AS count, SUBSTRING_INDEX(TRANS.datetime, '-', 1) AS year
FROM `orders` AS `ORDS`
INNER JOIN `transaction` AS `TRANS` ON (`TRANS`.`booking_id` = `ORDS`.`order_id`)
WHERE `TRANS`.`payment_for`='2' AND `TRANS`.`status` = '1'
GROUP BY SUBSTRING_INDEX(TRANS.datetime,'-',1)");
$result = array();
if(empty($query) || $query->num_rows < 0 || empty($query = $query->result_array())){
return $result;
}
foreach($query as $value){
$result[] = array('y'=>$value['year'],'item1'=>$value['count']);
}
return json_encode($result);
}
public function getBookingReportCount(){
$query = $this->db->query("
SELECT COUNT(BUK.booking_id) AS count, SUBSTRING_INDEX(TRANS.datetime, '-', 1) AS year
FROM `bookings` AS `BUK`
INNER JOIN `transaction` AS `TRANS` ON (`TRANS`.`booking_id` = `BUK`.`booking_id`)
WHERE `TRANS`.`payment_for`='1' AND `TRANS`.`status` = '1'
GROUP BY SUBSTRING_INDEX(TRANS.datetime,'-',1)");
$result = array();
if(empty($query) || $query->num_rows < 0 || empty($query = $query->result_array())){
return $result;
}
foreach($query as $value){
$result[] = array('y'=>$value['year'],'item1'=>$value['count']);
}
return json_encode($result);
}
}
?>