File: /home/awaldron/public_html/archive/teampay/application/controllers/create_team.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Create_team extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->library('tank_auth');
}
function index()
{
// Initialize page variables
$data = $this->tank_auth->auth_init( true, '');
$data['page_title'] = "Create New Team";
$data['icon_title'] = "fa-plus-circle";
$data['navon'] = "new_team";
$this->load->view('_header', $data);
$this->load->view('v_newteam', $data);
$this->load->view('_footer', $data);
}
function add() {
// Initialize page variables
$data = $this->tank_auth->auth_init( true, '');
$post = $this->input->post();
// Form Validation
$this->form_validation->set_rules('team_name', 'Team Name', 'trim|required|xss_clean');
$this->form_validation->set_rules('sport_id', 'Sport', 'trim|required|xss_clean');
$this->form_validation->set_rules('team_fee', 'Team Fee', 'trim|required|xss_clean|is_numeric');
$this->form_validation->set_rules('team_fees_due', 'Team Fees Due', 'trim|required|xss_clean');
if ($this->form_validation->run()) { // validation ok
// Format data
$post['team_fees_due'] = datetime( strtotime($post['team_fees_due']) );
$post['team_fee'] = preg_replace("/[^0-9\.]/","", $post['team_fee']);
$post['team_fee'] = number_format( $post['team_fee'], 2 );
$team_id = $this->teampay_model->create_team( $post, $data['user_id'] );
redirect('/my_teams/team/'.$team_id);
} else {
$data['navon'] = 'my_teams';
$data['page_title'] = 'New Team Error';
$data['icon_title'] = 'fa-plus-circle';
$data['message'] = array('Oops, something went wrong with your new team. You probably didn\'t fill out a required field. Click the back button and give it another shot.');
$this->load->view('_header.php', $data);
$this->load->view('auth/general_message', $data);
$this->load->view('_footer.php', $data);
}
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */