Exemple #1
0
 public function editar_form($cuenta_id = null)
 {
     if ($cuenta_id) {
         $cuenta = Doctrine::getTable('Cuenta')->find($cuenta_id);
     } else {
         $cuenta = new Cuenta();
     }
     $this->form_validation->set_rules('nombre', 'Nombre', 'required|url_title');
     $this->form_validation->set_rules('nombre_largo', 'Nombre largo', 'required');
     $respuesta = new stdClass();
     if ($this->form_validation->run() == true) {
         $cuenta->nombre = $this->input->post('nombre');
         $cuenta->nombre_largo = $this->input->post('nombre_largo');
         $cuenta->mensaje = $this->input->post('mensaje');
         $cuenta->logo = $this->input->post('logo');
         $cuenta->save();
         $this->session->set_flashdata('message', 'Cuenta guardada con éxito.');
         $respuesta->validacion = true;
         $respuesta->redirect = site_url('manager/cuentas');
     } else {
         $respuesta->validacion = false;
         $respuesta->errores = validation_errors();
     }
     echo json_encode($respuesta);
 }
 public function index()
 {
     $input = null;
     $output = null;
     $clear_form = (bool) $this->input->post('test_form_clear');
     $is_example = (bool) $this->input->post('test_form_example');
     if ($clear_form) {
         // Do nothing, all has been already initialized.
     } elseif ($is_example) {
         $input = @file_get_contents($this->load->path('test.json'));
         try {
             $output = $this->parser->parse_string($input, null, true, 'jsonmin');
         } catch (Exception $e) {
             $output = $e->getMessage();
         }
     } else {
         $validation_rules = array(array('field' => 'input', 'label' => 'Input JSON source', 'rules' => 'trim'));
         $this->form_validation->set_rules($validation_rules);
         if ($this->form_validation->run()) {
             $input = $this->input->post('input');
             try {
                 $output = $this->parser->parse_string($input, null, true, 'jsonmin');
             } catch (Exception $e) {
                 $output = $e->getMessage();
             }
         } elseif (validation_errors()) {
             $output = null;
             $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
             $this->template->set('validation_errors', validation_errors_array());
         }
     }
     $this->template->set('clear_form', $clear_form)->set('is_example', $is_example)->set('input', $input)->set('output', $output)->enable_parser_body('i18n')->build('jsonmin');
 }
 public function add_new_section()
 {
     $this->load->model('mission_section_model', 'MissionSectionModel');
     $data = array();
     //set validation rules
     $this->form_validation->set_rules('title', 'title', 'required|min_length[5]|max_length[250]');
     //$this->form_validation->set_rules('stitle','Small title','required|min_length[5]|max_length[250]');
     $this->form_validation->set_rules('paragraph-sec', 'paragraph', 'required|min_length[5]');
     //run validation
     if ($this->form_validation->run() == FALSE) {
         $this->session->set_flashdata('errors-section', validation_errors());
         redirect(base_url() . 'mission');
     } else {
         // Upload handling
         $config['upload_path'] = 'uploads/';
         $config['allowed_types'] = 'jpg|png';
         $config['max_size'] = '5000';
         $this->load->library('upload', $config);
         $field_name = 'sectionimg';
         if ($this->upload->do_upload($field_name) == FALSE) {
             $this->session->set_flashdata('errors-section', $this->upload->display_errors());
             redirect(base_url() . 'mission');
         } else {
             $file_data = $this->upload->data();
             $row = array('title' => $this->input->post('title'), 'img' => $file_data['file_name'], 'topic' => $this->input->post('paragraph-sec'), 't_small' => $this->input->post('stitle'));
             $this->MissionSectionModel->add_new_section($row);
             $this->session->set_flashdata('success-section', "Section added successfully");
             redirect(base_url() . 'mission');
         }
     }
 }
Exemple #4
0
 /**
  * 设置公司信息
  * @param  string  $logo           公司logo
  * @param  string  $company_name   公司名称
  * @param  string  $company_intro  公司简介
  * @return json
  */
 public function set()
 {
     $company_name = $this->input->get_post('company_name', TRUE);
     $company_intro = $this->input->get_post('company_intro', TRUE);
     if ($this->form_validation->run() == FALSE) {
         $error = validation_errors();
         $this->to_api_message(0, $error);
     }
     $data = array();
     if ($company_name) {
         $data['name'] = $company_name;
     }
     if ($company_intro) {
         $data['intro'] = $company_intro;
     }
     $company = $this->company->get();
     if (empty($company)) {
         $affected = $this->company->insert($data);
     } else {
         $affected = $this->company->update($data);
     }
     $op_description = sprintf("设置了企业信息:%s", $company_name);
     if ($affected) {
         $this->add_op_log($op_description, 1);
         $this->to_api_message(1, 'update_company_info_success');
     } else {
         $this->add_op_log($op_description, 0);
         $this->to_api_message(0, 'update_company_info_failed');
     }
 }
