File "mracers.php"

Full Path: /home/ichhrkpd/public_html/application/models/database/mracers.php
File size: 16.04 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 Mracers extends GSModel{	
	var $rid;
	var $tid;
	var $member_id;
	var $first_name;
	var $last_name;
	var $email;
	var $age;
	var $sex;
	var $town;
	var $phone;
	var $waiver_code;
	var $is_accepted;
	var $is_paid;
	var $payment_txn;
	var $e_sign;
	var $e_sign_ip;
	var $e_sign_date;


		function __construct() {
			parent::__construct ();
			$this->SetValidation();	
			$this->tableName="racers";
			$this->primaryKey="rid";
		}
			
	 function Reset(){
		$this->rid=$this->tid=$this->member_id=$this->first_name=$this->last_name=null;
		$this->email=$this->age=$this->sex=$this->town=$this->phone=$this->waiver_code=null;
		$this->is_accepted=$this->is_paid=$this->payment_txn=$this->e_sign=$this->e_sign_ip=null;
		$this->e_sign_date=null;

	}



	function SetValidation(){
		$this->validations=array(
			"rid"=>array("Text"=>"rid", "Rule"=>"required|xss_clean"),
			"tid"=>array("Text"=>"tid", "Rule"=>"required|xss_clean"),
			"member_id"=>array("Text"=>"member_id", "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"),
			"age"=>array("Text"=>"age", "Rule"=>"required|xss_clean"),
			//"sex"=>array("Text"=>"sex", "Rule"=>""),
			"town"=>array("Text"=>"town", "Rule"=>"required|xss_clean"),
			"phone"=>array("Text"=>"phone", "Rule"=>"required|xss_clean"),
			"waiver_code"=>array("Text"=>"waiver_code", "Rule"=>"required|xss_clean"),
			//"is_accepted"=>array("Text"=>"is_accepted", "Rule"=>""),
			//"is_paid"=>array("Text"=>"is_paid", "Rule"=>""),
			//"payment_txn"=>array("Text"=>"payment_txn", "Rule"=>""),
			//"e_sign"=>array("Text"=>"e_sign", "Rule"=>""),
			//"e_sign_ip"=>array("Text"=>"e_sign_ip", "Rule"=>""),
			"e_sign_date"=>array("Text"=>"e_sign_date", "Rule"=>"")
			
		);
	}
	 function GetAddForm($isEdit,$label_col=5,$input_col=7,$mainobj=null){
		
				if(!$mainobj){
				$mainobj=$this;
				}
					?>
			
			
			<div class="row">
				<div class="col-md-6">
				
					 <div class="form-group">
                          	<label class="control-label" for="first_name"><?php _e("First Name"); ?></label>
                            <input id="first_name" type="text" maxlength="100" name="first_name" class="form-control" placeholder="First Name *" required="required" data-error="First Name is required.">
                            <div id="first_name_err" class="help-block with-errors"></div>
                     </div>	
                     
					 <div class="form-group">
                          	<label class="control-label" for="last_name"><?php _e("Last Name"); ?></label>
                            <input id="last_name" type="text" maxlength="100" name="last_name" class="form-control" placeholder="Last Name *" required="required" data-error="Last Name is required.">
                            <div id="last_name_err" class="help-block with-errors"></div>
                     </div>
                     
                     <div class="form-group">
                          <label class="control-label" for="email"><?php _e("Email"); ?></label>
                          <input id="form_email" type="email" maxlength="100" autocomplete="off" name="email" class="form-control" placeholder="Email *" required="required" data-error="Valid email is required.">
                          <div class="help-block with-errors"></div><div id="check_race_email" style="color: #a94442;"></div>
                          <input type="hidden" name="email_exists" id="email_exists" value="N">
                    </div>
                    
     				<div class="form-group">
      					<label class="control-label" for="sex"><?php _e("Sex"); ?></label>
			      			<select name="sex" id="sex" class="form-control"> 
								<option value="M">Male</option>
								<option value="F">Female</option>
								<option value="X">Mixed</option>
							</select>		      	
				     </div>                     
                    

               </div>
               
               <div class="col-md-6"> 
					<div class="form-group">
                         <label class="control-label" for="age"><?php _e("Age"); ?></label>
                         <input id="age" type="number" min="16" max="999" step="1" maxlength="3" name="age" class="form-control" placeholder="Age *" required="required" data-error="All participants must be at least sixteen (16) years or age to run or walk">
                         <div id="age_err" class="help-block with-errors"></div>
                    </div>
				     
					 <div class="form-group">
                          	<label class="control-label" for="phone"><?php _e("Phone"); ?></label>
                            <input type="tel"  id="phone" maxlength="15" name="phone" class="form-control" placeholder="Phone *" required="required" data-error="Please enter valid number.">
                            <div id="phone_err" class="help-block with-errors"></div>
                     </div>				                          
                    
					 <div class="form-group">
                          	<label class="control-label" for="town"><?php _e("City of Residence"); ?></label>
                            <input id="town" type="text" maxlength="100" name="town" class="form-control" placeholder="City of Residence *" required="required" data-error="City of Residence is required.">
                            <div id="town_err" class="help-block with-errors"></div>
                     </div>
                </div> 
            </div>                   
			
			<?php 
	}

	function GetAddForm_bk($isEdit,$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="rid"><?php _e("Rid"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="11"  value="<?php echo  $mainobj->GetPostValue("rid");?>" class="form-control" id="rid" name="rid" placeholder="Rid" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Rid is required");?>">
			      	</div>
			      </div> 
				
				 <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="member_id"><?php _e("Member Id"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("member_id");?>" class="form-control" id="member_id" name="member_id" placeholder="Member Id" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Member Id 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="age"><?php _e("Age"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="3"  value="<?php echo  $mainobj->GetPostValue("age");?>" class="form-control" id="age" name="age" placeholder="Age" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Age is required");?>">
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="sex"><?php _e("Sex"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("sex");?>" class="form-control" id="sex" name="sex" placeholder="Sex" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Sex is required");?>">
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="town"><?php _e("Town"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("town");?>" class="form-control" id="town" name="town" placeholder="Town" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Town is required");?>">
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="phone"><?php _e("Phone"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="15"  value="<?php echo  $mainobj->GetPostValue("phone");?>" class="form-control" id="phone" name="phone" placeholder="Phone" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Phone is required");?>">
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="is_accepted"><?php _e("Is Accepted"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("is_accepted");?>" class="form-control" id="is_accepted" name="is_accepted" placeholder="Is Accepted" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Is Accepted is required");?>">
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="is_paid"><?php _e("Is Paid"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="1"  value="<?php echo  $mainobj->GetPostValue("is_paid");?>" class="form-control" id="is_paid" name="is_paid" placeholder="Is Paid" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Is Paid is required");?>">
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="payment_txn"><?php _e("Payment Txn"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="24"  value="<?php echo  $mainobj->GetPostValue("payment_txn");?>" class="form-control" id="payment_txn" name="payment_txn" placeholder="Payment Txn" >
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="e_sign"><?php _e("E Sign"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("e_sign");?>" class="form-control" id="e_sign" name="e_sign" placeholder="E Sign" >
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="e_sign_ip"><?php _e("E Sign Ip"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength="100"  value="<?php echo  $mainobj->GetPostValue("e_sign_ip");?>" class="form-control" id="e_sign_ip" name="e_sign_ip" placeholder="E Sign Ip" >
			      	</div>
			      </div> 
				
				 <div class="form-group">
			      	<label class="control-label col-md-<?php echo $label_col;?>" for="e_sign_date"><?php _e("E Sign Date"); ?></label>
			      	<div class="col-md-<?php echo $input_col;?>">                   			     	
			      		<input type="text" maxlength=""  value="<?php echo  $mainobj->GetPostValue("e_sign_date");?>" class="form-control" id="e_sign_date" name="e_sign_date" placeholder="E Sign Date" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("E Sign Date is required");?>">
			      	</div>
			      </div> 
				
				<?php 
		}
		
		
		function SelectJoin($QueryString = "", $orderBy = '', $order = 'asc', $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.".*, t.team_name, e.employer_name, e.employer_type" );
			}
			$this->GetSelectDB ()->join("teams AS t", "t.tid=".$this->tableName.".tid", "left");
			$this->GetSelectDB ()->join("employer AS e", "e.eid=t.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 = 'asc';
				$this->GetSelectDB ()->order_by ( $orderBy, $order );
			}
			if ($limit > 0) {
				$this->GetSelectDB ()->limit ( $limit, $limitStart );
			}
			$data = $this->GetSelectDB ()->get ( "racers" )->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();
			}
		
		}
}
?>