File "mtestimonial.php"

Full Path: /home/ichhrkpd/public_html/application/models/database/public_html/idcm/mtestimonial.php
File size: 9.8 KB
MIME-type: text/x-php
Charset: utf-8

<?php 
			
/**
 * Version 1.0.0
 * Creation date: 15/Feb/2015
 * @Written By: S.M. Sarwar Hasan
 *     Genuity Systems
CREATE TABLE `batch` (
	`batch_id` int(5) NOT NULL AUTO_INCREMENT,
	`batch_title` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
	`batch_year` int(4) NOT NULL,
	`year_no` int(1) NOT NULL DEFAULT '1',
	`batch_group` char(1) NOT NULL DEFAULT 'A' COMMENT 'A for Science, B for Arts, C for Commerce',
	`status` char(1) NOT NULL DEFAULT 'A',
	 PRIMARY KEY (`batch_id`)
);
 */						
class Mtestimonial extends GSModel{
	var $test_sl;
	var $std_reg;
	var $dois;
	var $hsc_gpa;
	var $passing_year;
	var $status;
	
	
	
		function __construct() {
			parent::__construct ();
			$this->SetValidation();	
			$this->tableName="testimonial";
			$this->primaryKey="test_sl";
			
			//$this->magic_quotes_active = get_magic_quotes_gpc();
			//$this->real_escape_string_exists = function_exists( "mysql_real_escape_string" );
		}
			
	 function Reset(){
		$this->rtype_id=$this->rtype_name=$this->description=$this->status=null;

	}

	public function escape_value( $value ) {
		if( $this->real_escape_string_exists ) { // PHP v4.3.0 or higher
			// undo any magic quote effects so mysql_real_escape_string can do the work
			if( $this->magic_quotes_active ) { $value = stripslashes( $value ); }
			$value = mysql_real_escape_string( $value );
		} else { // before PHP v4.3.0
			// if magic quotes aren't already on then add slashes manually
			if( !$this->magic_quotes_active ) { $value = addslashes( $value ); }
			// if magic quotes are active, then the slashes already exist
		}
		return $value;
	}
	

	
	function SetValidation(){
		$this->validations=array(
			"admin_pid"=>array("Text"=>"admin_pid", "Rule"=>"required|xss_clean"),
			"email"=>array("Text"=>"Email Address", "Rule"=>"required|xss_clean"),
			"password"=>array("Text"=>"Password", "Rule"=>"required|xss_clean"),
			"fname"=>array("Text"=>"First Name", "Rule"=>"required|xss_clean"),
			"lname"=>array("Text"=>"Last Name", "Rule"=>"required|xss_clean"),
			"title"=>array("Text"=>"Title", "Rule"=>"required|xss_clean"),
			//"time_zone"=>array("Text"=>"time_zone", "Rule"=>""),
			//"short_bio"=>array("Text"=>"short_bio", "Rule"=>""),
			//"role"=>array("Text"=>"role", "Rule"=>""),
			"status"=>array("Text"=>"status", "Rule"=>"")
		);
	}
	
	/*Use these time zones: Delete all others...
1. Eastern Standard Time
2. Pacific Standard Time
3. Mountain Standard Time
4. Central Standard Time
*/
	