Exemple #5
0
 function editar($id = null)
 {
     // Array de dados para a view
     $dados = array();
     // Obtém os dados
     if ($id) {
         // se não tem post e tem id, obtém da base de dados
         $dados['estado'] = $estado_old = $this->Estados_model->obter($id);
     }
     // Se tem post, salva os dados
     if ($this->input->post('submit')) {
         // Se existe procede, se não exibe erro!
         $dados = $this->input->post();
         // Validação
         $this->form_validation->set_rules('estado[nome]', 'Nome', 'trim|required');
         if ($this->form_validation->run()) {
             if ($this->Estados_model->salvar($dados['estado']) > 0) {
                 redirect('site/estados/listar');
             } else {
                 $dados['erro'] = 'Não foi possível salvar o registro.';
             }
         } else {
             $dados['erro'] = validation_errors();
         }
     }
     $dados['paises'] = array();
     $paises = $this->Paises_model->listar();
     foreach ($paises as $pais) {
         $dados['paises'][$pais['id']] = $pais['nome'];
     }
     $this->load->view('estados_editar', $dados);
 }
Exemple #6
0
 function index()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('sifre', 'Sifre', 'required|min_length[5]|max_length[12]');
     $this->form_validation->set_message('email');
     $data['errors'] = null;
     if ($this->form_validation->run() == FALSE) {
         $data['errors'] = validation_errors();
     } else {
         $email = $this->input->post('email');
         $sifre = $this->input->post('sifre');
         $login = $this->db->where('email', $email)->where('sifre', $sifre)->get('login');
         if ($login->num_rows() > 0) {
             $x = $login->row();
             $bilgiler = array('email' => $x->email, 'sifre' => $x->sifre, 'yetki' => $x->yetki);
             //var_dump($bilgiler);
             $this->session->set_userdata($bilgiler);
             redirect('admin/mainpage', 'refresh');
         } else {
             $data['errors'] = 'Böyle Bir Kullanıcı Bulunamadı';
         }
     }
     $this->load->view('admin/sabit/login', $data);
 }
 /**
  * The index page controller
  */
 function index()
 {
     $target_error = false;
     $data = array();
     $searchtarget = $this->config->item('search');
     $this->form_validation->set_rules('search', 'Search', 'required');
     if (count($searchtarget) == 1) {
         $searchtarget = $searchtarget[key($searchtarget)][0];
     } elseif (!isset($searchtarget[$this->input->post('target')])) {
         $target_error = true;
     } else {
         $searchtarget = $this->input->post('target');
     }
     if ($this->form_validation->run() == FALSE || $target_error) {
         $error = array();
         $validation_error = validation_errors();
         if ($validation_error) {
             $error[] = $validation_error;
         }
         if ($target_error) {
             $error[] = 'Please select a search-target.';
         }
         $data['validation_message'] = $error;
     } else {
         redirect($searchtarget . '/' . urlencode($this->input->post('search')));
     }
     $this->_render_page('search/search', $data);
 }
Exemple #8
0
 public function validate_user($user)
 {
     $data = array();
     $config = array(array('field' => 'username', 'label' => 'User Name', 'rules' => 'trim|required|valid_email'), array('field' => 'password', 'label' => 'Password', 'rules' => 'trim|required'));
     $this->form_validation->set_rules($config);
     $get_user_with_email = $this->get_user_with_email($user['username']);
     if ($this->form_validation->run() == FALSE) {
         $data["error_message"] = validation_errors();
         $data["is_login"] = FALSE;
     } else {
         if (!$get_user_with_email) {
             $data["error_message"] = "User not found,Please register";
             $data["is_login"] = FALSE;
         } else {
             if ($get_user_with_email['password'] == md5($user['password'])) {
                 $data["is_login"] = TRUE;
                 $data["success_message"] = "Successful log in !";
                 $current_user = array('user_id' => $get_user_with_email['id'], 'user_name' => $get_user_with_email['username'], 'first_name' => $get_user_with_email['first_name'], 'last_name' => $get_user_with_email['last_name']);
                 $this->session->set_userdata("current_user", $current_user);
             } else {
                 $data["error_message"] = "User password does not match";
                 $data["is_login"] = FALSE;
             }
         }
     }
     return $data;
 }
 public function tracking_meal_log()
 {
     $this->common->authenticate();
     $tables = $this->input->post('tables');
     $meal_date = $this->input->post('lunch_date');
     $note = $this->input->post('note');
     $private_note = $this->input->post('private_note');
     $actual_meals = $this->input->post('actual_meals');
     $shift = $this->input->post('shift');
     $this->validation('tracking');
     if ($this->form_validation->run() == FALSE) {
         $errors = validation_errors();
         $data['status'] = 'failure';
         $data['message'] = $errors;
     } else {
         $this->load->model('meals_model');
         $message = $this->common->get_message('gen_log_file_meal', array('gen_log_file_success', 'gen_log_file_failure'));
         if ($this->meals_model->update_meal_log($shift, $tables, $meal_date, $note, $private_note, $actual_meals)) {
             $data = array('status' => 'success', 'message' => $message['gen_log_file_success']);
         } else {
             $data = array('status' => 'failure', 'message' => $message['gen_log_file_failure']);
         }
     }
     echo json_encode($data);
 }
Exemple #10
0
 private function modificar()
 {
     if (isset($_GET['id']) && $this->aviones_model->exist('aviones', array('id_avion' => $_GET['id'], 'status' => 'ac'))) {
         $this->carabiner->css(array(array('general/forms.css', 'screen'), array('general/tables.css', 'screen')));
         $this->carabiner->js(array(array('aviones/frm_addmod.js')));
         $this->configAddAvion();
         if ($this->form_validation->run() == FALSE) {
             $params['frm_errors'] = $this->showMsgs(2, preg_replace("[\n|\r|\n\r]", '', validation_errors()));
         } else {
             $model_resp = $this->aviones_model->editAvion($_GET['id']);
             if ($model_resp[0]) {
                 $params['frm_errors'] = $this->showMsgs(3);
             } else {
                 $params['frm_errors'] = $this->showMsgs(2, 'El avión que desea modificar no existe');
             }
         }
         $params['info_empleado'] = $this->info_empleado['info'];
         $params['opcmenu_active'] = 'Aviones';
         //activa la opcion del menu
         $params['seo']['titulo'] = 'Modificar Avion';
         $params = array_merge($params, $this->aviones_model->getAviones($_GET['id']));
         if (isset($_GET['msg'][0])) {
             $params['frm_errors'] = $this->showMsgs($_GET['msg']);
         }
         $this->load->view('panel/header', $params);
         $this->load->view('panel/general/menu', $params);
         $this->load->view('panel/aviones/modificar', $params);
         $this->load->view('panel/footer', $params);
     } else {
         redirect(base_url('panel/aviones/'));
     }
 }
 public function add_semester()
 {
     $this->form_validation->set_rules('addsemester', 'Semester', 'trim|required');
     $this->form_validation->set_rules('addyear', 'Year', 'trim|required|greater_than[1997]|less_than[2100]');
     if ($this->form_validation->run() == TRUE) {
         $data = array('semester' => $this->input->post('addsemester'), 'curriculum_year' => $this->input->post('addyear'), 'userid' => $this->session->userdata('userid'));
         $this->load->model('semester_model');
         $this->semester_model->add_semester($data);
         $data = array('current_user' => $this->session->userdata('displayname'), 'current_username' => $this->session->userdata('username'), 'add_sem_error_msg' => NULL, 'add_sem_error_action' => NULL);
         redirect(base_url() . 'index.php/semester', 'refresh');
     } else {
         $add_sem_error_msg = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">&times;</button>' . validation_errors() . '</div>';
         $add_sem_error_action = "\$('#modalAddSemester').modal('show');";
         $data = array('current_user' => $this->session->userdata('displayname'), 'current_username' => $this->session->userdata('username'), 'add_sem_error_msg' => $add_sem_error_msg, 'add_sem_error_action' => $add_sem_error_action);
         $this->load->model('semester_model');
         if ($query = $this->semester_model->list_semester()) {
             $data['records'] = $query;
         }
         if (!$data['records']) {
             $add_sem_error_msg = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">&times;</button>The record is existing!</div>';
             $add_sem_error_action = "\$('#modalAddSemester').modal('show');";
             $data = array('current_user' => $this->session->userdata('displayname'), 'current_username' => $this->session->userdata('username'), 'add_sem_error_msg' => $add_sem_error_msg, 'add_sem_error_action' => $add_sem_error_action);
         }
         $this->session->set_userdata($data);
         $this->load->view('includes/nocache');
         $this->load->view('includes/header2');
         $this->load->view('semester_view', $data);
         $this->load->view('includes/semester_footer', $data);
     }
 }
Exemple #12
0
 public function edit_post()
 {
     $data = $this->data;
     //取得公用數據
     $this->form_validation->set_rules('name_Str', '產品名稱', 'required');
     if ($this->form_validation->run() !== FALSE) {
         //基本post欄位
         $showpieceid_Num = $this->input->post('showpieceid_Num', TRUE);
         $name_Str = $this->input->post('name_Str', TRUE);
         $price_Num = $this->input->post('price_Num', TRUE);
         $synopsis_Str = $this->input->post('synopsis_Str', TRUE);
         $classids_Arr = $this->input->post('classids_Arr', TRUE);
         $content_Str = $this->input->post('content_Str');
         $content_specification_Str = $this->input->post('content_specification_Str');
         $prioritynum_Num = $this->input->post('prioritynum_Num', TRUE);
         $picids_Arr = $this->input->post('picids_Arr', TRUE);
         //建構Showpiece物件,並且更新
         $showpiece_Showpiece = new Showpiece(['showpieceid_Num' => $showpieceid_Num, 'name_Str' => $name_Str, 'price_Num' => $price_Num, 'synopsis_Str' => $synopsis_Str, 'mainpicids_Arr' => $mainpicids_Arr, 'picids_Arr' => $picids_Arr, 'classids_Arr' => $classids_Arr, 'content_Str' => $content_Str, 'content_specification_Str' => $content_specification_Str, 'prioritynum_Num' => $prioritynum_Num]);
         $showpiece_Showpiece->update();
         //送出成功訊息
         $this->load->model('Message');
         $this->Message->show(['message' => '設定成功', 'url' => 'admin/base/showpiece/showpiece/tablelist']);
     } else {
         $validation_errors_Str = validation_errors();
         $validation_errors_Str = !empty($validation_errors_Str) ? $validation_errors_Str : '設定錯誤';
         $this->load->model('Message');
         $this->Message->show(['message' => $validation_errors_Str, 'url' => 'admin/base/showpiece/showpiece/tablelist']);
     }
 }
