Ejemplo n.º 1
0
 public function _validate_date()
 {
     if ($this->time <= time()) {
         return $this->error_message("_validate_date", "Incorrect Date");
     }
     $GameBlock = new Game_Block();
     if ($GameBlock->where(array("fixture_id" => $this->fixture_id, "time" => $this->time))->count()) {
         return $this->error_message("_validate_date", "There is already one game in this block with this date.");
     }
     return true;
 }
Ejemplo n.º 2
0
 public function add()
 {
     Auth::RequireManager();
     $this->template->setData("SelectedTab", "Games I manage");
     $this->Fixture = new Fixture();
     if ($this->input->post()) {
         $this->Fixture->type = $this->input->post("type");
         $this->Fixture->location = $this->input->post("location");
         $this->Fixture->address = $this->input->post("address");
         $this->Fixture->postcode = $this->input->post("postcode");
         $this->Fixture->directions = $this->input->post("directions");
         $this->Fixture->pitch_cost = $this->input->post("pitch_cost");
         $this->Fixture->owner = Auth::Get("id");
         $this->Fixture->blocks = $this->input->post("blocks");
         $this->Fixture->player_cost = $this->input->post("player_cost");
         $this->Fixture->payp_cost = $this->input->post("payp_cost");
         if ($this->Fixture->save()) {
             $this->Account = new Account(Auth::Get("id"));
             if (!$this->Account->exists()) {
                 Session::GoBack("Your account could not be loaded.");
             }
             // Relate this fixture to this account
             $this->Account->save($this->Fixture);
             // Add Games
             for ($i = 1; $i <= $this->Fixture->blocks; $i++) {
                 $GameBlock = new Game_Block();
                 $GameBlock->fixture_id = $this->Fixture->id;
                 $GameBlock->time = 0;
                 $GameBlock->position_names = 0;
                 $GameBlock->positions = $this->input->post("type");
                 $GameBlock->team_1 = "Red Team";
                 $GameBlock->team_2 = "Orange Team";
                 $GameBlock->save();
             }
             if ($_FILES['userfile']['name']) {
                 $config['upload_path'] = './public/uploads/';
                 $config['allowed_types'] = 'gif|jpg|png';
                 $config['max_size'] = '100';
                 $config['max_width'] = '1024';
                 $config['max_height'] = '768';
                 $config['overwrite'] = TRUE;
                 $config['encrypt_name'] = TRUE;
                 $this->load->library('upload', $config);
                 if (!$this->upload->do_upload()) {
                     $this->errors = $this->upload->display_errors();
                 } else {
                     $config = array();
                     $data = $this->upload->data();
                     $config['image_library'] = 'gd2';
                     $config['source_image'] = './public/uploads/' . $data['file_name'];
                     $config['create_thumb'] = FALSE;
                     $config['maintain_ratio'] = FALSE;
                     $config['width'] = 194;
                     $config['height'] = 113;
                     $this->load->library('image_lib', $config);
                     $this->image_lib->resize();
                     $this->Fixture->image = $data['file_name'];
                     $this->Fixture->save();
                     redirect('fixtures/manage_fixture/' . $this->Fixture->id);
                 }
             } else {
                 redirect('fixtures/manage_fixture/' . $this->Fixture->id);
             }
         } else {
             $this->errors = $this->Fixture->error->string;
         }
     }
     $this->load->view("fixtures/add");
 }