Ejemplo n.º 1
0
 /**
  * insert data
  * @param array $data
  * @return type
  */
 public function insert_data($data)
 {
     $data['update_at'] = date('Y-m-d H:i');
     $data['create_at'] = date('Y-m-d H:i');
     if (!count($data)) {
         return array();
     }
     foreach ($data as $key => $val) {
         if (!key_exists($key, $this->_data_default)) {
             unset($data[$key]);
         }
     }
     Fuel\Core\DB::query('LOCK TABLES ' . self::$_table_name . ' READ');
     try {
         $check_exits = static::forge()->find_by_pk($data['m_image_id']);
         $res = true;
         if (!count($check_exits)) {
             $data['create_at'] = date('Y-m-d H:i');
             $obj = static::forge();
             $obj->set($data);
             $res = $obj->save();
         }
     } catch (\Database_exception $e) {
         $res = false;
         throw $e;
     }
     Fuel\Core\DB::query('UNLOCK TABLES');
     return $res;
 }
Ejemplo n.º 2
0
 public function get_media_name($media_id)
 {
     if (count($media_id) == 0) {
         return array();
     }
     $sql = 'SELECT media_name FROM m_media' . ' WHERE m_media_id =' . $media_id;
     return Fuel\Core\DB::query($sql)->execute()->as_array();
 }
Ejemplo n.º 3
0
 public function get_list_post_id($media_id_list)
 {
     $is_where = DB::select('post_id')->from('m_post');
     $is_where->where('m_media_id', 'in', $media_id_list);
     return Fuel\Core\DB::query($is_where)->execute()->as_array();
 }
Ejemplo n.º 4
0
 public function get_person_division_3($array_ss_id, $array_order_id)
 {
     if (!count($array_ss_id) && !count($array_order_id)) {
         return array();
     }
     $wh = '';
     if (count($array_order_id)) {
         $wh .= 'person.order_id IN (' . implode(',', $array_order_id) . ')';
     }
     if (count($array_ss_id)) {
         $wh .= ' OR ( person.sssale_id IN (' . implode(',', $array_ss_id) . '))';
     }
     $wh = trim($wh, ' OR');
     if ($wh) {
         $sql = 'SELECT person.* FROM person ' . 'LEFT JOIN employment ON (person.person_id = employment.person_id) ' . 'WHERE (' . '(employment.contact_result IS null OR employment.contact_result < 2) AND ' . '(employment.review_result IS null OR employment.review_result < 2) AND ' . '(employment.adoption_result IS null OR employment.adoption_result < 2) AND ' . '(employment.contract_result IS null OR employment.contract_result < 2) AND ' . '(employment.work_confirmation IS null OR employment.work_confirmation < 2)' . ') AND (' . $wh . ')';
         //if($_GET['debug']) echo $sql;
         return Fuel\Core\DB::query($sql)->execute();
     }
     return array();
 }
Ejemplo n.º 5
0
 /**
  * @author NamDD <*****@*****.**>
  * @param $where
  * @return object
  */
 public function get_list_sssale($where)
 {
     $sql = 'SELECT * FROM sssale WHERE ' . $where;
     if ($where == '') {
         $sql = 'SELECT * FROM sssale';
     }
     return Fuel\Core\DB::query($sql)->execute();
 }
Ejemplo n.º 6
0
 public function get_list_oders_login($user_id)
 {
     $sql = 'SELECT order_id FROM orders WHERE  interview_user_id = ' . $user_id . ' OR agreement_user_id = ' . $user_id . ' OR training_user_id =' . $user_id;
     $result = Fuel\Core\DB::query($sql)->execute();
     return $result;
 }
Ejemplo n.º 7
0
 public function get_list_partner_login($user_id)
 {
     $sql = 'SELECT * FROM m_partner WHERE user_id = ' . $user_id;
     return Fuel\Core\DB::query($sql)->execute();
 }