Exemple #13
0
 public function AddPayNotification()
 {
     $this->load->library('form_validation');
     $orderId = $this->input->post('orderId');
     $account = $this->input->post('account');
     $money = $this->input->post('money');
     $memo = $this->input->post('memo', TRUE);
     $payDatetime = $this->input->post('payDatetime');
     $payWay = $this->input->post('payWay');
     $this->form_validation->set_rules('orderId', '訂單編號', 'required|numeric');
     $this->form_validation->set_rules('account', '匯款帳號', 'required|numeric');
     $this->form_validation->set_rules('money', '匯款金額', 'required|numeric');
     $this->form_validation->set_message('required', '%s為必填!');
     $this->form_validation->set_message('numeric', '%s必須為數字!');
     if ($this->form_validation->run() == FALSE) {
         echo validation_errors();
     } else {
         if ($payWay != 'ATM轉帳付款') {
             echo '錯誤發生! payWay=' . $payWay;
         } else {
             $data = array('orderId' => $orderId, 'account' => $account, 'money' => $money, 'payDatetime' => $payDatetime, 'memo' => $memo);
             $error = $this->Order_model->add_pay_notification($data);
             echo $error['code'];
         }
     }
 }
 public function validar_turnos()
 {
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|xss_clean');
     $this->form_validation->set_rules('contrasena', 'Contraseña', 'required|trim|min_length[8]|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         echo validation_errors('<span class="error">', '</span>');
     } else {
         $data['email'] = $this->input->post('email');
         $data['contrasena'] = $this->input->post('contrasena');
         $data = $this->security->xss_clean($data);
         $login_check = $this->modelo->check_login($data);
         if ($login_check != FALSE) {
             $usuario_historico = $this->modelo->anadir_historico_acceso($login_check[0]);
             $this->session->set_userdata('session', TRUE);
             $this->session->set_userdata('email', $data['email']);
             if (is_array($login_check)) {
                 foreach ($login_check as $login_element) {
                     $this->session->set_userdata('id', $login_element->id);
                     $this->session->set_userdata('id_perfil', $login_element->id_perfil);
                     $this->session->set_userdata('perfil', $login_element->perfil);
                     $this->session->set_userdata('operacion', $login_element->operacion);
                     $this->session->set_userdata('sala', $login_element->sala);
                     $this->session->set_userdata('coleccion_id_operaciones', $login_element->coleccion_id_operaciones);
                     $this->session->set_userdata('nombre_completo', $login_element->nombre . ' ' . $login_element->apellidos);
                 }
             }
             echo TRUE;
         } else {
             echo '<span class="error">¡Ups! tus datos no son correctos, verificalos e intenta nuevamente por favor.</span>';
         }
     }
 }
Exemple #15
0
 public function add()
 {
     $usertype = $this->session->userdata("usertype");
     if ($usertype == "Admin") {
         if ($_POST) {
             $rules = $this->rules();
             $this->form_validation->set_rules($rules);
             if ($this->form_validation->run() == FALSE) {
                 $this->data['form_validation'] = validation_errors();
                 $this->data["subview"] = "exam/add";
                 $this->load->view('_layout_main', $this->data);
             } else {
                 $array = array("termID" => $this->input->post("termID"), "exam" => $this->input->post("exam"), "date" => date("Y-m-d", strtotime($this->input->post("date"))), "note" => $this->input->post("note"));
                 $this->exam_m->insert_exam($array);
                 $this->session->set_flashdata('success', $this->lang->line('menu_success'));
                 redirect(base_url("exam/index"));
             }
         } else {
             $this->data["subview"] = "exam/add";
             $this->load->view('_layout_main', $this->data);
         }
     } else {
         $this->data["subview"] = "error";
         $this->load->view('_layout_main', $this->data);
     }
 }
