File "mteams.php"

Full Path: /home/ichhrkpd/public_html/application/hooks/mteams.php
File size: 10.79 KB
MIME-type: text/x-php
Charset: utf-8

<?php 
			
/**
 * Version 1.0.0
 * Creation date: 02/Dec/2017
 * @Written By: S.M. Sarwar Hasan
 *     Genuity Systems
 */						
class Mteams extends GSModel{	
	var $tid;
	var $eid;
	var $organizer_id;
	var $race_type;
	var $team_name;
	var $first_name;
	var $last_name;
	var $email;
	var $creation_date;
	var $code;
	var $status;
	var $is_claim;


		function __construct() {
			parent::__construct ();
			$this->SetValidation();	
			$this->tableName="teams";
			$this->primaryKey="tid";
		}
			
	 function Reset(){
		$this->tid=$this->eid=$this->organizer_id=$this->race_type=$this->team_name=null;
		$this->first_name=$this->last_name=$this->email=$this->creation_date=$this->code=null;
		$this->status=$this->is_claim=null;

	}



	function SetValidation(){
		$this->validations=array(
			"tid"=>array("Text"=>"tid", "Rule"=>"required|xss_clean"),
			"eid"=>array("Text"=>"eid", "Rule"=>"required|xss_clean"),
			//"organizer_id"=>array("Text"=>"organizer_id", "Rule"=>""),
			//"race_type"=>array("Text"=>"race_type", "Rule"=>""),
			"team_name"=>array("Text"=>"team_name", "Rule"=>"required|xss_clean"),
			"first_name"=>array("Text"=>"first_name", "Rule"=>"required|xss_clean"),
			"last_name"=>array("Text"=>"last_name", "Rule"=>"required|xss_clean"),
			"email"=>array("Text"=>"email", "Rule"=>"required|xss_clean"),
			//"creation_date"=>array("Text"=>"creation_date", "Rule"=>""),
			"code"=>array("Text"=>"code", "Rule"=>"required|xss_clean"),
			//"status"=>array("Text"=>"status", "Rule"=>""),
			"is_claim"=>array("Text"=>"is_claim", "Rule"=>"")
			
		);
	}
	
	public function authenticate($team_code=""){
		$this->code($team_code);
		if($this->Select()){
			$this->SetSingleSession();
			return true;
		}
		return false;
	}

	function SetSingleSession($data=null,$isLoggedIn=true){
		if(empty($data)){
			$data=$this;
		}
		
		//GPrint($data);die;
		/*
    [tid] => 16
    [eid] => 4
    [organizer_id] => 
    [race_type] => W
    [team_name] => fgdf
    [first_name] => dff
    [last_name] => df
    [email] => walid.islam77@gmail.com
    [creation_date] => 2017-12-08 19:04:31
    [code] => sSiw85rWE3XJYmAd
    [status] => A
    [is_claim] => N
		*/
	
		$adses=new SingleSession();
		$adses->tid=$data->tid;
		$adses->eid=$data->eid;
		$adses->organizer_id=$data->organizer_id;
		$adses->race_type=$data->race_type;
		$adses->team_name=$data->team_name;
		$adses->first_name=$data->first_name;
		$adses->last_name=$data->last_name;
		$adses->email=$data->email;
		$adses->creation_date=$data->creation_date;
		$adses->code=$data->code;
		$adses->status=$data->status;
		$adses->is_claim=$data->is_claim;
		$adses->LoggedIn=$isLoggedIn;
		$this->session->SetSingleData($adses);
	
	}
	
	
	
	 function GetAddForm($label_col=5,$input_col=7,$mainobj=null){
		
				if(!$mainobj){
				$mainobj=$this;
				}
					?>
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="tid"><?php _e("Tid"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="11"  value="<?php echo  $mainobj->GetPostValue("tid");?>" class="form-control" id="tid" name="tid" placeholder="Tid" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Tid is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="eid"><?php _e("Eid"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="11"  value="<?php echo  $mainobj->GetPostValue("eid");?>" class="form-control" id="eid" name="eid" placeholder="Eid" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Eid is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="organizer_id"><?php _e("Organizer Id"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="11"  value="<?php echo  $mainobj->GetPostValue("organizer_id");?>" class="form-control" id="organizer_id" name="organizer_id" placeholder="Organizer Id" >
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="race_type"><?php _e("Race Type"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("race_type");?>" class="form-control" id="race_type" name="race_type" placeholder="Race Type" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Race Type is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="team_name"><?php _e("Team Name"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("team_name");?>" class="form-control" id="team_name" name="team_name" placeholder="Team Name" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Team Name is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="first_name"><?php _e("First Name"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("first_name");?>" class="form-control" id="first_name" name="first_name" placeholder="First Name" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("First Name is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="last_name"><?php _e("Last Name"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("last_name");?>" class="form-control" id="last_name" name="last_name" placeholder="Last Name" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Last Name is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="email"><?php _e("Email"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("email");?>" class="form-control" id="email" name="email" placeholder="Email" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Email is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="creation_date"><?php _e("Creation Date"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength=""  value="<?php echo  $mainobj->GetPostValue("creation_date");?>" class="form-control" id="creation_date" name="creation_date" placeholder="Creation Date" >
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="code"><?php _e("Code"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="16"  value="<?php echo  $mainobj->GetPostValue("code");?>" class="form-control" id="code" name="code" placeholder="Code" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Code is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="status"><?php _e("Status"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("status");?>" class="form-control" id="status" name="status" placeholder="Status" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Status is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="is_claim"><?php _e("Is Claim"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("is_claim");?>" class="form-control" id="is_claim" name="is_claim" placeholder="Is Claim" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Is Claim is required");?>">
		      	</div>
		      </div> 
			
			<?php 
	}

	function SelectJoin($QueryString = "", $orderBy = '', $order = 'desc', $limit = 0, $limitStart = 0) {
		if ($this->tableName == null) {
			$this->AddSystemLog ( $this->msg->GetMsg ( 's002' ) );
			return false;
		}
		if ($QueryString != ""){
			$this->GetSelectDB ()->Select ( $QueryString );
		}else {
			$this->GetSelectDB ()->Select ( $this->tableName.".*, e.*" );
		}
		$this->GetSelectDB ()->join("employer AS e", "e.eid=".$this->tableName.".eid", "left");
		foreach ( $this->setProperties as $key => $value ) {
			if (isset ( $this->setOption [$key] )) {
				$this->GetSelectDB ()->where ( $this->tableName.".".$this->$key, '', $this->setOption [$key] );
			} else {
				$this->GetSelectDB ()->where ( $this->tableName.".".$key, $this->$key );
			}
	
		}
		$pkey=$this->primaryKey;
		if(isset($this->setOption[$pkey])){
			$this->GetSelectDB ()->where ( $this->tableName.".".$this->$pkey, '', $this->setOption [$pkey] );
		}else{
			if(!empty($this->$pkey)){
				$this->GetSelectDB ()->where ($this->tableName.".".$pkey,$this->$pkey);
			}
		}
		if ($orderBy != '' && property_exists ( $this, $orderBy )) {
			if ($order == '')
				$order = 'desc';
			$this->GetSelectDB ()->order_by ( $orderBy, $order );
		}
		if ($limit > 0) {
			$this->GetSelectDB ()->limit ( $limit, $limitStart );
		}
		$data = $this->GetSelectDB ()->get ( "teams" )->result ();//here to assign FROM TABLE_NAME
		if (count ( $data ) > 0) {
			$allData = null;
			$i = 0;
			foreach ( $data as $tm ) {
				$allData [$i ++] = $this->BindObject ( $tm, true );
			}
			$this->AddDebugMsg ( "SelectAll of " . get_class ( $this ) . " is found data" );
			return $allData;
		} else {
			$this->AddDebugMsg ( "SelectAll of " . get_class ( $this ) . " return null for  no data found", StatusError );
			return array();
		}
	
	}

}
?>