JezK
Edit File: school_admin_student.php
<?php ini_set("memory_limit","512M"); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\OAuth; use League\OAuth2\Client\Provider\Google; require '../composer_test/vendor/autoload.php'; class studentacess { private $conn; function __construct() { require_once dirname(__FILE__) . '/DbConnect.php'; // opening db connection $db = new DbConn(); $this->conn = $db->connect(); } function create_student($post,$session){ $created_date = date('Y-m-d'); $dateInput = explode('/',$post['stu_admissiondate']); $admision_date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $qry="INSERT INTO ced_t_students ( student_rollno, class_id, section_id, student_firstname, student_lastname, student_admission_number, student_admission_date, student_address, student_blood_group, student_father_name, student_father_email, student_father_mobile, student_father_mobile2, student_mother_name, student_mother_email, student_mother_mobile, student_mother_mobile2, student_guardian_name, student_guardian_email, student_guardian_mobile, student_guardian_mobile2, academic_year_id, school_id, status, created_on, created_by ) VALUES ( '".$post['stu_rollnum']."', '".$post['classes']."', '".$post['sections']."', '".$post['stu_firstname']."', '".$post['stu_lastname']."', '".$post['stu_admissionnumber']."', '".$admision_date."', '".$post['stu_address']."', '".$post['stu_blodgroup']."', '".$post['stu_fathername']."', '".$post['stu_fatheremail']."', '".$post['stu_fathermobile']."', '".$post['stu_fathermobile2']."', '".$post['stu_mothername']."', '".$post['stu_motheremail']."', '".$post['stu_mothermobile']."', '".$post['stu_mothermobile2']."', '".$post['stu_gurdianname']."', '".$post['stu_gurdianemail']."', '".$post['stu_gurdianmobile']."', '".$post['stu_gurdianmobile2']."', '".$session['child']['choosen_academic_id']."', '".$session['child']['log_school_id']."', '1', '".$created_date."', '".$session['child']['auth_id']."') "; $exe=mysqli_query($this->conn,$qry); $student_id=mysqli_insert_id($this->conn); $_SESSION['student_add']['stu_id'] = $student_id; $_SESSION['child']['section_id'] = $post['sections']; $_SESSION['child']['stu_class_id'] = $post['classes']; // exit; if($exe) { $qry1 = "SELECT status from ced_t_students WHERE student_id = '".$student_id."'"; $res = mysqli_query($this->conn,$qry1); $qry="INSERT INTO ced_t_students_parent (student_id,authenticate_id,school_id,created_by,created_on,account_status) VALUES ('".$student_id.",''".$session['child']['choosen_academic_id']."','".$session['child']['log_school_id']."','".$session['child']['auth_id']."',".$created_date."','".$res."')"; //~ echo $qry; //~ exit; $exe=mysqli_query($this->conn,$qry); $response=ERR203; } else { $response=ERR204; } //~ if($exe) //~ { //~ $response=ERR203; //~ } //~ else{ //~ $response=ERR204; //~ } return $response; } function check_student($admission_number,$school_id ){ $qry = "select student_id from ced_t_students where student_admission_number = '".$admission_number."' and school_id ='".$school_id."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function check_student_edit($admission_number,$student_id,$school_id ){ $qry = "select student_id from ced_t_students where student_admission_number = '".$admission_number."' and school_id ='".$school_id."' and student_id !='".$student_id."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function update_student($post,$session){ $update_date = date('Y-m-d'); //$admision_date = date_format($post['stu_admissiondate'],"Y/m/d"); $dateInput = explode('/',$post['stu_admissiondate']); $admision_date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $qry="update ced_t_students set student_rollno='".$post['stu_rollnum']."', class_id='".$post['classes']."', section_id='".$post['sections']."', student_firstname='".$post['stu_firstname']."', student_lastname='".$post['stu_lastname']."', student_admission_number='".$post['stu_admissionnumber']."', student_admission_date='".$admision_date."', student_address='".$post['stu_address']."', student_blood_group='".$post['stu_blodgroup']."', student_father_name='".$post['stu_fathername']."', student_father_email='".$post['stu_fatheremail']."', student_father_mobile='".$post['stu_fathermobile']."', student_father_mobile2='".$post['stu_fathermobile2']."', student_mother_name='".$post['stu_mothername']."', student_mother_email='".$post['stu_motheremail']."', student_mother_mobile='".$post['stu_mothermobile']."', student_mother_mobile2='".$post['stu_mothermobile2']."', student_guardian_name='".$post['stu_gurdianname']."', student_guardian_email='".$post['stu_gurdianemail']."', student_guardian_mobile='".$post['stu_gurdianmobile']."', student_guardian_mobile2='".$post['stu_gurdianmobile2']."', academic_year_id='".$session['child']['choosen_academic_id']."', updated_on='".$update_date."', updated_by='".$session['child']['auth_id']."' where student_id = '".$post['student_id']."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $_SESSION['student_edit']['stu_id'] = $post['student_id']; $_SESSION['child']['section_id'] = $post['sections']; $_SESSION['child']['stu_class_id'] = $post['classes']; $response=ERR203; } else { $response=ERR205; } return $response; } function getEventDates($date,$academic_yearid) { $eventdates=array(); $dtes=explode('-',$date); $sql_event="SELECT `created_on` FROM `ced_t_noticeboard` WHERE `notification_type`=6 and month(created_on)='".$dtes[1]."' and Year(`created_on`)='".$dtes[0]."' and `academicyear_id`='".$academic_yearid."'"; //echo $sql_event; //exit; $res_event=mysqli_query($this->conn,$sql_event); if(mysqli_num_rows($res_event)>0) { while($row=mysqli_fetch_array($res_event)) { $edates=explode(' ',$row['created_on']); $chngedte=explode('-',$edates[0]); $actual_date=$chngedte[1].'/'.$chngedte[2].'/'.$chngedte[0]; $eventdates[]=$actual_date; } } return $eventdates; } function delete_student($student_id){ $qry = "delete from ced_t_students where student_id = '".$student_id."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $qry_lic= "select * from ced_t_student_licenses where student_id = '".$student_id."' "; $result=mysqli_query($this->conn,$qry_lic); if( mysqli_num_rows($result) > 0){ $qry = "delete from ced_t_student_licenses where student_id = '".$student_id."' "; $exe=mysqli_query($this->conn,$qry); } $response=ERR203; } else { $response=ERR205; } return $response; } function update_student_status($student_id,$status){ $update_date = date('Y-m-d'); if($status == '1'){ $status = '0'; }else { $status = '1'; } $qry="update ced_t_students set status = '".$status."' ,updated_on='".$update_date."', updated_by='admin_user' where student_id = '".$student_id."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $exe=mysqli_query($this->conn,$qry); $response=ERR203; } else { $response=ERR205; } return $response; } function insert_student_licences($stuid,$license,$user_id,$licence_id,$acadamic_id){ $created_date = date('Y-m-d'); $selectquery = "select student_license_id from ced_t_student_licenses where student_id = '".$stuid."' and academic_year_id ='".$acadamic_id."' "; //~ echo $selectquery; $exe=mysqli_query($this->conn,$selectquery); if( mysqli_num_rows($exe) > 0){ $row=mysqli_fetch_array($exe); $qry= "update ced_t_student_licenses school_license_id = '".$licence_id."',license_status = 1 where student_license_id = '".$row['student_license_id']."' "; echo($qry); }else{ $qry="INSERT INTO ced_t_student_licenses ( student_id,license_key,license_status,school_license_id,academic_year_id,created_on,created_by) VALUES ('".$stuid."','".$license."','1','".$licence_id."','".$acadamic_id."','".$created_date."','".$user_id."')"; echo($qry); } $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function students_license_data($schoolid){ $qry = "SELECT st.student_id as stuid,stl.student_id as stulid ,stl.license_key,stl.license_status ,stl.student_license_id FROM `ced_t_students` as st INNER JOIN `ced_t_student_licenses` as stl ON st.student_id = stl.student_id"; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data[$row['stulid']]=$row; //$data2[]=$data; } //~ echo "<br>"; //~ print_r($data); //~ exit; return $data; } function update_student_licensestatus($ids){ $str= ltrim ($ids, ','); $str= rtrim ($ids, ','); $qry = "update ced_t_student_licenses set license_status='0' where student_id in(".$str.")"; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function check_student_licensestatus($ids){ $str= ltrim ($ids, ','); $str= rtrim ($ids, ','); $qry = "select license_status,student_id from ced_t_student_licenses where student_id in(".$str.") and student_id != 0 "; //~ echo $qry; //~ exit; $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { $data2[$row['license_status']]=$row; //$data2[$row['license_status']][]=$row; } return $data2; }else { return '0'; } } function update_license_status($post){ $qry = "update ced_t_student_licenses set license_status='".$post['status']."' where student_id ='".$post['stuid']."' "; //~ echo $qry; //~ exit; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function send_licences_mail($studid){ $qry = "select student_firstname,student_lastname,student_id,student_father_name,student_father_mobile,student_mother_name,student_mother_mobile,student_guardian_name,student_father_email,student_mother_email,student_guardian_email from ced_t_students where student_id in(".$studid.")"; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data[$row['student_id']]=$row; //$data2[]=$data; } return $data; } function get_licences_key($studid){ $qry = "Select student_id,license_key,license_status from ced_t_student_licenses where license_status = '1' and student_id in(".$studid.")"; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data[$row['student_id']]=$row; //$data2[]=$data; } return $data; } /******************* Funciton for getting app details*************/ function gettingAppDetails() { $data=array(); $sql="SELECT `details_id`,`app_logo`,`app_name`,`sender_mail`,`support_mail`,`domain` FROM `ced_t_app_details` where `details_id`=1"; $result=mysqli_query($this->conn,$sql); if(mysqli_num_rows($result)>0) { $row=mysqli_fetch_array($result); $data['details_id']=$row['details_id']; //$data['app_logo']=APP_LOGO_PATH.$row['app_logo']; $data['app_logo']=ADMIN_PATH."uploads/".$row['app_logo']; $data['app_name']=$row['app_name']; $data['sender_mail']=$row['sender_mail']; $data['support_mail']=$row['support_mail']; $data['domain']=$row['domain']; } return $data; } function send_LicenceKey_student($result_data,$license_data,$session){ $appdetails=$this->gettingAppDetails(); $qry_school="select school_name,school_email,school_phone from ced_t_school where school_id=".(int)$session['child']['log_school_id']; $exe_school=mysqli_query($this->conn,$qry_school); $res_school=mysqli_fetch_array($exe_school); foreach($result_data as $key=>$val){ if($license_data[$key]['license_key']){ //$subject = "Student License Key"; $subject = $appdetails['app_name']." Parent App Access for ".$session['child']['school_name']; if($val['student_father_email']){ $to_father = $val['student_father_email']; /* if($to_father != ''){ $mails[] = $to_father; } if($to_mother != ''){ $mails[] = $to_mother; } if($to_gaurdiun != ''){ $mails[] = $to_gaurdiun; } print_r($mails); exit;*/ $content_father = "<body> <p>Dear ".$val['student_father_name'].",<br><br> <p>Welcome!!</p> <p> You have been successfully registered for ".$appdetails['app_name']." mobile services provided by ".$session['child']['school_name']." for your Child <b>".$val['student_firstname']." ".$val['student_lastname'].".</b> </p> <p>You can download the ".$appdetails['app_name']." Parent App on your mobile phone from the Google App Store by simply searching for '".$appdetails['app_name']."'. Your one time license key for accessing the ".$appdetails['app_name']." Parent App is as follows: </p> <p><b>License Key:</b> <b style='font-family: myfont;'>".$license_data[$key]['license_key']."</b></p> <p>After entering the license key in the mobile app, you would be asked to create a Username and Password.</p> <p>Please DO NOT share your username and password with any other person to ensure complete security of data related to your child.</p> <p>If you have any questions related to your account / services, you can email us at ".$res_school['school_email']." or call us on ".$res_school['school_phone'].".</p> <p> In case of any technical help related to the mobile app, you can reach out to ".$appdetails['support_mail'].".</p> <p>Thank You,</p> <p>Regards,</p> <p>".$session['child']['school_name']."</p> </body>"; $message_father = " <html> <head> <title>".$appdetails['app_name']."</title> </head> ".$content_father." </html>"; //echo $message_father; $mail_send = $this->mail_send($to_father,$subject,$message_father); $message_sms="Dear Parent, License key of ".$val['student_firstname']." for accessing Skoolonline App is ".$license_data[$key]['license_key']." you can download the App from www.skoolonline.in - Thank You"; $send_msg=file_get_contents("http://180.149.242.74/unified.php?usr=dharani@krify.net&pwd=dksmr555&ph=".$val['student_father_mobile']."&sndr=SKLONL&text=".urlencode($message_sms)); //echo $templat="http://180.149.242.74/unified.php?usr=dharani@krify.net&pwd=dksmr555&ph=".$val['student_father_mobile']."&sndr=SKLONL&text=".urlencode($message_sms); if($mail_send == '1'){ $qry = "update ced_t_students set student_email_send_status='1' where student_id ='".$key."' "; $exe=mysqli_query($this->conn,$qry); } } if($val['student_mother_email'] && $val['student_father_email'] != $val['student_mother_email'] ){ $to_mother = $val['student_mother_email']; $content_mother = "<body> <p>Dear ".$val['student_mother_name'].",</p><br> <p>Welcome!!</p> <p> You have been successfully registered for ".$appdetails['app_name']." mobile services provided by ".$session['child']['school_name']." for your Child ".$val['student_firstname']." ".$val['student_lastname'].". </p> <p>You can download the ".$appdetails['app_name']." <a href='https://drive.google.com/a/krify.net/file/d/0B92kgEjhfWlPMUlIX2dfaUZpSFE/view?usp=sharing' target='_blank'>Parent App</a> on your mobile phone from the Google App Store by simply searching for '".$appdetails['app_name']."'. Your one time license key for accessing the ".$appdetails['app_name']." Parent App is as follows: </p> <p>License Key: <b style='font-family: myfont;'>".$license_data[$key]['license_key']."</b></p> <p>After entering the license key in the mobile app, you would be asked to create a Username and Password.</p> <p>Please DO NOT share your username and password with any other person to ensure complete security of data related to your child.</p> <p>If you have any questions related to your account / services, you can email us at ".$res_school['school_email']." or call us on ".$res_school['school_phone'].".</p> <p> In case of any technical help related to the mobile app, you can reach out to ".$appdetails['support_mail'].".</p> <p>Thank You,</p> <p>Regards,</p> <p>".$session['child']['school_name']."</p> </body>"; $message_mother = " <html> <head> <title>".$appdetails['app_name']."</title> </head> ".$content_mother." </html>"; $mail_send = $this->mail_send($to_mother,$subject,$message_mother); /*$message_sms="Dear ".$val['student_father_name'].", License key of ".$val['student_firstname']." ".$val['student_lastname']." for accessing Skoolonline App is ".$license_data[$key]['license_key']."; you can download the App from www.skoolonline.in - Thank You"; $send_msg=file_get_contents("http://180.149.242.74/unified.php?usr=dharani@krify.net&pwd=dksmr555&ph=".$val['student_father_mobile']."&sndr=SKLONL&text=".urlencode($message_sms));*/ if($mail_send == '1'){ $qry = "update ced_t_students set student_email_send_status='1' where student_id ='".$key."' "; $exe=mysqli_query($this->conn,$qry); } } } } return $mail_send; } function mail_send($to,$sub,$mess) { $google_email = 'productsbu1@gmail.com'; $oauth2_clientId = '707771317205-m01emngdqfp8a7s5fn412pdl14d9s2ma.apps.googleusercontent.com'; $oauth2_clientSecret = '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'; $oauth2_refreshToken = '1//04mwEsI6-S-8WCgYIARAAGAQSNwF-L9IrMwoiBVMD5u7LcnOoAQgCGSR-FS3kp-kdyDV4g3kTCFUAzWtIIhH1yBZBm_Bl2wa4-ek'; $mail = new PHPMailer(TRUE); try { $mail->setFrom($google_email, 'Skoolonline'); $mail->addAddress($to); $mail->Subject = $sub; $mail->Body = $mess; $mail->isSMTP(); $mail->Port = 587; $mail->SMTPAuth = TRUE; $mail->SMTPSecure = 'tls'; $mail->IsHTML(true); /* Google's SMTP */ $mail->Host = 'smtp.gmail.com'; /* Set AuthType to XOAUTH2. */ $mail->AuthType = 'XOAUTH2'; /* Create a new OAuth2 provider instance. */ $provider = new Google( [ 'clientId' => $oauth2_clientId, 'clientSecret' => $oauth2_clientSecret, ] ); /* Pass the OAuth provider instance to PHPMailer. */ $mail->setOAuth( new OAuth( [ 'provider' => $provider, 'clientId' => $oauth2_clientId, 'clientSecret' => $oauth2_clientSecret, 'refreshToken' => $oauth2_refreshToken, 'userName' => $google_email, ] ) ); /* Finally send the mail. */ if ($mail->send()) { // echo "Mail sent successfully"; return 1; } else { echo "Mail not sent";exit; } } catch (Exception $e) { echo $e->errorMessage(); } catch (\Exception $e) { echo $e->getMessage(); } } function dairy_data($class_id,$section_id,$dairy_date,$school_id,$dairy_type,$academic_id,$studentids){ /*echo $studentids; exit; $studentids =ltrim($studentids,','); $studentids =rtrim($studentids,','); $studentids_data = explode(',',$studentids); $studencon = ''; $i=1; $str =''; $string = '';*/ $data = array(); if($studentids == "all"){ $str_new = "all"; $status = "all"; }else{ $str = str_replace("all","",$studentids); $str= ltrim ($studentids, ','); $str =rtrim($studentids,','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); $status = "singles"; } /* if($studentids != ''){ foreach($studentids_data as $key=>$val){ if($i == count($studentids_data)){ $str = " OR student_id = 'all' "; }else { $str = " OR "; } if($val != '' ){ $studencon .= "student_id like '%".$val."%' ".$str; } $i++; } }else{ $studencon .= "student_id = '' "; } $string = "and (".$studencon.")";*/ $dateInput = explode('/',$dairy_date); $dairy_newdate=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $qry = "select sd.*,ss.subject_name from ced_t_school_diary as sd INNER JOIN ced_t_subjects as ss ON sd.subject_id=ss.subject_id and sd.class_id = '".$class_id."' and sd.section_id='".$section_id."' and sd.school_id='".$school_id."' and sd.diary_date='".$dairy_newdate."' and sd.academic_year_id='".$academic_id."' and sd.diary_type ='".$dairy_type."' and student_id = '".$str_new."' and student_id != '' order by sd.School_diary_id desc"; //echo $qry; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data[$row['School_diary_id']]=$row; //$data2[]=$data; } return $data; } function get_subjects_dairy($class_id,$school_id,$academic_id){ $qry = "select ss.subject_name,ss.subject_id from ced_t_subjects as ss INNER JOIN ced_t_class as cc ON cc.class_category_id = ss.class_category_id and cc.class_id='".$class_id."' and cc.school_id='".$school_id."' and ss.academic_year_id = '".$academic_id."' "; //echo $qry; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data2[]=$row; } return $data2; } function get_students_data($class_id,$school_id,$section_id){ $qry = "select student_id,class_id,section_id,student_firstname,student_lastname from ced_t_students where class_id='".$class_id."' and school_id='".$school_id."' and section_id='".$section_id."' "; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data2[]=$row; } return $data2; } function get_students_data_dairy($class_id,$school_id,$section_id,$acadamicid){ $qry = "select student_id,class_id,section_id,student_firstname,student_lastname from ced_t_students where class_id='".$class_id."' and school_id='".$school_id."' and section_id='".$section_id."' and academic_year_id = '".$acadamicid."' and status = '1' "; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data2[]=$row; } return $data2; } function check_generalcomment($post){ $dateInput = explode('/',$post['dairy_date']); $dairy_date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $category = '2'; $qry = "select count(School_diary_id) as cnt,description,class_id,section_id,subject_id,school_id,academic_year_id from ced_t_school_diary where class_id='".$post['classes']."' and section_id='".$post['sections']."' and subject_id='".$post['subjects']."' and diary_date='".$dairy_date."' and diary_type='".$category."' "; $exe=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($exe); return $row; } function update_generalcomment($data,$post){ $update_date = date('Y-m-d'); $qry = "update ced_t_school_diary set description ='".$post['dairy_desription']."' where class_id = '".$data['class_id']."' and section_id ='".$data['section_id']."' and subject_id = '".$data['subject_id']."' and school_id = '".$data['school_id']."' and academic_year_id = '".$data['academic_year_id'] ."' and diary_type = 2"; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function update_generalcomment_edit_dump($data){ //print_r($data); //exit; $str= ltrim ($data['student_ids_all'], ','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); $update_date = date('Y-m-d'); $qry = "update ced_t_school_diary set description ='".$data['dairy_desription']."', student_id ='".$str_new."' where School_diary_id = '".$data['sudent_dairy_id']."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function update_generalcomment_edit($data,$session,$attachment_file){ $dateInput = explode('/',$data['dairy_date']); $dairy_newdate=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; if($data['student_ids_data'] == "all"){ $str_new = "all"; $status = "all"; }else{ $str= ltrim ($data['student_ids_data'], ','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); $status = "singles"; } $today_date =date('d/m/Y'); if($today_date == $data['dairy_date']){ $date_msg = "Today"; }else { $date_msg = $data['dairy_date']; } $update_date = date('Y-m-d'); $qry = "update ced_t_school_diary set description ='".mysqli_escape_string($this->conn,$data['dairy_desription'])."', updated_by='".$session['child']['auth_id']."', updated_on='".$update_date."',attachment='".$attachment_file."' where School_diary_id = '".$data['sudent_dairy_id']."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $_SESSION['child']['dairy_section_id'] = $data['sections']; $_SESSION['child']['dairy_class_id'] = $data['classes']; $_SESSION['child']['dairy_date'] = $data['dairy_date']; $_SESSION['child']['studentids'] = $str_new; $_SESSION['child']['dairy_type_general'] = $status; $_SESSION['child']['general_names'] = $data['student_allnamesedit_data']; $response=ERR203; if($data['student_ids_data'] == "all"){ // $qry="select student_id,student_firstname,student_lastname from ced_t_students where school_id=".(int)$data['school_id']." and academic_year_id=".(int)$data['acadamic_id']." and section_id=".(int)$data['sections']." and class_id=".(int)$data['classes']; $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$data['school_id']." and s.academic_year_id=".(int)$data['acadamic_id']." and s.section_id=".(int)$data['sections']." and s.class_id=".(int)$data['classes']; }else{ //$qry="select student_id,student_firstname,student_lastname from ced_t_students where school_id=".(int)$data['school_id']." and academic_year_id=".(int)$data['acadamic_id']." and section_id=".(int)$data['sections']." and class_id=".(int)$data['classes']." and student_id in(".$str.")" ; $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$data['school_id']." and s.academic_year_id=".(int)$data['acadamic_id']." and s.section_id=".(int)$data['sections']." and s.class_id=".(int)$data['classes']." and s.student_id in(".$str.")" ; } $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { //$qry2="select student_id from ced_t_student_licenses where student_id=".(int)$row['student_id']." and academic_year_id=".(int)$data['acadamic_id']." and license_status=1"; //$exe2=mysqli_query($qry2); $cklic=$this->check_lic_status($row['student_id']); $notification_status=$this->check_notification_status($row['authenticate_id']); $subject_name = $this->getsubject_name($data['subjects'],$data['school_id'],$data['acadamic_id']); $student_name = $this->student_name($row['student_id']); //if($devid!='0') //{ $message = $student_name." has been assigned Individual Work for ".$subject_name." for ".$date_msg; if($row['device_id'] !='' && $cklic && $notification_status == 1) { //$devid=$this->parentDeviceId($row['student_id']); $notify=$this->send_notification($row['device_id'],$message,$row['student_id'],'gencmnt',date('Y-m-d'),$dairy_newdate,'',$data['sudent_dairy_id']); //} } if($cklic!=0) { $noteins="insert into ced_t_notifications set notify_name='".$message."',student_id=".(int)$row['student_id'].",class_id=".(int)$row['class_id'].",section_id=".(int)$row['section_id'].",school_id=".(int)$row['school_id'].",notify_type='gencmnt',general_column1='".$dairy_newdate."',read_status=1,created_on='".date('Y-m-d')."'"; mysqli_query($this->conn,$noteins); } } } } else { $response=ERR205; } return $response; } function update_generalcomment_new($data,$id,$attachment_file){ $dateInput = explode('/',$data['dairy_date']); $dairy_newdate =$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; if($data['student_ids'] == "all" ){ $str_new = "all"; $status = "all"; }else{ $str= ltrim ($data['student_ids_data'], ','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); $status = $data['student_status']; } if($post['student_ids_data'] == "all"){ $str = $data['student_ids_all']; }else{ $str = $data['student_ids_data']; } $str =ltrim($str,','); $str =rtrim($str,','); $today_date =date('d/m/Y'); if($today_date == $data['dairy_date']){ $date_msg = "Today"; }else { $date_msg = $data['dairy_date']; } $update_date = date('Y-m-d'); $qry = "update ced_t_school_diary set description ='".mysqli_escape_string($this->conn,$data['dairy_desription'])."', student_id ='".$str_new."',attachment='".$attachment_file."' where School_diary_id = '".$id."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $_SESSION['child']['dairy_section_id'] = $data['sections']; $_SESSION['child']['dairy_class_id'] = $data['classes']; $_SESSION['child']['dairy_date'] = $data['dairy_date']; $_SESSION['child']['studentids'] = $str_new; $_SESSION['child']['dairy_type_general'] = $status; $_SESSION['child']['general_names'] = $data['student_allnames_data']; $response=ERR203; // $qry="select student_id,student_firstname,student_lastname from ced_t_students where school_id=".(int)$data['school_id']." and academic_year_id=".(int)$data['acadamic_id']." and section_id=".(int)$data['sections']." and class_id=".(int)$data['classes']." and student_id in(".$str.")" ; $qry = "select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$data['school_id']." and s.class_id=".(int)$data['classes']." and s.section_id=".(int)$data['sections']." and s.academic_year_id=".(int)$data['acadamic_id']." and s.student_id in(".$str.") and s.status=1 and sp.account_status=1"; $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { //$qry2="select student_id from ced_t_student_licenses where student_id=".(int)$row['student_id']." and academic_year_id=".(int)$data['acadamic_id']." and license_status=1"; //$exe2=mysqli_query($qry2); $cklic=$this->check_lic_status($row['student_id']); $notification_status=$this->check_notification_status($row['authenticate_id']); $subject_name = $this->getsubject_name($data['subjects'],$data['school_id'],$data['acadamic_id']); $student_name = $this->student_name($row['student_id']); $message = $student_name." has been assigned Individual Work for ".$subject_name." for ".$date_msg; if($row['device_id'] !='' && $cklic && $notification_status == 1) { //$devid=$this->parentDeviceId($row['student_id']); $notify=$this->send_notification($row['device_id'],$message,$row['student_id'],'gencmnt',date('Y-m-d'),$dairy_newdate,'',$id); } if($cklic!=0) { $noteins="insert into ced_t_notifications set notify_name='".$message."',student_id=".(int)$row['student_id'].",class_id=".(int)$row['class_id'].",section_id=".(int)$row['section_id'].",school_id=".(int)$row['school_id'].",notify_type='gencmnt',general_column1='".$dairy_newdate."',read_status=1,created_on='".date('Y-m-d')."'"; //echo $noteins; mysqli_query($this->conn,$noteins); } } } } else { $response=ERR205; } return $response; } function check_parent_data($post){ if($post['student_ids_data'] == "all"){ $str = $post['student_ids_all']; }else{ $str = $post['student_ids_data']; } $str =ltrim($str,','); $str =rtrim($str,','); $select_parent_qry = "select * from ced_t_students_parent where student_id in (".$str.") "; //echo $select_parent_qry; $exe_parent=mysqli_query($this->conn,$select_parent_qry); while($row_parent =mysqli_fetch_array($exe_parent)) { $data2[]=$row_parent; } return $data2; } function check_parent_data_licence($ids){ $ids =ltrim($ids,','); $ids =rtrim($ids,','); $select_parent_qry = "select * from ced_t_students_parent where student_id in (".$ids.") "; // echo $select_parent_qry; // echo "<br>"; $exe_parent=mysqli_query($this->conn,$select_parent_qry); while($row_parent =mysqli_fetch_array($exe_parent)) { $data2[]=$row_parent; } return $data2; } function insert_generalcomment($post,$attachment_file){ $dateInput = explode('/',$post['dairy_date']); $dairy_date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; if( $post['student_ids'] == "all" ){ $str_new = "all"; $status = "all"; }else{ $str=''; $str = $post['student_ids_data']; /*if($post['students_ids']){ foreach($post['students_ids'] as $key=>$val){ $str .= ",".$val; } $str =ltrim($str,','); $str =rtrim($str,','); }*/ $str =ltrim($str,','); $str =rtrim($str,','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); $status = $post['student_status']; } if($post['student_ids_data'] == "all"){ $str_students = $post['student_ids_all']; }else{ $str_students = $post['student_ids_data']; } $str_students = ltrim($str_students,','); $str_students = rtrim($str_students,','); $today_date = date('d/m/Y'); if($today_date == $post['dairy_date']){ $date_msg = "Today"; } else { $date_msg = $post['dairy_date']; } $category = '2'; $created_date = date('Y-m-d'); /*$select_qry = "select student_id from ced_t_students where class_id='".$post['classes']."' and section_id='".$post['sections']."' and school_id='".$post['school_id']."' ".$con ; //$select_qry = "select student_id from ced_t_students where class_id='1' and section_id='1' and school_id='1' "; $exe=mysqli_query($select_qry); while($row=mysqli_fetch_array($exe)) { $data2[$row['student_id']]=$row; }*/ $values= ''; //foreach($data2 as $k=>$val){ $values= "('".$post['classes']."','".$post['sections']."','".$str_new."','".$dairy_date."','".$post['subjects']."','".$category."','".$post['auth_id']."','".$post['school_id']."','".mysqli_escape_string($this->conn,$post['dairy_desription'])."','".$created_date."','".$post['auth_id']."','".$post['acadamic_id']."','".$attachment_file."')"; //} $str= ltrim ($str, ','); $qry = "insert into ced_t_school_diary (class_id,section_id,student_id,diary_date,subject_id,diary_type,assigned_by,school_id,description,created_on,created_by,academic_year_id,attachment) values ".$values." "; $exe=mysqli_query($this->conn,$qry); $lastid = mysqli_insert_id($this->conn); if($exe) { $_SESSION['child']['dairy_section_id'] = $post['sections']; $_SESSION['child']['dairy_class_id'] = $post['classes']; $_SESSION['child']['dairy_date'] = $post['dairy_date']; $_SESSION['child']['studentids'] = $str_new; $_SESSION['child']['dairy_type_general'] = $status; $_SESSION['child']['general_names'] = $post['student_allnames_data']; $response = $lastid; // $qry="select student_id,student_firstname,student_lastname from ced_t_students where school_id=".(int)$post['school_id']." and academic_year_id=".(int)$post['acadamic_id']." and section_id=".(int)$post['sections']." and class_id=".(int)$post['classes']." and student_id in(".$str_students.")" ; if($str_new == "all"){ $qry = "select sp.device_id,sp.authenticate_id,sp.student_id,s.school_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$post['school_id']." and s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']." and s.academic_year_id=".(int)$post['acadamic_id']." and s.status=1 and sp.account_status=1"; }else{ $qry = "select sp.device_id,sp.authenticate_id,sp.student_id,s.school_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$post['school_id']." and s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']." and s.academic_year_id=".(int)$post['acadamic_id']." and s.student_id in(".$str.") and s.status=1 and sp.account_status=1"; } $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { // $qry2="select student_id from ced_t_student_licenses where student_id=".(int)$row['student_id']." and academic_year_id=".(int)$post['acadamic_id']." and license_status=1"; // $exe2=mysqli_query($qry2); $cklic=$this->check_lic_status($row['student_id']); $notification_status=$this->check_notification_status($row['authenticate_id']); $subject_name = $this->getsubject_name($post['subjects'],$post['school_id'],$post['acadamic_id']); $student_name = $this->student_name($row['student_id']); $message = $student_name." has been assigned Individual Work for ".$subject_name." for ".$date_msg; if($row['device_id']!='' && $cklic && $notification_status == 1) { //$devid=$this->parentDeviceId($row['student_id']); $notify=$this->send_notification($row['device_id'],$message,$row['student_id'],'gencmnt',date('Y-m-d'),$dairy_date,'',$lastid); } if($cklic !=0) { $noteins="insert into ced_t_notifications set notify_name='".$message."',student_id=".(int)$row['student_id'].",class_id=".(int)$row['class_id'].",section_id=".(int)$row['section_id'].",school_id=".(int)$row['school_id'].",notify_type='gencmnt',general_column1='".$dairy_date."',read_status=1,created_on='".date('Y-m-d')."'"; //echo $noteins; mysqli_query($this->conn,$noteins); } } } } else { $response=ERR205; } return $response; //exit; //$qry = "insert into ced_t_school_diary (class_id,section_id) values () "; } function details_nonteach_staff($schoolid,$acadamicid) { $select_qry = "select staff_name,staff_id,staff_type,staff_driving_license,staff_mobile from ced_t_school_staff where school_id='".$schoolid."' and academic_year_id='".$acadamicid."' and staff_type <>1 "; $exe=mysqli_query($this->conn,$select_qry); while($row=mysqli_fetch_array($exe)) { $data2[$row['staff_id']]=$row; } return $data2; } function create_nonteach_staff($post,$session,$file) { $created_date = date('Y-m-d'); $qry="INSERT INTO ced_t_school_staff ( staff_name, staff_otherperson, staff_mobile, staff_address, staff_pic, status, school_id, staff_driving_license, staff_experience, staff_type, academic_year_id, created_by, created_on) VALUES ('".$post['staff_name']."', '".$post['staff_person']."', '".$post['staff_number']."', '".$post['staff_address']."', '".$file['nonteach_pic']['name']."', '1', '".$session['child']['log_school_id']."', '".$post['staff_licence']."', '".$post['staff_exp']."', '".$post['staff_type']."', '".$session['child']['choosen_academic_id']."', '".$session['child']['auth_id']."', '".$created_date."' ) "; $result=mysqli_query($this->conn,$qry); if($result){ $response=ERR203; }else{ $response=ERR204; } return $response; } function staff_data_byid($staff_id){ $qry = "select * from ced_t_school_staff where staff_id = '".$staff_id."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function staff_data_update($post,$session) { $update_date = date('Y-m-d'); $qry = "update ced_t_school_staff set staff_name='".$post['staff_name']."', staff_otherperson='".$post['staff_person']."', staff_mobile='".$post['staff_number']."', staff_address='".$post['staff_address']."', staff_driving_license='".$post['staff_licence']."', staff_experience='".$post['staff_exp']."', staff_type='".$post['staff_type']."', updated_by='".$session['child']['auth_id']."', updated_on='".$update_date."' where staff_id ='".$post['staff_id']."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function delete_staff($staff_id){ $qry = "delete from ced_t_school_staff where staff_id = '".$staff_id."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function route_data($scool_id,$acadamic_id){ $select_qry = "select * from ced_t_routes where school_id='".$scool_id."' and academic_year_id ='".$acadamic_id."' "; //echo $select_qry; $exe=mysqli_query($this->conn,$select_qry); while($row=mysqli_fetch_array($exe)) { $data2[$row['route_id']]=$row; } return $data2; } function stop_count($route_id){ $qry = "select count(*) as cnt,route_id from ced_t_route_stops where route_id = '".$route_id."' "; $exe=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($exe); return $row; } function insert_route_data($post,$session){ foreach($post['stopname'] as $k=>$val){ $stopnames['names'][] = $val; } foreach($post['soursedate'] as $sk=>$sval){ $stopnames['times'][] = $sval; } $create_date = date('Y-m-d'); $stops = explode(",",$post['stop_no']); $qry="INSERT INTO ced_t_routes ( source_name, route_number, source_time, destination_name, destination_time, vehicle_type, vehicle_number, school_id, created_by, created_on, academic_year_id) VALUES ('".$post['source_name']."', '".$post['route_number']."', '".$post['source_time']."', '".$post['destination_name']."', '".$post['destination_time']."', '".$post['route_vehical_type']."', '".$post['route_vehical_no']."', '".$session['child']['log_school_id']."', '".$session['child']['auth_id']."', '".$create_date."', '".$session['child']['choosen_academic_id']."' ) "; $exe=mysqli_query($this->conn,$qry); $route_id=mysqli_insert_id($this->conn); if($route_id){ $str = ''; $str .= ",('".$post['source_name']."','".$post['source_time']."','".$route_id."','".$create_date."','".$post['acadamic_id']."')"; $str .= ",('".$post['destination_name']."','".$post['destination_time']."','".$route_id."','".$create_date."','".$post['acadamic_id']."')"; for($k=0; $k < count($stopnames['names']); $k++){ $str .= ",('".$stopnames['names'][$k]."','".$stopnames['times'][$k]."','".$route_id."','".$create_date."','".$post['acadamic_id']."')"; } $str= ltrim ($str, ','); $qry = "insert into ced_t_route_stops (route_stop_name,route_stop_time,route_id,Created_on,academic_year_id) values ".$str." "; //~ echo $qry; //~ exit; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR204; } return $response; } } function route_data_byid($routeid){ $qry = "select * from ced_t_routes where route_id = '".$routeid."' "; //~ echo $qry; $exe=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($exe); return $row; } function stop_data_byrouteid($route_id){ /*$qry = "select count(route_id) as count from ced_t_route_stops where route_id = '".$route_id."' "; $exe=mysqli_query($qry); $row=mysqli_fetch_array($exe); return $row;*/ $data2 = array(); $qry = "select * from ced_t_route_stops where route_id = '".$route_id."' order by route_stop_id asc"; //~ echo $qry; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data2[$row['route_stop_id']]=$row; } return $data2; } function students_data_byid($student_id){ $qry = "select class_id,section_id from ced_t_students where student_id = '".$student_id."' "; $exe=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($exe); return $row; } function check_student_count($school_id) { $qry = "select count(student_id) as cnt from ced_t_students where school_id = '".$school_id."' "; $exe=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($exe); return $row; } function check_fathermail($post,$schoolid) { $qry = "select student_id from ced_t_students where student_father_email = '".$post['stu_fatheremail']."' and class_id = '".$post['classes']."' and section_id ='".$post['sections']."' and school_id ='".$schoolid."'"; $result=mysqli_query($this->conn,$qry); if(mysqli_num_rows($result)) { $row=mysqli_fetch_array($result); return $row; } else return 0; } function check_mothermail($post,$schoolid) { $qry = "select student_id from ced_t_students where student_mother_email = '".$post['stu_motheremail']."' and class_id = '".$post['classes']."' and section_id ='".$post['sections']."' and school_id ='".$schoolid."'"; $result=mysqli_query($this->conn,$qry); if(mysqli_num_rows($result)) { $row=mysqli_fetch_array($result); return $row; } else return 0; } function check_fathermail_edit($post,$schoolid){ $qry = "select student_id from ced_t_students where student_father_email = '".$post['stu_fatheremail']."' and class_id = '".$post['classes']."' and section_id ='".$post['sections']."' and school_id ='".$schoolid."' and student_id != '".$post['student_id']."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function check_mothermail_edit($post,$schoolid){ $qry = "select student_id from ced_t_students where student_mother_email = '".$post['stu_motheremail']."' and class_id = '".$post['classes']."' and section_id ='".$post['sections']."' and school_id ='".$schoolid."' and student_id != '".$post['student_id']."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function data_comment($commentid){ $qry = "select * from ced_t_school_diary where School_diary_id = '".$commentid."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function delete_comment($id){ $qry = "delete from ced_t_school_diary where School_diary_id = '".$id."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function get_description_dairy($data){ $dateInput = explode('/',$data['dairy_date']); $dairy_date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $str= ltrim ($data['studentids'], ','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); //$str= rtrim ($data['studentids'], ','); $qry = "select School_diary_id,description from ced_t_school_diary where class_id = '".$data['class_id']."' and section_id = '".$data['sec_id']."' and diary_date ='".$dairy_date."' and subject_id ='".$data['subject']."' and student_id ='".$str_new."' and diary_type = 2"; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function check_generalcomment_edit($data){ if($data['student_ids'] == "all"){ $str_new = "all"; }else{ $str= ltrim ($data['student_ids_data'], ','); $str= rtrim ($data['student_ids_data'], ','); $str_data = explode(',',$str); arsort($str_data); $str_new = implode(",",$str_data); } $dateInput = explode('/',$data['dairy_date']); $dairy_date=$dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $qry = "select count(School_diary_id) as cnt , School_diary_id,description from ced_t_school_diary where class_id = '".$data['classes']."' and section_id = '".$data['sections']."' and diary_date ='".$dairy_date."' and subject_id ='".$data['subjects']."' and student_id ='".$str_new."' and diary_type = 2 " ; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function check_licencekey($key){ $qry = "select student_id from ced_t_student_licenses where license_key = '".$key."' "; $result=mysqli_query($this->conn,$qry); if(mysqli_num_rows($result)) { $row=mysqli_fetch_array($result); //~ print_r($row); //~ exit; return $row; } else return 0; } function student_details_completedata($clas,$sect,$school_id,$acadamic_id){ $qry = "select student_id from ced_t_students where class_id = '".$clas."' and section_id ='".$sect."' and school_id ='".$school_id."' and academic_year_id = '".$acadamic_id."' "; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['student_id']]=$row; } return $data2; } function update_routestop_data($post,$editids,$session){ if($post['delete_route_ids'] != ''){ $stopidsids =ltrim($post['delete_route_ids'],','); $delete=$this->delete_stops($stopidsids); } $update_date = date('Y-m-d'); $stops = explode(",",$editids); $stops_sdids = explode(",",$post['stopids']); foreach($post['stopname'] as $k=>$val){ $stopnames['names'][] = $val; } foreach($post['soursedate'] as $sk=>$sval){ $stopnames['times'][] = $sval; } $i=1; $qry_route = "update `ced_t_routes` set route_number='".$post['route_number']."', source_name='".$post['source_name']."', source_time='".$post['source_time']."', destination_name='".$post['destination_name']."', destination_time='".$post['destination_time']."', vehicle_type='".$post['route_vehical_type']."', vehicle_number='".$post['route_vehical_no']."', updated_by='".$session['child']['auth_id']."', updated_on='".$update_date."' where route_id ='".$post['route_id']."' "; //echo $qry_route; $exe_route=mysqli_query($this->conn,$qry_route); $sqry = "update ced_t_route_stops set route_stop_name='".$post['source_name']."', route_stop_time='".$post['source_time']."', route_id='".$post['route_id']."', updated_by='".$session['child']['auth_id']."', updated_on='".$update_date."' where route_stop_id ='".$stops_sdids[0]."' "; $exe=mysqli_query($this->conn,$sqry); $dqry = "update ced_t_route_stops set route_stop_name='".$post['destination_name']."', route_stop_time='".$post['destination_time']."', route_id='".$post['route_id']."', updated_by='".$session['child']['auth_id']."', updated_on='".$update_date."' where route_stop_id ='".$stops_sdids[1]."' "; $exe=mysqli_query($this->conn,$dqry); for($i=0; $i <= count($stops); $i++){ if($stops[$i]){ $qry = "update ced_t_route_stops set route_stop_name='".$stopnames['names'][$i]."', route_stop_time='".$stopnames['times'][$i]."', route_id='".$post['route_id']."', updated_by='".$session['child']['auth_id']."', updated_on='".$update_date."' where route_stop_id ='".$stops[$i]."' "; // echo $qry; // echo "<br>"; } $exe=mysqli_query($this->conn,$qry); } // exit; if($exe_route) { $response=ERR203; } else { $response=ERR204; } return $response; } function insert_routestop_data($post,$ids,$session){ $create_date = date('Y-m-d'); $ids =ltrim($post['stop_no'],','); $ids =rtrim($post['stop_no'],','); $stops = explode(",",$ids); foreach($post['stopname'] as $k=>$val){ $stopnames['names'][] = $val; } foreach($post['soursedate'] as $sk=>$sval){ $stopnames['times'][] = $sval; } if($post['delete_route_ids'] != ''){ $stopidsids =ltrim($post['delete_route_ids'],','); $delete=$this->delete_stops($stopidsids); } $str =''; for($i=0; $i <= count($stops); $i++){ if($stops[$i] != '' && $stopnames['names'][$stops[$i]] != ''){ $str .= ",('".$stopnames['names'][$stops[$i]]."','".$stopnames['times'][$stops[$i]]."','".$post['route_id']."','".$create_date."','".$post['acadamic_id']."')"; } } $str= ltrim ($str, ','); $qry = "insert into ced_t_route_stops (route_stop_name,route_stop_time,route_id,Created_on,academic_year_id) values ".$str." "; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR204; } return $response; } function route_data_staff($route_id,$acadamic_id){ $qry = "select * from ced_t_staff_routes where route_id = '".$route_id."' and academic_year_id = '".$acadamic_id."' "; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['staff_route_id']]=$row; } return $data2; } function route_data_student($route_id,$acadamic_id){ $qry = "select * from ced_t_students_routes where route_id = '".$route_id."' and academic_year_id = '".$acadamic_id."' "; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['staff_route_id']]=$row; } return $data2; } function route_data_staff_edit($route_id,$acadamic_id){ $qry = "select * from ced_t_staff_routes where route_id = '".$route_id."' and academic_year_id = '".$acadamic_id."' "; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['staff_route_id']]=$row; } return $data2; } function route_data_student_edit($route_id,$acadamic_id){ $qry = "select * from ced_t_students_routes where route_stop_id = '".$route_id."' and academic_year_id = '".$acadamic_id."' "; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['staff_route_id']]=$row; } return $data2; } function check_route_data($post,$session){ $qry = "select * from ced_t_routes where route_number = '".$post['route_number']."' and academic_year_id = '".$session['child']['choosen_academic_id']."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function check_route_data_edit($post,$session){ $qry = "select * from ced_t_routes where route_number = '".$post['route_number']."' and academic_year_id = '".$session['child']['choosen_academic_id']."' and route_id != '".$post['route_id']."' "; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function delete_route($routeid){ $qry = "delete from ced_t_route_stops where route_id = '".$routeid."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $qry = "delete from ced_t_routes where route_id = '".$routeid."' "; $exe=mysqli_query($this->conn,$qry); $response=ERR203; } else { $response=ERR204; } return $response; } function delete_route_stop($routeid){ $qry = "delete from ced_t_route_stops where route_stop_id = '".$routeid."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR204; } return $response; } function check_generalnotice_data($post){ $qry = "select * from `ced_t_noticeboard` where class_id = '".$post['classes']."' and section_id ='".$post['sections']."' and notification_type ='".$post['category']."' and academicyear_id = '".$post['academic_id']."' and school_id = '".$post['school_id']."' "; //echo $qry; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function insert_generalnotice($post,$session,$file){ $target_dir = "uploads/noticeboard/"; //~ print_r($post); //~ exit; $au_type =''; if($post['classes'] == "all" && $post['sections'] == "all"){ $au_type = "1"; }else if($post['classes'] != "all" && $post['sections'] == "all"){ $au_type = "2"; }else if($post['classes'] != "all" && $post['sections'] != "all"){ $au_type = "3"; } if($post['category'] == "1"){ $category = "General"; }else if($post['category'] == "2"){ $category = "Vacation"; }else if($post['category'] == "3"){ $category = "Activities"; }else if($post['category'] == "4"){ $category = "PTM"; } $created_date = date('Y-m-d H:i:s'); $qry="INSERT INTO ced_t_noticeboard ( class_id, section_id, academicyear_id, notification_type, school_id, created_by, created_on, notification_description, student_id, audience_type) VALUES ('".$post['classes']."', '".$post['sections']."', '".$session['child']['choosen_academic_id']."', '".$post['category']."', '".$session['child']['log_school_id']."', '".$session['child']['auth_id']."', '".$created_date."', '".mysqli_real_escape_string($this->conn,$post['notice_description'])."', 'all', '".$au_type."' ) "; //~ echo $qry; //~ exit; $result=mysqli_query($this->conn,$qry); $ntc=mysqli_insert_id($this->conn); $i=0; if($ntc){ foreach($file['photos']['name'] as $img) { if (($file["photos"]["type"][$i] == "image/jpeg") || ($file["photos"]["type"][$i] == "image/png") || ($file["photos"]["type"][$i] == "image/jpg")) { $target_file = $target_dir .date('his'). basename($img); $filename = $this->compress_image($file["photos"]["tmp_name"][$i], $target_file, 50); $savef=basename($target_file); $sql="insert into ced_t_noticeboard_images set notice_id='$ntc',image='".$savef."'"; mysqli_query($this->conn,$sql); } /*$target_file = $target_dir .date('his'). basename($img); if (move_uploaded_file($file["photos"]["tmp_name"][$i], $target_file)) { $savef=basename($target_file); $sql="insert into ced_t_noticeboard_images set notice_id='$ntc',image='".$savef."'"; mysqli_query($sql); }*/ $i++; } $response=ERR203; $_SESSION['child']['notice_cate_id'] = $post['category']; $error=1; if($post['classes'] == "all" && $post['sections'] == "all"){ if($post['category']==3) { $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.hostler_status=1" ; }else { $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']; } }else if($post['classes'] == "all" && $post['sections'] != "all"){ if($post['category']==3) { $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.section_id=".(int)$post['sections']." and s.hostler_status=1" ; }else { $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.section_id=".(int)$post['sections'] ; } }else if($post['classes'] != "all" && $post['sections'] == "all"){ if($post['category']==3) { $qry="select sp.device_id,sp.student_id,sp.authenticate_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.class_id=".(int)$post['classes']." and s.hostler_status=1" ; }else { $qry="select sp.device_id,sp.student_id,sp.authenticate_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.class_id=".(int)$post['classes'] ; } }else { if($post['category']==3) { $qry="select sp.device_id,sp.student_id,sp.authenticate_id,s.student_firstname,s.student_firstname,s.student_father_mobile,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']." and s.hostler_status=1"; }else { $qry="select sp.device_id,sp.student_id,sp.authenticate_id,s.student_firstname,s.student_father_mobile,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']; } } $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { //$qry2="select student_id from ced_t_student_licenses where student_id=".(int)$row['student_id']." and academic_year_id=".(int)$session['child']['choosen_academic_id']." and license_status=1"; $cklic=$this->check_lic_status($row['student_id']); $notification_status=$this->check_notification_status($row['authenticate_id']); $message="Notice Board updated for ".$row['student_firstname']." ".$row['student_lastname']." for ".$category." messages"; // $exe2=mysqli_query($qry2); //$devid=$this->parentDeviceId($row['student_id']); if($row['device_id']!='' && $cklic && $notification_status == 1) { //echo $devid; //echo "<br>"; $notify=$this->send_notification($row['device_id'],$message,$row['student_id'],'notbrd',date('Y-m-d'),$created_date,$post['category'],$ntc); if($post['category']==1) { $name=$row['student_father_name']; $mobile=$row['student_father_mobile']; $message_sms="Dear Parent, this is to inform you that ".$post['notice_description']." - Thank You"; $send_msg=file_get_contents("http://180.149.242.74/unified.php?usr=dharani@krify.net&pwd=dksmr555&ph=".$mobile."&sndr=SKLONL&text=".urlencode($message_sms)); } //print_r($notify); } if($cklic!=0) { $noteins="insert into ced_t_notifications set notify_name='".$message."',student_id=".(int)$row['student_id'].",class_id=".(int)$row['class_id'].",section_id=".(int)$row['section_id'].",school_id=".(int)$row['school_id'].",notify_type='notbrd',general_column1='".$created_date."',general_column2=".$post['category'].",read_status=1,created_on='".date('Y-m-d')."'"; mysqli_query($this->conn,$noteins); } } } }else{ $response=ERR204; } return $response; } function generalnotice_data($sessions,$type){ $qry = "select * from ced_t_noticeboard where school_id = '".$sessions['child']['log_school_id']."' and academicyear_id = '".$sessions['child']['choosen_academic_id']."' and notification_type = '".$type."' order by notification_id desc"; //echo $qry; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['notification_id']]=$row; } return $data2; } function generalnotice_calenderview($sessions,$type,$date) { $month = explode("-",$date); //$qry = "select * from ced_t_noticeboard where school_id = '".$sessions['child']['log_school_id']."' and academicyear_id = '".$sessions['child']['choosen_academic_id']."' and date(`created_on`) = '".$date."' order by notification_id desc"; $qry = "select * from ced_t_noticeboard where school_id = '".$sessions['child']['log_school_id']."' and academicyear_id = '".$sessions['child']['choosen_academic_id']."' and notification_type =6 and month(created_on)='".$month[1]."' order by created_on asc"; //echo $qry; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['notification_id']]=$row; } return $data2; } function generalnotice_images_data($id){ $qry = "select * from `ced_t_noticeboard_images` where notice_id = '".$id."' order by noticeboard_img_id asc"; //echo $qry; $result=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($result)) { $data2[$row['noticeboard_img_id']]=$row; } return $data2; } function notice_data_byid($id){ $qry = "select * from `ced_t_noticeboard` where notification_id = '".$id."' "; //~ echo $qry; //~ exit; $result=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($result); return $row; } function update_generalnotice($post,$session,$file){ $imageids =ltrim($post['edit_image_ids'],','); $target_dir = "uploads/noticeboard/"; $created_date = date('Y-m-d H:i:s'); if($post['category'] == "1"){ $category = "General"; }else if($post['category'] == "2"){ $category = "Vacation"; }else if($post['category'] == "3"){ $category = "Activities"; }else if($post['category'] == "4"){ $category = "PTM"; }else if($post['category'] == "5"){ $category = "For You"; } $qry="update ced_t_noticeboard set updated_by='".$session['child']['auth_id']."',notification_description='".mysqli_real_escape_string($this->conn,$post['notice_description'])."' where notification_id = '".mysqli_real_escape_string($this->conn,$post['notice_id'])."' "; //~ echo $qry; //~ exit; $exe=mysqli_query($this->conn,$qry); $i=0; if($exe) { if($post['edit_image_ids'] != ''){ $delete=$this->deletethisimage($imageids); } foreach($file['photos']['name'] as $img) { if (($file["photos"]["type"][$i] == "image/jpeg") || ($file["photos"]["type"][$i] == "image/png") || ($file["photos"]["type"][$i] == "image/jpg")) { $target_file = $target_dir .date('his'). basename($img); $filename = $this->compress_image($file["photos"]["tmp_name"][$i], $target_file, 70); $savef=basename($target_file); $sql="insert into ced_t_noticeboard_images set notice_id='".$post['notice_id']."',image='".$savef."'"; mysqli_query($this->conn,$sql); } /*$target_file = $target_dir .date('his'). basename($img); if (move_uploaded_file($file["photos"]["tmp_name"][$i], $target_file)) { $savef=basename($target_file); $sql="insert into ced_t_noticeboard_images set notice_id='".$post['notice_id']."',image='".$savef."'"; mysqli_query($sql); }*/ $i++; } $response=ERR203; $_SESSION['child']['notice_cate_id'] = $post['category']; $error=1; if($post['classes'] == "all" && $post['sections'] == "all"){ $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']; }else if($post['classes'] == "all" && $post['sections'] != "all"){ $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.section_id=".(int)$post['sections'] ; }else if($post['classes'] != "all" && $post['sections'] == "all"){ $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.class_id=".(int)$post['classes'] ; }else if($post['student'] == '' || $post['student'] == 'all'){ $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']; }else { $qry="select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']." and s.student_id in(".$post['student'].") "; } $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { //$qry2="select student_id from ced_t_student_licenses where student_id=".(int)$row['student_id']." and academic_year_id=".(int)$session['child']['choosen_academic_id']." and license_status=1"; //$exe2=mysqli_query($qry2); $cklic=$this->check_lic_status($row['student_id']); $notification_status=$this->check_notification_status($row['authenticate_id']); $message="Notice Board updated for ".$row['student_firstname']." ".$row['student_lastname']." for ".$category." messages"; if($row['device_id'] !='' && $cklic && $notification_status == 1) { //$devid=$this->parentDeviceId($row['student_id']); //if($devid!='0') //{ $notify=$this->send_notification($row['device_id'],$message,$row['student_id'],'notbrd',date('Y-m-d'),$created_date,$post['category'],$post['notice_id']); //} } if($cklic!=0) { $noteins="insert into ced_t_notifications set notify_name='".$message."',student_id=".(int)$row['student_id'].",class_id=".(int)$row['class_id'].",section_id=".(int)$row['section_id'].",school_id=".(int)$row['school_id'].",notify_type='notbrd',general_column1='".$created_date."',general_column2='".$post['category']."',read_status=1,created_on='".date('Y-m-d')."'"; mysqli_query($this->conn,$noteins); } } } } else { $response=ERR205; } return $response; } function delete_notice($notice_id){ $qry = "delete from ced_t_noticeboard where notification_id = '".$notice_id."' "; $exe=mysqli_query($this->conn,$qry); if($exe) { $qry = "delete from ced_t_noticeboard_images where noticeboard_img_id = '".$notice_id."' "; $exe=mysqli_query($this->conn,$qry); $response=ERR203; } else { $response=ERR204; } return $response; } function parentDeviceId($id) { $sql="SELECT sp.device_id FROM `ced_t_students_parent` sp inner join `ced_t_student_licenses` sl on sp.student_id=sl.student_id WHERE sp.student_id='$id' and sp.account_status=1 and sl.license_status=1"; //$sql="select device_id from ced_t_students_parent where student_id=".(int)$id; $exe=mysqli_query($this->conn,$sql); if(mysqli_num_rows($exe)) { $res=mysqli_fetch_array($exe); return $res['device_id']; } else return '0'; } function send_notification($registatoin_ids,$message,$uid,$type,$date,$today,$category,$id) { $msg['message']=$message; $msg['student_id']=$uid; $msg['type']=$type; $msg['date']=$date; $msg['apldate']=$today; $msg['category']=$category; $msg['notice_id']=$id; $registatoin_ids=array($registatoin_ids); $googleapi='AIzaSyDZjnc0dm76JpZpk5mJSw_oOPgfoDSSbR0'; $url = 'https://android.googleapis.com/gcm/send'; $fields = array('registration_ids' => $registatoin_ids,'data' => $msg); $headers = array('Authorization: key='.$googleapi,'Content-Type: application/json'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Disabling SSL Certificate support temporarly curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); // Execute post $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } function insert_generalnotice_foryou($post,$session,$file){ $target_dir = "uploads/noticeboard/"; $au_type ='4'; $category = "For You"; $str = ''; $created_date = date('Y-m-d H:i:s'); if($post['status'] == "all"){ $studentids = "all"; }else { foreach($post['student'] as $k=>$val){ $str .= ",".$val; } $str =ltrim($str,','); $studentids = $str; } $qry="INSERT INTO ced_t_noticeboard ( class_id, section_id, academicyear_id, notification_type, student_id, school_id, created_by, created_on, notification_description, audience_type) VALUES ('".$post['classes']."', '".$post['sections']."', '".$session['child']['choosen_academic_id']."', '".$post['category']."', '".$studentids."', '".$session['child']['log_school_id']."', '".$session['child']['auth_id']."', '".$created_date."', '".mysqli_real_escape_string($this->conn,$post['notice_description'])."', '".$au_type."' ) "; $result=mysqli_query($this->conn,$qry); $ntc=mysqli_insert_id($this->conn); $i=0; if($ntc){ foreach($file['photos']['name'] as $img) { if (($file["photos"]["type"][$i] == "image/jpeg") || ($file["photos"]["type"][$i] == "image/png") || ($file["photos"]["type"][$i] == "image/jpg")) { $target_file = $target_dir .date('his'). basename($img); $filename = $this->compress_image($file["photos"]["tmp_name"][$i], $target_file, 70); $savef=basename($target_file); $sql="insert into ced_t_noticeboard_images set notice_id='$ntc',image='".$savef."'"; mysqli_query($this->conn,$sql); } /*$target_file = $target_dir .date('his'). basename($img); if (move_uploaded_file($file["photos"]["tmp_name"][$i], $target_file)) { $savef=basename($target_file); $sql="insert into ced_t_noticeboard_images set notice_id='$ntc',image='".$savef."'"; mysqli_query($sql); }*/ $i++; } $response=ERR203; if($post['status'] == "all"){ //$qry="select student_id,student_firstname,student_lastname from ced_t_students where school_id=".(int)$session['child']['log_school_id']." and academic_year_id=".(int)$session['child']['choosen_academic_id']." and section_id=".(int)$post['sections']." and class_id=".(int)$post['classes']; $qry = "select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.status=1 and sp.account_status=1"; }else { //$qry = "select student_id,class_id,section_id,student_firstname,student_lastname from ced_t_students where class_id='".(int)$post['classes']."' and school_id='".(int)$session['child']['log_school_id']."' and academic_year_id=".(int)$session['child']['choosen_academic_id']." and section_id='".(int)$post['sections']."' and student_id in(".$studentids.") "; $qry = "select sp.device_id,sp.authenticate_id,sp.student_id,s.student_firstname,s.student_lastname,s.section_id,s.class_id,s.school_id from ced_t_students_parent sp inner join ced_t_students s on sp.student_id=s.student_id where s.school_id=".(int)$session['child']['log_school_id']." and s.class_id=".(int)$post['classes']." and s.section_id=".(int)$post['sections']." and s.academic_year_id=".(int)$session['child']['choosen_academic_id']." and s.student_id in(".$studentids.") and s.status=1 and sp.account_status=1"; } $exe=mysqli_query($this->conn,$qry); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_array($exe)) { //$qry2="select student_id from ced_t_student_licenses where student_id=".(int)$row['student_id']." and academic_year_id=".(int)$session['child']['choosen_academic_id']." and license_status=1"; //$exe2=mysqli_query($qry2); // if(mysqli_num_rows($exe2)) //{ $cklic=$this->check_lic_status($row['student_id']); $notification_status=$this->check_notification_status($row['authenticate_id']); $message="Notice Board updated for ".$row['student_firstname']." ".$row['student_lastname']." for ".$category." messages"; //$devid=$this->parentDeviceId($row['student_id']); if($row['device_id']!='' && $cklic && $notification_status == 1 ) { $notify=$this->send_notification($row['device_id'],$message,$row['student_id'],'notbrd',date('Y-m-d'),$created_date,$post['category'],$ntc); } if($cklic!=0) { $noteins="insert into ced_t_notifications set notify_name='".$message."',student_id=".(int)$row['student_id'].",class_id=".(int)$row['class_id'].",section_id=".(int)$row['section_id'].",school_id=".(int)$row['school_id'].",notify_type='notbrd',general_column1='".$created_date."',general_column2='".$post['category']."',read_status=1,created_on='".date('Y-m-d')."'"; mysqli_query($this->conn,$noteins); } // } } } }else{ $response=ERR204; } return $response; } function get_students_data_notice($class_id,$section_id,$school_id){ $qry = "select student_id,class_id,section_id,student_firstname,student_lastname from ced_t_students where class_id='".$class_id."' and school_id='".$school_id."' and section_id='".$section_id."' "; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data2[$row['student_id']]=$row; } return $data2; } function get_students_data_notice_byids($class_id,$section_id,$studentids,$school_id){ $qry = "select student_id,class_id,section_id,student_firstname,student_lastname from ced_t_students where class_id='".$class_id."' and school_id='".$school_id."' and section_id='".$section_id."' and student_id in(".$studentids.") "; //echo $qry; $exe=mysqli_query($this->conn,$qry); while($row=mysqli_fetch_array($exe)) { $data2[$row['student_id']]=$row; } return $data2; } function notice_data_images($notice_id) { $sql="select * from ced_t_noticeboard_images where notice_id=".(int)$notice_id; $exe=mysqli_query($this->conn,$sql); if(mysqli_num_rows($exe)) { while($row=mysqli_fetch_assoc($exe)) { $rec[]=$row; } return $rec; } else { return 0; } } function deletethisimage($imgids) { $sql="delete from ced_t_noticeboard_images where noticeboard_img_id in (".$imgids.")"; mysqli_query($this->conn,$sql); return 'deleted'; } function getsubject_name($subject_id,$school_id,$academic_id) { $sql="SELECT `subject_name` FROM `ced_t_subjects` WHERE `subject_id` ='".$subject_id."' and `school_id`='".$school_id."' and `academic_year_id`='".$academic_id."'"; //echo $sql; $result=mysqli_query($this->conn,$sql); $row=mysqli_fetch_array($result); return $row['subject_name']; } function student_name($id) { $sql="SELECT `student_firstname` , `student_rollno`,`student_lastname` FROM `ced_t_students` WHERE `student_id` = '".$id."' "; //echo $sql; $result=mysqli_query($this->conn,$sql); /*while($row=mysqli_fetch_array($result)) { $data[]=$row; }*/ $row=mysqli_fetch_array($result); $data=$row['student_firstname']." ".$row['student_lastname']; //$data=$row['student_rollno']; return $data; } function delete_stops($stopids) { $sql="delete from ced_t_route_stops where route_stop_id in (".$stopids.")"; mysqli_query($this->conn,$sql); return 'deleted'; } function check_password($pass,$uid){ $sql="SELECT `password` FROM `ced_t_authentication_details` WHERE `authenticate_id` = '".$uid."' "; $result=mysqli_query($this->conn,$sql); $row=mysqli_fetch_array($result); $pwd=$this->decrypt($row['password']); return $pwd; } /*********************Decrypt the password*********************/ function decrypt($string) { //~ echo 234; $key='skoolonl!ne2o2!'; $result=''; $string = base64_decode($string); for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)-ord($keychar)); $result.=$char; } return $result; } /*********************Encrypt the password*********************/ function encrypt($string) { //~ echo 2432; $key='skoolonl!ne2o2!'; $result = ''; for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)+ord($keychar)); $result.=$char; } return base64_encode($result); } function check_lic_status($student_id) { $sql="select license_status from ced_t_student_licenses where student_id=".(int)$student_id." and license_status=1"; $exe=mysqli_query($this->conn,$sql); if(mysqli_num_rows($exe)>0) return 1; else return 0; } function check_notification_status($notification_id){ $sql="select notifications from ced_t_authentication_details where authenticate_id=".(int)$notification_id." and notifications=1"; $exe=mysqli_query($this->conn,$sql); if(mysqli_num_rows($exe)>0) return 1; else return 0; } function check_schoollicence_count($studentid){ $today_date = date('Y-m-d'); $qry = "SELECT sl.license_count,sl.school_license_id,sl.school_id FROM `ced_t_school_licenses` as sl INNER JOIN `ced_t_student_licenses` as stl ON sl.school_license_id = stl.school_license_id where stl.student_id = '".$studentid."' and sl.license_valid_to > '".$today_date."' and sl.license_status = 1"; //echo $qry; $exe=mysqli_query($this->conn,$qry); $row=mysqli_fetch_array($exe); return $row; } function check_license_count($licen_id){ $sql="select count(student_id) as cnt from ced_t_student_licenses where school_license_id=".(int)$licen_id." "; $exe=mysqli_query($this->conn,$sql); $row=mysqli_fetch_array($exe); //~ print_r($row); //~ exit; return $row; } function update_license_set($post,$val){ $qry = "update ced_t_student_licenses set license_status='".$post['status']."',school_license_id = '".$val."' where student_id ='".$post['stuid']."' "; //echo $qry; //exit; $exe=mysqli_query($this->conn,$qry); if($exe) { $response=ERR203; } else { $response=ERR205; } return $response; } function compress_image($source_url, $destination_url, $quality) { $info = getimagesize($source_url); if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url); elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url); elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url); imagejpeg($image, $destination_url, $quality); return $destination_url; } } ?>