Exemple #16
0
 public function add_stock()
 {
     if (isset($_POST['product_add_stock_submit']) && trim($_POST['product_add_stock_submit']) !== '') {
         try {
             $this->form_validation->set_rules('product_id', 'Product', 'trim|required');
             $this->form_validation->set_rules('qty', 'Quantity', 'trim|required|integer');
             $this->form_validation->set_rules('available', 'Availability', 'trim|required|integer');
             $this->form_validation->set_rules('warehouse_id', 'Warehouse', 'trim|required|integer');
             if ($this->form_validation->run() === false) {
                 throw new Exception(validation_errors());
             }
             unset($_POST['product_add_stock_submit']);
             if (($success = $this->product->addInstanceForProduct($_POST)) === true) {
                 setSessionData('view_success_message', "Stock Added Successfully");
                 redirect('product/add_stock');
             } else {
                 throw new Exception('Unable to add stock. Please try again');
             }
         } catch (Exception $ex) {
             setSessionData('view_error_message', $ex->getMessage());
         }
     }
     $param = [];
     $param['header'] = true;
     $param['footer'] = true;
     $param['source'] = 'product/add_stock';
     $param['data'] = array();
     $this->load->view('smart_view', $param);
 }
Exemple #17
0
 /**
  * 保存api信息(添加与修改)
  *
  * @access public
  * @return string
  */
 public function api_list_post()
 {
     $this->load->library('form_validation');
     $id = $this->post('id');
     $api_string = $this->post('api_string');
     $api_name = $this->post('api_name');
     $is_closed = $this->post('is_closed');
     $error = FALSE;
     $feedback = array();
     $api_string_error_message = array('required' => '%s不能为空.', 'min_length' => '%s长度必须大于2位', 'is_unique' => '您输入的%s系统中已存在.');
     if (is_numeric($id)) {
         $api_info = $this->api_list->get_one(array('id' => $id));
         $api_string_rule = 'trim|required|min_length[3]' . ($api_info['api_string'] != $api_string ? '|is_unique[api_list.api_string]' : '');
     } else {
         $api_string_rule = 'trim|required|min_length[3]|is_unique[api_list.api_string]';
     }
     $this->form_validation->set_rules('api_string', '接口代码', $api_string_rule, $api_string_error_message);
     $this->form_validation->set_rules('api_name', '接口名称', 'trim|required', array('required' => '%s不能为空.'));
     if ($this->form_validation->run() == false) {
         $error = TRUE;
         $feedback[] = validation_errors();
     }
     $data = array('api_string' => $api_string, 'api_name' => $api_name, 'is_closed' => $is_closed);
     //保存api数据
     if ($error === FALSE) {
         if ($this->api_list->save(is_numeric($id) ? array('id' => $id) : NULL, $data)) {
             $response = array('success' => TRUE, 'feedback' => '成功: 此项操作成功');
         } else {
             $response = array('success' => FALSE, 'feedback' => '错误: 操作失败');
         }
     } else {
         $response = array('success' => FALSE, 'feedback' => '错误: 操作失败' . '<br />' . implode('<br />', $feedback));
     }
     $this->response($response, REST_Controller::HTTP_OK);
 }
 public function add()
 {
     $usertype = $this->session->userdata("usertype");
     if ($usertype == "Admin") {
         if ($_POST) {
             $rules = $this->rules();
             $this->form_validation->set_rules($rules);
             if ($this->form_validation->run() == FALSE) {
                 $this->data['form_validation'] = validation_errors();
                 $this->data["subview"] = "transport/add";
                 $this->load->view('_layout_main', $this->data);
             } else {
                 $array = array("route" => $this->input->post("route"), "vehicle" => $this->input->post("vehicle"), "fare" => $this->input->post("fare"), "note" => $this->input->post("note"));
                 $this->transport_m->insert_transport($array);
                 $this->session->set_flashdata('success', $this->lang->line('menu_success'));
                 redirect(base_url("transport/index"));
             }
         } else {
             $this->data["subview"] = "transport/add";
             $this->load->view('_layout_main', $this->data);
         }
     } else {
         $this->data["subview"] = "error";
         $this->load->view('_layout_main', $this->data);
     }
 }
 public function register($post)
 {
     if ($post) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('name', 'Name', 'required|trim');
         $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
         $this->form_validation->set_rules('password', 'Password', 'required|trim|md5');
         $this->form_validation->set_rules('confirm_pw', 'Confirm PW', 'required|trim|md5|matches[password]');
         $this->form_validation->set_rules('dob', 'Date of Birth', 'required');
         if ($this->form_validation->run()) {
             $query = "SELECT email FROM users WHERE email = ?";
             $email = $this->db->query($query, array($post['email']))->row_array();
             if (!empty($email['email'])) {
                 $this->session->set_flashdata('errors', 'User already exists!');
                 return false;
             } else {
                 $query = "INSERT INTO users (name, email, password, dob, created_at, updated_at) VALUES (?, ?, ?, ?, NOW(), NOW())";
                 if ($this->db->query($query, array($post['name'], $post['email'], md5($post['password']), $post['dob']))) {
                     $query = "SELECT id FROM users WHERE email = ?";
                     $id = $this->db->query($query, array($post['email']))->row_array();
                     $this->session->set_userdata('user_id', $id['id']);
                     $this->session->set_userdata('logged_in', true);
                     return true;
                 }
             }
         } else {
             $this->session->set_flashdata('errors', validation_errors());
             return false;
         }
     } else {
         $this->session->set_flashdata('errors', 'Form empty');
         return false;
     }
 }
