Example #1
0
 public function action_edit($id = null)
 {
     $post = Model_Post::find($id, array('where' => $this->status_where));
     if ($this->current_user == null || empty($post)) {
         Response::redirect('welcome/404', 'location', 404);
     }
     $fieldset = $this->_fieldset()->populate($post, true);
     if (Input::method() == 'POST') {
         if ($fieldset->validation()->run()) {
             $fields = $fieldset->validated();
             foreach ($fields as $key => $value) {
                 $post->{$key} = $value;
             }
             $post->dive_time = Model_Post::calc_diff_of_time($post->exit, $post->entry);
             $post->user_id = $this->current_user->id;
             $post->creatures = Model_Creature::parseCreatures(Input::post('report'));
             if ($post->save()) {
                 Session::set_flash('success', e('Updated log #' . $id));
                 Response::redirect('log/edit/' . $id);
             } else {
                 Session::set_flash('error', e('Could not update log #' . $id));
             }
         }
     }
     $data['post'] = $post;
     $this->template->set_global('fieldset', $fieldset, false);
     $this->template->title = ' | ログを編集する';
     $this->template->set_global('title', 'ログを編集する', false);
     $this->template->content = View::forge('log/edit', $data);
     $this->template->set_global('noindex', true);
 }
Example #2
0
 public static function getList()
 {
     return json_encode(\Arr::pluck(Model_Creature::find('all', array('select' => 'name')), 'name'));
 }
Example #3
0
<script>
$(document).ready(function() {
    $("#form_report").select2({
        tags:<?php 
echo Model_Creature::getList();
?>
,
            tokenSeparators: [","]});

        $("#form_diving_shop").select2({
            tags:<?php 
echo Model_Post::getTypeaheadList('diving_shop');
?>
,
                tokenSeparators: [","]});

            $("#form_location").select2({
                tags:<?php 
echo Model_Post::getTypeaheadList('location');
?>
,
                    tokenSeparators: [","]});

                $("#form_point").select2({
                    tags:<?php 
echo Model_Post::getTypeaheadList('point');
?>
,
                        tokenSeparators: [","]});
});
Example #4
0
 private function _form($post)
 {
     $post->date = Input::post('date');
     $post->location = Input::post('location');
     $post->point = Input::post('point');
     $post->point_type = Input::post('point_type');
     $post->purpose_of_dive = Input::post('purpose_of_dive');
     $post->diving_shop = Input::post('diving_shop');
     $post->entry = Input::post('entry');
     $post->exit = Input::post('exit');
     $post->water_temp_top = Input::post('water_temp_top');
     $post->water_temp_bottom = Input::post('water_temp_bottom');
     $post->depth_of_water_ave = Input::post('depth_of_water_ave');
     $post->depth_of_water_max = Input::post('depth_of_water_max');
     $post->pressure_start = Input::post('pressure_start');
     $post->pressure_end = Input::post('pressure_end');
     $post->dive_time = Model_Post::calc_diff_of_time(Input::post('exit'), Input::post('entry'));
     $post->weather = Input::post('weather');
     $post->air_temp = Input::post('air_temp');
     $post->wind = Input::post('wind');
     $post->wind_type = Input::post('wind_type');
     $post->wave = Input::post('wave');
     $post->suit = Input::post('suit');
     $post->suit_thickness = Input::post('suit_thickness');
     $post->weight = Input::post('weight');
     $post->computer = Input::post('computer');
     $post->tank = Input::post('tank');
     $post->tank_cap = Input::post('tank_cap');
     $post->visibility = Input::post('visibility');
     $post->impression = Input::post('impression');
     $post->buddy = Input::post('buddy');
     $post->instructor_and_guide = Input::post('instructor_and_guide');
     $post->report = Input::post('report');
     $post->comment = Input::post('comment');
     $post->status = Input::post('status');
     $post->user_id = $this->current_user->id;
     $post->creatures = Model_Creature::parseCreatures(Input::post('report'));
 }
Example #5
0
 public function view()
 {
     $this->tags = Model_Creature::getList();
 }