/** * board group 테이블에서 가져옵니다 */ public function get_baord_group($bgr_id = 0, $bgr_key = '') { if (empty($bgr_id) && empty($bgr_key)) { return false; } if ($bgr_id) { $group = $this->CI->Board_group_model->get_one($bgr_id); } elseif ($bgr_key) { $where = array('bgr_key' => $bgr_key); $group = $this->CI->Board_group_model->get_one('', '', $where); } else { return false; } if (element('bgr_id', $group)) { $group_meta = $this->get_all_meta(element('bgr_id', $group)); if (is_array($group_meta)) { $group = array_merge($group, $group_meta); } } if (element('bgr_id', $group)) { $this->group_id[element('bgr_id', $group)] = $group; } if (element('bgr_key', $group)) { $this->group_key[element('bgr_key', $group)] = $group; } }
public function update_project($userParameters) { $project_name = element("project_name", $userParameters, ""); $location = element("location", $userParameters, ""); $consultant_name = element("consultant_name", $userParameters, ""); $contractor_name = element("contractor_name", $userParameters, ""); $responsible_salesman = element("responsible_salesman", $userParameters, ""); $e_date = element("e_date", $userParameters, ""); $cn = element("cn", $userParameters, ""); $project_g_view = element("project_g_view", $userParameters, ""); $project_area = element("project_area", $userParameters, ""); $project_quantity = element("project_quantity", $userParameters, ""); $project_type = element("project_type", $userParameters, '0'); $project_size = element("project_size", $userParameters, ""); $project_diameters = element("project_diameters", $userParameters, ""); $average_diameter = element("average_diameter", $userParameters, ""); $wastage_rate = element("wastage_rate", $userParameters, ""); $shop_drawings_difficulty = element("shop_drawings_difficulty", $userParameters, ""); $shop_drawings_productivity = element("shop_drawings_productivity \t", $userParameters, ""); $fabrications_difficulty = element("fabrications_difficulty", $userParameters, ""); $fabrications_productivity = element("fabrications_productivity", $userParameters, ""); $tech_office_status = element("tech_office_status", $userParameters, ""); $technical_recommentation = element("technical_recommentation", $userParameters, '0'); $from = element("from", $userParameters, ""); $to = element("to", $userParameters, ""); $u_id = $this->session->userdata('auth.user_id'); $updated = date("Y-m-d h:i:s"); $data = array('project_name' => $project_name, 'location' => $location, 'consultant_name' => $consultant_name, 'contractor_name' => $contractor_name, 'responsible_salesman' => $responsible_salesman, 'e_date' => $e_date, 'cn' => $cn, 'project_g_view' => $project_g_view, 'project_area' => $project_area, 'project_quantity' => $project_quantity, 'project_type' => $project_type, 'project_size' => $project_size, 'project_diameters' => $project_diameters, 'average_diameter' => $average_diameter, 'wastage_rate' => $wastage_rate, 'shop_drawings_difficulty' => $shop_drawings_difficulty, 'shop_drawings_productivity' => $shop_drawings_productivity, 'fabrications_difficulty' => $fabrications_difficulty, 'fabrications_productivity' => $fabrications_productivity, 'tech_office_status' => $tech_office_status, 'technical_recommentation' => $technical_recommentation, 'from' => $from, 'to' => $to, 'u_id' => $u_id, 'updated' => $updated); $this->db->update('urf_estimation', $data); }
public function up() { $this->load->helper('date'); $is_datetime = strtolower(Model::TIMESTAMP_FORMAT) == 'datetime'; foreach ($this->tables() as $name => $prop) { $keys = []; $is_auto_timestamp = element(self::FLAG_AUTOTIMESTAMP, $prop, true); if ($schemas = element(self::DB_SCHEMAS, $prop, [])) { if (true === $is_auto_timestamp) { $this->_auto_timestamp = true; $creator = ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'default' => null]; if ($is_datetime) { $timestamp = ['type' => 'datetime', 'default' => '0000-00-00 00:00:00']; } else { $timestamp = ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'default' => 0]; } $schemas[Model::CREATION_KEY . '_by'] = $creator; $schemas[Model::CREATION_KEY . '_at'] = $timestamp; $schemas[Model::MODIFICATION_KEY . '_by'] = $creator; $schemas[Model::MODIFICATION_KEY . '_at'] = $timestamp; } if (false === element(self::FLAG_DESTRUCTIVE, $prop, false)) { $schemas[Model::DELETION_KEY] = ['type' => 'tinyint', 'constraint' => 1, 'unsigned' => true, 'DEFAULT' => 0]; } foreach ($schemas as $column => $schema) { if (isset($schema['key'])) { $keys[$column] = $schema['key']; unset($schema['key']); } } if (true === element(self::FLAG_OVERRIDE, $prop, true)) { $this->dbforge->drop_table($name, true); } $this->dbforge->add_field($schemas); if (!empty($keys)) { foreach ($keys as $key => $value) { $this->dbforge->add_key($key, $value); } } if (false === element(self::FLAG_ALTERTABLE, $prop, false)) { if ($this->dbforge->create_table($name, true, ['engine' => 'InnoDB'])) { log_message('info', 'Migration successfully create table ' . $name); } else { log_message('error', 'Migration failed to create table ' . $name); } } } if ($data = element(self::DB_DATA, $prop, [])) { if (true === $is_auto_timestamp) { $now = $is_datetime ? date('Y-m-d H:i:s') : time(); for ($d = 0; $d < count($data); $d++) { $data[$d] += [Model::CREATION_KEY . '_by' => null, Model::CREATION_KEY . '_at' => $now, Model::MODIFICATION_KEY . '_by' => null, Model::MODIFICATION_KEY . '_at' => $now]; } } if ($this->db->insert_batch($name, $data)) { log_message('info', 'Migration successfully insert data to table ' . $name); } } } }
public function render() { $app = $this->app; $yaml = $this->yaml; $datas = []; foreach ($yaml['entry'] as $value) { $custom = element('custom', $value); $type = element('type', $value); $label = element('label', $value); $required = element('required', $value); $help = element('help', $value); $text = element('text', $value); $attributes = element('attributes', $value); $permission = element('permission', $value); if ($permission && !$app['acl']->allow($permission)) { continue; } $misc = ['type' => $type, 'label' => $label, 'required' => $required, 'text' => $text, 'help' => $help]; if ($custom) { $class = element('class', $custom); $action = element('action', $custom); $param = ['label' => $label, 'help' => $help]; $form = call_user_func([$class, $action], $app, $param); } else { $form = $this->build($app, $misc, $attributes); } $datas[] = $form; } return $app['twig']->render('grid/entry/entry.html', ['datas' => $datas]); }
/** * 전체 메인 페이지입니다 */ public function index() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_main_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $where = array('brd_search' => 1); $board_id = $this->Board_model->get_board_list($where); $board_list = array(); if ($board_id && is_array($board_id)) { foreach ($board_id as $key => $val) { $board_list[] = $this->board->item_all(element('brd_id', $val)); } } $view['view']['board_list'] = $board_list; $view['view']['canonical'] = site_url(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_main'); $meta_description = $this->cbconfig->item('site_meta_description_main'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_main'); $meta_author = $this->cbconfig->item('site_meta_author_main'); $page_name = $this->cbconfig->item('site_page_name_main'); $layoutconfig = array('path' => 'main', 'layout' => 'layout', 'skin' => 'main', 'layout_dir' => $this->cbconfig->item('layout_main'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_main'), 'use_sidebar' => $this->cbconfig->item('sidebar_main'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_main'), 'skin_dir' => $this->cbconfig->item('skin_main'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_main'), 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
/** * Produces JSON results for autocomplete form of prduct name entry * Used on both the member side (fancy search) and admin side (find products to add to a members order) * **/ public function product_search($query = null) { //get the searce term and some other parameters that might have come with this query if ($query == null) { $query = $this->input->get('term'); } //get other parameters and set some defaults $params = $this->input->get(); if (element('return_seasons', $params) == null) { $params['return_seasons'] = 'yes'; } $this->load->model('products_model'); $search_params = array('p_name' => $query, 'p_status' => 'Active', 'include_supplier' => true, 'extended_detail' => true); $products = $this->products_model->get_products($search_params); // do some tidying for ajax before you send it back $product_view = 'products/partial_product_item'; foreach ($products as $key => $p) { if ($params['return_seasons'] == 'yes') { $products[$key]['seasons'] = $this->products_model->get_product_allowances($p['p_id']); } if ($params['return_html'] == 'yes') { $p_data = array('p' => $p, 'category' => array('cat_slug' => 'all')); $products[$key]['item_html'] = $this->load->view($product_view, $p_data, TRUE); } } $this->json = $products; }
function saveStudents($arrPost) { $this->load->helper('array'); $studentsId = element('studentsid', $arrPost, NULL); unset($arrPost['studentsid']); if ($studentsId == null) { $this->db->insert('students', $arrPost); log_message('debug', '>>>$sql: '.$this->db->last_query()); } else { $sql = 'UPDATE sisrama.students SET regno = ? ,name = ? ,class=? ,parent = ? ,address = ? ,city = ? ,phone = ? ,birthdate=? ,birthplace=? WHERE students.id = ?'; $arrPost['studentsid']=$studentsId; $this->db->query($sql,$arrPost); log_message('debug', '>>>$sql: '.$this->db->last_query()); } }
/** * 버전정보 페이지입니다 */ public function index() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_admin_config_cbversion_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); Requests::register_autoloader(); $headers = array('Accept' => 'application/json'); $postdata = array('requesturl' => current_full_url(), 'package' => CB_PACKAGE, 'version' => CB_VERSION); $request = Requests::post(config_item('ciboard_check_latest_version'), $headers, $postdata); $view['view']['latest_versions'] = json_decode($request->body, true); if (strtolower(CB_PACKAGE) === 'premium') { $view['view']['latest_version_name'] = $view['view']['latest_versions']['premium_version']; $view['view']['latest_download_url'] = $view['view']['latest_versions']['premium_downloadurl']; } else { $view['view']['latest_version_name'] = $view['view']['latest_versions']['basic_version']; $view['view']['latest_download_url'] = $view['view']['latest_versions']['basic_downloadurl']; } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 어드민 레이아웃을 정의합니다 */ $layoutconfig = array('layout' => 'layout', 'skin' => 'index'); $view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
/** * 更新商品分类 */ public function update_category($category_id, $category) { $location = trim(element('location', $category)); $category_name = trim(element('category_name', $category)); // 判断 if (!$category_name) { return array('error_code' => '10010', 'error' => '商品分类名称不能为空!'); } // 判断 $this->db->where('category_id !=', $category_id)->where('category_name', $category_name); $count = $this->db->where('status', 1)->count_all_results("category"); if ($count > 0) { return array('error_code' => '10011', 'error' => '商品分类名称已经存在!'); } // 整理数据 $data = array('location' => intval($location), 'category_name' => $category_name); // 更新数据 $res = $this->db->where('category_id', $category_id)->update('category', $data); if ($res === false) { return array('error_code' => '10012', 'error' => '修改商品分类失败!'); } // 写日志 $this->load_model('logs_model')->add_content("修改商品分类: [{$category_name}]"); return array('message' => '修改商品分类成功!'); }
public function index_post() { $this->load->database(); $this->load->helper('array'); try { $data = array('test_name' => $this->post('test_name'), 'test_heading' => $this->post('test_heading'), 'test_short_name' => $this->post('test_short_code'), 'group_id' => $this->post('test_group'), 'test_amount' => $this->post('test_charge'), 'test_remark' => $this->post('test_remark'), 'flag_id' => $this->post('flag_id'), 'method_id' => $this->post('method_id'), 'sample_id' => $this->post('sample_id'), 'instrument_id' => $this->post('instrument_id'), 'testIsOutsourced' => $this->post('testIsOutsourced'), 'testIsOutsourcedLab' => $this->post('testIsOutsourcedLab'), 'is_deleted' => 0); $productDetails = $this->post('productDetails'); $this->db->where('test_name', element('test_name', $data)); $query = $this->db->get('test_master'); $count = $query->num_rows(); if ($count === 0) { $this->db->insert('test_master', $data); if ($this->db->affected_rows() > 0) { $totalCount = $this->db->insert_id(); // get last inserted record Id for ($i = 0; $i < count($productDetails); $i++) { $user = array('test_id' => $totalCount, 'test_details' => $productDetails[$i]['parameters'], 'test_min_ref' => $productDetails[$i]['refbelow'], 'test_max_ref' => $productDetails[$i]['refabove'], 'patient_min_age' => $productDetails[$i]['agebelow'], 'patient_max_age' => $productDetails[$i]['ageabove'], 'patient_gender' => $productDetails[$i]['gender'], 'test_exam_type' => $productDetails[$i]['examination'], 'test_unit' => $productDetails[$i]['unit'], 'test_display_order' => $productDetails[$i]['order'], 'test_ref_range' => $productDetails[$i]['normalrange'], 'is_deleted' => 0); $this->db->insert('test_detail_master', $user); } if ($this->db->affected_rows() > 0) { $this->response(array("data" => array("status" => 201, "id" => element('test_name', $data), "message" => "Test and Test Details added succefully"))); } else { $this->response(array("data" => array("status" => 301, "message" => "This test details allready exists.", "query" => $this->db->last_query()))); } } else { $this->response(array("data" => array("status" => 301, "message" => "Something went wrong please contact admin.", "query" => $this->db->last_query()))); } } else { $this->response(array("data" => array("status" => 301, "message" => "This test allready exists.", "query" => $this->db->last_query()))); } } catch (Exception $e) { $this->response(array("data" => array("message" => "Some error occured. Please contact admin."))); } }
public function get($key = null, $default = null) { if (!$key) { return $this->all(); } return element($key, $this->data, $default); }
public function update_order($order_id, $invoice_id) { $session = $this->login(); if ($session) { $result = $this->get_address($session, $invoice_id); if (isset($result['shipping_address'])) { $shipping = $result['shipping_address']; $ship_to_name = $shipping['firstname']; if (!empty($shipping['middlename'])) { $ship_to_name .= ' ' . $shipping['middlename']; } if (!empty($shipping['lastname'])) { $ship_to_name .= ' ' . $shipping['lastname']; } $ship_to_street = $shipping['street']; $ship_to_street = str_replace(array("\n", '<br/>'), ' ', $ship_to_street); $ship_to_street2 = ''; $ship_to_city = $shipping['city']; $ship_to_state = $shipping['region']; $ship_to_zip = element('postcode', $shipping, ''); $ship_to_country = $this->CI->mixture_model->get_country_name_in_english_by_code(strtoupper($shipping['country_id'])); $contact_phone_number = element('telephone', $shipping, ''); $shipping_address = $ship_to_name . ' ' . $ship_to_street . ' ' . $ship_to_city . ' ' . $ship_to_state . ' ' . $ship_to_country; if ($order_id) { $data = array('name' => $ship_to_name, 'shipping_address' => $shipping_address, 'address_line_1' => $ship_to_street, 'address_line_2' => $ship_to_street2, 'town_city' => $ship_to_city, 'state_province' => $ship_to_state, 'zip_code' => $ship_to_zip, 'country' => $ship_to_country, 'contact_phone_number' => $contact_phone_number); $this->CI->order_model->update_order_information($order_id, $data); } } } }
public function get_ds() { $this->db->select('SQL_CALC_FOUND_ROWS _currencies.rid as rid, _currencies.code as code, _currencies.currency_name as currency_name, _currencies.left_word as left_word, _currencies.right_word as right_word, DATE_FORMAT(_currencies.modifyDT, \'%d.%m.%Y\') as modifyDT, _currencies.owner_users_rid, _currencies.descr as descr, _currencies.archive', False); $this->db->from('_currencies'); if ($searchRule = element('like', $this->ci->get_session('searchrule'), null)) { $this->db->like($searchRule); } if ($searchRule = element('where', $this->ci->get_session('searchrule'), null)) { $this->db->where($searchRule); } if ($searchRule = element('having', $this->ci->get_session('searchrule'), null)) { $this->db->having($searchRule); } if ($sort = $this->ci->get_session('sort')) { $this->db->orderby($sort['c'], $sort['r']); } $this->db->limit($this->ci->config->item('crm_grid_limit'), element('p', $this->ci->a_uri_assoc, null)); $query = $this->db_get('_currencies'); return $query->num_rows() ? $query->result() : array(); }
/** * 更新关注 */ function update_focus($focus_id, $focus) { $sort = trim(element('sort', $focus)); $name = trim(element('name', $focus)); $score = trim(element('score', $focus)); $icon = trim(element('icon', $focus)); $url = trim(element('url', $focus)); // 判断 if (!$name) { return array('error_code' => '10010', 'error' => '关注名称不能为空!'); } // 判断 $this->db->where('focus_id !=', $focus_id)->where('name', $name); $count = $this->db->where('status', 1)->count_all_results("focus"); if ($count > 0) { return array('error_code' => '10011', 'error' => '关注名称已经存在!'); } // 整理数据 $data = array('sort' => intval($sort), 'name' => $name, 'score' => $score, 'icon' => $icon, 'url' => $url); // 更新数据 $res = $this->db->where('focus_id', $focus_id)->update('focus', $data); if ($res === false) { return array('error_code' => '10012', 'error' => '修改关注失败!'); } // 写日志 $this->load_model('logs_model')->add_content("修改关注: [{$focus_name}]"); return array('message' => '修改关注成功!'); }
public function index() { $providers = array(); // Look for all oauth and oauth2 strategies foreach (array('oauth', 'oauth2') as $strategy) { if ($libraries = glob($this->module_details['path'] . '/' . $strategy . '/libraries/providers/*.php')) { // Build an array of what is available foreach ($libraries as $provider) { $name = strtolower(basename($provider, '.php')); $providers[$name] = array('strategy' => $strategy, 'human' => $this->providers[$name]['human'], 'default_scope' => element('default_scope', $this->providers[$name], NULL)); } } } // Existing credentials, display id/key/secret/etc. $all_credentials = $this->credential_m->get_all(); foreach ($all_credentials as $provider_credential) { // Why do you have a credential for a missing provider? Weird if (empty($providers[$provider_credential->provider])) { continue; } $providers[$provider_credential->provider]['credentials'] = $provider_credential; } unset($all_credentials, $provider_credentials); // Sort by provider. If oauth 1 and 2, it will use 2 ksort($providers); $this->template->build('admin/index', array('providers' => $providers)); }
public function get_ds() { $this->db->select('SQL_CALC_FOUND_ROWS _clients.rid, _clients.l_name, _clients.f_name, _clients._dcarts_rid, _clients.email, _clients.archive, _clients.f_pass_num, _dcarts.num as card_num, CONCAT(_clients.l_name," ",_clients.f_name) as client_name, DATE_FORMAT(_clients.birthday, \'%d.%m.%Y\') as birthday, DATE_FORMAT(_clients.f_pass_period, \'%d.%m.%Y\') as f_pass_period, _cities.city_name as city_name, DATE_FORMAT(_clients.modifyDT, \'%d.%m.%Y\') as modifyDT', False); $this->db->from('_clients'); $this->db->join('_cities', '_clients._cities_rid = _cities.rid'); $this->db->join('_demands_rows', '_demands_rows._clients_rid = _clients.rid', 'LEFT'); $this->db->join('_demands_headers', '_demands_rows._demands_headers_rid = _demands_headers.rid', 'LEFT'); $this->db->join('_tours', '_demands_headers._tours_rid = _tours.rid', 'LEFT'); $this->db->join('_countries', '_tours._countries_rid = _countries.rid', 'LEFT'); $this->db->join('_dcarts', '_clients._dcarts_rid = _dcarts.rid', 'LEFT'); $this->db->group_by('_clients.rid'); if ($searchRule = element('like', $this->ci->get_session('searchrule'), null)) { $this->db->like($searchRule); } if ($searchRule = element('where', $this->ci->get_session('searchrule'), null)) { $this->db->where($searchRule); } if ($searchRule = element('having', $this->ci->get_session('searchrule'), null)) { $this->db->having($searchRule); } if ($sort = $this->ci->get_session('sort')) { $this->db->orderby($sort['c'], $sort['r']); } $this->db->limit($this->ci->config->item('crm_grid_limit'), element('p', $this->ci->a_uri_assoc, null)); $query = $this->db_get('_clients'); return $query->num_rows() ? $query->result() : array(); }
function create_tour($data) { $data['from_start_time'] = date('Y-m-d', strtotime(element('from_start_date', $data))) . ' ' . element('from_start_time', $data); $crop_data = elements(array('from', 'to', 'available_seats', 'start_price', 'from_start_time'), $data); $add_tour = $this->db->insert_string('tours', $crop_data); $this->db->query($add_tour); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; $arg = $input->getArgument('arg'); $fs = new Filesystem(); $generators = getcwd() . '/resources/generators'; $loader = new \Twig_Loader_Filesystem($generators); $twig = new \Twig_Environment($loader); $config = (include getcwd() . '/config/generator.php'); $config = element($arg[0], $config); $source = $generators . '/' . element('source', $config); $destination = element('destination', $config); $destination = $this->replaceArguments($destination); if (!$config) { $output->writeln("<error>{$arg[0]} does not exist. Please check your confile file.</error>"); return; } if (!$fs->exists($source)) { $output->writeln('<error>The source file does not exist</error>'); return; } if (!$fs->exists(dirname($destination))) { $output->writeln('<error>The destination folder does not exist</error>'); $output->writeln('<info>Create the destination folder at (' . dirname($destination) . ').</info>'); return; } if ($fs->exists($destination)) { $output->writeln('<error>Unable to create the destination file.</error>'); $output->writeln("<info>File already exist ({$destination}).</info>"); return; } $contents = $twig->render(basename($source), $this->replaceContent($config['replace'])); file_put_contents($destination, $contents); $output->writeln("<info>Sucessfully created template ({$destination}).</info>"); }
public function run($post_opts = array()) { $config = $this->application->get_config(element('action', $post_opts), 'actions'); $post_data = array_merge(clean_parameters($config), clean_parameters(elements(array_keys($config), $post_opts))); $response = array(); $start = microtime(true); $this->curl->create(element('server', $post_opts)); $this->curl->option('buffersize', 10); $this->curl->option('useragent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)'); $this->curl->option('returntransfer', true); $this->curl->option('followlocation', true); $this->curl->option('connecttimeout', true); $this->curl->post($post_data); $data = $this->curl->execute(); $this->response_time = round(microtime(true) - $start, 3) . " seconds"; if ($data !== false) { if (strcasecmp(element('responseformat', $post_opts), 'json') == 0) { $response = json_decode($data, true); } else { $response = $data; } $this->set_message('call_search_success'); } else { $this->set_error('call_search_error'); } $this->curl->close(); return $response; }
function savePeriod($arrPost) { $this->load->helper('array'); $data = array( 'fromdate' => $arrPost['begin'] ,'todate' => $arrPost['end'] ,'active' => $arrPost['active'] ); $periodId = element('periodid', $arrPost, NULL); if ($periodId == null) { $this->db->insert('period', $data); log_message('debug', '>>>$sql: '.$this->db->last_query()); } else { $this->db->set($data); $this->db->where('periodid', $arrPost['periodid']); $this->db->update('period'); log_message('debug', '>>>$sql: '.$this->db->last_query()); } }
/** * Проверка доступа * @return unknown_type */ function hook_check_security() { $ci =& get_instance(); // исключаем welcome, login, logout, tasks $free_controllers = array('', 'login', 'logout', 'welcome', 'tasks', 'language'); if (in_array($ci->menu->get_currcontroller(), $free_controllers)) { return; } $permissions = $ci->menu->get_rights(); if (!element('viewed_space', $permissions, null)) { return show_error(lang('MENU_SECURITY_ERROR')); } if (!element('add_allow', $permissions, null) && element('create', $ci->a_uri_assoc, null)) { return show_error(lang('MENU_SECURITY_ERROR')); } if (!element('edit_allow', $permissions, null) && element('edit', $ci->a_uri_assoc, null)) { return show_error(lang('MENU_SECURITY_ERROR')); } if (!element('details_allow', $permissions, null) && element('details', $ci->a_uri_assoc, null)) { return show_error(lang('MENU_SECURITY_ERROR')); } if (!element('delete_allow', $permissions, null) && element('delete', $ci->a_uri_assoc, null)) { return show_error(lang('MENU_SECURITY_ERROR')); } return; }
public function index() { // Define the page title. $data['title'] = lang('tle_recent_discussions'); // Define the template. $data['template'] = 'pages/home/home'; // Get the discussions from the database. $discussions = $this->discussions->order_by(array('sticky' => 'DESC', 'posted' => 'DESC'))->get_all(); // Loop through the discussions. if (!empty($discussions)) { foreach ($discussions as $row) { // Get the category associated with the discussion. $cat = $this->categories->get_by('id', $row->category_id); $data['discussions'][] = array('subject' => anchor(site_url('discussions/view/' . $row->id), $row->subject), 'replies' => $row->replies, 'views' => $row->views, 'last_comment' => unix_to_human($row->last_comment), 'last_poster' => anchor(site_url('users/profile/' . $row->last_poster_id), $row->last_poster), 'category' => anchor(site_url('categories/' . $cat->slug . ''), $cat->name), 'is_sticky' => $row->sticky == 1 ? '<i class="fa fa-thumb-tack"></i> ' : '', 'is_closed' => $row->closed == 1 ? '<i class="fa fa-lock"></i> ' : ''); } } else { // Fill with blank data to prevent errors. $data['discussions'] = ''; } // Build the page breadcrumbs. $this->crumbs->add(lang('crumb_recent_discussions')); // Define the page data. $data['page'] = array('btn_new_discussion' => anchor(site_url('discussions/new_discussion'), lang('btn_new_discussion'), array('class' => 'btn btn-default btn-xs')), 'discussions' => element('discussions', $data), 'has_discussions' => !empty($discussions) ? 1 : 0, 'breadcrumbs' => $this->crumbs->output(), 'pagination' => $this->pagination->create_links()); $this->render(element('page', $data), element('title', $data), element('template', $data)); }
function initLang() { $CI =& get_instance(); $CI->lang->is_loaded = array(); $CI->lang->language = array(); $languages = array('es' => 'spanish', 'pt-br' => 'portuguese-br', 'en' => 'english', 'zh-cn' => 'zh-CN'); $langId = $CI->session->userdata('langId'); if ($langId === false) { $CI->load->library('user_agent'); foreach ($languages as $key => $value) { // Trato de setear el idioma del browser if ($CI->agent->accept_lang($key)) { $langId = $key; break; } } if ($langId === false) { $langId = config_item('langId'); } } if (!in_array($langId, array_keys($languages))) { $langId = config_item('langId'); } $langName = element($langId, $languages, config_item('langId')); $CI->config->set_item('language', $langName); $CI->config->set_item('langId', $langId); $CI->session->set_userdata('langId', $langId); $CI->lang->load('default', $langName); $CI->lang->load(config_item('siteId'), $langName); }
public function get_ds() { $this->db->select('SQL_CALC_FOUND_ROWS _users.rid as rid, _users.user_login as user_login, _users.user_passwd as user_passwd, DATE_FORMAT(_users.edate_passwd, \'%d.%m.%Y \') as edate_passwd, DATE_FORMAT(_users.chdate_passwd, \'%d.%m.%Y \') as chdate_passwd, DATE_FORMAT(_users.modifyDT, \'%d.%m.%Y\') as modifyDT, _users.descr as descr, _users.archive, CONCAT(_employeers.l_name,\' \', _employeers.f_name, \' \', _employeers.s_name) as emp_name', False); $this->db->from('_users'); $this->db->join('_employeers', '_users._employeers_rid = _employeers.rid'); if ($searchRule = element('like', $this->ci->get_session('searchrule'), null)) { $this->db->like($searchRule); } if ($searchRule = element('where', $this->ci->get_session('searchrule'), null)) { $this->db->where($searchRule); } if ($searchRule = element('having', $this->ci->get_session('searchrule'), null)) { $this->db->having($searchRule); } if ($sort = $this->ci->get_session('sort')) { $this->db->orderby($sort['c'], $sort['r']); } $this->db->limit($this->ci->config->item('crm_grid_limit'), element('p', $this->ci->a_uri_assoc, null)); $query = $this->db_get('_users'); return $query->num_rows() ? $query->result() : array(); }
function listing() { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $page = (int) $this->input->get('page'); if ($page == 0) { $page = 1; } $statusId = $this->input->get('statusId'); if ($statusId === false) { $statusId = ''; } $tag = null; $tagId = $this->input->get('tagId'); if ($tagId != null) { $tag = $this->Tags_Model->get($tagId); } $user = null; $userId = $this->input->get('userId'); if ($userId != null) { $user = $this->Users_Model->get($userId); } $feedSuggest = $this->input->get('feedSuggest') == 'on'; $filters = array('search' => $this->input->get('search'), 'statusId' => $statusId, 'countryId' => $this->input->get('countryId'), 'langId' => $this->input->get('langId'), 'tagId' => $tagId, 'userId' => $userId, 'feedSuggest' => $feedSuggest); $query = $this->Feeds_Model->selectToList($page, config_item('pageSize'), $filters, array(array('orderBy' => $this->input->get('orderBy'), 'orderDir' => $this->input->get('orderDir')))); $this->load->view('pageHtml', array('view' => 'includes/crList', 'meta' => array('title' => lang('Edit feeds')), 'list' => array('showId' => true, 'urlList' => strtolower(__CLASS__) . '/listing', 'urlEdit' => strtolower(__CLASS__) . '/edit/%s', 'urlAdd' => strtolower(__CLASS__) . '/add', 'columns' => array('feedName' => lang('Name'), 'feedDescription' => lang('Description'), 'statusName' => lang('Status'), 'countryName' => lang('Country'), 'langName' => lang('Language'), 'feedUrl' => lang('Url'), 'feedLink' => lang('Link'), 'feedLastEntryDate' => array('class' => 'datetime', 'value' => lang('Last entry')), 'feedLastScan' => array('class' => 'datetime', 'value' => lang('Last update')), 'feedCountUsers' => array('class' => 'numeric', 'value' => lang('Users')), 'feedCountEntries' => array('class' => 'numeric', 'value' => lang('Entries'))), 'foundRows' => $query['foundRows'], 'data' => $query['data'], 'filters' => array('statusId' => array('type' => 'dropdown', 'label' => lang('Status'), 'value' => $statusId, 'source' => $this->Status_Model->selectToDropdown(), 'appendNullOption' => true), 'countryId' => array('type' => 'dropdown', 'label' => lang('Country'), 'value' => $this->input->get('countryId'), 'source' => $this->Countries_Model->selectToDropdown(), 'appendNullOption' => true), 'langId' => array('type' => 'dropdown', 'label' => lang('Language'), 'value' => $this->input->get('langId'), 'source' => $this->Languages_Model->selectToDropdown(), 'appendNullOption' => true), 'tagId' => array('type' => 'typeahead', 'label' => 'Tags', 'source' => base_url('search/tags?onlyWithFeeds=true'), 'value' => array('id' => element('tagId', $tag), 'text' => element('tagName', $tag)), 'multiple' => false, 'placeholder' => 'tags'), 'userId' => array('type' => 'typeahead', 'label' => lang('User'), 'source' => base_url('search/users/'), 'value' => array('id' => element('userId', $user), 'text' => element('userFirstName', $user) . ' ' . element('userLastName', $user)), 'multiple' => false, 'placeholder' => lang('User')), 'feedSuggest' => array('type' => 'checkbox', 'label' => lang('Only feed suggest'), 'checked' => $feedSuggest)), 'sort' => array('feedId' => '#', 'feedName' => lang('Name'), 'feedLastEntryDate' => lang('Last entry'), 'feedLastScan' => lang('Last update'), 'feedCountUsers' => lang('Count users'), 'feedCountEntries' => lang('Count entries'))))); }
public function get_ds() { $this->db->select('SQL_CALC_FOUND_ROWS _documents.rid, DATE_FORMAT(_calls_headers.date_doc, \'%d.%m.%Y\') as date_doc, GROUP_CONCAT(distinct _countries.country_name order by _countries.country_name asc separator \',\') as country_name, _calls_rows._advertisessources_rid as _advertisessources_rid, _advertisessources.source_name as source_name, _calls_rows._clients_rid as _clients_rid, if(_calls_rows._clients_rid, _clients.f_name, _calls_rows.f_name) as f_name, if(_calls_rows._clients_rid, _clients.l_name, _calls_rows.l_name) as l_name, _calls_rows.s_name as s_name, TRIM(CONCAT(_calls_rows.l_name, \' \', _calls_rows.f_name)) as call_clname, (select _filials.rid FROM _emp_to_positions_rows JOIN _emp_to_positions_headers ON _emp_to_positions_rows._emp_to_positions_headers_rid=_emp_to_positions_headers.rid JOIN _filials ON _emp_to_positions_rows._filials_rid=_filials.rid WHERE _emp_to_positions_rows._employeers_rid = _employeers.rid AND _emp_to_positions_headers.date_doc < now() ORDER BY _emp_to_positions_headers.date_doc ASC LIMIT 1 ) as _filials_rid, CONCAT(_employeers.l_name, \' \', SUBSTRING(_employeers.f_name FROM 1 FOR 1), \'.\') as emp_name, DATE_FORMAT(_documents.modifyDT, \'%d.%m.%Y\') as modifyDT, _documents.descr as descr, _documents.archive, _documents.descr as descr', False); $this->db->from('_documents'); $this->db->join('_calls_headers', '_calls_headers._documents_rid = _documents.rid'); $this->db->join('_calls_rows', '_calls_rows._calls_headers_rid = _calls_headers.rid'); $this->db->join('_clients', '_calls_rows._clients_rid = _clients.rid', 'LEFT'); $this->db->join('_calls_countries', '_calls_countries._calls_headers_rid = _calls_headers.rid'); $this->db->join('_countries', '_calls_countries._countries_rid = _countries.rid'); $this->db->join('_advertisessources', '_calls_rows._advertisessources_rid = _advertisessources.rid'); $this->db->join('_currencies', '_calls_rows._currencies_rid = _currencies.rid'); $this->db->join('_users', '_documents.owner_users_rid = _users.rid');
public function curl($server = NULL, $parameters = array()) { $response = false; $start = microtime(true); if ($server) { $this->CI->curl->create($server); $this->CI->curl->option('buffersize', 10); $this->CI->curl->option('useragent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)'); $this->CI->curl->option('returntransfer', true); $this->CI->curl->option('followlocation', true); $this->CI->curl->option('connecttimeout', true); $this->CI->curl->post($parameters); $data = $this->CI->curl->execute(); $this->CI->response_time = round(microtime(true) - $start, 3) . " seconds"; if ($data !== false) { if (strcasecmp(element('format', $parameters), 'json') == 0) { $response = json_decode($data, true); } else { $response = $data; } $this->CI->notification->set_message('idol_server_response_success'); } else { $this->CI->notification->set_error('idol_server_response_error'); } $this->CI->curl->close(); } else { $this->CI->notification->set_error('idol_server_response_noserverdefined'); } return $response; }
/** * banner url 이동 관련 함수입니다 */ public function banner($ban_id = 0) { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_gotourl_banner'; $this->load->event($eventname); // 이벤트가 존재하면 실행합니다 Events::trigger('before', $eventname); $ban_id = (int) $ban_id; if (empty($ban_id) or $ban_id < 1) { show_404(); } $this->load->model(array('Banner_model')); $banner = $this->Banner_model->get_one($ban_id); if (!element('ban_id', $banner)) { show_404(); } if (!element('ban_activated', $banner)) { show_404(); } if (!element('ban_url', $banner)) { show_404(); } if (!$this->session->userdata('banner_click_' . $ban_id)) { $this->session->set_userdata('banner_click_' . $ban_id, '1'); $this->Banner_model->update_plus($ban_id, 'ban_hit', 1); } // 이벤트가 존재하면 실행합니다 Events::trigger('after', $eventname); redirect(prep_url(element('ban_url', $banner))); }
function update_item($itemid, $title, $content) { $data = array('title' => $title, 'content' => $content, 'editor' => element('realname', $this->CI->session->userdata('user')), 'update_ts' => date('Y-m-d H:i:s')); $this->db->where('itemid', $itemid); $this->db->update('board_list', $data); return true; }
/** * 分页列表 * * @param type $offset 偏移量 * @param type $where 条件 * @return type */ function get_user_list($offset = 0, $where = array()) { $nickname = element('nickname', $where); $sex = element('sex', $where); // 总数 if (trim($sex) != '') { $this->db->where('sex', $sex); } if (trim($nickname) != '') { $this->db->like('nickname', $nickname); } $count = $this->db->count_all_results('user'); // 条件、排序 if (trim($sex) != '') { $this->db->where('sex', $sex); } if (trim($nickname) != '') { $this->db->like('nickname', $nickname); } $this->db->order_by('user_id', 'desc'); // 分页查询数据 $this->db->limit(PAGE_LIMIT, $offset); $list_data = $this->db->get('user')->result(); // 分页 $this->pagination->set_base_url(site_url('user/index')); $this->pagination->set_total_rows($count); $pagination = $this->pagination->get_links(); return array('list_data' => $list_data, 'count' => $count, 'pagination' => $pagination); }