File "mstudents.php"
Full Path: /home/ichhrkpd/public_html/application/models/mstudents.php
File size: 8.88 KB
MIME-type: text/plain
Charset: utf-8
<?php
class Mstudents extends GSModel{
var $std_reg;
var $batch_id;
var $std_roll;
var $sub_ids;
var $opt_ids;
var $name;
var $fname;
var $mname;
var $std_mobile;
var $email;
var $guardian_name;
var $std_session;
var $guardian_mobile;
var $present_address;
var $permanent_address;
var $dob;
var $gender;
var $ssc_equi;
var $ssc_board;
var $passing_year;
var $cgpa;
var $is_eligible;
var $comments;
var $status;
function __construct() {
parent::__construct ();
$this->SetValidation();
$this->tableName="students";
$this->primaryKey="std_reg";
}
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($std_reg="", $std_mobile=""){
//echo $std_reg.$std_mobile;die;
$this->std_reg($std_reg);
if($this->Select()){
//if($this->password==md5($password)){
if($this->std_mobile==$std_mobile && $this->status=="A"){
//echo "oxford";die;
$this->SetStudentSession();
return true;
}
}
return false;
}
function SetStudentSession($data=null,$isLoggedIn=true){
if(empty($data)){
$data=$this;
}
// Gprint($data);die;
/*
[std_reg] => 1518824976
[batch_id] => 6
[std_roll] => 285
[sub_ids] => 101,102,107,108,275,269,270,123,124,267,268,121,122
[opt_ids] => 123,124
[name] => SHARMIN AKTER
[fname] => ABED ALI
[mname] => FIROZA BEGUM
[std_mobile] => 01797361533
[email] =>
[guardian_name] => ABED ALI
[std_session] => 2020-2021
[guardian_mobile] => 01797361533
[present_address] => RANIRBANDAR CHIRIRBANDAR DINAJPUR
[permanent_address] => RANIRBANDAR CHIRIRBANDAR DINAJPUR
[dob] => 2005-01-05
[gender] => F
[ssc_equi] => S
[ssc_board] => O
[passing_year] => 2020
[cgpa] => 3.25
[is_eligible] => Y
[comments] =>
[status] => A
*/
$adses=new AdminSession();
$adses->std_reg=$data->std_reg;
$adses->batch_id=$data->batch_id;
$adses->sub_ids=$data->sub_ids;
$adses->opt_ids=$data->opt_ids;
$adses->name=$data->name;
$adses->std_mobile=$data->std_mobile;
$adses->mobile=$data->mobile;
$adses->gender=$data->gender;
$adses->status=$data->status;
$adses->LoggedIn=$isLoggedIn;
$this->session->SetAdminData($adses);
}
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();
}
}
}
?>