Ejemplo n.º 1
0
 public function changeStatus(Dtouser $user)
 {
     $this->db->set('updated_date', date('Y-m-d H:i:s'));
     $this->db->set('updated_by', $this->ion_auth->get_user_id());
     $this->db->set('active', 1 - $user->getActive());
     $this->db->where('id', $user->getId());
     return $this->db->update('users');
 }
Ejemplo n.º 2
0
 public function getSaleOfBAExecutiveArchievement(Dtouser $Dtouser, $status = 0)
 {
     $this->db->select("\n\t\t\t\t\t\t\tIFNULL(SUM(sale_items.price*sale_items.quantity),0) AS amount\n\t\t\t\t\t\t\t", FALSE);
     $this->db->from('sales');
     $this->db->join('users', 'sales.ba_id = users.id AND users.active = 1', 'LEFT');
     $this->db->join('sale_items', 'sales.id=sale_items.sale_id', 'LEFT');
     $this->db->where('sales.status', 1);
     $this->db->where('users.parent_id IN (SELECT id FROM users where parent_id = ' . $Dtouser->getId() . ')');
     if ($status == 0) {
         $this->db->where("DATE(sales.sale_date)=DATE_FORMAT(CONVERT_TZ(NOW(), @@session.time_zone, '+07:00'),'%Y-%m-%d')");
     } else {
         if ($status == 1) {
             $this->db->where("(sales.sale_date between  DATE_FORMAT(NOW() ,'%Y-%m-01') AND CONVERT_TZ(NOW(), @@session.time_zone, '+07:00') )");
         } else {
             if ($status == 2) {
                 $this->db->where("(sales.sale_date between  DATE_FORMAT(NOW() ,'%Y-01-01') AND CONVERT_TZ(NOW(), @@session.time_zone, '+07:00') )");
             }
         }
     }
     $query = $this->db->get();
     return $query->row();
 }
Ejemplo n.º 3
0
 public function getSupervisorInformation(Dtouser $user)
 {
     $this->db->select("A.id\n\t\t\t\t\t\t\t\t, A.first_name\n\t\t\t\t\t\t\t\t, A.last_name\n\t\t\t\t\t\t\t\t, (SELECT CONCAT(last_name, ' ', first_name) AS supervisor \n\t\t\t\t\t\t\t\t   FROM users where id = A.parent_id) AS executive\n\t\t\t\t\t\t\t\t, A.photo", FALSE);
     $this->db->from('users A');
     $this->db->where("A.deleted_at", null);
     $this->db->where('A.id', $user->getId());
     $query = $this->db->get();
     return $query->row();
 }