Exemplo n.º 1
0
 function edit($id = false)
 {
     $this->load->library('form_validation');
     #
     $statuses = new Translate_status();
     $recipe = new Translate_recipe();
     $recipe->get_by_id($id);
     #vihodit esli net takogo id
     # Js function from main.js which loads by default
     array_push($this->data['js_functions'], array('name' => 'translate_recipes_init', 'data' => FALSE));
     #
     if ($this->form_validation->run('translate_recipe')) {
         $recipe->name = $this->input->post('text_name');
         $recipe->name_translate = $this->input->post('text_name_translate');
         $recipe->custom = $this->input->post('text_custom');
         $recipe->custom_translate = $this->input->post('text_custom_translate');
         $recipe->ingredients = $this->input->post('text_ingredients');
         $recipe->ingredients_translate = $this->input->post('text_ingredients_translate');
         $recipe->preparation = $this->input->post('text_preparation');
         $recipe->preparation_translate = $this->input->post('text_preparation_translate');
         $recipe->url = $this->input->post('inp_url');
         $recipe->comments = $this->input->post('comments');
         $recipe->status = $this->input->post('rdo_statuses');
         if ($recipe->save()) {
             $this->data['form_success'] = 'Рецепт Сохранен';
         } else {
             $this->data['form_error'] = 'error';
         }
     } else {
         $this->data['form_error'] = validation_errors();
     }
     $this->data['recipe'] = $recipe;
     $this->data['dm_statuses'] = $statuses->get_iterated();
     $this->template->load('/admin/templates/main_template', '/admin/translate_recipes/edit', $this->data);
 }
Exemplo n.º 2
0
 function translate_recipe_name_valid_insert()
 {
     $recipe = new Translate_recipe();
     // esli recept translate redaktiruetsya - to budet peredano ego id a znachit ego nado iskluchit iz proverki
     $current_recipe_translate = $this->input->post('recipe_translate_id');
     if ($current_recipe_translate) {
         $recipe->where('id != ' . $current_recipe_translate);
     }
     $recipe->get_by_name(trim($this->input->post('text_name')));
     echo json_encode(!$recipe->exists());
 }