Beispiel #1
0
 public function get_users($id = null, $asJson = true)
 {
     $post = array();
     $page = "";
     $joinTables['user_roles'] = array('content' => 'users.role = user_roles.id');
     $select = 'users.*, user_roles.role';
     $items = $this->site_model->get_tbl('users', array(), array('users.id' => 'asc'), $joinTables, true, $select);
     $json = array();
     if (count($items) > 0) {
         foreach ($items as $res) {
             $json[$res->id] = array("title" => $res->fname . " " . $res->mname . " " . $res->lname . " " . $res->suffix, "subtitle" => $res->role, "caption" => sql2Date($res->reg_date), "inactive" => $res->inactive == 0 ? 'No' : 'Yes');
             $ids[] = $res->id;
         }
         $images = $this->site_model->get_image(null, null, 'users', array('images.img_ref_id' => $ids));
         foreach ($images as $res) {
             if (isset($json[$res->img_ref_id])) {
                 $js = $json[$res->img_ref_id];
                 $js['image'] = $res->img_path;
                 $json[$res->img_ref_id] = $js;
             }
         }
     }
     if ($asJson) {
         // echo json_encode($json);
         echo json_encode(array('rows' => $json, 'page' => "", 'post' => $post));
     } else {
         return array('rows' => $json, 'page' => "", 'post' => $post);
         // return $json;
     }
 }
Beispiel #2
0
 public function __construct()
 {
     parent::__construct();
     if ($this->input->post('change_db')) {
         $this->change_db($this->input->post('change_db'));
     }
     $date = null;
     if ($this->input->post('daterange')) {
         $date = $this->input->post('daterange');
     } else {
         if ($this->input->post('date')) {
             $date = $this->input->post('date');
         } else {
             if ($this->input->post('month')) {
                 $today = sql2Date(phpNow());
                 $year = date('Y', strtotime($today));
                 $date = $year . "-" . $this->input->post('month') . "-01";
             }
         }
     }
     if ($date != null) {
         $dates = explode(" to ", $date);
         $used = $dates[0];
         $today = sql2Date(phpNow());
         if (strtotime($used) < strtotime($today)) {
             $this->change_db('main');
         }
     } else {
         if ($this->input->post('change_db')) {
             $this->change_db('main');
         }
     }
 }