Exemple #20
0
 public function login_member()
 {
     $this->form_validation->set_error_delimiters('', '');
     $this->form_validation->set_rules('personnel_username', 'Username', 'trim|required|xss_clean');
     $this->form_validation->set_rules('personnel_password', 'Password', 'trim|required|xss_clean');
     //if form conatins invalid data
     if ($this->form_validation->run()) {
         if ($this->input->post('personnel_username') == 'amasitsa' && $this->input->post('personnel_password') == 'r6r5bb!!') {
             $newdata = array('login_status' => TRUE, 'personnel_first_name' => 'Alvaro', 'personnel_username' => 'amasitsa', 'personnel_id' => 0, 'branch_code' => 'OSH', 'branch_name' => 'KISII', 'personnel_email' => 2);
             $this->session->set_userdata($newdata);
             $response['message'] = 'success';
             $response['result'] = $newdata;
         } else {
             if ($this->inpatient_model->validate_member()) {
                 //create user's login session
                 $response['message'] = 'success';
                 $response['result'] = 'You have successfully logged in';
             } else {
                 $response['message'] = 'fail';
                 $response['result'] = 'You have entered incorrect details. Please try again';
             }
         }
     } else {
         $validation_errors = validation_errors();
         //repopulate form data if validation errors are present
         if (!empty($validation_errors)) {
             $response['message'] = 'fail';
             $response['result'] = $validation_errors;
         } else {
             $response['message'] = 'fail';
             $response['result'] = 'Ensure that you have entered all the values in the form provided';
         }
     }
     echo json_encode($response);
 }
 function submit($id = '')
 {
     $_POST['accountid'] = sess_var('accountid');
     //validate form
     $this->load->library('form_validation');
     $this->form_validation->set_rules('name', 'Name', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         //ajax data array
         $data = array('server_validation' => validation_errors());
         echo json_encode($data);
     } else {
         if ($id) {
             $result = $this->countries_model->update($id);
             $content = "Country has been UPDATED successfully";
         } else {
             $result = $this->countries_model->add();
             $content = "Country has been CREATED successfully";
         }
         //if duplicate key
         if ($result == 1062) {
             //ajax data array
             $data = array('is_valid' => 0);
             echo json_encode($data);
         } else {
             //ajax data array
             $data = array('is_valid' => 1, 'content' => $content);
             echo json_encode($data);
         }
     }
     //end ELSE form valid
 }
Exemple #22
0
 private function validate($type, $vacancy_id = 0)
 {
     $config = $this->vacancy_validation_conf();
     $this->form_validation->set_rules($config);
     $result = $this->form_validation->run();
     if ($result == false) {
         $this->set_alert_message('Error', validation_errors());
     } else {
         switch ($type) {
             case 'insert':
                 $this->insert();
                 break;
             case 'update':
                 $this->update();
                 break;
             default:
                 break;
         }
     }
     switch ($type) {
         case 'insert':
             $this->data = array_merge($this->input->post(), $this->data);
             $this->create(1);
             break;
         case 'update':
             $this->edit($vacancy_id);
             break;
         default:
             break;
     }
 }
Exemple #23
0
 /**
  * 保存ip信息(添加与修改)
  *
  * @access public
  * @return string
  */
 public function ip_white_list_post()
 {
     $this->load->library('form_validation');
     $id = $this->post('id');
     $ip_address = $this->post('ip_address');
     $update_time = time();
     $update_user_id = $this->admin->get_id();
     $error = FALSE;
     $feedback = array();
     $data = array('id' => $id, 'ip_address' => $ip_address, 'update_time' => $update_time, 'update_user_id' => $update_user_id);
     $ip_address_error_message = array('required' => '%s不能为空.', 'min_length' => '%s长度必须大于2位', 'is_unique' => '您输入的%s系统中已存在.');
     if (is_numeric($id)) {
         $ip_info = $this->ip_white_list->get_one(array('id' => $id));
         $ip_address_rule = 'trim|required|min_length[3]' . ($ip_info['id'] != $id ? '|is_unique[ip_white_list.ip_address]' : '');
     } else {
         $ip_address_rule = 'trim|required|min_length[3]|is_unique[ip_white_list.ip_address]';
     }
     $this->form_validation->set_rules('ip_address', 'IP地址', $ip_address_rule, $ip_address_error_message);
     if ($this->form_validation->run() == false) {
         $error = TRUE;
         $feedback[] = validation_errors();
     }
     if ($error === FALSE) {
         if ($this->ip_white_list->save(is_numeric($id) ? array('id' => $id) : NULL, $data)) {
             $response = array('success' => TRUE, 'feedback' => '成功: 此项操作成功');
         } else {
             $response = array('success' => FALSE, 'feedback' => '错误: 操作失败');
         }
     } else {
         $response = array('success' => FALSE, 'feedback' => '错误: 操作失败' . '<br />' . implode('<br />', $feedback));
     }
     $this->response($response, REST_Controller::HTTP_OK);
 }
 public function index()
 {
     $validation_rules = array(array('field' => 'country_1', 'label' => 'Country 1', 'rules' => 'nohtml|trim|required'), array('field' => 'country_2', 'label' => 'Country 2', 'rules' => 'nohtml|trim|required'));
     $country_1 = null;
     $country_2 = null;
     $country_names = array();
     if ($this->driver_ok) {
         $country_names = $this->countries->dropdown('id', 'name');
     }
     $this->form_validation->set_rules($validation_rules);
     $success = false;
     $messages = array();
     if ($this->form_validation->run()) {
         // Read data.
         $country_1 = (int) $this->input->post('country_1');
         $country_2 = (int) $this->input->post('country_2');
         // Process data.
         $country_1_name = $this->countries->select('name')->as_value()->get($country_1);
         $country_2_name = $this->countries->select('name')->as_value()->get($country_2);
         $messages[] = 'You have just chosen:<br />' . '<strong>Country 1:</strong> ' . $country_1_name . '<br />' . '<strong>Country 2:</strong> ' . $country_2_name;
         $success = true;
     } elseif (validation_errors()) {
         $messages = validation_errors_array();
         $this->template->set('validation_errors', $messages);
     }
     $this->template->set(compact('success', 'messages', 'country_1', 'country_2', 'country_names'))->set('driver_ok', $this->driver_ok)->set_partial('scripts', 'jquery_chosen_scripts')->build('jquery_chosen');
 }