	 function GetAddForm($isEdit,$label_col=5,$input_col=7,$mainobj=null){
	 	//$tzlist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);GPrint($tzlist);
	 	//http://stackoverflow.com/questions/1727077/generating-a-drop-down-list-of-timezones-with-php
	 	$timezonesArr = array (
	 			'-5' => '[UTC - 5] Eastern Standard Time',
	 			'-8' => '[UTC - 8] Pacific Standard Time',
	 			'-7' => '[UTC - 7] Mountain Standard Time',
	 			'-6' => '[UTC - 6] Central Standard Time'
	 	);	 	
		
				if(!$mainobj){
				$mainobj=$this;
				}
				
				$role = $this->session->GetAdminData ()->role;
				
					?>
					
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="fname"><?php _e("First Name"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="50"  value="<?php echo  $mainobj->GetPostValue("fname");?>" class="form-control" id="fname" name="fname" 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="lname"><?php _e("Last Name"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="50"  value="<?php echo  $mainobj->GetPostValue("lname");?>" class="form-control" id="lname" name="lname" placeholder="Last Name" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Last Name is required");?>">
		      	</div>
		      </div> 
		      
		      
		      <?php if($role == 'S'){?>
		      <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="role"><?php _e("Role"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">
	      			<select name="role" class="form-control"> 
						<option <?php echo $mainobj->role=="V"?' selected="selected" ':"";?> value="V">Volunteer</option>
						<option <?php echo $mainobj->role=="A"?' selected="selected" ':"";?> value="A">Admin</option>
						<option <?php echo $mainobj->role=="S"?' selected="selected" ':"";?> value="S">Super Admin</option>
					</select>		      	
		      	</div>
		     </div>	
		     <?php }?>	
		     
		    <?php if($role == 'A'){?>
		      <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="role"><?php _e("Role"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">
	      			<select name="role" class="form-control"> 
						<option <?php echo $mainobj->role=="V"?' selected="selected" ':"";?> value="V">Volunteer</option>
					</select>		      	
		      	</div>
		     </div>	
		     <?php }?>					
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="email"><?php _e("Email Address"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="50"  value="<?php echo  $mainobj->GetPostValue("email");?>" class="form-control" id="email" name="email" placeholder="Email Address" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Email Address is required");?>">
		      	</div>
		      </div> 
			
			 <?php if(!$isEdit){ ?>
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="password"><?php _e("Password"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="32"  value="<?php echo  $mainobj->GetPostValue("password");?>" class="form-control" id="password" name="password" placeholder="Password" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Password is required");?>">
		      	</div>
		      </div> 
		      <?php }?>
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="title"><?php _e("Title"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<input type="text" maxlength="50"  value="<?php echo  $mainobj->GetPostValue("title");?>" class="form-control" id="title" name="title" placeholder="Title" data-bv-notempty="true" 	data-bv-notempty-message="<?php  _e("Title is required");?>">
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="time_zone"><?php _e("Time Zone"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">    
	      			<select name="time_zone" class="form-control">
						<?php foreach ($timezonesArr as $key => $zone) { ?>
							<option <?php echo $mainobj->time_zone==$key?' selected="selected" ':"";?>  value="<?php echo $key;?>"><?php echo $zone;?></option>
						<?php } ?>
					</select>		      	               			     	
		      	</div>
		      </div> 
			
			 <div class="form-group">
		      	<label class="control-label col-md-<?php echo $label_col;?>" for="short_bio"><?php _e("Short Biography"); ?></label>
		      	<div class="col-md-<?php echo $input_col;?>">                   			     	
		      		<textarea class="form-control" id="short_bio" name="short_bio" placeholder="Enter ..." rows="3" ><?php echo  $mainobj->GetPostValue("short_bio");?></textarea>
		      	</div>
		      </div> 
		      
		     <?php if($isEdit){ ?> 
			 <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;?>">
	      			<select name="status" class="form-control"> 
						<option <?php echo $mainobj->status=="A"?' selected="selected" ':"";?> value="A">Active</option>
						<option <?php echo $mainobj->status=="I"?' selected="selected" ':"";?> value="I">Inactive</option>
					</select>		      	
		      	</div>
		     </div>		      
			<?php }?>
		      
		      <div class="form-group">		      	
		      	
		      	<div class="col-md-9 text-right">			      	
					<div class="fileUpload btn btn-primary m-r-zero">
					    <span>Add photo</span>
					    <input id="uploadBtn" name="file_upload" type="file" class="upload" />
					</div>	
					<br/><input id="uploadFile" class="form-control" placeholder="Choose File" disabled="disabled" />	      	
		      	</div>	
		      	<div class="col-md-3 text-left">
		      		<?php 
		      			$image_link=base_url()."img/admin/user.png";
						if(file_exists(BASEPATH."../img/admin/".$mainobj->admin_pid.".jpg")){
							$image_link=base_url()."img/admin/".$mainobj->admin_pid.".jpg?v=".filemtime(BASEPATH."../img/admin/".$mainobj->admin_pid.".jpg");
						}
					?>
		      	<img id="inst_img" style="height:100px;" class="img-thumbnail" border="0" alt="<?php echo $mainobj->fname;?>" title="<?php echo $mainobj->fname;?>" src="<?php echo $image_link;?>">
		      	</div>
					
		      </div> 
			<script type="text/javascript">
				document.getElementById("uploadBtn").onchange = function () {
				    document.getElementById("uploadFile").value = this.value;
				    
				};
				$("#uploadBtn").change(function(){
				    readURL(this,"#inst_img");				  
				});
			</script>		      
			
			<?php 
	}

}


?>