Current File : /home/inlingua/www/sensoriumpsychologists.com/franchise_between/student_funcs.php |
<?php
require_once("../../franchise_between/e_wallet_funcs.php");
require_once("../../franchise_back/database_func.php");
class student_funcs
{
private $registration_no,$registration_date,$franchise_id,$child_name,$age,$gender,$dob_date,$education,$school_name,$contact_no,$informant,$c_local,$c_city,$c_district,$c_state,$c_pincode,$p_local,$p_city,$p_district,$p_state,$p_pincode,$problem,$walking,$first_sentence,$toilet_behaviour,$self_help,$sleeping_pattern,$play,$play_group,$type_of_play,$behav_with_family,$reln_with_siblings,$admission_fees;
private $created_by,$created_browser,$created_ip,$updated_by,$updated_browser,$updated_ip,$updated_date;
private $theme_class,$themes_font;
public function __construct()
{
$this->registration_no="";
$this->registration_date="";
$this->theme_class="";
$this->themes_font="";
$this->franchise_id="";
$this->child_name="";
$this->age="";
$this->gender="";
$this->dob_date="";
$this->education="";
$this->school_name="";
$this->contact_no="";
$this->informant="";
$this->c_local="";
$this->c_city="";
$this->c_district="";
$this->c_state="";
$this->c_pincode="";
$this->p_local="";
$this->p_city="";
$this->p_district="";
$this->p_state="";
$this->p_pincode="";
$this->problem="";
$this->walking="";
$this->first_sentence="";
$this->toilet_behaviour="";
$this->self_help="";
$this->sleeping_pattern="";
$this->play="";
$this->play_group="";
$this->type_of_play="";
$this->behav_with_family="";
$this->reln_with_siblings="";
$this->admission_fees="";
$this->created_by="";
$this->created_browser="";
$this->created_ip="";
$this->updated_by="";
$this->updated_browser="";
$this->updated_ip="";
$this->updated_date="0000-00-00 00:00:00";
}
public function set_value($variable_name,$new_value){
switch($variable_name)
{
case 'registration_no':$this->registration_no=$new_value;break;
case 'registration_date':$this->registration_date=$new_value;break;
case 'theme_class':$this->theme_class=$new_value;break;
case 'themes_font':$this->themes_font=$new_value;break;
case 'franchise_id':$this->franchise_id=$new_value;break;
case 'child_name':$this->child_name=$new_value;break;
case 'gender':$this->gender=$new_value;break;
case 'age':$this->age=$new_value;break;
case 'dob_date':$this->dob_date=$new_value;break;
case 'education':$this->education=$new_value;break;
case 'school_name':$this->school_name=$new_value;break;
case 'contact_no':$this->contact_no=$new_value;break;
case 'informant':$this->informant=$new_value;break;
case 'c_local':$this->c_local=$new_value;break;
case 'c_city':$this->c_city=$new_value;break;
case 'c_district':$this->c_district=$new_value;break;
case 'c_state':$this->c_state=$new_value;break;
case 'c_pincode':$this->c_pincode=$new_value;break;
case 'p_local':$this->p_local=$new_value;break;
case 'p_city':$this->p_city=$new_value;break;
case 'p_district':$this->p_district=$new_value;break;
case 'p_state':$this->p_state=$new_value;break;
case 'p_pincode':$this->p_pincode=$new_value;break;
case 'problem':$this->problem=$new_value;break;
case 'walking':$this->walking=$new_value;break;
case 'first_sentence':$this->first_sentence=$new_value;break;
case 'toilet_behaviour':$this->toilet_behaviour=$new_value;break;
case 'self_help':$this->self_help=$new_value;break;
case 'sleeping_pattern':$this->sleeping_pattern=$new_value;break;
case 'play':$this->play=$new_value;break;
case 'play_group':$this->play_group=$new_value;break;
case 'type_of_play':$this->type_of_play=$new_value;break;
case 'behav_with_family':$this->behav_with_family=$new_value;break;
case 'reln_with_siblings':$this->reln_with_siblings=$new_value;break;
case 'admission_fees':$this->admission_fees=$new_value;break;
case 'created_by':$this->created_by=$new_value;break;
case 'created_browser':$this->created_browser=$new_value;break;
case 'created_ip':$this->created_ip=$new_value;break;
}
}
public function get_value($variable_name)
{
$to_return="";
switch($variable_name)
{
case 'registration_no':$to_return=$this->registration_no;break;
case 'registration_date':$to_return=$this->registration_date;break;
case 'theme_class':$to_return=$this->theme_class;break;
case 'theme_font':$to_return=$this->themes_font;break;
case 'child_name':$to_return=$this->child_name;break;
case 'age':$to_return=$this->age;break;
case 'gender':$to_return=$this->gender;break;
case 'dob_date':$to_return=$this->dob_date;break;
case 'education':$to_return=$this->education;break;
case 'problem':$to_return=$this->problem;break;
case 'school_name':$to_return=$this->school_name;break;
}
return $to_return;
}
public function new_admission()
{
$franchise_id=$this->franchise_id;
$child_name=$this->child_name;
$age=$this->age;
$gender=$this->gender;
$dob_date=$this->dob_date;
$education=$this->education;
$school_name=$this->school_name;
$contact_no=$this->contact_no;
$informant=$this->informant;
$c_local=$this->c_local;
$c_city=$this->c_city;
$c_district=$this->c_district;
$c_state=$this->c_state;
$c_pincode=$this->c_pincode;
$p_local=$this->p_local;
$p_city=$this->p_city;
$p_district=$this->p_district;
$p_state=$this->p_state;
$p_pincode=$this->p_pincode;
$problem=$this->problem;
$walking=$this->walking;
$first_sentence=$this->first_sentence;
$toilet_behaviour=$this->toilet_behaviour;
$self_help=$this->self_help;
$sleeping_pattern=$this->sleeping_pattern;
$play=$this->play;
$play_group=$this->play_group;
$type_of_play=$this->type_of_play;
$behav_with_family=$this->behav_with_family;
$reln_with_siblings=$this->reln_with_siblings;
$admission_fees=$this->admission_fees;
$columns_array=array("name","age","gender","dob_date","education","school_name","contact_no","informant","c_local","c_city","c_district","c_state","c_pincode","p_local","p_city","p_district","p_state","p_pincode","problem","walking","first_sentence","toilet_behaviour","self_help","sleeping_pattern","play","play_group","type_of_play","behav_with_family","reln_with_siblings","franchise_id");
$columns_array_2=array("student_id","franchise_id","credit","status","type");
$table_name="shristi_child_details";
$table_name_2="shristi_students_payments";
$values_array=array($child_name,$age,$gender,$dob_date,$education,$school_name,$contact_no,$informant,$c_local,$c_city,$c_district,$c_state,$c_pincode,$p_local,$p_city,$p_district,$p_state,$p_pincode,$problem,$walking,$first_sentence,$toilet_behaviour,$self_help,$sleeping_pattern,$play,$play_group,$type_of_play,$behav_with_family,$reln_with_siblings,$franchise_id);
$e_wallet_obj_inner=new e_wallet();
$e_wallet_obj_inner->set_value("franchise_id",$franchise_id);
$balance=$e_wallet_obj_inner->e_wallet_balance();
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$mysql_obj->start_transaction();
$mysql_obj->insert_simple($columns_array,$values_array,$table_name);
$student_id=$mysql_obj->get_value("last_insert_id");
$prepared_statement="UPDATE shristi_child_details SET registration_no='REF-NO-$student_id' WHERE table_id='$student_id'";
$mysql_obj->simply_run_statement_passed($prepared_statement);
$values_array_2=array($student_id,$franchise_id,$admission_fees,"unpaid","initial");
$mysql_obj->insert_simple_for_transaction($columns_array_2,$values_array_2,$table_name_2);
$payment_no=$mysql_obj->get_value("last_insert_id");
$mysql_obj->commit();
$mysql_obj->close_connection();
return $payment_no;
}
public function view_all_child_names($franchise_id){
$columns_array=array("table_id","name");
$table_name="shristi_child_details";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$franchise_id=$mysql_obj->real_escape($franchise_id);
$conditions=" WHERE franchise_id='$franchise_id' ORDER BY name ";
$res=$mysql_obj->select_simple($table_name,$columns_array,$conditions);
while($detail=$res->fetch_assoc())
{
echo("<option value=\"".$detail['table_id']."\">".$detail['name']."</option>");
}
$mysql_obj->close_connection();
}
public function view_all_screenings_reports_list_student($student_id){
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$student_id=$mysql_obj->real_escape($student_id);
$prepared_statement="SELECT 'ref_no','screening_id', DATE('created_date') AS 'screening_date' FROM shristi_questionnaires_permanent_answers WHERE 'ref_no'='$student_id' GROUP BY 'screening_id'";
/*_____________________________________________changes done by sushant_____________________________________________*/
//$prepared_statement="SELECT *,DATE(created_date) AS screening_date FROM shristi_questionnaires_permanent_answers WHERE ref_no='$student_id' GROUP BY screening_id";
/*__________________________________________________________________________________________________________________*/
$res=$mysql_obj->simply_run_statement_passed($prepared_statement);
$mysql_obj->close_connection();
while($detail=$res->fetch_assoc()){
$screening_id=$detail['screening_id'];
echo $screening_date=$detail['screening_date'];
echo("<tr>");
$date_array=explode("-",$screening_date);
$month="";
$year=$date_array[0];
switch(abs($date_array[1])){
case 1:$month="JAN";break;
case 2:$month="FEB";break;
case 3:$month="MAR";break;
case 4:$month="APR";break;
case 5:$month="MAY";break;
case 6:$month="JUN";break;
case 7:$month="JUL";break;
case 8:$month="AUG";break;
case 9:$month="SEP";break;
case 10:$month="OCT";break;
case 11:$month="NOV";break;
case 12:$month="DEC";break;
}
echo("<td><a href=\"view_questionnaire_report.php?ref_no=".$student_id."&screening_id=".$screening_id."&franchise_id={$_SESSION['log_id']}\">".$month."-".$year."</a></td>");
echo("<td>".$detail['screening_id']."</td>");
echo("<td></td>");
echo("<td></td>");
echo("<td></td>");
echo("<td></td>");
echo("</tr>");
}
}
public function view_child($ref_no){
$franchise_id=$this->franchise_id;
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$ref_no=$mysql_obj->real_escape($ref_no);
$franchise_id=$mysql_obj->real_escape($franchise_id);
$prepared="SELECT *,DATE_FORMAT(FROM_DAYS(DATEDIFF(CURDATE(),dob_date)), '%Y')+0 AS calculated_age FROM shristi_child_details WHERE table_id='$ref_no' AND franchise_id='$franchise_id'";
$res=$mysql_obj->simply_run_statement_passed($prepared);
$mysql_obj->close_connection();
if($res->num_rows==1)
{
$detail=$res->fetch_assoc();
$this->registration_no=$detail['registration_no'];
$dob=$detail['registration_date'];
if($dob!="0000-00-00")
{
$date_obj = new DateTime($dob);
$dob=$date_obj->format('d-M-Y');
}
$this->registration_date=$dob;
$this->theme_class=$detail['theme_class'];
$this->theme_font=$detail['theme_font'];
$this->child_name=$detail['name'];
$this->age=$detail['calculated_age'];
$this->gender=$detail['gender'];
$this->school_name=$detail['school_name'];
$this->problem=$detail['problem'];
$edu="";
switch($detail['education'])
{
case '1' :$edu="1st";break;
case '2' :$edu="2nd";break;
case '3' :$edu="3rd";break;
case '4' :$edu="4th";break;
case '5' :$edu="5th";break;
case '6' :$edu="6th";break;
case '7' :$edu="7th";break;
case '8' :$edu="8th";break;
case '9' :$edu="9th";break;
case '10' :$edu="10th";break;
}
$edu.=" std";
$this->education=$edu;
$dob=$detail['dob_date'];
if($dob!="0000-00-00")
{
$date_obj = new DateTime($dob);
$dob=$date_obj->format('d-M-Y');
}
$this->dob_date=$dob;
}
else
{
echo("Error : Invalid request...");
exit();
}
}
public function view_child_applied($ref_no)
{
$franchise_id=$this->franchise_id;
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$ref_no=$mysql_obj->real_escape($ref_no);
$franchise_id=$mysql_obj->real_escape($franchise_id);
$prepared="SELECT *,DATE_FORMAT(FROM_DAYS(DATEDIFF(CURDATE(),dob_date)), '%Y')+0 AS calculated_age FROM shristi_child_details WHERE table_id='$ref_no' AND franchise_id='$franchise_id' AND status='applied'";
$res=$mysql_obj->simply_run_statement_passed($prepared);
$mysql_obj->close_connection();
if($res->num_rows==1)
{
$detail=$res->fetch_assoc();
$this->registration_no=$detail['registration_no'];
$this->child_name=$detail['name'];
$this->age=$detail['calculated_age'];
$this->gender=$detail['gender'];
$edu="";
switch($detail['education'])
{
case '1' :$edu="1st";break;
case '2' :$edu="2nd";break;
case '3' :$edu="3rd";break;
case '4' :$edu="4th";break;
case '5' :$edu="5th";break;
case '6' :$edu="6th";break;
case '7' :$edu="7th";break;
case '8' :$edu="8th";break;
case '9' :$edu="9th";break;
case '10' :$edu="10th";break;
}
$edu.=" std";
$this->education=$edu;
$dob=$detail['dob_date'];
if($dob!="0000-00-00")
{
$date_obj = new DateTime($dob);
$dob=$date_obj->format('d-M-Y');
}
$this->dob_date=$dob;
}
else
{
echo("Error : Invalid request...");
exit();
}
}
public function view_child_pending($ref_no)
{
$franchise_id=$this->franchise_id;
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$ref_no=$mysql_obj->real_escape($ref_no);
$franchise_id=$mysql_obj->real_escape($franchise_id);
$prepared="SELECT *,DATE_FORMAT(FROM_DAYS(DATEDIFF(CURDATE(),dob_date)), '%Y')+0 AS calculated_age FROM shristi_child_details WHERE table_id='$ref_no' AND franchise_id='$franchise_id' AND status='pending'";
$res=$mysql_obj->simply_run_statement_passed($prepared);
$mysql_obj->close_connection();
if($res->num_rows==1)
{
$detail=$res->fetch_assoc();
$this->registration_no=$detail['registration_no'];
$this->child_name=$detail['name'];
$this->age=$detail['calculated_age'];
$this->gender=$detail['gender'];
$edu="";
switch($detail['education'])
{
case '1' :$edu="1st";break;
case '2' :$edu="2nd";break;
case '3' :$edu="3rd";break;
case '4' :$edu="4th";break;
case '5' :$edu="5th";break;
case '6' :$edu="6th";break;
case '7' :$edu="7th";break;
case '8' :$edu="8th";break;
case '9' :$edu="9th";break;
case '10' :$edu="10th";break;
}
$edu.=" std";
$this->education=$edu;
$dob=$detail['dob_date'];
if($dob!="0000-00-00")
{
$date_obj = new DateTime($dob);
$dob=$date_obj->format('d-M-Y');
}
$this->dob_date=$dob;
}
else
{
echo("Error : Invalid request...");
exit();
}
}
public function view_all_states($to_select="none")
{
$franchise_id=$this->franchise_id;
$columns_array=array("table_id","name");
$table_name="shristi_states_india";
$conditions="";
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$to_select=$mysql_obj->real_escape($to_select);
$res=$mysql_obj->select_simple($table_name,$columns_array,$conditions);
$mysql_obj->close_connection();
while($detail=$res->fetch_assoc())
{
echo("<option value=\"".$detail['table_id']."\"");
if($detail['table_id']==$to_select)
{
echo(" selected");
}
echo(">".$detail['name']."</option>");
}
}
public function show_available_screening($ref_no){
$franchise_id=$this->franchise_id;
$today_date=date("Y-m-d");
$mysql_obj=new mysql_functions_class;
$mysql_obj->open_connection();
$ref_no=$mysql_obj->real_escape($ref_no);
$franchise_id=$mysql_obj->real_escape($franchise_id);
try
{
$prepared="SELECT * FROM shristi_child_details WHERE table_id='$ref_no' AND franchise_id='$franchise_id' AND status='active' AND next_end_date>=$today_date";
$res=$mysql_obj->simply_run_statement_passed($prepared);
if($res->num_rows==0){
$mysql_obj->close_connection();
throw new Exception('no');
}
$detail=$res->fetch_assoc();
$std=$detail['education'];
//echo "<br>";
$prepared="SELECT a.* FROM shristi_questionnaires a WHERE a.for_std LIKE '%[$std]%' AND a.status='active'";
$res=$mysql_obj->simply_run_statement_passed($prepared);
if($res->num_rows==0)
{
$mysql_obj->close_connection();
throw new Exception('no');
}
$detail=$res->fetch_assoc();
$screening_available=$detail['table_id'];
$prepared="SELECT a.* FROM shristi_questionnaires_permanent_answers a WHERE a.ref_no='$ref_no' AND a.screening_id='$screening_available'";
$res=$mysql_obj->simply_run_statement_passed($prepared);
if($res->num_rows>0)
{
$mysql_obj->close_connection();
throw new Exception('no');
}
$detail=$res->fetch_assoc();
return $screening_available;
}
catch (Exception $e)
{
$error=$e->getMessage();
return $error;
}
}
public function show_available_treatment($ref_no){
$today_date=date("Y-m-d");
$mysql_obj=new mysql_functions_class;
$treatments_array=array();
$mysql_obj->open_connection();
$ref_no=$mysql_obj->real_escape($ref_no);
try{
$prepared="SELECT b.* FROM shristi_treatments_available a INNER JOIN shristi_treatments b ON b.table_id=a.treatment_id WHERE a.ref_no='$ref_no' AND b.status='active' AND a.end_date>='$today_date' AND a.start_date<='$today_date'";
$res=$mysql_obj->simply_run_statement_passed($prepared);
if($res->num_rows==0){
$mysql_obj->close_connection();
throw new Exception('no');
}
$mysql_obj->close_connection();
while($detail=$res->fetch_assoc())
{
$treatments_array[]=$detail['table_id'];
}
return $treatments_array;
}
catch (Exception $e)
{
$error=$e->getMessage();
return $error;
}
}
}
?>