public function setUp() { $this->pass = Model_Pass::forge(array('name' => 'test name', 'description' => 'desc', 'logo_text' => 'sample', 'barcode_message' => 'message', 'barcode_format' => 0)); $this->pass->locations[] = Model_Location::forge(array('latitude' => 1.01, 'longitude' => 1.02)); $this->pass->locations[] = Model_Location::forge(array('latitude' => 2.03, 'longitude' => 2.04, 'altitude' => 2.05, 'relevant_text' => 'text')); $this->pass->save(); }
public function action_create() { if (Input::method() == 'POST') { $val = Model_Location::validate('create'); if ($val->run()) { $location = Model_Location::forge(array('name' => Input::post('name'), 'can_sell' => Input::post('can_sell'))); if ($location and $location->save()) { Session::set_flash('success', e('Added location #' . $location->id . '.')); Response::redirect('admin/locations'); } else { Session::set_flash('error', e('Could not save location.')); } } else { Session::set_flash('error', $val->error()); } } $this->template->title = "Locations"; $this->template->content = View::forge('admin/locations/create'); }
$event_numbers = array(); // \DB::query('TRUNCATE TABLE fleamarkets')->execute(); // \DB::query('TRUNCATE TABLE fleamarket_entry_styles')->execute(); // \DB::query('TRUNCATE TABLE fleamarket_abouts')->execute(); // \DB::query('TRUNCATE TABLE locations')->execute(); for ($i = 1; $i <= 2000; $i++) { $group_code = array_rand($group_codes); $group_code_name = $group_codes[$group_code]; $register_type = array_rand($register_types); // 開催地情報 $location_name = array_rand($location_list, 1); $location = $location_list[$location_name]; list($prefecture, $address) = getAddress($location); $prefecture_id = array_search($prefecture, $prefectures); $location_line = array('branch_id' => null, 'name' => $location_name, 'zip' => '100-0001', 'prefecture_id' => $prefecture_id, 'address' => $address, 'googlemap_address' => $location, 'register_type' => $register_types[$register_type], 'created_user' => 0, 'updated_user' => null, 'created_at' => \Date::forge()->format('mysql')); $location = \Model_Location::forge($location_line); $location->save(); $location_id = $location->location_id; // フリマ情報 if (isset($event_numbers[$group_code])) { $event_number = ++$event_numbers[$group_code]; } else { $event_number = $event_numbers[$group_code] = 1; } $event_status = array_rand($event_statuses); $event_reservation_status = array_rand($event_reservation_statuses); $event_month = array_rand($event_months); $event_day = array_rand($event_days); $event_date = '2014-' . $event_months[$event_month] . '-' . $event_days[$event_day]; $event_start = array_rand($event_start_list); $event_end = array_rand($event_end_list);
/** * 会場情報を登録する * * @access private * @param * @return object * @author kobayashi */ private function registerLocation() { $data = $this->getLocationData(); if (!$data) { throw new \Exception(\Model_Error::ER00402); } if (\Input::param('location_id')) { $location = \Model_Location::find(\Input::post('location_id')); $data['updated_user'] = $this->administrator->administrator_id; unset($data['register_type']); unset($data['created_at']); unset($data['created_user']); } else { $location = \Model_Location::forge(); $data['created_user'] = $this->administrator->administrator_id; $data['register_type'] = \Model_Location::REGISTER_TYPE_ADMIN; } if ($location) { $location->set($data)->save(); } return $location; }
public function action_locations($id = null) { $pass = Model_Pass::find($id); if (Input::method() == 'POST') { $val = Model_Location::validate('create'); if ($val->run()) { $location = Model_Location::forge(array('latitude' => \Fuel\Core\Input::post('latitude'), 'longitude' => \Fuel\Core\Input::post('longitude'), 'altitude' => \Fuel\Core\Input::post('altitude', null), 'relevant_text' => \Fuel\Core\Input::post('relevant_text', null))); $pass->locations[] = $location; if ($location and $pass->save()) { Session::set_flash('success', e('Added location #' . $location->id . '.')); \Fuel\Core\Response::redirect('admin/pass/locations/' . $id); return; } else { Session::set_flash('error', e('Could not save location.')); } } else { Session::set_flash('error', $val->error()); } } $this->template->set_global('pass', $pass, false); $this->template->title = "Pass Locations"; $this->template->content = View::forge('admin/pass/locations'); }
/** * 会場情報登録・更新 * * @access private * @param object $fieldset フィールドセット * @param mixed $location_id 会場ID * @return bool * @author ida */ private function saveLocation($fieldset) { $location_data = $this->createLocation($fieldset); if (!empty($location_data['location_id'])) { $location = \Model_Location::find($location_data['location_id']); } else { $location = \Model_Location::forge(); } unset($location_data['location_id']); if ($location->set($location_data)->save()) { return $location; } else { throw new Exception(); } }