public function action_edit($id = null, $one = null, $two = null) { $redirect = $two ? $one . '/' . $two : $one; $auction = Model_Auction::find($id); $val = Model_Auction::validate_edit(); if ($val->run()) { $auction->item_count = Input::post('item_count'); $auction->price = Input::post('price'); $auction->memo = Input::post('memo'); if (\Security::check_token() && $auction->save()) { Session::set_flash('success', e('Updated auction #' . $auction->auc_id)); Response::redirect('admin/' . $redirect); } else { Session::set_flash('error', e('Could not update auction #' . $auction->auc_id)); } } else { if (Input::method() == 'POST') { $auction->item_count = $val->validated('item_count'); $auction->price = $val->validated('price'); $auction->memo = $val->validated('memo'); Session::set_flash('error', $val->error()); } $this->template->set_global('auction', $auction, false); } $this->template->set_global('redirect', $redirect, false); $this->template->title = $auction->title; $this->template->content = View::forge('admin/auction/edit'); }
public function action_index() { $data["subnav"] = array('index' => 'active'); $data['items'] = Model_Auction::find('all', ['related' => ['user'], 'where' => ['part_id' => null, 'username' => 'vyacheslav']]); $this->template->title = 'Admin/won » Index'; $this->template->content = View::forge('admin/won/index', $data); }
public function post_createpart() { $result = ''; $val_error = []; $combine_id = (int) \Input::post('combine_id'); $ids = \Input::post('ids'); if ($ids) { $part_id = null; if ($combine_id && \Model_part::find($combine_id)) { $part_id = $combine_id; $result = 'Part ID: ' . $part_id . ' was successfully updated'; } else { $part = new \Model_part(); if ($part->save()) { $part_id = $part->id; } $result = 'Part ID: ' . $part_id . ' was successfully created'; } foreach ($ids as $id) { $auction = \Model_Auction::find($id); $auction->part_id = $part_id; $auction->save(); } } else { $val_error[] = 'Could not create new part'; } $this->response(['result' => $result, 'error' => implode('<br>', (array) $val_error)]); }