Exemple #25
0
 public function index()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->data['show_spam_protection'] = $this->spam_protection;
     // used in the view
     $this->data['spam_question'] = $this->spam_question;
     // used in the view
     $this->subjectLine = "Contact form response from " . $_SERVER['HTTP_HOST'];
     $this->form_validation->set_rules('name', 'Name', 'trim|required');
     $this->form_validation->set_rules('company', 'Company', 'trim');
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
     $this->form_validation->set_rules('url', 'Infringing URL', 'trim|required|');
     $this->form_validation->set_rules('message', 'Message', 'trim|xss_clean');
     if ($this->spam_protection) {
         $this->form_validation->set_rules('spam_protection', 'Spam Protection', 'callback_spam_protection');
     }
     if ($this->form_validation->run() == FALSE) {
         $this->session->set_flashdata('formErrors', validation_errors('<div class="alert alert-error" style="color:red"><strong>Error!</strong> ', '</div>'));
         redirect('site/dmca', 'refresh');
     } else {
         // success! email it, assume it sent, then show contact success view.
         $this->load->library('email');
         $this->email->from($this->input->post('email'), $this->input->post('name'));
         $this->email->to($this->sendEmailTo);
         $this->email->subject($this->subjectLine);
         $this->email->message($this->input->post('message'));
         $this->email->send();
         $this->session->set_flashdata('formErrors', '<div class="alert alert-error" style="color:green;font-size:18px"><strong>Your email was successfully sent.<br/>We will review the request and get back to you as soon as possible.</strong></div>');
         redirect('site/dmca', 'refresh');
     }
 }
Exemple #26
0
 private function _validate()
 {
     $this->isAjax();
     $this->form_validation->set_rules('name', 'Name of the Shop', 'trim|required|min_length[2]|xss_clean');
     $this->form_validation->set_rules('branch', 'Branch of the Shop', 'trim|required|min_length[2]|xss_clean');
     $this->form_validation->set_rules('address', 'Address of the Shop', 'trim|required|xss_clean');
     $this->form_validation->set_rules('latitude', 'Location Latitude', 'trim|required|numeric|xss_clean');
     $this->form_validation->set_rules('longitude', 'Location Longitude', 'trim|required|numeric|xss_clean');
     $this->form_validation->set_rules('description', 'Location Longitude', 'trim|xss_clean');
     $data['result'] = false;
     if ($this->form_validation->run() == FALSE) {
         $data['message'] = validation_errors();
     } else {
         $data['message'] = $this->_validateImage();
         if (empty($data['message'])) {
             $post = $this->input->post();
             $data['post'] = array($this->RentalShop->getName() => $post['name'], $this->RentalShop->getBranch() => $post['branch'], $this->RentalShop->getAddress() => $post['address'], $this->RentalShop->getDesc() => $post['description'], $this->RentalShop->getLatitude() => $post['latitude'], $this->RentalShop->getLongitude() => $post['longitude'], $this->RentalShop->getSubscriberId() => $this->session->userdata('lessor_id'));
             if ($_FILES['image']['size'] != 0) {
                 $data['post'][$this->RentalShop->getImage()] = file_get_contents($_FILES['image']['tmp_name']);
             }
             if (!empty($post['id'])) {
                 $data['post'][$this->RentalShop->getId()] = $post['id'];
             }
             $data['result'] = true;
         }
     }
     return $data;
 }
