Пример #1
0
 protected function onValidationEvent($op, $id = false)
 {
     $this->data['branches'] = dd2menu('branches', ['branch_id' => 'name']);
     $this->data['usergroups'] = dd2menu('usergroups', ['usergroup_id' => 'name']);
     $this->data['user_status'] = dd2menu('user_status', ['user_status_id' => name()]);
     $this->data['languages'] = ddlanguages();
     $config['upload_path'] = './cdn/' . $this->_table;
     $config['allowed_types'] = 'gif|jpg|png|jpeg';
     $this->load->library('upload', $config);
     $required = $op == 'add' ? '1' : '0';
     $this->form_validation->set_rules('branch_id', lang('users_branch_id'), "trim|required");
     $this->form_validation->set_rules('usergroup_id', lang('users_usergroup_id'), "trim|required");
     $this->form_validation->set_rules('language', lang('users_language'), "trim|required");
     $this->form_validation->set_rules('username', lang('users_username'), "trim|required");
     $this->form_validation->set_rules('full_name', lang('users_full_name'), "trim|required");
     $this->form_validation->set_rules('email', lang('users_email'), "trim|required|valid_email");
     $this->form_validation->set_rules('phone', lang('users_phone'), "trim|numeric");
     $this->form_validation->set_rules('mobile', lang('users_mobile'), "trim|required|numeric");
     $this->form_validation->set_rules('password', lang('users_password'), "trim" . $op == 'add' ? '|required' : null);
     $this->form_validation->set_rules('address', lang('users_address'), "trim");
     $this->form_validation->set_rules('notes', lang('users_notes'), "trim");
     $this->form_validation->set_rules('salary', lang('users_salary'), "trim|numeric");
     $this->form_validation->set_rules('commision', lang('users_commision'), "trim|required");
     $this->form_validation->set_rules('id_no', lang('users_id_no'), "trim|required");
     $this->form_validation->set_rules('id_expiredate', lang('users_id_expiredate'), "trim|required");
     $this->form_validation->set_rules('passport_no', lang('users_passport_no'), "trim|required");
     $this->form_validation->set_rules('passport_expiredate', lang('users_passport_expiredate'), "trim|required");
     $this->form_validation->set_rules('status', lang('users_status'), "trim|required");
     $this->form_validation->set_rules('image', lang('users_image'), "callback_file[image," . $required . "]");
 }
Пример #2
0
 public function index()
 {
     $this->load->library("form_validation");
     $data['languages'] = ddlanguages();
     $data['item'] = new stdClass();
     foreach ($this->General_model->get() as $setting) {
         //            if ($setting->key == 'random_cats')
         //                $data['item']->{$setting->key} = unserialize($setting->value);
         //            else
         $data['item']->{$setting->key} = $setting->value;
         $this->form_validation->set_rules('setting[' . $setting->key . ']', $setting->key, "trim");
     }
     if ($this->form_validation->run() == false) {
         //foreach($data['item'] as $item) {
         //    echo '$lang[\'general_settings_'.$item.'\'] = \''.ucfirst($item).'\';'."\n";
         //    echo '<div class="form-group">
         //                                <label class="col-sm-3 control-label">{{ lang(\'settings_'.$item.'\') }}</label>
         //
         //                                <div class="col-sm-9">
         //                                    {{ form_input(\'setting['.$item.']\', set_value(\'setting['.$item.']\', item.'.$item.'), \'class="bg-focus form-control" data-required="true" id="'.$item.'"\') }}
         //                                </div>
         //                            </div>
         //                            <div class="form-group-separator"></div>';
         //}
         $this->twiggy->set($data)->template("general_settings")->display();
     } else {
         //            $this->image();
         $save = $this->input->post('setting');
         //            if ($lcn = $this->input->post('lcn')) {
         //                $lcn['random_cats'] = serialize($lcn['random_cats']);
         ////                if ($this->image_file)
         ////                    $lcn['lcn_image'] = $this->image_file;
         //
         //            }
         //
         //            $save = array_merge($save, $lcn);
         //
         foreach ($save as $key => $value) {
             $this->General_model->key = $key;
             $this->General_model->value = $value;
             $this->General_model->save();
         }
         //            $this->report->set('{report_update_settings}');
         redirect(ADMIN . "/general_settings/index");
     }
 }