Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
application
/
examples
:
mteachers.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php class Mteachers extends GSModel{ var $teacher_id; var $email; var $mobile_no; var $password; var $name; var $gender; var $designation; var $dept_id; var $rank; var $type; var $status; function __construct() { parent::__construct (); $this->SetValidation(); $this->tableName="teachers"; $this->primaryKey="teacher_id"; } function Reset(){ $this->teacher_id=$this->email=$this->mobile_no=$this->password=$this->fname=$this->lname=null; $this->designation_id=$this->last_degree=$this->dept_id=$this->role=$this->status=null; } function SetValidation(){ $this->validations=array( "teacher_id"=>array("Text"=>"teacher_id", "Rule"=>"required|xss_clean"), "email"=>array("Text"=>"email", "Rule"=>"required|xss_clean"), "password"=>array("Text"=>"password", "Rule"=>"required|xss_clean"), "fname"=>array("Text"=>"fname", "Rule"=>"required|xss_clean"), "lname"=>array("Text"=>"lname", "Rule"=>"required|xss_clean"), "designation_id"=>array("Text"=>"designation_id", "Rule"=>"required|xss_clean"), "last_degree"=>array("Text"=>"last_degree", "Rule"=>"required|xss_clean"), "dept_id"=>array("Text"=>"dept_id", "Rule"=>"required|xss_clean"), //"role"=>array("Text"=>"role", "Rule"=>""), "status"=>array("Text"=>"status", "Rule"=>"") ); } public function authenticate($email="", $password=""){ $this->email($email); if($this->Select()){ //if($this->password==md5($password)){ if($this->password==md5($password) && $this->status=="A"){ $this->SetTeacherSession(); return true; } } return false; } function SetTeacherSession($data=null,$isLoggedIn=true){ if(empty($data)){ $data=$this; } $TrSes=new TrSession(); $TrSes->teacher_id=$data->teacher_id; $TrSes->email=$data->email; $TrSes->mobile=$data->mobile_no; $TrSes->name=$data->fname . ' '. $data->lname; $TrSes->role='T'; $TrSes->status=$data->status; $TrSes->LoggedIn=$isLoggedIn; $this->session->SetTrData($TrSes); } function GetAddForm($isEdit,$label_col=5,$input_col=7,$mainobj=null){ if(!$mainobj){ $mainobj=$this; } $this->load->model("database/Mdesignation"); $degination_data = $this->Mdesignation->SelectAll(); $this->load->model("database/Mdepartment"); $dept_data = $this->Mdepartment->SelectAll(); ?> <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("Fname 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("Lname 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="50" 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="designation"><?php _e("Designation"); ?></label> <div class="col-md-<?php echo $input_col;?>"> <select name="designation_id" class="form-control"> <?php foreach ($degination_data as $d) { ?> <option <?php echo $mainobj->designation_id==$d->designation_id?' selected="selected" ':"";?> value="<?php echo $d->designation_id;?>"><?php echo $d->designation_name;?></option> <?php } ?> </select> </div> </div> <div class="form-group"> <label class="control-label col-md-<?php echo $label_col;?>" for="dept_id"><?php _e("Department"); ?></label> <div class="col-md-<?php echo $input_col;?>"> <select name="dept_id" class="form-control"> <?php foreach ($dept_data as $dept) { ?> <option <?php echo $mainobj->dept_id==$dept->dept_id?' selected="selected" ':"";?> value="<?php echo $dept->dept_id;?>"><?php echo $dept->dept_name;?></option> <?php } ?> </select> </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.".*,d.dept_name, f.faculty_name, dg.designation_name" ); } $this->GetSelectDB ()->join("department AS d", "d.dept_id=".$this->tableName.".dept_id", "left"); $this->GetSelectDB ()->join("faculty AS f", "f.faculty_id = d.faculty_id", "left"); $this->GetSelectDB ()->join("designation AS dg", "dg.designation_id=".$this->tableName.".designation_id", "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 ( "teachers" )->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(); } } } ?>