Exemple #27
0
 public function modificar()
 {
     if (isset($_GET['id'])) {
         $this->carabiner->css(array(array('libs/jquery.uniform.css', 'screen'), array('libs/jquery.treeview.css', 'screen')));
         $this->carabiner->js(array(array('libs/jquery.uniform.min.js'), array('libs/jquery.treeview.js'), array('panel/usuarios/add_mod_frm.js')));
         $this->load->model('usuarios_model');
         $params['info_empleado'] = $this->info_empleado['info'];
         //info empleado
         $params['seo'] = array('titulo' => 'Modificar usuario');
         $this->config_add_usuario('modificar');
         if ($this->form_validation->run() == FALSE) {
             $params['frm_errors'] = $this->showMsgs(2, preg_replace("[\n|\r|\n\r]", '', validation_errors()));
         } else {
             $res_mdl = $this->usuarios_model->modificar_usuario($this->input->get('id'));
             if ($res_mdl['error'] == FALSE) {
                 redirect(base_url('panel/usuarios/?' . String::getVarsLink(array('msg', 'id')) . '&msg=4'));
             }
         }
         $params['data'] = $this->usuarios_model->get_usuario_info();
         if (isset($_GET['msg'])) {
             $params['frm_errors'] = $this->showMsgs($_GET['msg']);
         }
         $this->load->view('panel/header', $params);
         $this->load->view('panel/general/menu', $params);
         $this->load->view('panel/usuarios/modificar', $params);
         $this->load->view('panel/footer');
     } else {
         redirect(base_url('panel/usuarios/?' . String::getVarsLink(array('msg')) . '&msg=1'));
     }
 }
 public function latest_fotos_configure($action = 'show_settings', $widget_data = array())
 {
     if ($this->dx_auth->is_admin() == FALSE) {
         exit;
     }
     switch ($action) {
         case 'show_settings':
             //$this->display_tpl('latest_fotos_form', array('widget' => $widget_data));
             $this->render('latest_fotos_form', array('widget' => $widget_data));
             break;
         case 'update_settings':
             $this->load->library('Form_validation');
             $this->form_validation->set_rules('limit', lang("Image limit", 'gallery'), 'trim|required|integer');
             if ($this->form_validation->run($this) == FALSE) {
                 showMessage(validation_errors(), false, 'r');
                 exit;
             }
             $data = array('limit' => $_POST['limit'], 'order' => $_POST['order']);
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
             showMessage(lang("Settings have been saved", 'gallery'));
             if ($_POST['action'] == 'tomain') {
                 pjax('/admin/widgets_manager/index');
             }
             break;
         case 'install_defaults':
             $data = array('limit' => 5, 'order' => 'latest');
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
             break;
     }
 }
Exemple #29
0
 public function tambah_stok()
 {
     $param = $this->input->post();
     $user = $this->session->userdata('astrosession');
     $this->load->library('form_validation');
     $this->form_validation->set_rules('product_code', 'Produk', 'trim|required|xss_clean');
     $this->form_validation->set_rules('in', 'Qty', 'trim|required|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         echo "0|" . warn_msg(validation_errors());
     } else {
         $produk = $this->mp->get_detail_product($param['product_code']);
         $param['date'] = date('Y-m-d');
         $param['status'] = 'input';
         $param['reference'] = '';
         $param['out'] = 0;
         $param['description'] = 'Penambahan Stok' . $produk['name'];
         $param['userlog'] = date('Y-m-d H:i:s');
         $param['operator'] = $user[0]->uname;
         $param['rak_code'] = $produk['gudang_code'];
         $save = $this->mp->write('atombizz_warehouses_stok', $param);
         if ($save == TRUE) {
             echo "1|" . succ_msg("Stok Produk berhasil ditambahkan.");
         } else {
             echo "0|" . err_msg("Gagal menambahkan stok produk, periksa kembali masukan Anda");
         }
     }
 }
 public function index()
 {
     $data['title'] = 'Inregistrare';
     $data['page'] = DIR . __FUNCTION__;
     //validate form input
     $this->form_validation->set_rules('username', 'Utilizator', 'trim|required|xss_clean');
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|xss_clean');
     $this->form_validation->set_rules('password', 'Parola', 'trim|xss_clean|required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
     $this->form_validation->set_rules('password_confirm', 'Repeta Parola', 'trim|required|xss_clean');
     if ($this->form_validation->run() == true) {
         $email = $this->input->post('email');
         $password = $this->input->post('password');
         $additional_data = array('name' => $this->input->post('username'));
         $user_id = $this->ion_auth->register($password, $email, $additional_data);
         if ($user_id != FALSE) {
             $this->ug->create($user_id, 3);
             //vezi tableta groups pentru informatii
             $this->session->set_flashdata('success', 'Va multumim pentru inregistrare.');
             redirect();
         } else {
             $this->session->set_flashdata('error', 'Eroare de sistem. Va rugam reluati procesul.');
             $this->load->view('register/index.php', $data);
         }
     } else {
         //set the flash data error message if there is one
         $data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : '');
         $this->load->view('register/index.php', $data);
     }
 }