JezK
Edit File: 2021-09-24adm_operations2.php
<?php date_default_timezone_set("Asia/Calcutta"); include_once("connect.php"); include_once("error_codes.php"); class adm_operations2 { function details_nonteach_staff($schoolid,$acadamicid) { $select_qry = "select staff_name,staff_id,staff_email,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' order by staff_type"; //echo $select_qry; //exit; $exe=mysql_query($select_qry); if(mysql_num_rows($exe)) { while($row=mysql_fetch_assoc($exe)) { $data2[]=$row; //$data2[$row['staff_id']]=$row; } return $data2; } else return 0; } function encryptIt($q) { $cryptKey = 'qJB0rGtIn5UB1xG03efyCp'; $qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) ); return( $qEncoded ); } function create_nonteach_staff($post,$session) { $autogenerate=rand(30000,100000); $created_date = date('Y-m-d'); $autogenerate=$this->encryptIt($autogenerate); $phsql="select school_id from ced_t_school where school_phone='".$post['staff_number']."'"; $exe=mysql_query($phsql); $phsql1="select staff_mobile from ced_t_school_staff where staff_mobile='".$post['staff_number']."'"; $exe1=mysql_query($phsql1); if(mysql_num_rows($exe) || mysql_num_rows($exe1)) { $response='exists'; return $response; } else { $qry="INSERT INTO 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_email='".$post['email_id']."',status=1,school_id='".$session['child']['log_school_id']."',staff_driving_license='".$post['staff_licence']."',issuing_authority='".$post['issuing_authority']."', staff_type='".$post['staff_type']."',academic_year_id='".$session['child']['choosen_academic_id']."',created_by='".$session['child']['auth_id']."',created_on='".$created_date."'"; $result=mysql_query($qry); if($result) $response=mysql_insert_id(); else $response=ERR204; } return $response; } function staff_data_byid($staff_id) { $qry = "select * from ced_t_school_staff where staff_id = '".$staff_id."' "; $result=mysql_query($qry); $row=mysql_fetch_array($result); return $row; } function uploadmypic($id,$file) { $qry="update ced_t_school_staff set staff_pic='".$file."' where staff_id=".(int)$id; mysql_query($qry); } function staff_data_update($post,$session,$files) { $sql="select school_phone from ced_t_school where school_phone='".$post['staff_number']."'"; $exe=mysql_query($sql); $sql1="select staff_mobile from ced_t_school_staff where staff_mobile='".$post['staff_number']."' and staff_id<>".(int)$post['staff_id']; $exe1=mysql_query($sql1); /* $emsql="select staff_email from ced_t_school_staff where staff_email='".$post['email_id']."' and school_id<>".(int)$session['child']['log_school_id']; $emexe=mysql_query($emsql); $emsql1="select school_email from ced_t_school where school_email='".$post['email_id']."' and school_id<>".(int)$session['child']['log_school_id']; $emexe1=mysql_query($emsql1); if(mysql_num_rows($emexe) || mysql_num_rows($emexe1)) { return 'email_exist'; } */ if(mysql_num_rows($exe) || mysql_num_rows($exe1)) { $response='exists'; return $response; } else { $pull="select auth_ref from ced_t_school_staff where staff_id=".(int)$post['staff_id']; $pullexe=mysql_query($pull); $record=mysql_fetch_array($pullexe); if($record['auth_ref']!='0') { $sql1="update ced_t_authentication_details set email='".$post['staff_number']."' where authenticate_id=".(int)$record['auth_ref']; $exe1=mysql_query($sql1); } if($files!='') { $picupd="update ced_t_school_staff set staff_pic='".$files."' where staff_id=".(int)$post['staff_id']; mysql_query($picupd); } $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_email='".$post['email_id']."',school_id='".$session['child']['log_school_id']."',staff_driving_license='".$post['staff_licence']."',issuing_authority='".$post['issuing_authority']."', academic_year_id='".$session['child']['choosen_academic_id']."',updated_by='".$session['child']['auth_id']."',updated_on='".$update_date."' where staff_id ='".$post['staff_id']."'"; $exe=mysql_query($qry); $response=ERR203; } return $response; } function deletenonteachstaff($nt_id) { $qry2="select staff_route_id from ced_t_staff_routes where staff_id=".(int)$nt_id; $exe1=mysql_query($qry2); $qry1="select driver_id from ced_t_geovalues where driver_id=".(int)$nt_id; $exe=mysql_query($qry1); if(mysql_num_rows($exe) || mysql_num_rows($exe1)) return 'RE'; else { $sql="select auth_ref from ced_t_school_staff where staff_id=".(int)$nt_id; $execute=mysql_query($sql); $rec=mysql_fetch_array($execute); $del="delete from ced_t_authentication_details where authenticate_id=".(int)$rec['auth_ref']; mysql_query($del); $del1="delete from ced_t_school_staff where staff_id=".(int)$nt_id; mysql_query($del1); return 'SUC'; } } }