Ejemplo n.º 8
0
    public function get_search_data($export = false)
    {
        $config['where'] = array();
        $config_pagination = array();
        $rs = true;
        if (\Fuel\Core\Input::get('media_search', null) != null) {
            $config['where'][] = array('media_list', 'LIKE', '%,' . \Fuel\Core\Input::get('media_search') . ',%');
        }
        if (Fuel\Core\Input::get('group_search', null) != null) {
            $sql = 'select m_ss.ss_id from m_ss
				inner join m_partner on (m_ss.partner_code = m_partner.partner_code)
				where m_partner.m_group_id = :group_id';
            $group_id = Fuel\Core\Input::get('group_search');
            $_array = Fuel\Core\DB::query($sql)->bind('group_id', $group_id)->execute()->as_array();
            $ss_list_id[] = -1;
            foreach ($_array as $row) {
                $ss_list_id[] = $row['ss_id'];
            }
            $config['where'][] = array('ss_id', 'IN', $ss_list_id);
        }
        if (Fuel\Core\Input::get('partner_search')) {
            $ss_list_id = array();
            $list_ss_search = $this->get_list_ss('partner_code="' . Fuel\Core\Input::get('partner_search') . '"');
            $ss_list_id[] = -1;
            foreach ($list_ss_search as $row) {
                $ss_list_id[] = $row['ss_id'];
            }
            $config['where'][] = array('ss_id', 'IN', $ss_list_id);
        }
        if (\Fuel\Core\Input::get('address_1') || \Fuel\Core\Input::get('address_2')) {
            $filter = array('addr_1' => \Fuel\Core\Input::get('address_1', 0), 'addr_2' => \Fuel\Core\Input::get('address_2', ''));
            $ss_list_id = $this->mss->get_list_ss_addr($filter);
            if (!empty($ss_list_id)) {
                $config['where'][] = array('ss_id', 'IN', $ss_list_id);
            } else {
                $config['where'][] = array('ss_id', 'IN', array(-1));
            }
        }
        if (Fuel\Core\Input::get('ss_search')) {
            $config['where'][] = array('ss_id', '=', Fuel\Core\Input::get('ss_search'));
        }
        if (\Fuel\Core\Input::get('public_type_1') && \Fuel\Core\Input::get('public_type_2')) {
            $config['where'][] = array('public_type', '&9=', '9');
        } else {
            if (\Fuel\Core\Input::get('public_type_1')) {
                $config['where'][] = array('public_type', '&1=', '1');
            }
            if (\Fuel\Core\Input::get('public_type_2')) {
                $config['where'][] = array('public_type', '&8=', '8');
            }
        }
        if (\Fuel\Core\Input::get('status', null) != null) {
            $config['where'][] = array('status', '=', \Fuel\Core\Input::get('status'));
        }
        if (\Fuel\Core\Input::get('start_date')) {
            $config['where'][] = array('start_date', '>=', \Fuel\Core\Input::get('start_date'));
        }
        if (\Fuel\Core\Input::get('end_date')) {
            $config['where'][] = array('end_date', '<=', \Fuel\Core\Input::get('end_date'));
        }
        if (\Fuel\Core\Input::get('is_available', null) != null) {
            $config['where'][] = array('is_available', '=', \Fuel\Core\Input::get('is_available'));
        }
        if (\Fuel\Core\Input::get('department_id', null) != null) {
            $sql = 'select m_ss.ss_id from m_ss
				inner join m_partner on (m_ss.partner_code = m_partner.partner_code)
				where m_partner.department_id = :department_id';
            $department_id = Fuel\Core\Input::get('department_id');
            $_array = Fuel\Core\DB::query($sql)->bind('department_id', $department_id)->execute()->as_array();
            $department_ss_list_id[] = -1;
            foreach ($_array as $row) {
                $department_ss_list_id[] = $row['ss_id'];
            }
            $config['where'][] = array('ss_id', 'IN', $department_ss_list_id);
        }
        $config_pagination = $config['where'];
        $config_pagination = array('pagination_url' => \Uri::base() . 'job/jobs/index?' . http_build_query(\Input::get()), 'total_items' => $this->job->count('job_id', true, $config_pagination), 'per_page' => Constants::$default_limit_pagination, 'uri_segment' => 'page', 'num_links' => Constants::$default_num_links, 'show_last' => true);
        if ($export) {
            $config_pagination['per_page'] = 100000;
            // get all
        }
        $pagination = \Uospagination::forge('jobpage', $config_pagination);
        $config['limit'] = $pagination->per_page;
        $config['offset'] = $pagination->offset;
        $config['order_by'] = array('job_id' => 'desc');
        $res = $this->job->find($config);
        $list_ss_id = '';
        $list_sssale_id = '';
        $list_partner_id = '';
        $_arr_res = $_arr_res = array('res' => array(), 'res_ss' => array(), 'res_partner' => array(), 'res_sssale' => array());
        if (count($res)) {
            foreach ($res as $row) {
                if ($row['ss_id']) {
                    $list_ss_id .= $row['ss_id'] . ',';
                }
                if ($row['sssale_id']) {
                    $list_sssale_id .= $row['sssale_id'] . ',';
                }
            }
            $list_sssale_id = trim($list_sssale_id, ',');
            $list_ss_id = trim($list_ss_id, ',');
            $res_ss = array();
            if ($list_ss_id) {
                $res_ss = $this->get_list_ss('ss_id IN (' . $list_ss_id . ')');
                foreach ($res_ss as $row) {
                    $list_partner_id .= '"' . $row['partner_code'] . '",';
                }
                $list_partner_id = trim($list_partner_id, ',');
            }
            $list_sssale = array();
            if ($list_sssale_id) {
                $list_sssale = $this->get_list_sssale('sssale_id IN (' . $list_sssale_id . ')');
            }
            $list_partner = array();
            $list_group = array();
            if ($list_partner_id) {
                $list_partner = $this->get_list_partner('partner_code IN (' . $list_partner_id . ')');
                /*Get group name */
                $list_group_id = array();
                foreach ($list_partner as $row) {
                    $list_group_id[] = $row['m_group_id'];
                }
                $list_group = $this->mgroup->get_list_by_partner($list_group_id);
            }
            $_arr_res = array('res' => $res, 'res_ss' => $this->array_key_value($res_ss, 'ss_id'), 'res_partner' => $this->array_key_value($list_partner, 'partner_code'), 'res_sssale' => $this->array_key_value($list_sssale, 'sssale_id'), 'res_group' => $this->array_key_value($list_group, 'm_group_id'), 'paging' => $pagination);
        }
        return $_arr_res;
    }
Ejemplo n.º 9
0
 /**
  *
  * @param type $id
  * @return array([0]['name'])
  */
 public function get_user_name($id)
 {
     if (count($id) == 0) {
         return array();
     }
     $sql = 'SELECT name FROM m_user' . ' WHERE user_id =' . $id;
     return Fuel\Core\DB::query($sql)->execute()->as_array();
 }