public function update($id) { $this->form_validation->set_rules('name', 'Name', 'trim|required'); if ($this->form_validation->run() == FALSE) { $group = sentinel()->findRoleBySlug('edt'); $data['kategori'] = Model\Portal\Category::findOrFail($id); $data['kategori_lists'] = $this->model->getLists($id); $data['users'] = $group->users->pluck('email', 'id')->toArray(); $this->template->build('kategori_edit', $data); } else { $kategori['name'] = $this->input->post('name'); $kategori['description'] = $this->input->post('description'); $kategori['parent'] = $this->input->post('parent'); $editor = set_value('editor', []); $category = Model\Portal\Category::findOrFail($id); $category->update($kategori); $category->editors()->sync($editor); if ($res == TRUE) { set_message_success('Kategori berhasil diperbarui.'); redirect('kategori'); } else { set_message_error('Kategori gagal diperbarui.'); redirect('kategori/update'); } } }
/** * Create new article * @access public * @return void */ public function create() { $this->load->library('form_validation'); //append the check slug callback function to rules array $this->validation_rules[1]['rules'] .= '|callback__check_slug'; $this->form_validation->set_rules($this->validation_rules); if ($this->form_validation->run()) { $date = $this->input->post('date'); $date = explode('/', $date); $id = $this->news_m->insert(array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'intro' => $this->input->post('intro'), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on_hour' => $this->input->post('created_on_hour'), 'created_on_minute' => $this->input->post('created_on_minute'), 'created_on_day' => $date[1], 'created_on_month' => $date[0], 'created_on_year' => $date[2])); if ($id) { $this->cache->delete_all('news_m'); $this->session->set_flashdata('success', sprintf($this->lang->line('news_article_add_success'), $this->input->post('title'))); } else { $this->session->set_flashdata('error', $this->lang->line('news_article_add_error')); } // Redirect back to the form or main page $this->input->post('btnAction') == 'save_exit' ? redirect('admin/news') : redirect('admin/news/edit/' . $id); } else { // Go through all the known fields and get the post values foreach ($this->validation_rules as $key => $field) { $article->{$field}['field'] = set_value($field['field']); } } $this->template->title($this->module_details['name'], lang('news_create_title'))->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_metadata(js('news_form.js', 'news'))->set('article', $article)->build('admin/form'); }
public function submit($category) { $media = $this->medialib; $category = $media->setCategory($category)->getCategory(); $uploaded = []; $input_name = 'filemedia'; if (is_array($_FILES[$input_name]['name'])) { foreach ($_FILES[$input_name]['name'] as $i => $name) { $filemedia['name'] = $_FILES[$input_name]['name'][$i]; $filemedia['type'] = $_FILES[$input_name]['type'][$i]; $filemedia['tmp_name'] = $_FILES[$input_name]['tmp_name'][$i]; $filemedia['error'] = $_FILES[$input_name]['error'][$i]; $filemedia['size'] = $_FILES[$input_name]['size'][$i]; $uploaded[] = $this->submitSingle($category, $filemedia, $metadata); } } else { $uploaded[] = $this->submitSingle($category, $_FILES[$input_name], set_value('meta', [])); } if ($this->input->is_ajax_request()) { echo json_encode($uploaded); } else { set_message_success('Media berhasil diunggah.'); redirect('elibrary/show/' . $category->id, 'refresh'); } }
function doMediaUpload() { $this->load->library('form_validation'); if ($this->form_validation->run() == FALSE) { $data['mediaList'] = $this->upload_model->getMedia(); $data['error'] = validation_errors(); $data['filelabel'] = set_value('filelabel'); $this->load->view('mediaupload_form', $data); return; } $config['upload_path'] = './media/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '2000'; $config['max_width'] = '800'; $config['max_height'] = '600'; $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $data['mediaList'] = $this->upload_model->getMedia(); $data = array('error' => $this->upload->display_errors()); $data['filelabel'] = set_value('filelabel'); $this->load->view('mediaupload_form', $data); } else { //$data['error'] = '<pre>'.var_dump($this->upload->data()).'</pre>'; $fileData = $this->upload->data(); $modelData['label'] = $this->input->post('filelabel'); $modelData['fileName'] = $fileData['file_name']; $this->upload_model->saveImage($modelData); $data['mediaList'] = $this->upload_model->getMedia(); $data['filelabel'] = ""; $this->load->view('mediaupload_form', $data); } }
public function kkm() { $cek = $this->session->userdata('logged_in'); $stts = $this->session->userdata('stts'); if (!empty($cek) && $stts == 'mahasiswa') { $data = array('button' => 'Create', 'action' => site_url('mahasiswa/daftar_kkm'), 'no_daftar' => set_value('no_daftar'), 'jenis_kelamin' => set_value('jenis_kelamin'), 'tempat_tanggal_lahir' => set_value('tempat_tanggal_lahir'), 'semester' => set_value('semester'), 'alamat_asal' => set_value('alamat_asal'), 'alamat_sekarang' => set_value('alamat_sekarang'), 'no_telp' => set_value('no_telp'), 'keterangan_khusus' => set_value('keterangan_khusus'), 'photo_2x3' => set_value('photo_2x3'), 'id_kelompok' => set_value('id_kelompok'), 'dpl' => set_value('dpl')); $d['judul'] = "Formulir Pendaftaran - Sistem Informasi Pendaftaran Kuliah Kerja Mahasiswa"; $bc['no'] = $this->session->userdata('no'); $bc['nama'] = $this->session->userdata('nama'); $bc['status'] = $this->session->userdata('stts'); $bc['nim'] = $this->session->userdata('nim'); $bc['jurusan'] = $this->session->userdata('jurusan'); $bc['fakultas'] = $this->session->userdata('fakultas'); $bc['id_kelompok'] = $this->session->userdata('id_kelompok'); $bc['dpl'] = $this->session->userdata('dpl'); $bc['semester'] = $this->session->userdata('semester'); $bc['kkma'] = $this->web_app_model->getmauDaftarkkm($bc['nim']); $bc['cek'] = $this->web_app_model->cek_kelompok($bc['id_kelompok']); $bc['menu'] = $this->load->view('mahasiswa/menu', '', true); $bc['bio'] = $this->load->view('mahasiswa/bio', $bc, true); $this->load->view('global/bg_top', $bc); $this->load->view('mahasiswa/bg_jadwal', $data, $bc); $this->load->view('global/bg_footer', $d); } else { header('location:' . base_url() . 'web'); } }
public function create() { $data['title'] = 'Create Product'; // is user submitting form or viewing? if ($this->input->post()) { // handle cancelling if (strtolower($this->input->post('submit')) == 'cancel') { redirect('product'); } // validate form $this->form_validation->set_rules('type', 'type', 'trim|xss_clean'); $this->form_validation->set_rules('name', 'name', 'trim|required|xss_clean'); $this->form_validation->set_rules('price', 'price', 'trim|decimal|required|xss_clean'); $this->form_validation->set_rules('model', 'model', 'trim|required|xss_clean'); if ($this->form_validation->run() == TRUE) { // save new product $name = set_value('name'); $price = set_value('price'); $model = set_value('model'); $type = set_value('type') ? set_value('type') : NULL; if ($this->product_model->create($name, $price, $model, $type)) { // success $this->contentData['message'] = 'product created'; return $this->index(); } else { // error creating new user $this->contentData['message'] = $this->product_model->getMessage(); } } else { $this->contentData['message'] = validation_errors(); } } $data['content'] = $this->load->view('product/product_create', $this->contentData, TRUE); $this->techniart->load($data); }
public function add() { $this->load->library('form_validation'); $this->form_validation->set_rules($this->validation_rules); if ($this->form_validation->run() == TRUE) { // preparing for insertion foreach ($this->validation_rules as $k => $v) { $fields[] = $v['field']; } // $fields = array('title', 'slug', 'description', 'date', 'description', 'url', 'status'); $data = $this->grade_m->array_from_post($fields); if ($this->grade_m->save($data)) { $this->session->set_flashdata('success', 'New Grade Added Successfully.'); } else { $this->session->set_flashdata('error', 'sorry, Grade cannot be Added.'); } redirect('grade/add/', 'refresh'); } else { $grade = new stdClass(); // Go through all the known fields and get the post values foreach ($this->validation_rules as $key => $field) { $grade->{$field}['field'] = set_value($field['field']); } } $data = array('method' => 'add', 'main_content' => 'form', 'editData' => $grade); $this->load->view('admin_wrapper', $data); }
public function send_email() { // Form validation $this->load->library("form_validation"); //set_rules is function from CI library where first parameter is the field name, // second is name for this field, which will be inserted into the error message // and the third is the validation rules for this form field $this->form_validation->set_rules("fullName", "Full Name", "required|alpha"); $this->form_validation->set_rules("email", "Email Address", "required|valid_email"); $this->form_validation->set_rules("message", "Message", "required"); $this->form_validation->set_rules('g-recaptcha-response', 'Captcha', 'callback_recaptcha'); if ($this->form_validation->run() == FALSE) { $data['message'] = ""; $this->load->view("site_header"); $this->load->view("site_nav"); $this->load->view("content_contact", $data); $this->load->view("site_footer"); } else { $data['message'] = "The email is successful send!"; /*Storing submitted values $fullName = $this->input->post('fullName'); $email = $this->input->post('email'); $message = $this->input->post('message');*/ // Configure email library $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.googlemail.com'; $config['smtp_port'] = 465; $config['smtp_user'] = '******'; $config['smtp_pass'] = '******'; $config['mailtype'] = 'html'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard //load the codeigniter email library and use its methods to send mail. $this->load->library("email"); $this->email->from(set_value("email"), set_value("fullName")); $this->email->to("*****@*****.**"); $this->email->subject("Message from out from"); $this->email->message(set_value("message")); $this->email->send(); // show message..print_debugger from the CI library echo $this->email->print_debugger(); // Insert into database model $insert['query'] = $this->insert_model->insert(); if ($insert['query'] != NULL) { $data = "The email is not successful send!"; $this->load->view("site_header"); $this->load->view("site_nav"); $this->load->view("content_contact", $data); $this->load->view("site_footer"); } else { $data['message'] = "The email is successful send!"; $this->load->view("site_header"); $this->load->view("site_nav"); $this->load->view("content_contact", $data); $this->load->view("site_footer"); } } }
function index() { $this->form_validation->set_rules('id_masivo', 'id masivo:', 'required|xss_clean|max_length[3]'); $this->form_validation->set_rules('id_pais', 'id pais:', 'required|xss_clean|max_length[3]'); $this->form_validation->set_rules('id_institucion', 'id institucion:', 'required|xss_clean|max_length[3]'); $this->form_validation->set_rules('expediente_id_masivo', 'expediente id masivo:', 'required|xss_clean|max_length[3]'); $this->form_validation->set_rules('id_expediente', 'id expediente:', 'required|xss_clean|max_length[3]'); $this->form_validation->set_rules('tipo_masivo', 'tipo masivo:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('nombre', 'nombre:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('apellido', 'apellido:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('sexo', 'sexo:', 'required|xss_clean|max_length[10]'); $this->form_validation->set_rules('fecha_de_emision', 'fecha de emision:', 'required|xss_clean'); $this->form_validation->set_rules('observacion_masiva', 'observacion masiva:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('ruta_masiva', 'ruta masiva:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('nombre_adoptivo', 'nombre adoptivo:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('apellido_adoptivo', 'apellido adoptivo:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == FALSE) { // $this->load->view('pages/view_expediente_masivo'); $this->load->view('pages/expediente_masivo02'); } else { // build array for the model $form_data = array('id_masivo' => set_value('id_masivo'), 'id_pais' => set_value('id_pais'), 'id_institucion' => set_value('id_institucion'), 'expediente_id_masivo' => set_value('expediente_id_masivo'), 'id_expediente' => set_value('id_expediente'), 'tipo_masivo' => set_value('tipo_masivo'), 'nombre' => set_value('nombre'), 'apellido' => set_value('apellido'), 'sexo' => set_value('sexo'), 'fecha_de_emision' => set_value('fecha_de_emision'), 'observacion_masiva' => set_value('observacion_masiva'), 'ruta_masiva' => set_value('ruta_masiva'), 'nombre_adoptivo' => set_value('nombre_adoptivo'), 'apellido_adoptivo' => set_value('apellido_adoptivo')); // run insert model to write data to db if ($this->model_expediente_masivo->SaveForm($form_data) == TRUE) { redirect('controller_expediente_masivo/success'); // or whatever logic needs to occur } else { echo 'An error occurred saving your information. Please try again later'; // Or whatever error handling is necessary } } }
public function newImagem() { $this->form_validation->set_rules('id', 'ID', ''); $this->form_validation->set_rules('referencia', 'Referência', 'max_length[45]'); $this->form_validation->set_rules('nome_produto', 'Nome Produto', 'max_length[200]'); $this->form_validation->set_rules('data_cadastro', 'Data Cadastro', ''); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == FALSE) { session_start(); if ($this->session->userdata('logged_in')) { $session_data = $this->session->userdata('logged_in'); $data['login'] = $session_data['login']; $this->load->view('imagens/includes/header'); $this->load->view('includes/nav', $data); $this->load->view('imagens/cad_imagens'); $this->load->view('imagens/includes/footer'); } else { //If no session, redirect to login page redirect('login', 'refresh'); } } else { // build array for the model $form_data = array('id' => set_value('id'), 'referencia' => set_value('referencia'), 'nome_produto' => set_value('nome_produto'), 'data_cadastro' => set_value('data_cadastro')); // run insert model to write data to db if ($this->myform_model->SaveForm($form_data) == TRUE) { redirect('myform/success'); // or whatever logic needs to occur } else { echo 'An error occurred saving your information. Please try again later'; // Or whatever error handling is necessary } } }
function form_open($action = '', $attributes = '', $hidden = array()) { $_ci = & get_instance(); $_ci->load->library('form_validation'); if ($attributes == '') { $attributes = 'method="post"'; } $action = ( strpos($action, '://') === FALSE) ? $_ci->config->site_url($action) : $action; $form = '<form action="' . $action . '"'; $form .= _attributes_to_string($attributes, TRUE); $form .= '>'; if ($_ci->form_validation->has_nonce()) { $value = set_value('nonce'); if ($value == '') { $value = $_ci->form_validation->create_nonce(); } $hidden['nonce'] = set_value('nonce', $value); } if (is_array($hidden) && count($hidden) > 0) { $form .= form_hidden($hidden); } return $form; }
/** * Create a new redirect * @access public * @return void */ public function add() { // Got validation? if ($this->form_validation->run()) { if ($this->redirect_m->insert($_POST)) { $this->session->set_flashdata('success', lang('redirects.add_success')); // Redirect redirect('admin/redirects'); } $this->data->messages['error'] = lang('redirects.add_error'); } // Loop through each validation rule foreach($this->validation_rules as $rule) { $redirect->{$rule['field']} = set_value($rule['field']); } $this->data->redirect =& $redirect; $this->template->build('admin/form', $this->data); }
function process() { $this->load->library('form_validation'); $this->form_validation->set_rules('movementstypes_id', 'movementstypes_id', 'required'); $this->form_validation->set_rules('products_id', 'products_id', 'required'); $this->form_validation->set_rules('quantity', 'quantity', 'required'); $this->form_validation->set_rules('comment', 'comment', ''); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == FALSE) { $data['showMessage'] = TRUE; echo validation_errors(); } else { $this->load->model('movementstypes_model', 'movtypes'); /* GET THE PRODUCT TO KNOW THE PRICE */ $the_product = $this->products->get(set_value('products_id')); /* GET THE TYPE OF MOVEMENT TO KNOW IF IS A + OR - OPERATION */ $the_type = $this->movtypes->get(set_value('movementstypes_id')); $form_data = array('id' => -1, 'products_id' => set_value('products_id'), 'movementstypes_id' => set_value('movementstypes_id'), 'quantity' => set_value('quantity') * $the_type->sign, 'unitprice' => $the_product->price, 'comment' => set_value('comment')); $id = $this->mov->save_form($form_data); if ($id) { /* UPDATE THE STOCK */ $this->products->update_stock(set_value('products_id'), set_value('quantity') * $the_type->sign); redirect(site_url('movimientos')); } else { echo 'An error occurred saving your information. Please try again later'; } } }
/** * Member import */ public function index() { if (!ee()->cp->allowed_group('can_access_utilities')) { show_error(lang('unauthorized_access')); } $groups = ee('Model')->get('MemberGroup')->order('group_title', 'asc')->all(); $member_groups = array(); foreach ($groups as $group) { $member_groups[$group->group_id] = $group->group_title; } ee()->lang->loadfile('settings'); $vars['sections'] = array(array(array('title' => 'mbr_xml_file', 'desc' => 'mbr_xml_file_location', 'fields' => array('xml_file' => array('type' => 'text', 'required' => TRUE)))), 'mbr_import_default_options' => array(array('title' => 'member_group', 'fields' => array('group_id' => array('type' => 'select', 'choices' => $member_groups))), array('title' => 'mbr_language', 'fields' => array('language' => array('type' => 'select', 'choices' => ee()->lang->language_pack_names(), 'value' => ee()->config->item('deft_lang') ?: 'english'))), array('title' => 'timezone', 'fields' => array('timezones' => array('type' => 'html', 'content' => ee()->localize->timezone_menu(set_value('default_site_timezone') ?: ee()->config->item('default_site_timezone'), 'timezones')))), array('title' => 'mbr_datetime_fmt', 'desc' => 'used_in_cp_only', 'fields' => array('date_format' => array('type' => 'select', 'choices' => array('%n/%j/%Y' => 'mm/dd/yyyy', '%j/%n/%Y' => 'dd/mm/yyyy', '%j-%n-%Y' => 'dd-mm-yyyy', '%Y-%m-%d' => 'yyyy-mm-dd')), 'time_format' => array('type' => 'select', 'choices' => array('24' => lang('24_hour'), '12' => lang('12_hour'))))), array('title' => 'include_seconds', 'desc' => 'include_seconds_desc', 'fields' => array('include_seconds' => array('type' => 'yes_no'))), array('title' => 'mbr_create_custom_fields', 'desc' => 'mbr_create_custom_fields_desc', 'fields' => array('auto_custom_field' => array('type' => 'yes_no', 'value' => set_value('auto_custom_field') ?: 'y'))))); ee()->load->library('form_validation'); ee()->form_validation->set_rules(array(array('field' => 'xml_file', 'label' => 'lang:mbr_xml_file', 'rules' => 'required|file_exists'), array('field' => 'auto_custom_field', 'label' => 'lang:auto_custom_field', 'rules' => ''))); $base_url = ee('CP/URL')->make('utilities/member-import'); if (AJAX_REQUEST) { ee()->form_validation->run_ajax(); exit; } elseif (ee()->form_validation->run() !== FALSE) { return $this->memberImportConfirm(); } elseif (ee()->form_validation->errors_exist()) { ee()->view->set_message('issue', lang('member_import_error'), lang('member_import_error_desc')); } ee()->view->base_url = $base_url; ee()->view->ajax_validate = TRUE; ee()->view->cp_page_title = lang('member_import'); ee()->view->save_btn_text = 'mbr_import_btn'; ee()->view->save_btn_text_working = 'mbr_import_btn_saving'; ee()->cp->render('settings/form', $vars); }
public function create() { $data = array('button' => '创建', 'action' => site_url('user/create_action'), 'id' => set_value('id'), 'username' => set_value('username'), 'jsdm' => set_value('jsdm'), 'password' => set_value('password'), 'email' => set_value('email'), 'created_on' => set_value(time()), 'active' => set_value('active'), 'sex' => set_value('sex'), 'birth_date' => set_value('birth_date'), 'yxdm' => set_value('yxdm'), 'jszw' => set_value('jszw'), 'jszc' => set_value('jszc'), 'jsxl' => set_value('jsxl'), 'phone' => set_value('phone'), 'jsinfo' => set_value('jsinfo')); $this->load->view('common/header'); $this->load->view('users_form', $data); $this->load->view('common/footer'); }
public function edit($id) { $rules = [['field' => 'caption', 'label' => 'Caption', 'rules' => 'required'], ['field' => 'description', 'label' => 'Description', 'rules' => 'required']]; $this->form_validation->set_rules($rules); $image = $this->Gallery_model->find($id)->row(); if ($this->form_validation->run() == FALSE) { $this->load->view('admin/gallery/edit_view', ['image' => $image]); } else { if (isset($_FILES["userfile"]["name"])) { /* Start Uploading File */ $config = ['upload_path' => './uploads/', 'allowed_types' => 'gif|jpg|png', 'max_size' => 100, 'max_width' => 1024, 'max_height' => 768]; $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('admin/gallery/edit_view', ['image' => $image, 'error' => $error]); } else { $file = $this->upload->data(); $data['file'] = 'uploads/' . $file['file_name']; unlink($image->file); } } $data['caption'] = set_value('caption'); $data['description'] = set_value('description'); $this->Gallery_model->update($id, $data); $this->session->set_flashdata('message', 'New image has been updated..'); redirect('/admin/gallery'); } }
function add() { $this->checkLogin(); $this->load->library('form_validation'); $this->data['custom_error'] = ''; $table = 'venta_credito'; $key = 'id'; $value = 'id'; $list = null; foreach ($this->codegen_model->get($table, $key . "," . $value, "", "", "") as $row) { $list[$row[$key]] = $row[$value]; } $this->data['venta_credito_id'] = $list; if ($this->form_validation->run('cpx') == false) { $this->data['custom_error'] = validation_errors() ? '<div class="form_error">' . validation_errors() . '</div>' : false; } else { $data = array('pago' => set_value('pago'), 'venta_credito_id' => set_value('venta_credito_id')); //add cause sometimes, when pass empty string I get troubles in the insert foreach ($data as $i => $value) { if ($value === "") { $data[$i] = null; } } if ($this->codegen_model->add('cpx', $data) == TRUE) { //$this->data['custom_error'] = '<div class="form_ok"><p>Added</p></div>'; // or redirect redirect(base_url() . 'index.php/cpx/manage/'); } else { $this->data['custom_error'] = '<div class="form_error"><p>An Error Occured.</p></div>'; } } $this->load->view('cpx_add', $this->data); //$this->template->load('content', 'cpx_add', $this->data); }
function adicionar() { if (!$this->permission->checkPermission($this->session->userdata('permissao'), 'aProduto')) { $this->session->set_flashdata('error', 'Você não tem permissão para adicionar produtos.'); redirect(base_url()); } $this->load->library('form_validation'); $this->data['custom_error'] = ''; if ($this->form_validation->run('produtos') == false) { $this->data['custom_error'] = validation_errors() ? '<div class="form_error">' . validation_errors() . '</div>' : false; } else { $precoCompra = $this->input->post('precoCompra'); $precoCompra = str_replace(",", "", $precoCompra); $precoVenda = $this->input->post('precoVenda'); $precoVenda = str_replace(",", "", $precoVenda); $data = array('descricao' => set_value('descricao'), 'unidade' => set_value('unidade'), 'precoCompra' => $precoCompra, 'precoVenda' => $precoVenda, 'estoque' => set_value('estoque'), 'estoqueMinimo' => set_value('estoqueMinimo')); if ($this->produtos_model->add('produtos', $data) == TRUE) { $this->session->set_flashdata('success', 'Produto adicionado com sucesso!'); redirect(base_url() . 'index.php/produtos/adicionar/'); } else { $this->data['custom_error'] = '<div class="form_error"><p>An Error Occured.</p></div>'; } } $this->data['view'] = 'produtos/adicionarProduto'; $this->load->view('tema/topo', $this->data); }
public function addEdit($id) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- if (!bTestForURLHack('showClients')) { return; } $this->load->helper('dl_util/verify_id'); verifyIDsViaType($this, CENUM_CONTEXT_STATUSCAT, $id, true); $id = (int) $id; $bNew = $id <= 0; $this->load->model('clients/mclient_status', 'clsClientStat'); $this->clsClientStat->loadClientStatCats(true, true, $id); // validation rules $this->form_validation->set_error_delimiters('<div class="formError">', '</div>'); $this->form_validation->set_rules('txtStatCatName', 'Status Category', 'trim|required|' . 'callback_verifyUniqueStatCat[' . $id . ']'); $this->form_validation->set_rules('txtNotes'); if ($this->form_validation->run() == FALSE) { $displayData = array(); $displayData['formD'] = new stdClass(); $this->load->library('generic_form'); if ($bNew) { $this->clsClientStat->loadClientStatCats(true, true, -1); $this->clsClientStat->statCats[0]->lKeyID = -1; $this->clsClientStat->statCats[0]->strCatName = ''; } if (validation_errors() == '') { $displayData['formD']->txtStatCatName = htmlspecialchars($this->clsClientStat->statCats[0]->strCatName); $displayData['formD']->txtNotes = htmlspecialchars($this->clsClientStat->statCats[0]->strDescription); } else { setOnFormError($displayData); $displayData['formD']->txtStatCatName = set_value('txtStatCatName'); $displayData['formD']->txtNotes = set_value('txtNotes'); } //-------------------------- // breadcrumbs //-------------------------- $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('admin/alists/showLists', 'Lists', 'class="breadcrumb" ') . ' | ' . anchor('admin/admin_special_lists/clients/statCatView', 'Client Status Categories', 'class="breadcrumb" ') . ' | ' . ($bNew ? 'Add new status category' : 'Edit status category'); $displayData['title'] = CS_PROGNAME . ' | Lists'; $displayData['nav'] = $this->mnav_brain_jar->navData(); $displayData['id'] = $id; $displayData['bNew'] = $bNew; $displayData['statCats'] = $this->clsClientStat->statCats; $displayData['mainTemplate'] = 'client/client_status_cat_add_edit'; $this->load->vars($displayData); $this->load->view('template'); } else { $this->clsClientStat->statCats[0]->strCatName = trim($_POST['txtStatCatName']); $this->clsClientStat->statCats[0]->strDescription = trim($_POST['txtNotes']); if ($id == 0) { $id = $this->clsClientStat->addNewClientStatusCat(); $this->session->set_flashdata('msg', 'Your status category was added'); } else { $this->clsClientStat->updateClientStatusCat($id); $this->session->set_flashdata('msg', 'Your status category was updated'); } redirect('admin/admin_special_lists/clients/statCatView'); } }
public function edit_profile() { $this->form_validation->set_rules('fullname', 'Fullname', 'required|trim|xss_clean|max_length[40]'); $this->form_validation->set_rules('sex', 'Sex', 'required|trim|xss_clean|max_length[10]'); $this->form_validation->set_rules('city', 'City', 'trim|xss_clean|max_length[30]'); //$this->form_validation->set_rules('zipcode', 'ZipCode', 'trim|xss_clean|max_length[8]'); $this->form_validation->set_rules('state_province', 'State/Province', 'trim|xss_clean|max_length[20]'); $this->form_validation->set_rules('country', 'Country', 'required|trim|xss_clean|max_length[30]'); $this->form_validation->set_rules('mobile', 'Mobile', 'trim|xss_clean|max_length[11]'); $this->form_validation->set_rules('date_of_birth', 'Date of Birth', 'trim|xss_clean'); //$this->form_validation->set_rules('marial_status', 'Marial Status', 'trim|xss_clean|max_length[8]'); $this->form_validation->set_error_delimiters('<label class="error">', '</label>'); if ($this->form_validation->run() == FALSE) { $this->load->view('_partials/header', $this->data); $this->load->view('profile/edit_profile'); $this->load->view('_partials/footer'); } else { // build array for the model $form_data = array('fullname' => set_value('fullname'), 'sex' => set_value('sex'), 'city' => set_value('city'), 'state_province' => set_value('state_province'), 'country' => set_value('country'), 'mobile' => set_value('mobile'), 'dob' => set_value('date_of_birth')); if ($this->user_profile->SaveProfile($form_data, $this->user_id)) { $this->data['success'] = 1; } else { $this->data['success'] = 2; } $this->load->view('_partials/header', $this->data); $this->load->view('profile/edit_profile'); $this->load->view('_partials/footer'); } }
function create() { $this->load->library('validation'); $this->rules['slug'] .= '|callback__check_slug'; $this->validation->set_rules($this->rules); $this->validation->set_fields(); // Go through all the known fields and get the post values foreach (array_keys($this->rules) as $field) { $article->{$field} = set_value($field); } if ($this->validation->run()) { $id = $this->news_m->insert(array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'intro' => $this->input->post('intro'), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on_hour' => $this->input->post('created_on_hour'), 'created_on_minute' => $this->input->post('created_on_minute'), 'created_on_day' => $this->input->post('created_on_day'), 'created_on_month' => $this->input->post('created_on_month'), 'created_on_year' => $this->input->post('created_on_year'))); if (!empty($id)) { $this->session->set_flashdata('success', sprintf($this->lang->line('news_article_add_success'), $this->input->post('title'))); // The twitter module is here, and enabled! if ($this->settings->item('twitter_news') == 1 && $this->input->post('status') == 'live') { $url = shorten_url('news/' . $this->input->post('created_on_year') . '/' . $this->input->post('created_on_month') . '/' . url_title($this->input->post('title'))); $this->load->model('twitter/twitter_m'); if (!$this->twitter_m->update(sprintf($this->lang->line('news_twitter_posted'), $this->input->post('title'), $url))) { $this->session->set_flashdata('error', lang('news_twitter_error') . ": " . $this->twitter->last_error['error']); } } // End twitter code } else { $this->session->set_flashdata('error', $this->lang->line('news_article_add_error')); } redirect('admin/news'); } $this->data->article =& $article; // Load WYSIWYG editor $this->template->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_metadata(js('news_form.js', 'news')); $this->template->build('admin/form', $this->data); }
function index() { $this->form_validation->set_rules('id_evento', 'id evento:', 'required|xss_clean|max_length[3]'); $this->form_validation->set_rules('dia_inicio', 'dia inicio:', 'required|xss_clean|max_length[5]'); $this->form_validation->set_rules('mes_inicio', 'mes inicio:', 'required|xss_clean|max_length[10]'); $this->form_validation->set_rules('ano_inicio', 'año inicio:', 'required|xss_clean|max_length[5]'); $this->form_validation->set_rules('dia_fin', 'dia fin:', 'max_length[5]'); $this->form_validation->set_rules('mes_fin', 'mes fin', 'required|xss_clean|max_length[10]'); $this->form_validation->set_rules('ano_fin', 'año fin:', 'max_length[5]'); $this->form_validation->set_rules('descripcion_de_evento', 'descripcion de evento:', 'required|xss_clean|max_length[150]'); $this->form_validation->set_rules('lugar_de_evento', 'lugar de evento:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('unidad_responsable', 'unidad responsable:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_rules('responsable_evento', 'responsable evento:', 'required|xss_clean|max_length[25]'); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == FALSE) { $this->load->view('pages/view_evento'); } else { // build array for the model $form_data = array('id_evento' => set_value('id_evento'), 'dia_inicio' => set_value('dia_inicio'), 'mes_inicio' => set_value('mes_inicio'), 'ano_inicio' => set_value('ano_inicio'), 'dia_fin' => set_value('dia_fin'), 'mes_fin' => set_value('mes_fin'), 'ano_fin' => set_value('ano_fin'), 'descripcion_de_evento' => set_value('descripcion_de_evento'), 'lugar_de_evento' => set_value('lugar_de_evento'), 'unidad_responsable' => set_value('unidad_responsable'), 'responsable_evento' => set_value('responsable_evento')); // run insert model to write data to db if ($this->model_evento->SaveForm($form_data) == TRUE) { redirect('controller_evento/success'); // or whatever logic needs to occur } else { echo 'An error occurred saving your information. Please try again later'; // Or whatever error handling is necessary } } }
public function create() { $this->form_validation->set_rules($this->validation); if ($this->form_validation->run()) { $created_at = date('Y-m-d H:i:s'); $uniq = uniqid(); $user = $this->session->userdata('user_id'); $data = array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'subtitle' => $this->input->post('subtitle'), 'description' => $this->input->post('description'), 'category_id' => $this->input->post('category'), 'meta_tag' => $this->input->post('meta_tag'), 'meta_description' => $this->input->post('meta_description'), 'status' => $this->input->post('status'), 'user_id' => $user, 'uniq' => $uniq, 'created_at' => $created_at, 'updated_at' => $created_at); if (isset($_FILES['banner_image'])) { $this->load->library('upload'); $this->upload->initialize($this->set_upload_options($uniq, 'banner_image')); if ($this->upload->do_upload('banner_image')) { $upload_data = $this->upload->data(); $data['banner_image'] = 'uploads/post/' . $uniq . '/' . $upload_data['file_name']; } } if ($id = $this->blog_m->insertData('post', $data)) { $this->session->set_flashdata('success', 'Success to insert data'); if ($this->input->post('btnAction') == 'save_exit') { redirect(ADMIN_URL . '/blog', 'refresh'); } else { redirect(ADMIN_URL . '/blog/edit/' . $id, 'refresh'); } } else { $this->session->set_flashdata('error', 'Failed to insert data'); } } else { $data = array(); foreach ($this->validation as $field) { $data[$field['field']] = set_value($field['field']); } } $this->template->title('Mexious Photography', 'Blog', 'Create')->set('data', $data)->build('admin/blog_form'); }
/** * Create a new group role * * @access public * @return void */ public function add() { if ($_POST) { $this->form_validation->set_rules($this->validation_rules); if ($this->form_validation->run()) { $this->group_m->insert($_POST) ? $this->session->set_flashdata('success', sprintf(lang('groups.add_success'), $this->input->post('name'))) : $this->session->set_flashdata('error', sprintf(lang('groups.add_error'), $this->input->post('name'))); redirect('admin/groups'); } } // Loop through each validation rule foreach ($this->validation_rules as $rule) { $group->{$rule['field']} = set_value($rule['field']); } $this->template ->title($this->module_details['name'], lang('groups.add_title')) ->set('group', $group) ->build('admin/form', $this->data); }
function create() { $albums = $this->photo_albums_m->get_all(); $this->data->albums = array(); foreach ($albums as $album) { $this->data->albums[$album->parent][] = $album; } $this->load->library('form_validation'); $this->form_validation->set_rules($this->validation_rules); foreach ($this->validation_rules as $rule) { $album->{$rule['field']} = set_value($rule['field']); } if ($this->form_validation->run()) { if ($this->photo_albums_m->insert($_POST)) { $this->session->set_flashdata('success', sprintf(lang('photo_albums.add_success'), $this->input->post('title'))); } else { $this->session->set_flashdata(array('error' => lang('photo_albums.add_error'))); } redirect('admin/photos'); } $this->data->album =& $album; // Load WYSIWYG editor $this->template->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_metadata(js('form.js', 'photos')); $this->template->build('admin/form', $this->data); }
public function output() { htmlspecialchars($tring); //automatically filtered echo anchor('url', 'linkname', 'attributes'); echo form_input('name', set_value('name')); }
function set_form() { $i_user = array('name' => 'username', 'value' => set_value('username'), 'placeholder' => 'ชื่อผู้ใช้', 'autofocus' => true, 'class' => 'form-control'); $i_pass = array('name' => 'password', 'placeholder' => 'รหัสผ่าน', 'class' => 'form-control'); $data = array('username' => form_input($i_user), 'password' => form_password($i_pass)); return $data; }
function login() { $this->data['title'] = "Login"; //validate form input $this->form_validation->set_rules('identity', 'Identity', 'trim|required'); $this->form_validation->set_rules('password', 'Password', 'trim|required'); if ($this->form_validation->run() == true) { // check to see if the user is logging in // check for "remember me" $remember = (bool) $this->input->post('remember'); if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) { //if the login is successful //redirect them back to the home page $this->session->set_flashdata('message', $this->ion_auth->messages()); redirect('/', 'refresh'); } else { // if the login was un-successful // redirect them back to the login page $this->session->set_flashdata('message', $this->ion_auth->errors()); redirect('auth/login', 'refresh'); // use redirects instead of loading views // for compatibility with MY_Controller libraries } } else { // the user is not logging in so display the login page // set the flash data error message if there is one $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message'); $this->data['identity'] = array('name' => 'identity', 'id' => 'identity', 'class' => 'form-control', 'value' => set_value('identity'), 'placeholder' => 'Identidade', 'value' => $this->form_validation->set_value('identity')); $this->data['password'] = array('name' => 'password', 'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Password'); $this->load->view('auth/login', $this->data); //$this->_render_page('auth/login', $this->data); } }
function add() { $this->checkLogin(); $this->load->library('form_validation'); $this->data['custom_error'] = ''; if ($this->form_validation->run('venta_productos') == false) { $this->data['custom_error'] = validation_errors() ? '<div class="form_error">' . validation_errors() . '</div>' : false; } else { $data = array('venta_id' => set_value('venta_id'), 'producto_id' => set_value('producto_id'), 'cantidad' => set_value('cantidad')); //add cause sometimes, when pass empty string I get troubles in the insert foreach ($data as $i => $value) { if ($value === "") { $data[$i] = null; } } if ($this->codegen_model->add('venta_productos', $data) == TRUE) { //$this->data['custom_error'] = '<div class="form_ok"><p>Added</p></div>'; // or redirect redirect(base_url() . 'index.php/venta_productos/manage/'); } else { $this->data['custom_error'] = '<div class="form_error"><p>An Error Occured.</p></div>'; } } $this->load->view('venta_productos_add', $this->data); //$this->template->load('content', 'venta_productos_add', $this->data); }
public function block_content($context, array $blocks = array()) { // line 4 echo "<div class=\"btn-group pull-right\">\n <a class=\"btn btn-primary btn-small\" href=\""; // line 5 echo twig_escape_filter($this->env, site_url("tugas/tambah_soal/" . $this->getAttribute(isset($context["tugas"]) ? $context["tugas"] : null, "id")), "html", null, true); echo "\">Tambah Pertanyaan</a>\n "; // line 6 if ($this->getAttribute(isset($context["tugas"]) ? $context["tugas"] : null, "type_id") == 3) { // line 7 echo " <a class=\"btn btn-primary btn-small\" href=\""; echo twig_escape_filter($this->env, site_url("tugas/tambah_pilihan/" . $this->getAttribute(isset($context["tugas"]) ? $context["tugas"] : null, "id") . "/" . $this->getAttribute(isset($context["pertanyaan"]) ? $context["pertanyaan"] : null, "id")), "html", null, true); echo "\">Tambah Pilihan</a>\n "; } // line 9 echo "</div>\n\n<h4>Edit Pertanyaan ke "; // line 11 echo twig_escape_filter($this->env, isset($context["no_pertanyaan"]) ? $context["no_pertanyaan"] : null, "html", null, true); echo "</h4>\n"; // line 12 echo get_flashdata("tugas"); echo "\n\n"; // line 14 echo form_open("tugas/edit_soal/" . $this->getAttribute(isset($context["tugas"]) ? $context["tugas"] : null, "id") . "/" . $this->getAttribute(isset($context["pertanyaan"]) ? $context["pertanyaan"] : null, "id")); echo "\n<table class=\"table table-striped\" style=\"margin-top:20px;\">\n <tbody>\n <tr>\n <td>\n <textarea name=\"pertanyaan\" id=\"pertanyaan\" style=\"height:400px;width:100%;\">"; // line 19 echo set_value("pertanyaan", html_entity_decode($this->getAttribute(isset($context["pertanyaan"]) ? $context["pertanyaan"] : null, "pertanyaan"))); echo "</textarea>\n "; // line 20 echo form_error("pertanyaan"); echo "\n </td>\n <tr>\n <tr>\n <td colspan=\"2\">\n <button type=\"submit\" class=\"btn btn-primary\">Update</button>\n </td>\n </tr>\n </tbody>\n</table>\n"; // line 30 echo form_close(); echo "\n"; }