Advertisement
badlogic

student info class

Jul 27th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 78.45 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Initial Declaration
  4.  */
  5.  
  6. /**
  7.  * Class Module
  8.  *
  9.  * @author  Arnold P. Orbista
  10.  *
  11.  */
  12.  
  13. class clsStudInfo{
  14.  
  15.     var $conn;
  16.     var $fieldMap_PData;
  17.     var $fieldMap_Fbg;
  18.     var $fieldMap_schHistory;
  19.     var $fieldMap_hhistory;
  20.     var $Data;
  21.     var $otherInfo;
  22.     var $otherFamInfo;
  23.     var $familyMember;
  24.     var $otherMember;
  25.     var $schHistory;
  26.  
  27.     /**
  28.      * Class Constructor
  29.      *
  30.      * @param object $dbconn_
  31.      * @return clsStudInfo object
  32.      */
  33.     function clsStudInfo($dbconn_ = null){
  34.         $this->conn =& $dbconn_;
  35.         $this->fieldMap_PData = array(
  36.             "ppd_lastname" => "ppd_lastname"
  37.         ,"ppd_firstname" => "ppd_firstname"
  38.         ,"ppd_mothers_maiden_name" => "ppd_mothers_maiden_name"
  39.         ,"ppd_middlename" => "ppd_middlename"
  40.         ,"ppd_nickname" => "ppd_nickname"
  41.         ,"ppd_gender" => "ppd_gender"
  42.         ,"ppd_bday_mm" => "ppd_bday_mm"
  43.         ,"ppd_bday_dd" => "ppd_bday_dd"
  44.         ,"ppd_bday_yy" => "ppd_bday_yy"
  45.         ,"ppd_bday" => "ppd_bday"
  46. //      ,"ppd_age" => "ppd_age"
  47.         ,"ppd_caddress1" => "ppd_caddress1"
  48.         ,"ppd_caddress2" => "ppd_caddress2"
  49.         ,"ppd_caddress3" => "ppd_caddress3"
  50.         ,"ppd_caddress4" => "ppd_caddress4"
  51.         ,"ppd_caddress5" => "ppd_caddress5"
  52.         ,"ppd_czipcode" => "ppd_czipcode"
  53.         ,"ppd_paddress1" => "ppd_paddress1"
  54.         ,"ppd_paddress2" => "ppd_paddress2"
  55.         ,"ppd_paddress3" => "ppd_paddress3"
  56.         ,"ppd_paddress4" => "ppd_paddress4"
  57.         ,"ppd_paddress5" => "ppd_paddress5"
  58.         ,"ppd_pzipcode" => "ppd_pzipcode"
  59.         ,"ppd_citizenship" => "ppd_citizenship"
  60.         ,"ppd_citizenshipoth" => "ppd_citizenshipoth"
  61. //      ,"ppd_telcelno" => "ppd_telcelno"
  62. //      ,"ppd_telcelno2" => "ppd_telcelno2"
  63. //      ,"ppd_mobileno" => "ppd_mobileno"
  64. //      ,"ppd_mobileno2" => "ppd_mobileno2"
  65.         ,"ppd_email" => "ppd_email"
  66.         ,"ppd_guardian" => "ppd_guardian"
  67.         ,"ppd_guardian_address" => "ppd_guardian_address"
  68.         ,"ppd_guardian_contact_num" => "ppd_guardian_contact_num"
  69.         ,"ppd_guardian_email" => "ppd_guardian_email"
  70.         ,"ppd_acrno" => "ppd_acrno"
  71.         ,"ppd_dateofissue" => "ppd_dateofissue"
  72.         ,"ppd_placeofissue" => "ppd_placeofissue"
  73.         ,"ppd_passportno" => "ppd_passportno"
  74.         ,"ppd_studno" => "ppd_studno"
  75. //      ,"ppd_picture" => "ppd_picture"
  76.         ,"stud_info_yearsinschool" => "stud_info_yearsinschool"
  77.         );
  78.  
  79.         $this->fieldMap_Fbg = array(
  80.             "studfambg_fathersname" => "studfambg_fathersname"
  81.         ,"studfambg_fatherslastname" => "studfambg_fatherslastname"
  82.         ,"studfambg_fathersbday" => "studfambg_fathersbday"
  83.         ,"studfambg_fathersage" => "studfambg_fathersage"
  84.         ,"studfambg_fathersplaceofbirth" => "studfambg_fathersplaceofbirth"
  85.         ,"studfambg_fathersmaritalstatus" => "studfambg_fathersmaritalstatus"
  86.         ,"studfambg_fathersaddress1" => "studfambg_fathersaddress1"
  87.         ,"studfambg_fathersaddress2" => "studfambg_fathersaddress2"
  88.         ,"studfambg_fathersaddress3" => "studfambg_fathersaddress3"
  89.         ,"studfambg_fathersaddress4" => "studfambg_fathersaddress4"
  90.         ,"studfambg_fathersaddress5" => "studfambg_fathersaddress5"
  91.         ,"studfambg_fathershomeownership" => "studfambg_fathershomeownership"
  92.         ,"studfambg_fatherscitizenship" => "studfambg_fatherscitizenship"
  93.         ,"studfambg_fatherscontactnumber" => "studfambg_fatherscontactnumber"
  94.         ,"studfambg_fathersemail" => "studfambg_fathersemail"
  95.         ,"studfambg_fathersreligion" => "studfambg_fathersreligion"
  96.         ,"studfambg_fatherslanguage" => "studfambg_fatherslanguage"
  97.         ,"studfambg_fathersschool" => "studfambg_fathersschool"
  98.         ,"studfambg_fathershighesteducattain" => "studfambg_fathershighesteducattain"
  99.         ,"studfambg_fathersoccupation" => "studfambg_fathersoccupation"
  100.         ,"studfambg_fatherscompany" => "studfambg_fatherscompany"
  101.         ,"studfambg_fathersofw" => "studfambg_fathersofw"
  102.         ,"studfambg_fathersbussadd" => "studfambg_fathersbussadd"
  103.         ,"studfambg_fathersbusstelno" => "studfambg_fathersbusstelno"
  104.         ,"studfambg_fathersannualincome" => "studfambg_fathersannualincome"
  105.         ,"studfambg_mothersname" => "studfambg_mothersname"
  106.         ,"studfambg_mothersmaidenname" => "studfambg_mothersmaidenname"
  107.         ,"studfambg_mothersbday" => "studfambg_mothersbday"
  108.         ,"studfambg_mothersage" => "studfambg_mothersage"
  109.         ,"studfambg_mothersplaceofbirth" => "studfambg_mothersplaceofbirth"
  110.         ,"studfambg_mothersmaritalstatus" => "studfambg_mothersmaritalstatus"
  111.         ,"studfambg_mothersaddress1" => "studfambg_mothersaddress1"
  112.         ,"studfambg_mothersaddress2" => "studfambg_mothersaddress2"
  113.         ,"studfambg_mothersaddress3" => "studfambg_mothersaddress3"
  114.         ,"studfambg_mothersaddress4" => "studfambg_mothersaddress4"
  115.         ,"studfambg_mothersaddress5" => "studfambg_mothersaddress5"
  116.         ,"studfambg_mothershomeownership" => "studfambg_mothershomeownership"
  117.         ,"studfambg_motherscontactnumber" => "studfambg_motherscontactnumber"
  118.         ,"studfambg_mothersemail" => "studfambg_mothersemail"
  119.         ,"studfambg_mothersreligion" => "studfambg_mothersreligion"
  120.         ,"studfambg_motherscitizenship" => "studfambg_motherscitizenship"
  121.         ,"studfambg_motherslanguage" => "studfambg_motherslanguage"
  122.         ,"studfambg_mothershighesteducattain" => "studfambg_mothershighesteducattain"
  123.         ,"studfambg_mothersschool" => "studfambg_mothersschool"
  124.         ,"studfambg_mothersoccupation" => "studfambg_mothersoccupation"
  125.         ,"studfambg_motherscompany" => "studfambg_motherscompany"
  126.         ,"studfambg_mothersofw" => "studfambg_mothersofw"
  127.         ,"studfambg_mothersbussadd" => "studfambg_mothersbussadd"
  128.         ,"studfambg_mothersbusstelno" => "studfambg_mothersbusstelno"
  129.         ,"studfambg_mothersannualincome" => "studfambg_mothersannualincome"
  130.         ,"studfambg_totalhouseholdincome" => "studfambg_totalhouseholdincome"
  131.         ,"studfambg_sameascurrentadd_mother" => "studfambg_sameascurrentadd_mother"
  132.         ,"studfambg_sameascurrentadd_father" => "studfambg_sameascurrentadd_father"
  133.         );
  134.  
  135.         $this->fieldMap_schHistory = array(
  136.             "schistory_lvl" => "schistory_lvl"
  137.         ,"schistory_school" => "schistory_school"
  138.         ,"schistory_schooladdress" => "schistory_schooladdress"
  139.         ,"schistory_yrsFrom" => "schistory_yrsFrom"
  140.         ,"schistory_yearsTo" => "schistory_yearsTo"
  141.         ,"schistory_honors" => "schistory_honors"
  142.         ,"schistory_honorsYear" => "schistory_honorsYear"
  143.         ,"schistory_specialCourse" => "schistory_specialCourse"
  144.         ,"schistory_specialCourseRadio" => "schistory_specialCourseRadio"
  145.         ,"schistory_specialCourseYear" => "schistory_specialCourseYear"
  146.         ,"schistory_summerClasses" => "schistory_summerClasses"
  147.         ,"schistory_summerClassesRadio" => "schistory_summerClassesRadio"
  148.         ,"schistory_summerClassesYear" => "schistory_summerClassesYear"
  149.         ,"schistory_failedSubject" => "schistory_failedSubject"
  150.         ,"schistory_failedSubjectRadio" => "schistory_failedSubjectRadio"
  151.         ,"schistory_failedSubjectYear" => "schistory_failedSubjectYear"
  152.         ,"schistory_repeated" => "schistory_repeated"
  153.         ,"schistory_repeatedRadio" => "schistory_repeatedRadio"
  154.         ,"schistory_repeatedYear" => "schistory_repeatedYear"
  155.         ,"transferee_prev_school_from" => "transferee_prev_school_from"
  156.         ,"transferee_prev_school_to" => "transferee_prev_school_to"
  157.         ,"transferee_reason" => "transferee_reason"
  158.         ,"transferee_prev_school_from1" => "transferee_prev_school_from1"
  159.         ,"transferee_prev_school_to1" => "transferee_prev_school_to1"
  160.         ,"transferee_disciplinary" => "transferee_disciplinary"
  161.         );
  162.  
  163.         $this->fieldMap_hhistory = array(
  164.             //"health_height" => "health_height"
  165.             "health_weight" => "health_weight"
  166.         ,"health_eyesight" => "health_eyesight"
  167.         ,"health_hearing" => "health_hearing"
  168.         ,"health_allergies" => "health_allergies"
  169.         ,"health_immunizations" => "health_immunizations"
  170.         ,"health_speech_difficulties" => "health_speech_difficulties"
  171.         ,"health_childhood_diseases" => "health_childhood_diseases"
  172.         ,"medicalcondition" => "medicalcondition"
  173.         ,"health_handycap" => "health_handycap"
  174.         ,"studhhis_insurance" => "studhhis_insurance"
  175.         ,"studhhis_family_doctor" => "studhhis_family_doctor"
  176.         ,"studhhis_hospitalclinic_telno" => "studhhis_hospitalclinic_telno"
  177.         ,"studhhis_blood_type" => "studhhis_blood_type"
  178.         );
  179.  
  180.     }
  181.  
  182.     function setOtherInfo($arr_= ''){
  183.  
  184. //            foreach($arr_ as $key => $value){
  185. //
  186. //                $value = stripslashes($value);
  187. //                $value = str_replace("'", "&#39;",$value);
  188. //
  189. //                $arr_[$key] = $value;
  190. //            }
  191.  
  192.         $arr['birthplace'] = $arr_['ppd_bdayplace'];
  193.         $arr['siblingcount'] = $arr_['ppd_numsiblingcount'];
  194.         $arr['birthorder'] = $arr_['ppd_birthorder'];
  195.         $arr['childstatus'] = $arr_['ppd_appchildstatus'];
  196.         $arr['language'] = $arr_['ppd_dialect'];
  197.         $arr['talent_skills'] = $arr_['ppd_talents'];
  198.         $arr['hobbiesNinterest'] = $arr_['ppd_hobbies'];
  199.  
  200.         $this->otherInfo = serialize($arr);
  201.  
  202.     }
  203.  
  204.     function setFamilyMember($arr_=''){
  205.  
  206. //            foreach($arr_ as $key => $value){
  207. //                if (is_array($arr_[$key])){
  208. //                    foreach ($arr_[$key] as $key2 => $valueX){
  209. //                        $valueX = stripslashes($valueX);
  210. //                        $valueX = str_replace("'", "&#39;",$valueX);
  211. //
  212. //                        $arr_[$key][$key2] = $valueX;
  213. //                    }
  214. //                }
  215. //            }
  216.  
  217.         for($i=0;$i<count($arr_['sibling_name']);$i++){
  218.             $newArr[$i]['name']       = $arr_['sibling_name'][$i];
  219.             $newArr[$i]['bday']       = $arr_['sibling_birthday'][$i];
  220.             $newArr[$i]['age']        = $arr_['sibling_age'][$i];
  221.             $newArr[$i]['grd_yr_lvl'] = $arr_['sibling_grade_level'][$i];
  222.             $newArr[$i]['school']     = $arr_['sibling_school_name'][$i];
  223.         }
  224.  
  225.         for($i=0;$i<count($arr_['othfamily_name']);$i++){
  226.             $newArr1[$i]['name'] = $arr_['othfamily_name'][$i];
  227.             $newArr1[$i]['relationship'] = $arr_['othfamily_relationship'][$i];
  228.             $newArr1[$i]['age'] = $arr_['othfamily_age'][$i];
  229.             $newArr1[$i]['grd_yr_lvl'] = $arr_['othfamily_level'][$i];
  230.             $newArr1[$i]['school'] = $arr_['othfamily_company'][$i];
  231.         }
  232.  
  233.         $this->otherFamInfo = serialize($newArr1);
  234.         $this->familyMember = serialize($newArr);
  235.  
  236.     }
  237.  
  238.     function setSchHistory($arr_=''){
  239.  
  240. //            foreach($arr_ as $key => $value){
  241. //                if (is_array($arr_[$key])){
  242. //                    foreach ($arr_[$key] as $key2 => $valueX){
  243. //                        $valueX = stripslashes($valueX);
  244. //                        $valueX = str_replace("'", "&#39;",$valueX);
  245. //
  246. //                        $arr_[$key][$key2] = $valueX;
  247. //                    }
  248. //                }
  249. //            }
  250.  
  251.         for($i=0;$i<count($arr_['schistory_lvl']);$i++){
  252.  
  253.             $newArr[$i]['lvl']   = $arr_['schistory_lvl'][$i];
  254.             $newArr[$i]['school']   = $arr_['schistory_school'][$i];
  255.             $newArr[$i]['schooladd']  = $arr_['schistory_schooladdress'][$i];
  256.             $newArr[$i]['from'] = $arr_['schistory_yrsFrom'][$i];
  257.             $newArr[$i]['to']  = $arr_['schistory_yearsTo'][$i];
  258.             $newArr[$i]['honors'] = $arr_['schistory_honors'][$i];
  259.             $newArr[$i]['honorsYr'] = $arr_['schistory_honorsYear'][$i];
  260.             $newArr[$i]['sCOurse'] = $arr_['schistory_specialCourse'][$i];
  261.             $newArr[$i]['sCOurseSwitch'] = $arr_['schistory_specialCourseRadio'][$i];
  262.             $newArr[$i]['sCOurseYear']    = $arr_['schistory_specialCourseYear'][$i];
  263.             $newArr[$i]['summerClass']    = $arr_['schistory_summerClasses'][$i];
  264.             $newArr[$i]['summerClassSwitch']      = $arr_['schistory_summerClassesRadio'][$i];
  265.             $newArr[$i]['summerClassYear']    = $arr_['schistory_summerClassesYear'][$i];
  266.             $newArr[$i]['failedSubject']      = $arr_['schistory_failedSubject'][$i];
  267.             $newArr[$i]['failedSubjectSwitch']    = $arr_['schistory_failedSubjectRadio'][$i];
  268.             $newArr[$i]['failedSubjectYear']      = $arr_['schistory_failedSubjectYear'][$i];
  269.             $newArr[$i]['repeated']       = $arr_['schistory_repeated'][$i];
  270.             $newArr[$i]['repeatedSwitch']     = $arr_['schistory_repeatedRadio'][$i];
  271.             $newArr[$i]['repeatedYear']       = $arr_['schistory_repeatedYear'][$i];
  272.             $newArr[$i]['prevSchoolFrom']     = $arr_['transferee_prev_school_from'];
  273.             $newArr[$i]['prevSchoolFrom1']    = $arr_['transferee_prev_school_from1'];
  274.             $newArr[$i]['prevSchoolTo']       = $arr_['transferee_prev_school_to'];
  275.             $newArr[$i]['prevSchoolTo1']      = $arr_['transferee_prev_school_to1'];
  276.             $newArr[$i]['transfereeReason1']      = $arr_['transferee_reason1'];
  277.             $newArr[$i]['transfereeReason2']      = $arr_['transferee_reason2'];
  278.             $newArr[$i]['transferee_disciplinary']    = $arr_['transferee_disciplinary'];
  279.         }
  280.  
  281.         $this->schHistory = serialize($newArr);
  282.  
  283.     }
  284.  
  285.  
  286.     /**
  287.      * Get the records from the database
  288.      *
  289.      * @param string $id_
  290.      * @return array
  291.      *
  292.      */
  293.     function dbFetch($id_ = "", $dbconn = null, $sy_id = null){
  294. //echo 'x';
  295.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  296.  
  297.         $flds = array();
  298.         $flds[] = "sai.stud_applicant_id as sai";
  299.         $flds[] = "sai.*";
  300.         $flds[] = "DATE_FORMAT(sai.ppd_bday,'%m-%d-%Y') as ppd_bday";
  301.         $flds[] = "DATE_FORMAT(sai.ppd_dateofissue,'%m-%d-%Y') as dof";
  302.         $flds[] = "sfb.*";
  303.         $flds[] = "DATE_FORMAT(sfb.studfambg_fathersbday,'%m-%d-%Y') as studfambg_fathersbday";
  304.         $flds[] = "DATE_FORMAT(sfb.studfambg_mothersbday,'%m-%d-%Y') as studfambg_mothersbday";
  305.         $flds[] = "shh.*";
  306.         $flds[] = "ssh.*";
  307.         $flds[] = "addmission.sai_id";
  308.         $flds[] = "display.sequence_no as sai_id";
  309.         $fields = implode(",",$flds);
  310.  
  311.         $sql = "SELECT $fields
  312.                    from dps_registrar_db.student_applicant_information sai
  313.                    left join dps_registrar_db.student_family_background sfb ON sai.stud_applicant_id = sfb.stud_applicant_id
  314.                    left join dps_registrar_db.student_health_history shh ON shh.stud_applicant_id = sai.stud_applicant_id
  315.                    left join dps_registrar_db.student_school_history ssh ON ssh.stud_applicant_id = sai.stud_applicant_id
  316.                    left join dps_registrar_db.student_admission_info_$selected_table addmission on (addmission.stud_applicant_id = sai.stud_applicant_id)
  317.                    left join dps_registrar_db.display_sequence display on display.table_id = addmission.sai_id
  318.                    where sai.stud_applicant_id = ?";
  319.  
  320.         $rsResult = $this->conn->Execute($sql,array($id_));
  321.  
  322.         if(!$rsResult->EOF){
  323.             return $rsResult->fields;
  324.         }
  325.     }
  326.  
  327.     function getPhoto($id_ = ""){
  328.         $sql = "SELECT sai.ppd_picture
  329.                    FROM student_applicant_photo sai
  330.                    WHERE sai.stud_applicant_id = ?";
  331.  
  332.         $rsResult = $this->conn->Execute($sql,array($id_));
  333.  
  334.         if(!$rsResult->EOF){
  335.             if (strlen($rsResult->fields['ppd_picture'])>0){
  336.                 return $rsResult->fields['ppd_picture'];
  337.             }else{
  338.                 return file_get_contents(SYSCONFIG_THEME_PATH.SYSCONFIG_THEME."/images/blank_photo.jpg");
  339.             }
  340.         }else{
  341.             return file_get_contents(SYSCONFIG_THEME_PATH.SYSCONFIG_THEME."/images/blank_photo.jpg");
  342.         }
  343.     }
  344.     /**
  345.      * populate personal info fields
  346.      *
  347.      */
  348.     function doPopulateData_Pdata($pData_ = array(),$isForm_ = false){
  349.         if(count($pData_)>0){
  350.             foreach ($this->fieldMap_PData as $key => $value) {
  351.                 if ($isForm_) {
  352.                     $this->Personal_Data[$value] = $pData_[$value];
  353.                 }else{
  354.                     $this->Personal_Data[$key] = $pData_[$value];
  355.                 }
  356.             }
  357.             return true;
  358.         }
  359.         return false;
  360.     }
  361.  
  362.     /**
  363.      * populate family background fields
  364.      *
  365.      */
  366.     function doPopulateData_Fbg($pData_ = array(),$isForm_ = false){
  367.         if(count($pData_)>0){
  368.             foreach ($this->fieldMap_Fbg as $key => $value) {
  369.                 if ($isForm_) {
  370.                     $this->Family_Background[$value] = $pData_[$value];
  371.                 }else {
  372.                     $this->Family_Background[$key] = $pData_[$value];
  373.                 }
  374.             }
  375.             return true;
  376.         }
  377.         return false;
  378.     }
  379.  
  380.     /**populate school history data
  381.      *
  382.      */
  383.  
  384.     function doPopulateData_schHis($pData_ = array(),$isForm_ = false){
  385.         if(count($pData_)>0){
  386.             foreach ($this->fieldMap_schHistory as $key => $value) {
  387.                 if ($isForm_) {
  388.                     $this->Data[$value] = $pData_[$value];
  389.                 }else{
  390.                     $this->Data[$key] = $pData_[$value];
  391.                 }
  392.             }
  393.             return true;
  394.         }
  395.         return false;
  396.     }
  397.  
  398.     /**populate health history data
  399.      *
  400.      */
  401.  
  402.     function doPopulateData_hHis($pData_ = array(),$isForm_ = false){
  403.         if(count($pData_)>0){
  404.             foreach ($this->fieldMap_hhistory as $key => $value) {
  405.                 if ($isForm_) {
  406.                     $this->Data[$value] = $pData_[$value];
  407.                 }else{
  408.                     $this->Data[$key] = $pData_[$value];
  409.                 }
  410.             }
  411.             return true;
  412.         }
  413.         return false;
  414.     }
  415.  
  416.     /**
  417.      * Populate array parameters to Data Variable
  418.      *
  419.      * @param array $pData_
  420.      * @param boolean $isForm_
  421.      * @return bool
  422.      */
  423.     function doPopulateData($pData_ = array(),$isForm_ = false){
  424.         if(count($pData_)>0){
  425.             foreach ($this->fieldMap_PData as $key => $value) {
  426.                 if ($isForm_) {
  427.                     $this->Data[$value] = $pData_[$value];
  428.                 }else {
  429.                     $this->Data[$key] = $pData_[$value];
  430.                 }
  431.             }
  432.             return true;
  433.         }
  434.         return false;
  435.     }
  436.  
  437.  
  438.     /**
  439.      * Validation function
  440.      *
  441.      * @param array $pData_
  442.      * @return bool
  443.      */
  444.     function doValidateData_Image($pData_ = array()){
  445.         $isValid = true;
  446.  
  447.         if($pData_['ppd_picture']['error']!=4){
  448.  
  449.             // allow jpeg file format only
  450.             if ($pData_['ppd_picture']['type']!="image/jpeg") {
  451.                 $isValid=false;
  452.                 $_SESSION['eMsg'][]="Invalid image type.Use JPEG only.";
  453.             }elseif ($pData_['ppd_picture']['size']>600000) {
  454.                 $isValid=false;
  455.                 $_SESSION['eMsg'][]="Uploaded image is grather than 600Kb ";
  456.  
  457.             }
  458.         }
  459.         return $isValid;
  460.  
  461.     }
  462.  
  463.     function doValidateData($pData_ = array()){
  464.  
  465.         $isValid = true;
  466.         if (empty($pData_['ppd_lastname'])) {
  467.             $_SESSION['eMsg'][] = "Enter Last Name";
  468.             $isValid = false;
  469.         }
  470.  
  471.         if (empty($pData_['ppd_firstname'])) {
  472.             $_SESSION['eMsg'][] = "Enter First Name.";
  473.             $isValid = false;
  474.         }
  475.  
  476.         if (empty($pData_['ppd_guardian'])) {
  477.             $isValid = false;
  478.             $_SESSION['eMsg'][] = "Please fill in Person / Legal Guardian";
  479.         }
  480.  
  481.         if (empty($pData_['ppd_guardian_contact_num'])) {
  482.             $isValid = false;
  483.             $_SESSION['eMsg'][] = "Please fill in  Contact no.";
  484.         }
  485.  
  486.         if (empty($pData_['ppd_gender'])) {
  487.             $isValid = false;
  488.             $_SESSION['eMsg'][] = "Select Gender";
  489.         }
  490.  
  491.         if (empty($pData_['ppd_bday'])) {
  492.             $isValid = false;
  493.             $_SESSION['eMsg'][] = "Enter Birthday";
  494.         }
  495.  
  496.         if (empty($pData_['ppd_guardian_address'])) {
  497.             $isValid = false;
  498.             $_SESSION['eMsg'][] = "Enter Guardian Address";
  499.         }
  500.  
  501.         // Required Current Address ----> DPS-COD-T0019
  502.         if ($pData_['ppd_paddress1'] == "") {
  503.             $isValid = false;
  504.             $_SESSION['eMsg'][] = "Please fill in Permanent Unit / House No.";
  505.         }
  506.  
  507.         if ($pData_['ppd_paddress2'] == "") {
  508.             $isValid = false;
  509.             $_SESSION['eMsg'][] = "Please fill in Permanent Street";
  510.         }
  511.  
  512.         if ($pData_['ppd_paddress3'] == "") {
  513.             $isValid = false;
  514.             $_SESSION['eMsg'][] = "Please fill in Permanent Brgy. / Subdivision";
  515.         }
  516.  
  517.         if ($pData_['ppd_paddress4'] == "") {
  518.             $isValid = false;
  519.             $_SESSION['eMsg'][] = "Please fill in Permanent District Municipality";
  520.         }
  521.  
  522.         if ($pData_['ppd_paddress5'] == "") {
  523.             $isValid = false;
  524.             $_SESSION['eMsg'][] = "Please fill in Permanent City / Province";
  525.         }
  526.  
  527.         //      if (empty($pData_['ppd_czipcode'])){
  528.         //          $isValid = false;
  529.         //            $_SESSION['eMsg'][]="Enter Current Zip Code";
  530.         //      }
  531.         // Required in the student family background
  532.         if (empty($pData_['studfambg_fathersname'])) {
  533.             $isValid = false;
  534.             $_SESSION['eMsg'][] = "Enter Father's First Name";
  535.         }
  536.  
  537.         if (empty($pData_['studfambg_fatherslastname'])) {
  538.             $isValid = false;
  539.             $_SESSION['eMsg'][] = "Enter Father's Last Name";
  540.         }
  541.  
  542.         if (empty($pData_['studfambg_mothersmaidenname'])) {
  543.             $isValid = false;
  544.             $_SESSION['eMsg'][] = "Enter Mother's Maiden Name";
  545.         }
  546.  
  547.         if (empty($pData_['studfambg_mothersname'])) {
  548.             $isValid = false;
  549.             $_SESSION['eMsg'][] = "Enter Mother's First Name";
  550.         }
  551.  
  552.  
  553.         //      if(!is_numeric($pData_['ppd_guardian_contact_num'])){
  554.         //          $isValid = false;
  555.         //          $_SESSION['eMsg'][]="Contact No. accepts numeric characters only.";
  556.         //      }
  557.         //      if (empty($pData_['studhhis_blood_type'])){
  558.         //          $isValid = false;
  559.         //            $_SESSION['eMsg'][]="Please fill in Blood Type";
  560.         //      }
  561.         //      if(is_numeric($pData_['studhhis_blood_type'])){
  562.         //          $isValid = false;
  563.         //          $_SESSION['eMsg'][]="Blood Type does not accept numeric characters.";
  564.         //      }
  565.         // check student number
  566.         //        if(!empty($pData_['ppd_studno'])){
  567.         //
  568.         //            $objClsPermits = new clsPermits($this->conn);
  569.         //            $permit = $objClsPermits->dbfetchStudentInfoPermittoEnroll($_GET['edit']);
  570.         //            if(!empty ($permit)){
  571.         //
  572.         //                if(isset($_GET['edit'])){
  573.         //                    $criteria = " and a.stud_applicant_id != '".$_GET['edit']."'";
  574.         //                }
  575.         //                $sql = "select * from dps_registrar_db.student_applicant_information a
  576.         //                        where a.ppd_studno = '".$pData_['ppd_studno']."' $criteria
  577.         //                        ";
  578.         //
  579.         //                $rsResult = $this->conn->Execute($sql);
  580.         //
  581.         //                if(!$rsResult->EOF){
  582.         //                    $isValid = false;
  583.         //                    $_SESSION['eMsg'][]="Student no. already exist.";
  584.         //                }
  585.         //            }else{
  586.         //                $isValid = false;
  587.         //                $_SESSION['eMsg'][]="Cannot save student number. No permit to enroll found for this student.";
  588.         //            }
  589.         //        }
  590.         // check if has no uploaded file
  591.  
  592.         if ($pData_['ppd_picture']['error'] != 4) {
  593.  
  594.             // allow jpeg file format only
  595.             if ($pData_['ppd_picture']['type'] != "image/jpeg") {
  596.                 $isValid = false;
  597.                 $_SESSION['eMsg'][] = "Invalid image type.Use JPEG or PNG only.";
  598.             }
  599.         }
  600.  
  601.         return $isValid;
  602.     }
  603.  
  604.     function doValidateData_fetcher($pData_ = array()){
  605.  
  606.         $isValid = true;
  607.  
  608.  
  609.         return $isValid;
  610.     }
  611.  
  612.  
  613.     /**
  614.      * Save New personal data
  615.      *
  616.      */
  617.     function doSaveAdd_Pdata($pData = array()){
  618.  
  619.         $flds = array();
  620.         foreach ($this->Data as $keyData => $valData) {
  621.  
  622.             if($keyData == 'ppd_dateofissue'){
  623.  
  624.                 $valData = dDate::parseDateTime($valData);
  625.  
  626.                 $flds[] = "$keyData='$valData'";
  627.  
  628.             }elseif ($keyData=='ppd_bday'){
  629.                 $valData = dDate::explodeDate($valData);
  630.                 $flds[] = "$keyData='$valData'";
  631.  
  632.             }elseif ($keyData=='ppd_picture'){
  633.                 //check for error in uploading image
  634.  
  635.                 if ($valData['error']!=4) {
  636.                     $valData=addslashes(file_get_contents($valData['tmp_name']));
  637.                     if ($valData==""){
  638.  
  639.                     }else{
  640.                         $flds[] = "$keyData='$valData'";
  641.                     }
  642.                 }
  643.  
  644.             }else{
  645.                 $valData = trim($valData);
  646.                 $valData = addslashes($valData);
  647.  
  648.                 $flds[] = "$keyData='$valData'";
  649.             }
  650.  
  651.         }
  652.  
  653.         $this->setOtherInfo($pData);
  654.  
  655.         $edad=$this->CalcAge($pData['ppd_bday']);
  656.         $flds[] ="ppd_age='".$edad."'";
  657.  
  658.         $flds[] = "ppd_otherinformation='$this->otherInfo'";
  659.         $flds[] = "ppd_telcelno='".$pData['sai_telno']."-".$pData['ppd_telcelno']."'";
  660.         $flds[] = "ppd_telcelno2='".$pData['sai_telno2']."-".$pData['ppd_telcelno2']."'";
  661.         $flds[] = "ppd_mobileno='".$pData['ppd_optMobileno']."-".$pData['ppd_mobileno']."'";
  662.         $flds[] = "ppd_mobileno2='".$pData['ppd_optMobileno2']."-".$pData['ppd_mobileno2']."'";
  663.  
  664.         $flds[] = "ppd_addwho='".AppUser::getdata('user_name')."'";
  665.  
  666.         $fields = implode(", ",$flds);
  667.  
  668.         $sql = "insert into student_applicant_information set $fields";
  669.  
  670.         $this->conn->Execute($sql);
  671.  
  672.         $id = $this->conn->Insert_ID();
  673.         $_SESSION['eMsg']="Successfully Added.";
  674.  
  675.         return $id;
  676.     }
  677.  
  678.  
  679.     /**
  680.      * Save New family background data
  681.      *
  682.      */
  683.     function doSaveAdd_Fbg(){
  684.  
  685.         $flds = array();
  686.  
  687.         foreach ($this->Data as $keyData => $valData) {
  688.  
  689.             $valData = addslashes($valData);
  690.             $flds[] = "$keyData='$valData'";
  691.  
  692.         }
  693.  
  694.         //  set family members
  695.         $this->setFamilyMember($_POST);
  696.  
  697.         $flds[] = "studfambg_familymember ='$this->familyMember'";
  698.  
  699.         $fields = implode(", ",$flds);
  700.  
  701.         $sql = "insert into student_family_background set $fields";
  702.  
  703.         $this->conn->Execute($sql);
  704.  
  705.         $_SESSION['eMsg']="Successfully Added.";
  706.     }
  707.  
  708.     /**
  709.      * save new school history
  710.      *
  711.      */
  712.     function doSaveAdd_SchHis($student_id){
  713.  
  714.  
  715.         $ser = $this->schHistory;
  716.  
  717.         $sql = "insert into student_school_history set `stud_applicant_id`={$student_id}, `studschhis_data`='{$ser}'";
  718.  
  719.         $this->conn->Execute($sql);
  720.  
  721.         $_SESSION['eMsg']="Successfully Added.";
  722.  
  723.  
  724.     }
  725.  
  726.     function doSaveAdd_hHis($student_id){
  727.  
  728.  
  729.         $ser= serialize($this->Data);
  730.  
  731.         $sql = "insert into student_health_history set `stud_applicant_id`={$student_id}, `studhhis_data`='{$ser}'";
  732.  
  733.         $this->conn->Execute($sql);
  734.  
  735.         $_SESSION['eMsg']="Successfully Added.";
  736.  
  737.  
  738.  
  739.     }
  740.     function doSaveAdd1_hHis($pData = array()){
  741.  
  742.  
  743.         $flds = array();
  744.  
  745.         $flds[] = "studhhis_insurance='".$pData['studhhis_insurance']."'";
  746.         $flds[] = "studhhis_family_doctor='".$pData['studhhis_family_doctor']."'";
  747.         $flds[] = "studhhis_hospitalclinic_telno='".$pData['studhhis_hospitalclinic_telno']."'";
  748.         $flds[] = "studhhis_blood_type='".$pData['studhhis_blood_type']."'";
  749.  
  750.         $fields=implode(", ",$flds);
  751.  
  752.         $sql = "insert into student_health_history set $fields";
  753.  
  754.         $this->conn->Execute($sql);
  755.  
  756.         $_SESSION['eMsg']="Successfully Added.";
  757.  
  758.     }
  759.  
  760.  
  761.     /**
  762.      * Save Update
  763.      *
  764.      */
  765.     function doSaveEdit(){
  766.         $id = $_GET['edit'];
  767.  
  768.         $flds = array();
  769.  
  770.  
  771.         foreach ($this->Data as $keyData => $valData) {
  772.  
  773.             $valData = trim($valData);
  774.             $valData = addslashes($valData);
  775.             $flds[] = "$keyData='$valData'";
  776.  
  777.  
  778.         }
  779.         $this->setOtherInfo($_POST);
  780.  
  781.         $flds[] = "ppd_otherinformation='$this->otherInfo'";
  782.  
  783.  
  784.         $fields = implode(", ",$flds);
  785.  
  786.         $sql = "update student_applicant_information set $fields where stud_applicant_id=$id";
  787.  
  788.  
  789.         $this->conn->Execute($sql);
  790.         $_SESSION['eMsg']="Successfully Updated.";
  791.     }
  792.  
  793.  
  794.     /**
  795.      * update personal data
  796.      *
  797.      */
  798.  
  799.  
  800.     function doSaveEdit_Pdata($pData = array()){
  801.         $id = $_GET['edit'];
  802.  
  803.         $flds = array();
  804.         foreach ($this->Personal_Data as $keyData => $valData) {
  805.             if($keyData == 'ppd_dateofissue' || $keyData == 'ppd_bday'){
  806.                 $valData = dDate::explodeDate($valData);
  807.                 $flds[] = "$keyData='$valData'";
  808.             }else{
  809.                 $valData = trim($valData);
  810.                 $valData = addslashes($valData);
  811.                 $flds[] = "$keyData='$valData'";
  812.             }
  813.         }
  814.         $this->setOtherInfo($_POST);
  815.         $edad=$this->CalcAge($pData['ppd_bday']);
  816.  
  817.         $flds[] = "ppd_age='".$edad."'";
  818.         $flds[] = "ppd_otherinformation='$this->otherInfo'";
  819.         $flds[] = "ppd_telcelno='".$pData['sai_telno']."-".$pData['ppd_telcelno']."'";
  820.         $flds[] = "ppd_telcelno2='".$pData['sai_telno2']."-".$pData['ppd_telcelno2']."'";
  821.         $flds[] = "ppd_mobileno='".$pData['ppd_optMobileno']."-".$pData['ppd_mobileno']."'";
  822.         $flds[] = "ppd_mobileno2='".$pData['ppd_optMobileno2']."-".$pData['ppd_mobileno2']."'";
  823.         $flds[] = "ppd_updatewhen='".date('Y-m-d h:i:s')."'";
  824.         $flds[] = "ppd_updatewho='".AppUser::getdata('user_name')."'";
  825.         $fields = implode(", ",$flds);
  826.  
  827.         $sql = "update student_applicant_information set $fields where stud_applicant_id=$id";
  828.         $this->conn->Execute($sql);
  829.  
  830.         $sql = "SELECT table_name
  831.                    FROM information_schema.tables
  832.                    WHERE lower(TABLE_NAME) like '%student_admission_info%'
  833.                    ORDER BY table_name DESC";
  834.  
  835.         $rsResult = $this->conn->Execute($sql);
  836.  
  837.         while(!$rsResult->EOF){
  838.  
  839.             $student_admission_info_table = $rsResult->fields['table_name'];
  840.  
  841.             $sai_lastname = addslashes($pData['ppd_lastname']);
  842.             $sai_firstname = addslashes($pData['ppd_firstname']);
  843.             $sai_middlename = addslashes($pData['ppd_middlename']);
  844.             $sai_mothers_maiden_name = addslashes($pData['ppd_mothers_maiden_name']);
  845.             $sai_nickname = addslashes($pData['ppd_nickname']);
  846.             $sai_gender = addslashes($pData['ppd_gender']);
  847.             $sai_birthday = dDate::explodeDate($pData['ppd_bday']);
  848.             $sai_caddress1 = addslashes($pData['ppd_caddress1']);
  849.             $sai_caddress2 = addslashes($pData['ppd_caddress2']);
  850.             $sai_caddress3 = addslashes($pData['ppd_caddress3']);
  851.             $sai_caddress4 = addslashes($pData['ppd_caddress4']);
  852.             $sai_caddress5 = addslashes($pData['ppd_caddress5']);
  853.             $sai_czipcode = addslashes($pData['ppd_czipcode']);
  854.             $sai_paddress1 = addslashes($pData['ppd_paddress1']);
  855.             $sai_paddress2 = addslashes($pData['ppd_paddress2']);
  856.             $sai_paddress3 = addslashes($pData['ppd_paddress3']);
  857.             $sai_paddress4 = addslashes($pData['ppd_paddress4']);
  858.             $sai_paddress5 = addslashes($pData['ppd_paddress5']);
  859.             $sai_pzipcode = addslashes($pData['ppd_pzipcode']);
  860.             $sai_citizenship = addslashes($pData['ppd_citizenship']);
  861.             $sai_citizenship_oth = addslashes($pData['ppd_citizenshipoth']);
  862.             $sai_email = addslashes($pData['ppd_email']);
  863.  
  864.             $flds = array();
  865.             $flds[] = "sai_lastname = '$sai_lastname'";
  866.             $flds[] = "sai_firstname = '$sai_firstname'";
  867.             $flds[] = "sai_middlename = '$sai_middlename'";
  868.             $flds[] = "sai_mothers_maiden_name = '$sai_mothers_maiden_name'";
  869.             $flds[] = "sai_nickname = '$sai_nickname'";
  870.             $flds[] = "sai_gender = '$sai_gender'";
  871.             $flds[] = "sai_birthday = '$sai_birthday'";
  872.             $flds[] = "sai_age = '$edad'";
  873.             $flds[] = "sai_caddress1 = '$sai_caddress1'";
  874.             $flds[] = "sai_caddress2 = '$sai_caddress2'";
  875.             $flds[] = "sai_caddress3 = '$sai_caddress3'";
  876.             $flds[] = "sai_caddress4 = '$sai_caddress4'";
  877.             $flds[] = "sai_caddress5 = '$sai_caddress5'";
  878.             $flds[] = "sai_czipcode = '$sai_czipcode'";
  879.             $flds[] = "sai_paddress1 = '$sai_paddress1'";
  880.             $flds[] = "sai_paddress2 = '$sai_paddress2'";
  881.             $flds[] = "sai_paddress3 = '$sai_paddress3'";
  882.             $flds[] = "sai_paddress4 = '$sai_paddress4'";
  883.             $flds[] = "sai_paddress5 = '$sai_paddress5'";
  884.             $flds[] = "sai_pzipcode = '$sai_pzipcode'";
  885.             $flds[] = "sai_citizenship = '$sai_citizenship'";
  886.             $flds[] = "sai_citizenship_oth = '$sai_citizenship_oth'";
  887.             $flds[] = "sai_email = '$sai_email'";
  888.             $flds[] = "sai_homephone1 = '".$pData['sai_telno']."-".$pData['ppd_telcelno']."'";
  889.             $flds[] = "sai_homephone1 = '".$pData['sai_telno2']."-".$pData['ppd_telcelno2']."'";
  890.             $flds[] = "sai_mobilephone1 = '".$pData['ppd_optMobileno']."-".$pData['ppd_mobileno']."'";
  891.             $flds[] = "sai_mobilephone2 = '".$pData['ppd_optMobileno2']."-".$pData['ppd_mobileno2']."'";
  892.             $flds[] = "sai_mobilephone2 = '".$pData['ppd_optMobileno2']."-".$pData['ppd_mobileno2']."'";
  893.             $fields = implode(",",$flds);
  894.  
  895.             $update = "update $student_admission_info_table set $fields where stud_applicant_id = '$id'";
  896.             $this->conn->Execute($update);
  897.  
  898.             $rsResult->MoveNext();
  899.         }
  900.  
  901.         $_SESSION['eMsg']="Successfully Updated.";
  902.     }
  903.  
  904.     /**
  905.      * update family background
  906.      *
  907.      */
  908.  
  909.     function doSaveEdit_fBg(){
  910.         $id = $_GET['edit'];
  911.  
  912.         $sql_x = "select stud_applicant_id from student_school_history where stud_applicant_id = $id";
  913.         $rsResult_x =$this->conn->Execute($sql_x);
  914.  
  915.         if($rsResult_x->EOF){
  916.  
  917.             $flds = array();
  918.             $flds[] = "stud_applicant_id={$id}";
  919.             $fields = implode(", ",$flds);
  920.             $sql_2 = "insert into student_family_background set $fields";
  921.             $this->conn->Execute($sql_2);
  922.  
  923.         }
  924.  
  925.         $flds = array();
  926.         foreach ($this->Family_Background as $keyData => $valData) {
  927.             if($keyData == 'studfambg_fathersbday' || $keyData == 'studfambg_mothersbday'){
  928.                 $valData = dDate::explodeDate($valData);
  929.                 $flds[] = "$keyData='$valData'";
  930.             }else{
  931.                 $valData = addslashes($valData);
  932.                 $flds[] = "$keyData='$valData'";
  933.             }
  934.         }
  935.  
  936.         //  set family members
  937.         $this->setFamilyMember($_POST);
  938.         $flds[] = "studfambg_familymember ='$this->familyMember'";
  939.         $flds[] = "studfambg_othermembers ='$this->otherFamInfo'";
  940.         $fields = implode(", ",$flds);
  941.  
  942.         $sql = "update student_family_background set $fields where stud_applicant_id=$id";
  943.         $this->conn->Execute($sql);
  944.  
  945.         $_SESSION['eMsg']="Successfully Updated.";
  946.     }
  947.  
  948.     /**
  949.      * update required fields in family backgroud
  950.      *
  951.      */
  952. //  function doSaveEdit1_fBg($pData_=array()){
  953. //      $id = $_GET['edit'];
  954. //
  955. //      $flds[] = "studfambg_fathersname ='{$pData_['studfambg_fathersname']}'";
  956. //      $flds[] = "studfambg_fatherslastname ='{$pData_['studfambg_fatherslastname']}'";
  957. //      $flds[] = "studfambg_mothersmaidenname ='{$pData_['studfambg_mothersmaidenname']}'";
  958. //      $flds[] = "studfambg_mothersname ='{$pData_['studfambg_mothersname']}'";
  959. //
  960. //      $fields = implode(", ",$flds);
  961. //
  962. //      $sql = "update student_family_background set $fields where stud_applicant_id=$id";
  963. //
  964. //      $this->conn->Execute($sql);
  965. //
  966. //      $_SESSION['eMsg']="Successfully Updated.";
  967. //
  968. //  }
  969.  
  970.     /**
  971.      * update school background
  972.      *
  973.      */
  974.     function doSaveEdit_schHis(){
  975.         $id = $_GET['edit'];
  976.  
  977.         $sql_x = "select stud_applicant_id from student_school_history where stud_applicant_id = $id";
  978.         $rsResult_x =$this->conn->Execute($sql_x);
  979.  
  980.         if ($rsResult_x->EOF){
  981.  
  982.             $sql_2 = "insert into student_school_history set `stud_applicant_id`={$id}";
  983.  
  984.             $this->conn->Execute($sql_2);
  985.         }
  986.  
  987.         $ser = $this->schHistory;
  988.         $sql = "update student_school_history set `studschhis_data`='{$ser}' where stud_applicant_id ={$id}";
  989.         $this->conn->Execute($sql);
  990.  
  991.         $_SESSION['eMsg']="Successfully Updated.";
  992.     }
  993.  
  994.     /**
  995.      * update health history
  996.      *
  997.      */
  998.     function doSaveEdit_hHis(){
  999.         $id = $_GET['edit'];
  1000.  
  1001.         $sql_x = "select stud_applicant_id from student_health_history where stud_applicant_id = $id";
  1002.         $rsResult_x =$this->conn->Execute($sql_x);
  1003.  
  1004.         if ($rsResult_x->EOF){
  1005.             $flds = array();
  1006.             $flds[] = "stud_applicant_id={$id}";
  1007.             $fields=implode(", ",$flds);
  1008.  
  1009.             $sql_2 = "insert into student_health_history set $fields";
  1010.             $this->conn->Execute($sql_2);
  1011.         }
  1012.  
  1013.         $ser= serialize($this->Data);
  1014.         $sql = "update student_health_history set `studhhis_data`='{$ser}' where stud_applicant_id ={$id}";
  1015.         $this->conn->Execute($sql);
  1016.  
  1017.         $_SESSION['eMsg']="Successfully Updated.";
  1018.  
  1019.     }
  1020.  
  1021.     function doSaveEdit_Image($pData = array()){
  1022.  
  1023.         $id = $_GET['edit'];
  1024.  
  1025.         $flds = array();
  1026.         $valData=addslashes(file_get_contents($pData['ppd_picture']['tmp_name']));
  1027.         $flds[] = "ppd_picture='$valData'";
  1028.  
  1029.         if(!$this->isStudAppIDExistOnPhoto($id)){
  1030.             $flds[] = "stud_applicant_id=$id";
  1031.             $fields = implode(", ",$flds);
  1032.             $sql = "insert into student_applicant_photo set $fields ";
  1033.         }else{
  1034.             $fields = implode(", ",$flds);
  1035.             $sql = "update student_applicant_photo set $fields where stud_applicant_id=$id";
  1036.         }
  1037.         $this->conn->Execute($sql);
  1038.         $_SESSION['eMsg']="Successfully Updated.";
  1039.     }
  1040.  
  1041.     function isStudAppIDExistOnPhoto($stud_applicant_id_ = null) {
  1042.         if(is_null($stud_applicant_id_)) return false;
  1043.  
  1044.         $sql = "select stud_applicant_id from student_applicant_photo where stud_applicant_id=$stud_applicant_id_";
  1045.         $rsResult = $this->conn->Execute($sql);
  1046.         if(!$rsResult->EOF){
  1047.             return true;
  1048.         }
  1049.         return false;
  1050.     }
  1051.  
  1052.     /**
  1053.      * update1 health history
  1054.      *
  1055.      */
  1056.     function doSaveEdit1_hHis($pData = array()){
  1057.         $id = $_GET['edit'];
  1058.  
  1059.         $flds = array();
  1060.  
  1061.         $flds[] = "studhhis_height='".$pData['studhhis_height']."'";
  1062.         $flds[] = "studhhis_insurance='".$pData['studhhis_insurance']."'";
  1063.         $flds[] = "studhhis_family_doctor='".$pData['studhhis_family_doctor']."'";
  1064.         $flds[] = "studhhis_hospitalclinic_telno='".$pData['studhhis_hospitalclinic_telno']."'";
  1065.         $flds[] = "studhhis_blood_type='".$pData['studhhis_blood_type']."'";
  1066.  
  1067.         $fields=implode(", ",$flds);
  1068.  
  1069.         $sql = "update student_health_history set $fields where stud_applicant_id =$id";
  1070.  
  1071.         $this->conn->Execute($sql);
  1072.  
  1073.         $_SESSION['eMsg']="Successfully Updated.";
  1074.  
  1075.     }
  1076.     /**
  1077.      * Delete Record
  1078.      *
  1079.      * @param string $id_
  1080.      */
  1081.  
  1082.     function doDelete($id_ = ""){
  1083.         $sql = "delete from app_modules where mnu_id=?";
  1084.         $this->conn->Execute($sql,array($id_));
  1085.         $_SESSION['eMsg']="Successfully Deleted.";
  1086.     }
  1087.  
  1088.     /**
  1089.      * Get all the Table Listings
  1090.      *
  1091.      * @return array
  1092.      */
  1093.     function getTableList($sy_id = null, $level_id = null){
  1094.  
  1095. //            $sql = "select th_id
  1096. //                    from dps_cashier_db.cashier_trans_detail
  1097. //                    where td_desc like '%2013%'";
  1098. //
  1099. //            $rsResult = $this->conn->Execute($sql);
  1100. //
  1101. //            while(!$rsResult->EOF){
  1102. //                $sql_ = "update dps_cashier_db.cashier_trans_header set sy_id = '20' where th_id = '{$rsResult->fields['th_id']}'";
  1103. //                $this->conn->Execute($sql_);
  1104. //                $rsResult->MoveNext();
  1105. //            }
  1106.  
  1107.         // Process the query string and exclude querystring named "p"
  1108.         if (!empty($_SERVER['QUERY_STRING'])) {
  1109.             $qrystr = explode("&",$_SERVER['QUERY_STRING']);
  1110.             foreach ($qrystr as $value) {
  1111.                 $qstr = explode("=",$value);
  1112.                 if ($qstr[0]!="p") {
  1113.                     $arrQryStr[] = implode("=",$qstr);
  1114.                 }
  1115.             }
  1116.             $aQryStr = $arrQryStr;
  1117.             $aQryStr[] = "p=@@";
  1118.             $queryStr = implode("&",$aQryStr);
  1119.         }
  1120.  
  1121.         //bby: search module
  1122.         $qry = array();
  1123.         if (isset($_REQUEST['search_field'])) {
  1124.  
  1125.             // lets check if the search field has a value
  1126.             if (strlen($_REQUEST['search_field'])>0) {
  1127.                 // lets assign the request value in a variable
  1128.                 $search_field = $_REQUEST['search_field'];
  1129.  
  1130.                 // create a custom criteria in an array
  1131.                 $qry[] = "(ppd_studno like '%$search_field%' ||
  1132.                                        ppd_firstname like '%$search_field%' ||
  1133.                                        ppd_lastname like '%$search_field%' ||
  1134.                                        ppd_middlename like '%$search_field%' ||
  1135.                                        )
  1136.                            ";
  1137.  
  1138.             }
  1139.         }
  1140.         if (isset($_GET['src_no']) || isset($_GET['src_lname']) || isset($_GET['src_fname'])) {
  1141.             // lets check if the search field has a value
  1142.             if ($_REQUEST['search_field']=="") {
  1143.                 // lets assign the request value in a variable
  1144.                 $src_sno = $_GET['src_sno'];
  1145.                 $src_fname = $_GET['src_fname'];
  1146.                 $src_lname = $_GET['src_lname'];
  1147.                 // create a custom criteria in an array
  1148.                 if ($src_sno!=""){
  1149.                     $qry[] = "ppd_studno = '$src_sno'";
  1150.                 }else{
  1151.                     if(empty($src_lname) && empty($src_fname)){
  1152.  
  1153.                     }
  1154.                     elseif (empty($src_lname)){
  1155.                         $qry[] = "
  1156.                                ppd_firstname like '%$src_fname%'
  1157.                                ";
  1158.                     }
  1159.                     elseif (empty($src_fname)){
  1160.                         $qry[] = "
  1161.                                ppd_lastname like '%$src_lname%'
  1162.                                ";
  1163.                     }else{
  1164.                         $qry[] = "
  1165.                                ppd_lastname like '%$src_lname%' &&
  1166.                                ppd_firstname like '%$src_fname%'
  1167.                                ";
  1168.                     }
  1169.                 }
  1170.             }
  1171.         }
  1172.  
  1173.         // put all query array into one criteria string
  1174.         if($_GET['male_'] == 1 and $_GET['female_'] != 1){
  1175.             $qry[] = "ppd_gender = 'M'";
  1176.         }else if($_GET['female_'] == 1 and $_GET['male_'] != 1){
  1177.             $qry[] = "ppd_gender = 'F'";
  1178.         }else{
  1179.  
  1180.         }
  1181.  
  1182.         // Sort field mapping
  1183.         $arrSortBy = array(
  1184.             "ppd_studno"=>"ppd_studno"
  1185.         ,"ppd_lastname"=>"ppd_lastname"
  1186.         ,"ppd_firstname"=>"ppd_firstname"
  1187.         ,"ppd_middlename"=>"ppd_middlename"
  1188.         ,"idlink"=>"idlink"
  1189.         );
  1190.  
  1191.         if(isset($_GET['sortby'])){
  1192.             $strOrderBy = " order by ".$arrSortBy[$_GET['sortby']]." ".$_GET['sortof'];
  1193.         }else{
  1194.             $strOrderBy = " order by am.ppd_lastname, am.ppd_firstname";
  1195.         }
  1196.  
  1197.         // Add Option for Image Links or Inline Form eg: Checkbox, Textbox, etc...
  1198.         $viewLink = "";
  1199.         $imgPhoto = "<img src=\"?statpos=studinfo&img=',am.stud_applicant_id,'\" border=0 width=\"53\" height=\"65.5\">";
  1200.         $editLink = "<a href=\"?statpos=studinfo&edit=',am.stud_applicant_id,'\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/edit.gif\" title=\"Edit\" hspace=\"2px\" border=0></a>";
  1201. //            $fetcherLink = "<a href=\"?statpos=studinfo&student_fetcher=',am.stud_applicant_id,'\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/info.png\" title=\"Edit\" hspace=\"2px\" border=0></a>";
  1202.         $idLinkF = "<a href=\"?statpos=studinfo&printid=',am.stud_applicant_id,'&f=1\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/print1.png\" title=\"Print ID Front\" hspace=\"2px\" border=0></a>";
  1203.         $idLinkB = "<a href=\"?statpos=studinfo&printid=',am.stud_applicant_id,'&f=0\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/print2.png\" title=\"Print ID Back\" hspace=\"2px\" border=0></a>";
  1204.         $IDinfoLink = "<a href=\"reports.php?statpos=printid&updateinfo=',am.stud_applicant_id,'\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/report_user.gif\" title=\"ID Info\" hspace=\"2px\" border=0></a>";
  1205. //      $delLink = "<a href=\"?statpos=studinfo&delete=',am.stud_applicant_id,'\" onclick=\"return confirm(\'Are you sure, you want to delete?\');\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/trash.gif\" title=\"Delete\" hspace=\"2px\"  border=0></a>";
  1206.  
  1207.         // SqlAll Query
  1208.         $flds = array();
  1209.         $flds[] = "am.stud_applicant_id";
  1210.         $flds[] = "am.ppd_studno";
  1211.         $flds[] = "am.ppd_lastname";
  1212.         $flds[] = "am.ppd_firstname";
  1213.         $flds[] = "am.ppd_middlename";
  1214.         $flds[] = "am.ppd_guardian";
  1215.         $flds[] = "am.ppd_guardian_contact_num";
  1216.         $flds[] = "am.ppd_telcelno";
  1217.         $flds[] = "date_format(am.ppd_bday,'%m-%d-%Y') as ppd_bday";
  1218.         $flds[] = "am.ppd_guardian_contact_num";
  1219.         $flds[] = "am.ppd_gender";
  1220.         $flds[] = "am.rfid";
  1221.  
  1222.         $flds[] = "a1.studhhis_hospitalclinic_telno";
  1223.         $flds[] = "a1.studhhis_family_doctor";
  1224.         $flds[] = "a1.studhhis_insurance";
  1225.         $flds[] = "a1.studhhis_blood_type";
  1226.  
  1227.         $flds[] = "CONCAT('$idLinkF','$idLinkB') as idlink";
  1228.         $flds[] = "CONCAT('$imgPhoto') as imgphoto";
  1229.         $flds[] = "CONCAT('$editLink','$delLink', '$IDinfoLink', '$fetcherLink') as viewdata";
  1230.  
  1231.         $fields = implode(",", $flds);
  1232.  
  1233.         if($sy_id != null){
  1234. //            echo $sy_id;
  1235. //            echo 'may laman';
  1236.             $selected_table = clsRegistrarMisc::getSelected_Table($this->conn,$sy_id);
  1237.             $join_table = "inner join dps_registrar_db.file_permit_to_enroll_$selected_table c on c.stud_applicant_id = am.stud_applicant_id";
  1238.  
  1239.             if($level_id != null){
  1240.                 //                echo 'w';
  1241.                 $qry[] = "c.stud_level_next = '$level_id'";
  1242.             }
  1243.         }
  1244.  
  1245.         $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  1246.         // SqlAll Query
  1247.         $sql = "select $fields
  1248.                    , CONCAT('$idLinkF','$idLinkB') as idlink
  1249.                    , CONCAT('$imgPhoto') as imgphoto
  1250.                    from dps_registrar_db.student_applicant_information am
  1251.                    left join dps_registrar_db.student_health_history a1 on a1.stud_applicant_id = am.stud_applicant_id
  1252.                    $join_table
  1253.                    $criteria
  1254.                    $strOrderBy";
  1255.  
  1256.         // Sql query for paginator list
  1257.         $sqlcount = "select count(*) as mycount from student_applicant_information $criteria";
  1258.  
  1259.         // Field and Table Header Mapping
  1260.         $arrFields = array(
  1261.             "imgphoto"=>"&nbsp;"
  1262.         ,"ppd_studno"=>"Student No."
  1263.         ,"ppd_lastname"=>"Last Name"
  1264.         ,"ppd_firstname"=>"First Name"
  1265.         ,"ppd_middlename"=>"M.I."
  1266.         ,"ppd_gender"=>"Gender"
  1267.             /*,"studhhis_blood_type"=>"Blood Type"
  1268.             ,"ppd_bday"=>"Birthday"
  1269.             ,"studhhis_hospitalclinic_telno"=>"HOSP./Clinic"
  1270.             ,"studhhis_family_doctor"=>"Fam. Doc."
  1271.             ,"studhhis_insurance"=>"Health Ins."
  1272.             ,"ppd_telcelno"=>"Tel/Cel No."
  1273.             */
  1274.         ,"ppd_guardian"=>"Parent/ Guardian"
  1275.         ,"ppd_guardian_contact_num"=>"P/G Contact No."
  1276.         ,"rfid"=>"RFID No"
  1277.         ,"idlink"=>"ID"
  1278.         ,"viewdata"=>"&nbsp;"
  1279.         );
  1280.  
  1281.         // Column (table data) User Defined Attributes
  1282.         $arrAttribs = array(
  1283.             "mnu_ord"=>" align='right'"
  1284.         ,"imgphoto"=>"width='55' align='center'"
  1285.         ,"idlink"=>"width='60' align='center'"
  1286.         ,"viewdata"=>"width='60' align='center'"
  1287.         );
  1288.  
  1289.         // Process the Table List
  1290.         $tblDisplayList = new clsTableList($this->conn);
  1291.         $tblDisplayList->tblBlock->templateFile = "table_nosearch.tpl.php";
  1292.         $tblDisplayList->arrFields = $arrFields;
  1293.         $tblDisplayList->paginator->linkPage = "?$queryStr";
  1294.         $tblDisplayList->sqlAll = $sql;
  1295.         $tblDisplayList->sqlCount = $sqlcount;
  1296.  
  1297.         return $tblDisplayList->getTableList($arrAttribs);
  1298.     }
  1299.  
  1300.     function doValidateData_Pdata($pData_ = array()){
  1301.         $isValid = true;
  1302.  
  1303.  
  1304.  
  1305. //      $isValid = false;
  1306.  
  1307.         return $isValid;
  1308.     }
  1309.  
  1310.     function CalcAge($birthday) { // YYYY-MM-DD
  1311.         $birthday = $birthday;
  1312.         list($BMonth, $BDay, $BYear)= explode('-', $birthday);
  1313.  
  1314.  
  1315.         $CYear = date('Y');
  1316.         $CMonth = date('m');
  1317.         $CDay = date('d');
  1318.  
  1319.         $age = 0;
  1320.  
  1321.         if (!empty($BYear) && $BYear < $CYear)
  1322.         {
  1323.             $age += $CYear - $BYear;
  1324.         }
  1325.  
  1326.         if (!empty($BMonth) && !empty($BDay))
  1327.         {
  1328.             $monthDiff = $CMonth - $BMonth;
  1329.             $dayDiff = $CDay - $BDay;
  1330.  
  1331.             if ($monthDiff < 0 || ($monthDiff == 0 && $dayDiff < 0))
  1332.             {
  1333.                 $age -= 1;
  1334.             }
  1335.         }
  1336.         return $age;
  1337.     }
  1338.  
  1339.  
  1340. //    function CalcAge($birthday) {
  1341. //
  1342. //      list($BMonth, $BDay, $BYear)= explode('-', $birthday);
  1343. //
  1344. //
  1345. //      $CYear = date('Y');
  1346. //      $CMonth = date('m');
  1347. //      $CDay = date('d');
  1348. //
  1349. //      $age = 0;
  1350. //
  1351. //      if (!empty($BYear) && $BYear < $CYear)
  1352. //      {
  1353. //          $age += $CYear - $BYear;
  1354. //      }
  1355. //
  1356. //      if (!empty($BMonth) && !empty($BDay))
  1357. //      {
  1358. //          $monthDiff = $CMonth - $BMonth;
  1359. //          $dayDiff = $CDay - $BDay;
  1360. //
  1361. //          if ($monthDiff < 0 || ($monthDiff == 0 && $dayDiff < 0))
  1362. //          {
  1363. //              $age -= 1;
  1364. //          }
  1365. //      }
  1366. //      return $age;
  1367. //  }
  1368.  
  1369.     function getTableList_AuditTrail($stud_id=null){
  1370.         // Process the query string and exclude querystring named "p"
  1371.         if (!empty($_SERVER['QUERY_STRING'])) {
  1372.             $qrystr = explode("&",$_SERVER['QUERY_STRING']);
  1373.             foreach ($qrystr as $value) {
  1374.                 $qstr = explode("=",$value);
  1375.                 if ($qstr[0]!="p") {
  1376.                     $arrQryStr[] = implode("=",$qstr);
  1377.                 }
  1378.             }
  1379.             $aQryStr = $arrQryStr;
  1380.             $aQryStr[] = "p=@@";
  1381.             $queryStr = implode("&",$aQryStr);
  1382.         }
  1383.  
  1384.         //bby: search module
  1385.         $qry = array();
  1386.  
  1387.  
  1388.         if (isset($_REQUEST['search_field'])) {
  1389.             // lets check if the search field has a value
  1390.             if (strlen($_REQUEST['search_field'])>0) {
  1391.                 // lets assign the request value in a variable
  1392.                 $search_field = $_REQUEST['search_field'];
  1393.  
  1394.  
  1395.                 // create a custom criteria in an array
  1396.                 $qry[] = "stud_applicant_id like '%$search_field%')";
  1397.  
  1398.             }
  1399.         }
  1400.  
  1401.         $qry[]="(a.trail_id=20 or a.trail_id = 80)";
  1402.         $qry[]="a.stud_applicant_id=$stud_id";
  1403.  
  1404.         // put all query array into one criteria string
  1405.         $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  1406.  
  1407.         // Sort field mapping
  1408.         $arrSortBy = array(
  1409.             "fat_action_details"=>"fat_action_details"
  1410.         ,"modifier"=>"modifier"
  1411.         ,"fat_addwhen"=>"fat_addwhen"
  1412.         );
  1413.  
  1414.         if(isset($_GET['sortby'])){
  1415.             $strOrderBy = " order by ".$arrSortBy[$_GET['sortby']]." ".$_GET['sortof'];
  1416.         }else{
  1417.             $strOrderBy = " order by a.fat_id DESC";
  1418.         }
  1419.  
  1420.  
  1421.         //$viewLink = "<a href=\"?statpos=applicant_information&edit=',am.stud_applicant_id,'\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/zoom.gif\" title=\"view\" hspace=\"2px\" border=0></a>";
  1422.         //$editLink = "<a href=\"?statpos=applicant_information&edit=',am.sai_admission_id,'\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/edit.gif\" title=\"Edit\" hspace=\"2px\" border=0></a>";
  1423.         $editLink = "<a href=\"?statpos=applicant_information&addreturnee=',sappi.stud_applicant_id,'\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/edit.gif\" title=\"Edit\" hspace=\"2px\" border=0></a>";
  1424.  
  1425.         //$delLink = "<a href=\"?statpos=applicant_information&delete=',am.sai_id,'\" onclick=\"return confirm(\'Are you sure, you want to delete?\');\"><img src=\"".SYSCONFIG_THEME_URLPATH.SYSCONFIG_THEME."/images/admin/trash.gif\" title=\"Delete\" hspace=\"2px\"  border=0></a>";
  1426.  
  1427.         // SqlAll Query
  1428.  
  1429.         $sql = "select a.fat_action_details,date_format(a.fat_addwhen,'%b. %d, %Y %h:%i %p') as fat_addwhen, CONCAT(hep.pi_firstname,' ',hep.pi_lastname) as fullname, b.user_fullname
  1430.                 from file_admission_trailings a
  1431.                 left join dps_hris_db.hris_emp_pinfo_master_rel hp
  1432.                     on hp.emp_id=a.fat_modified_by
  1433.                 left join dps_hris_db.hris_emp_personalinfo hep
  1434.                     on hep.pi_id=hp.pi_id
  1435.                 left join dps_hris_db.app_users b
  1436.                     on b.user_name=a.fat_addwho
  1437.                 $criteria
  1438.                 $strOrderBy";
  1439.  
  1440.         // Sql query for paginator list
  1441. //      $sqlcount = "select count(*) as mycount from student_admission_info
  1442. //                  $criteria";
  1443.  
  1444.         $sqlcount = "select count(*)
  1445.                 from file_admission_trailings
  1446.                     $criteria";
  1447.  
  1448.         // Field and Table Header Mapping
  1449.         $arrFields = array(
  1450.             "fat_action_details"=>"Action Details"
  1451.         ,"user_fullname"=>"Modified by"
  1452.         ,"fat_addwhen"=>"Date/Time"
  1453.         );
  1454.  
  1455.         // Column (table data) User Defined Attributes
  1456.         $arrAttribs = array(
  1457.             /*"mnu_ord"=>" align='right'",*/
  1458.             "viewdata"=>"width='50' align='center'"
  1459.         );
  1460.  
  1461.         // Process the Table List
  1462.         $tblDisplayList = new clsTableList($this->conn);
  1463.         $tblDisplayList->arrFields = $arrFields;
  1464.         $tblDisplayList->paginator->linkPage = "?$queryStr";
  1465.         $tblDisplayList->sqlAll = $sql;
  1466.         $tblDisplayList->sqlCount = $sqlcount;
  1467.  
  1468.         return $tblDisplayList->getTableList($arrAttribs);
  1469.     }
  1470.  
  1471.     function doValidate_Personal_Data($pData_ = array()){
  1472.         $isValid = true;
  1473.         if(empty($pData_['ppd_lastname'])) {
  1474.             $_SESSION['eMsg'][]="Enter Last Name";
  1475.             $isValid = false;
  1476.         }
  1477.  
  1478.         if(empty($pData_['ppd_firstname'])) {
  1479.             $_SESSION['eMsg'][]="Enter First Name.";
  1480.             $isValid = false;
  1481.         }
  1482.  
  1483.         if (empty($pData_['ppd_gender'])){
  1484.             $isValid = false;
  1485.             $_SESSION['eMsg'][]="Select Gender";
  1486.         }
  1487.  
  1488.         if (empty($pData_['ppd_bday'])){
  1489.             $isValid = false;
  1490.             $_SESSION['eMsg'][]="Enter Birthday";
  1491.         }
  1492.  
  1493.         // Required Current Address ----> DPS-COD-T0019
  1494.         if (empty($pData_['ppd_paddress1'])){
  1495.             $isValid = false;
  1496.             $_SESSION['eMsg'][]="Enter Permanent Unit / House No.";
  1497.         }
  1498.  
  1499.         if (empty($pData_['ppd_paddress2'])){
  1500.             $isValid = false;
  1501.             $_SESSION['eMsg'][]="Enter Permanent Street .";
  1502.         }
  1503.  
  1504.         if (empty($pData_['ppd_paddress3'])){
  1505.             $isValid = false;
  1506.             $_SESSION['eMsg'][]="Enter Permanent Brgy. / Subdivision";
  1507.         }
  1508.  
  1509.         if (empty($pData_['ppd_paddress4'])){
  1510.             $isValid = false;
  1511.             $_SESSION['eMsg'][]="Enter Permanent District Municipality";
  1512.         }
  1513.  
  1514.         if (empty($pData_['ppd_paddress5'])){
  1515.             $isValid = false;
  1516.             $_SESSION['eMsg'][]="Enter Permanent City / Province";
  1517.         }
  1518.  
  1519.  
  1520.         if (empty($pData_['ppd_guardian'])){
  1521.             $isValid = false;
  1522.             $_SESSION['eMsg'][]="Please fill in Person / Legal Guardian";
  1523.         }
  1524.  
  1525.         if (empty($pData_['ppd_guardian_address'])){
  1526.             $isValid = false;
  1527.             $_SESSION['eMsg'][]="Enter Guardian Address";
  1528.         }
  1529.  
  1530.         if (empty($pData_['ppd_guardian_contact_num'])){
  1531.             $isValid = false;
  1532.             $_SESSION['eMsg'][]="Please fill in  Contact no.";
  1533.         }
  1534.  
  1535.         return $isValid;
  1536.  
  1537.     }
  1538.  
  1539.     function doValidate_Family_Background($pData_ = array()){
  1540.         $isValid = true;
  1541.         if (empty($pData_['studfambg_fathersname'])){
  1542.             $isValid = false;
  1543.             $_SESSION['eMsg'][]="Enter Father's First Name";
  1544.         }
  1545.  
  1546.         if (empty($pData_['studfambg_fatherslastname'])){
  1547.             $isValid = false;
  1548.             $_SESSION['eMsg'][]="Enter Father's Last Name";
  1549.         }
  1550.  
  1551.         if (empty($pData_['studfambg_mothersmaidenname'])){
  1552.             $isValid = false;
  1553.             $_SESSION['eMsg'][]="Enter Mother's Maiden Name";
  1554.         }
  1555.  
  1556.         if (empty($pData_['studfambg_mothersname'])){
  1557.             $isValid = false;
  1558.             $_SESSION['eMsg'][]="Enter Mother's First Name";
  1559.         }
  1560.  
  1561.         return $isValid;
  1562.  
  1563.     }
  1564.  
  1565.     function doValidate_School_History($pData_ = array()){
  1566.         $isValid = true;
  1567.         return $isValid;
  1568.     }
  1569.  
  1570.     function doValidate_Health_History($pData_ = array()){
  1571.         $isValid = true;
  1572.         return $isValid;
  1573.     }
  1574.  
  1575.  
  1576.     function Return_Data($pData_ = array()){
  1577.  
  1578.         //returns Personal Information Data
  1579.         if(count($pData_['sibling_name'])>0){
  1580.             end($pData_['sibling_name']);
  1581.             $key = key($pData_['sibling_name']) + 1;
  1582.  
  1583.             $y = 0;
  1584.             while($key > $y){
  1585.                 $oData['familyMem'][$y]['name'] = $pData_['sibling_name'][$y];
  1586.                 $oData['familyMem'][$y]['birthday'] = $pData_['sibling_birthday'][$y];
  1587.                 $oData['familyMem'][$y]['age'] = $pData_['sibling_age'][$y];
  1588.                 $oData['familyMem'][$y]['grd_yr_lvl'] = $pData_['sibling_grade_level'][$y];
  1589.                 $oData['familyMem'][$y]['school'] = $pData_['sibling_school_name'][$y];
  1590.                 $y++;
  1591.             }
  1592.         }
  1593.  
  1594.         //return Personal Data (Other Information)
  1595.         $oData['otherInfo']['birthplace'] = $pData_['ppd_bdayplace'];
  1596.         $oData['otherInfo']['siblingcount'] = $pData_['ppd_numsiblingcount'];
  1597.         $oData['otherInfo']['birthorder'] = $pData_['ppd_birthorder'];
  1598.         $oData['otherInfo']['childstatus'] = $pData_['ppd_appchildstatus'];
  1599.         $oData['otherInfo']['language'] = $pData_['ppd_dialect'];
  1600.         $oData['otherInfo']['talent_skills'] = $pData_['ppd_talents'];
  1601.         $oData['otherInfo']['hobbiesNinterest'] = $pData_['ppd_hobbies'];
  1602.  
  1603.         //return Other Family Data
  1604.         if(count($pData_['othfamily_name'])>0){
  1605.             end($pData_['othfamily_name']);
  1606.             $othfam = key($pData_['othfamily_name']) + 1;
  1607.  
  1608.             $y = 0;
  1609.             while($othfam > $y){
  1610.                 $oData['otherMemb'][$y]['othfamily_name'] = $pData_['othfamily_name'][$y];
  1611.                 $oData['otherMemb'][$y]['othfamily_relationship'] = $pData_['othfamily_relationship'][$y];
  1612.                 $oData['otherMemb'][$y]['othfamily_age'] = $pData_['othfamily_age'][$y];
  1613.                 $oData['otherMemb'][$y]['othfamily_level'] = $pData_['othfamily_level'][$y];
  1614.                 $oData['otherMemb'][$y]['othfamily_company'] = $pData_['sibling_school_name'][$y];
  1615.                 $y++;
  1616.             }
  1617.         }
  1618.  
  1619.         //Return School History Data
  1620.         if(count($pData_['schistory_lvl'])>0){
  1621.             end($pData_['schistory_lvl']);
  1622.             $sch_his = key($pData_['schistory_lvl']) + 1;
  1623.  
  1624.             $y = 0;
  1625.             while($sch_his > $y){
  1626.                 $oData['schoolHis'][$y]['lvl'] = $pData_['schistory_lvl'][$y];
  1627.                 $oData['schoolHis'][$y]['school'] = $pData_['schistory_school'][$y];
  1628.                 $oData['schoolHis'][$y]['schooladd'] = $pData_['schistory_schooladdress'][$y];
  1629.                 $oData['schoolHis'][$y]['from'] = $pData_['schistory_yrsFrom'][$y];
  1630.                 $oData['schoolHis'][$y]['to'] = $pData_['schistory_yearsTo'][$y];
  1631.                 $oData['schoolHis'][$y]['honors'] = $pData_['schistory_honors'][$y];
  1632.                 $oData['schoolHis'][$y]['honorsYr'] = $pData_['schistory_honorsYear'][$y];
  1633.                 $oData['schoolHis'][$y]['sCOurseSwitch'] = $pData_['schistory_specialCourseRadio'];
  1634.                 $oData['schoolHis'][$y]['sCOurse'] = $pData_['schistory_specialCourse'][$y];
  1635.                 $oData['schoolHis'][$y]['sCOurseYear'] = $pData_['schistory_specialCourseYear'][$y];
  1636.                 $oData['schoolHis'][$y]['summerClassSwitch'] = $pData_['schistory_summerClassesRadio'];
  1637.                 $oData['schoolHis'][$y]['summerClass'] = $pData_['schistory_summerClasses'][$y];
  1638.                 $oData['schoolHis'][$y]['summerClassYear'] = $pData_['schistory_summerClassesYear'][$y];
  1639.                 $oData['schoolHis'][$y]['failedSubjectSwitch'] = $pData_['schistory_failedSubjectRadio'];
  1640.                 $oData['schoolHis'][$y]['failedSubject'] = $pData_['schistory_failedSubject'][$y];
  1641.                 $oData['schoolHis'][$y]['failedSubject'] = $pData_['failedSubjectYear'][$y];
  1642.                 $oData['schoolHis'][$y]['repeatedSwitch'] = $pData_['schistory_repeatedRadio'];
  1643.                 $oData['schoolHis'][$y]['repeated'] = $pData_['schistory_repeated'][$y];
  1644.                 $oData['schoolHis'][$y]['repeatedYear'] = $pData_['schistory_repeatedYear'][$y];
  1645.                 $oData['schoolHis'][$y]['prevSchoolFrom'] = $pData_['transferee_prev_school_from'];
  1646.                 $oData['schoolHis'][$y]['prevSchoolTo'] = $pData_['transferee_prev_school_to'];
  1647.                 $oData['schoolHis'][$y]['transfereeReason1'] = $pData_['transferee_reason1'];
  1648.                 $oData['schoolHis'][$y]['prevSchoolFrom1'] = $pData_['transferee_prev_school_from1'];
  1649.                 $oData['schoolHis'][$y]['prevSchoolTo1'] = $pData_['transferee_prev_school_to1'];
  1650.                 $oData['schoolHis'][$y]['transfereeReason2'] = $pData_['transferee_reason2'];
  1651.                 $oData['schoolHis'][$y]['transferee_disciplinary'] = $pData_['transferee_disciplinary'];
  1652.                 $y++;
  1653.             }
  1654.         }
  1655.  
  1656.         //Return Health History Data
  1657.         $oData['healthHis']['health_weight'] = $pData_['health_weight'];
  1658.         $oData['healthHis']['health_eyesight'] = $pData_['health_eyesight'];
  1659.         $oData['healthHis']['health_hearing'] = $pData_['health_hearing'];
  1660.         $oData['healthHis']['health_allergies'] = $pData_['health_allergies'];
  1661.         $oData['healthHis']['health_immunizations'] = $pData_['health_immunizations'];
  1662.         $oData['healthHis']['health_speech_difficulties'] = $pData_['health_speech_difficulties'];
  1663.         $oData['healthHis']['health_childhood_diseases'] = $pData_['health_childhood_diseases'];
  1664.         $oData['healthHis']['medicalcondition'] = $pData_['medicalcondition'];
  1665.         $oData['healthHis']['health_handycap'] = $pData_['health_handycap'];
  1666.  
  1667.         return $oData;
  1668.  
  1669.     }
  1670.  
  1671.     function doValidateData_Studno($pData_ = array()){
  1672.  
  1673.         $isValid = true;
  1674.  
  1675.         $sql_check = "select * from dps_registrar_db.student_applicant_information where ppd_studno = '{$pData_['ppd_studno']}'";
  1676.  
  1677.         $rsResult_check = $this->conn->Execute($sql_check);
  1678.  
  1679.         if (!$rsResult_check->EOF){
  1680.             $isValid = false;
  1681.             $_SESSION['eMsg'][]="Student Number Already been Used by Other Student";
  1682.         }
  1683.  
  1684.         return $isValid;
  1685.  
  1686.     }
  1687.  
  1688.     function doSaveEdit_Studno($pData_ = array(),$id = null){
  1689.  
  1690.         $sql = "update student_applicant_information set ppd_studno = '{$pData_['ppd_studno']}' where stud_applicant_id=$id";
  1691.         $this->conn->Execute($sql);
  1692.  
  1693.         $_SESSION['eMsg']="Successfully Updated.";
  1694.  
  1695.     }
  1696.  
  1697.     function getListReqSubmitted($dbconn = null, $sy_id = null, $id_ = null){
  1698.  
  1699.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  1700.  
  1701.         $sql = "select *
  1702.                from file_applicant_submitted_reqt_header_$selected_table a
  1703.                inner join file_applicant_submitted_reqt_$selected_table b on (a.asubreqh_id = b.asubreqh_id)
  1704.                inner join file_requirements c on (b.requirements_id = c.requirements_id)
  1705.                where a.stud_applicant_id=?";
  1706.  
  1707.         $rsResult = $this->conn->Execute($sql,$id_);
  1708.         while(!$rsResult->EOF){
  1709.             $arrData[] = $rsResult->fields;
  1710.             $rsResult->MoveNext();
  1711.         }
  1712. //      printa($arrData);
  1713.         return $arrData;
  1714.     }
  1715.  
  1716.     function doSaveEdit_Req($dbconn = null, $sy_id = null, $arrData = array()){
  1717.  
  1718.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  1719.  
  1720.         $qry = array();
  1721.         $qry[] = "a.stud_applicant_id = '{$arrData['stud_applicant_id']}'";
  1722.         $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  1723.  
  1724.         $sql = "select *
  1725.                from dps_registrar_db.file_applicant_submitted_reqt_header_$selected_table a
  1726.                inner join dps_registrar_db.file_applicant_submitted_reqt_$selected_table b on b.asubreqh_id = a.asubreqh_id
  1727.                $criteria
  1728.                ";
  1729.  
  1730.         $rsResult = $this->conn->Execute($sql);
  1731.  
  1732.         while(!$rsResult->EOF){
  1733.             for($x = 0; count($arrData['asubreq_requirements'])>$x; $x++){
  1734.  
  1735.                 $qry = array();
  1736.                 $qry[] = "a.stud_applicant_id = '{$arrData['stud_applicant_id']}'";
  1737.                 $qry[] = "b.requirements_id= '{$arrData['asubreq_requirements'][$x]['requirements_id']}'";
  1738.                 $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  1739.  
  1740.                 $sql_ = "select *
  1741.                        from dps_registrar_db.file_applicant_submitted_reqt_header_$selected_table a
  1742.                        inner join dps_registrar_db.file_applicant_submitted_reqt_$selected_table b on b.asubreqh_id = a.asubreqh_id
  1743.                        $criteria
  1744.                        ";
  1745.  
  1746.                 $rsResult_ = $this->conn->Execute($sql_);
  1747.  
  1748.                 $flds = array();
  1749.                 $flds[] = "asubreq_status = '20'";
  1750.                 $flds[] = "requirements_id = '{$arrData['asubreq_requirements'][$x]['requirements_id']}'";
  1751.  
  1752.                 if(!$rsResult_->EOF){
  1753.  
  1754.                     $flds[] = "asubreq_updatewho = '{$_SESSION['admin_session_obj']['user_data']['user_fullname']}'";
  1755.                     $flds[] = "asubreq_updatewhen = now()";
  1756.                     $fields = implode(",",$flds);
  1757.                     $update = "update dps_registrar_db.file_applicant_submitted_reqt_$selected_table set $fields
  1758.                               where asubreqh_id = '{$rsResult->fields['asubreqh_id']}'
  1759.                               and requirements_id = '{$arrData['asubreq_requirements'][$x]['requirements_id']}'";
  1760.                     $this->conn->Execute($update);
  1761.  
  1762.                 }else{
  1763.  
  1764.                     $flds[] = "asubreqh_id = '{$rsResult->fields['asubreqh_id']}'";
  1765.                     $flds[] = "asubreq_addwho = '{$_SESSION['admin_session_obj']['user_data']['user_fullname']}'";
  1766.                     $fields = implode(",",$flds);
  1767.                     $insert = "insert into dps_registrar_db.file_applicant_submitted_reqt_$selected_table set $fields";
  1768.                     $this->conn->Execute($insert);
  1769.  
  1770.                 }
  1771.             }
  1772.             $rsResult->MoveNext();
  1773.         }
  1774.     }
  1775.  
  1776.     function check_permit($dbconn = null, $sy_id = null, $stud_applicant_id = null){
  1777.  
  1778.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  1779.         $prev_table = clsRegistrarMisc::getSelected_Table($dbconn, $_SESSION['admin_session_obj']['syprevinfo']['sy_id']);
  1780.  
  1781.         $sql = "select ga_fg from dps_grade_db.grd_gen_average_fg_$prev_table where stud_applicant_id = '$stud_applicant_id'";
  1782.         $rsResult = $this->conn->Execute($sql);
  1783.         if(!$rsResult->EOF){
  1784.             $stud_grade = $rsResult->fields['ga_fg'];
  1785.         }
  1786.  
  1787.         $flds = array();
  1788.         $flds[] = "a.stud_applicant_id";
  1789.         $flds[] = "b.pte_issueddate";
  1790.         $flds[] = "b.pte_noofchildren_enrolled";
  1791.         $flds[] = "b.stud_level_prev";
  1792.         $flds[] = "if(isnull(b.stud_level_next),concat(c.yl_id),concat(b.stud_level_next)) as stud_level_next";
  1793.         $flds[] = "if(isnull(b.pte_general_ave),concat('$stud_grade'),concat(b.pte_general_ave)) as stud_grade";
  1794.         $flds[] = "CONCAT(h.pi_firstname,' ',h.pi_lastname) as issuer";
  1795.         $flds[] = "b.pte_status";
  1796.         $fields = implode(",",$flds);
  1797.  
  1798.         $sql = "select $fields
  1799.                from dps_registrar_db.student_applicant_information a
  1800.                left join dps_registrar_db.file_permit_to_enroll_$selected_table b on b.stud_applicant_id = a.stud_applicant_id
  1801.                left join dps_registrar_db.student_admission_info_$selected_table c on c.stud_applicant_id = a.stud_applicant_id
  1802.                left join dps_registrar_db.file_gradeyearlevel_$selected_table d on d.yl_id = b.stud_level_next
  1803.                left join dps_registrar_db.file_schoolyear e on e.sy_id = b.sy_id
  1804.  
  1805.                /*to get info of issuer of permit*/
  1806.                left join dps_hris_db.hris_emp_masterfile f on (f.emp_id = b.pte_issuedby)
  1807.                left join dps_hris_db.hris_emp_pinfo_master_rel g on (g.emp_id = f.emp_id)
  1808.                left join dps_hris_db.hris_emp_personalinfo h on (h.pi_id = g.pi_id)
  1809.                where a.stud_applicant_id = '$stud_applicant_id'
  1810.                order by pte_id DESC
  1811.                ";
  1812.  
  1813.         $rsResult = $this->conn->Execute($sql);
  1814.  
  1815.         if(!$rsResult->EOF){
  1816.             return $rsResult = $rsResult->fields;
  1817.         }
  1818.     }
  1819.  
  1820.     function doSaveEdit_Permit($dbconn = null, $sy_id = null, $arrData = array()){
  1821.  
  1822.         $stud_applicant_id = $_GET['edit'];
  1823.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  1824.  
  1825.         $sql = "select *
  1826.                from dps_registrar_db.file_permit_to_enroll_$selected_table
  1827.                where stud_applicant_id = '$stud_applicant_id'";
  1828.  
  1829.         $rsResult = $this->conn->Execute($sql);
  1830.  
  1831.         $flds = array();
  1832.         if(!$rsResult->EOF){
  1833.  
  1834.             $flds[] = "sy_id = '$sy_id'";
  1835.             $flds[] = "stud_level_prev = '{$arrData['stud_level_prev']}'";
  1836.             $flds[] = "stud_level_next = '{$arrData['stud_level_next']}'";
  1837.             $flds[] = "pte_general_ave = '{$arrData['stud_grade']}'";
  1838.             $flds[] = "pte_status = '{$arrData['pte_status']}'";
  1839.             $flds[] = "pte_updatewho = '".AppUser::getData('user_name')."'";
  1840.             $flds[] = "pte_issuedby_name = '".AppUser::getData('user_name')."'";
  1841.             $flds[] = "pte_updatewhen = now()";
  1842.             $fields = implode(", ",$flds);
  1843.             $sql = "update dps_registrar_db.file_permit_to_enroll_$selected_table set $fields where stud_applicant_id = '$stud_applicant_id'";
  1844.             $this->conn->Execute($sql);
  1845.  
  1846.             $this->Update_Permit($dbconn, $sy_id, $stud_applicant_id);
  1847.  
  1848.             $flds = array();
  1849.             $flds[] = "yl_id = '{$arrData['stud_level_next']}'";
  1850.             $flds[] = "sai_lastgyattended = '{$arrData['stud_level_prev']}'";
  1851.             $fields = implode(",",$flds);
  1852.             $sql = "update dps_registrar_db.student_admission_info_$selected_table set $fields where stud_applicant_id = '$stud_applicant_id'";
  1853.             $this->conn->Execute($sql);
  1854.  
  1855.         }else{
  1856.  
  1857.             $flds[] = "stud_applicant_id = '$stud_applicant_id'";
  1858.             $flds[] = "sy_id = '$sy_id'";
  1859.             $flds[] = "stud_level_prev = '{$arrData['stud_level_prev']}'";
  1860.             $flds[] = "stud_level_next = '{$arrData['stud_level_next']}'";
  1861.             $flds[] = "pte_general_ave = '{$arrData['stud_grade']}'";
  1862.             $flds[] = "pte_status = '{$arrData['pte_status']}'";
  1863.             $flds[] = "pte_issuedby = '".AppUser::getData('emp_id')."'";
  1864.             $flds[] = "pte_issuedby_name = '".AppUser::getData('user_name')."'";
  1865.             $flds[] = "pte_issueddate = '".date('Y-m-d')."'";
  1866.             $fields = implode(", ",$flds);
  1867.             $sql = "insert into dps_registrar_db.file_permit_to_enroll_$selected_table set $fields";
  1868.             $this->conn->Execute($sql);
  1869.  
  1870.             $this->Update_Permit($dbconn, $sy_id, $stud_applicant_id);
  1871.         }
  1872.  
  1873.         /// code for trailings added nov. 17 2009 : dps commonwealth  DPS � COD � T0019
  1874.         if($arrData['pte_status']==20){
  1875.             $act=", Marked as final";
  1876.         }
  1877.         $action="Edited file permit to enroll $act";
  1878.         clsRegistrarMisc::doSaveTrails($dbconn,$stud_applicant_id,$action,20);
  1879.     }
  1880.  
  1881.     function Update_Permit($dbconn = null, $sy_id = null, $stud_applicant_id = null){
  1882.  
  1883.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  1884.  
  1885.         $qry = array();
  1886.         if($stud_applicant_id != ''){
  1887.             $qry[] = "a.stud_applicant_id = '$stud_applicant_id'";
  1888.         }
  1889.         $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  1890.  
  1891.         $sql = "select a.stud_applicant_id, b.studenrol_status
  1892.                from dps_registrar_db.file_permit_to_enroll_$selected_table a
  1893.                left join dps_registrar_db.file_student_enrolled_$selected_table b on b.stud_applicant_id = a.stud_applicant_id
  1894.                $criteria";
  1895.  
  1896.         $rsResult = $this->conn->Execute($sql);
  1897.  
  1898.         while(!$rsResult->EOF){
  1899.  
  1900.             $qry = array();
  1901.             $qry[] = "a.sy_id = $sy_id";
  1902.             $qry[] = "a.stud_applicant_id = {$rsResult->fields['stud_applicant_id']}";
  1903.             $qry[] = "(c.ori_name like '%Tuition Fee%' or c.ori_name like '%Reservation Fee%')";
  1904.             $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  1905.  
  1906.             $sql_cashier = "select th_ornumber,th_or_amount,th_trandate,stud_applicant_id
  1907.                            from dps_cashier_db.cashier_trans_header a
  1908.                            inner join dps_cashier_db.cashier_trans_detail b on b.th_id = a.th_id
  1909.                            inner join dps_cashier_db.cashier_or_items c on c.ori_id = b.ori_id
  1910.                            $criteria
  1911.                           ";
  1912.  
  1913.             $rsResult_cashier = $this->conn->Execute($sql_cashier);
  1914.  
  1915.             if(!$rsResult_cashier->EOF){
  1916.  
  1917.                 $flds = array();
  1918.                 $flds[] = "yl_id = {$rsResult->fields['stud_level_next']}";
  1919.                 $flds[] = "stud_applicant_id = '{$rsResult->fields['stud_applicant_id']}'";
  1920.                 $flds[] = "studenrol_orno = '{$rsResult_cashier->fields['th_ornumber']}'";
  1921.                 $flds[] = "studenrol_amount = {$rsResult_cashier->fields['th_or_amount']}";
  1922.                 $flds[] = "studenrol_datepaid  = '{$rsResult_cashier->fields['th_trandate']}'";
  1923.                 $flds[] = "studenrol_addwho  = '{$_SESSION['admin_session_obj']['user_name']}'";
  1924.                 $flds[] = "studenrol_status  = 20";
  1925.                 $flds[] = "fse_remarks  = 'Automate Tagging - Backend'";
  1926.                 $fields = implode(",",$flds);
  1927.  
  1928.             }
  1929.  
  1930.             if($rsResult->fields['studenrol_status'] == null){
  1931.                 $insert_permit = "insert into dps_registrar_db.file_student_enrolled_$selected_table set $fields";
  1932.                 $this->conn->Execute($insert_permit);
  1933.  
  1934.             }else if ($rsResult->fields['studenrol_status'] != 20){
  1935.                 $update_permit = "update dps_registrar_db.file_student_enrolled_$selected_table set $fields where stud_applicant_id = '{$rsResult->fields['stud_applicant_id']}'";
  1936.                 $this->conn->Execute($update_permit);
  1937.  
  1938.             }
  1939.  
  1940.             $rsResult->MoveNext();
  1941.         }
  1942.     }
  1943.  
  1944.     function generate_studno($dbconn = null, $sy_id = null, $stud_applicant_id = null){
  1945.  
  1946.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  1947.  
  1948.         $sql = "select ppd_studno
  1949.                from dps_registrar_db.student_applicant_information
  1950.                where stud_applicant_id = '$stud_applicant_id'";
  1951.  
  1952.         $rsResult = $this->conn->Execute($sql);
  1953.  
  1954.         if(!$rsResult->EOF){
  1955.             if(is_null($rsResult->fields['ppd_studno'])){
  1956.  
  1957.                 $flds = array();
  1958.                 $flds[] = "stud_applicant_id = '$stud_applicant_id'";
  1959.                 $flds[] = "ab_id = '{$_SESSION['admin_session_obj']['ab_id']}'";
  1960.                 $flds[] = "sy_id = '$sy_id'";
  1961.                 $flds[] = "sn_addwho = '".AppUser::getData('user_name')."'";
  1962.                 $flds[] = "sn_status = 10";
  1963.                 $fields = implode(",",$flds);
  1964.  
  1965.                 $insert = "insert into file_student_no_$selected_table set $fields";
  1966.                 $this->conn->Execute($insert);
  1967.                 $id = $this->conn->Insert_ID();
  1968.  
  1969.                 $sql_ = "select sy_abbr from dps_registrar_db.file_schoolyear where sy_id = '$sy_id'";
  1970.                 $rsResult_ = $this->conn->Execute($sql_);
  1971.  
  1972.                 if(!$rsResult_->EOF){
  1973.                     $year_code = $rsResult_->fields['sy_abbr'];
  1974.                 }
  1975.  
  1976.                 $strpadded = str_pad($id,4,0,STR_PAD_LEFT);
  1977.                 $ppd_studno = "$year_code$strpadded";
  1978.                 $ppd_studno_printid = "$year_code-$strpadded";
  1979.  
  1980.                 $sql = "update file_student_no_$selected_table set sn_no = '$ppd_studno' where stud_applicant_id = '$stud_applicant_id' and sn_status = 10";
  1981.                 $this->conn->Execute($sql);
  1982.  
  1983.                 $sql = "update student_applicant_information set ppd_studno = '$ppd_studno',ppd_studno_printid = '$ppd_studno_printid' where stud_applicant_id = '$stud_applicant_id'";
  1984.                 $this->conn->Execute($sql);
  1985.             }
  1986.         }
  1987.     }
  1988.  
  1989.     function generate_user(){
  1990.  
  1991.         $sql = "select a.stud_applicant_id,a.ppd_studno, concat(a.ppd_lastname,' ',a.ppd_firstname) as student_name, c.yl_name, d.section_name
  1992.                from dps_registrar_db.student_applicant_information a
  1993.                inner join dps_registrar_db.file_sectioning_details_{$this->getCurrentSy()} b on b.fs_stud_applicant_id = a.stud_applicant_id
  1994.                inner join dps_registrar_db.file_gradeyearlevel_{$this->getCurrentSy()} c on c.yl_id = b.fs_yl_id
  1995.                inner join dps_registrar_db.file_section_{$this->getCurrentSy()} d on d.section_id = b.fs_sec_id
  1996.                where b.fs_yl_id in (1,2,3,4,5,6)
  1997.                order by b.fs_yl_id,d.section_name,a.ppd_lastname, a.ppd_firstname
  1998.                ";
  1999.  
  2000.         $rsResult = $this->conn->Execute($sql);
  2001.  
  2002.         $arrResult = array();
  2003.         while(!$rsResult->EOF){
  2004.             $arrResult[] = $rsResult->fields;
  2005.             $rsResult->MoveNext();
  2006.         }
  2007.  
  2008.         return $arrResult;
  2009.     }
  2010.  
  2011.     function getStud_Info($dbconn = null, $sy_id = null, $stud_applicant_id = null){
  2012.  
  2013.         $selected_table = clsRegistrarMisc::getSelected_Table($dbconn,$sy_id);
  2014.  
  2015.         $flds = array();
  2016.         $flds[] = "a.stud_applicant_id";
  2017.         $flds[] = "a.ppd_studno";
  2018.         $flds[] = "a.ppd_lastname";
  2019.         $flds[] = "a.ppd_firstname";
  2020.         $flds[] = "a.ppd_middlename";
  2021. //        $flds[] = "fetcher_lname";
  2022. //        $flds[] = "fetcher_fname";
  2023.         $fields = implode(",", $flds);
  2024.  
  2025.         $qry = array();
  2026.         $qry[] = "a.stud_applicant_id = '$stud_applicant_id'";
  2027.         if(isset($_GET['fetcher_id'])){
  2028. //            $qry[] = "f.id = '{$_GET['fetcher_id']}'";
  2029.         }
  2030.  
  2031.         $criteria = (count($qry)>0)?" where ".implode(" and ",$qry):"";
  2032.  
  2033.         $sql = "select $fields
  2034.                from dps_registrar_db.student_applicant_information a
  2035.                left join dps_registrar_db.student_health_history a1 on a1.stud_applicant_id = a.stud_applicant_id
  2036.                left join dps_registrar_db.file_sectioning_details_$selected_table b on a.stud_applicant_id = b.fs_stud_applicant_id
  2037.                left join dps_registrar_db.file_gradeyearlevel_$selected_table c on c.yl_id = b.fs_yl_id
  2038.                left join dps_registrar_db.file_section_$selected_table d on d.section_id = b.fs_sec_id
  2039.                left join dps_registrar_db.file_schoolyear e on e.sy_id = c.sy_id
  2040.                /*left join dps_registrar_db.fetcher_info f on f.stud_applicant_id = a.stud_applicant_id*/
  2041.                $criteria";
  2042.  
  2043.         $rsResult = $this->conn->Execute($sql);
  2044.  
  2045.         if (!$rsResult->EOF){
  2046.             return $rsResult = $rsResult->fields;
  2047.         }
  2048.  
  2049.     }
  2050.  
  2051.     function doSave_fetcher($pData = null){
  2052.  
  2053.         $flds = array();
  2054.         foreach ($pData as $key => $value){
  2055.             $value = trim($value);
  2056.             $value = addslashes($value);
  2057.             if($key == 'save' or $key == 'saveaddnew'){
  2058.  
  2059.             }else{
  2060.                 $flds[] = "$key = '$value'";
  2061.             }
  2062.  
  2063.         }
  2064.  
  2065.         $flds[] = "stud_applicant_id = {$_GET['student_fetcher']}";
  2066.         $fields = implode(",",$flds);
  2067.  
  2068.         if(isset($_GET['fetcher_id'])){
  2069.             $command = "update dps_registrar_db.fetcher_info set $fields where id = {$_GET['fetcher_id']}";
  2070.         }else{
  2071.             $command = "insert into dps_registrar_db.fetcher_info set $fields";
  2072.         }
  2073.  
  2074.         $this->conn->Execute($command);
  2075.  
  2076.         $_SESSION['eMsg'] = "Fetcher Information Successfully Saved";
  2077.  
  2078.     }
  2079.  
  2080.     function getFetcher_info($id = null){
  2081.  
  2082.         $sql = "select b.*
  2083.                from dps_registrar_db.student_applicant_information a
  2084.                inner join dps_registrar_db.fetcher_info b on b.stud_applicant_id = a.stud_applicant_id
  2085.                where id = '$id'
  2086.                ";
  2087.  
  2088.         $rsResult = $this->conn->Execute($sql);
  2089.  
  2090.         if(!$rsResult->EOF){
  2091.             $rsResult = $rsResult->fields;
  2092.         }
  2093.  
  2094.         return $rsResult;
  2095.  
  2096.     }
  2097.  
  2098.     function getFetcher_List($id = null){
  2099.  
  2100.         $sql = "select b.*
  2101.                from dps_registrar_db.student_applicant_information a
  2102.                inner join dps_registrar_db.fetcher_info b on b.stud_applicant_id = a.stud_applicant_id
  2103.                ";
  2104.  
  2105.         $rsResult = $this->conn->Execute($sql);
  2106.  
  2107.         $arrResult = array();
  2108.         while(!$rsResult->EOF){
  2109.             $arrResult[] = $rsResult->fields;
  2110.             $rsResult->MoveNext();
  2111.         }
  2112.  
  2113.         return $arrResult;
  2114.  
  2115.     }
  2116.  
  2117.     function delete_fetcher($id = null){
  2118.  
  2119.         $command = "delete from dps_registrar_db.fetcher_info where id = '$id'";
  2120.         $this->conn->Execute($command);
  2121.  
  2122.         $_SESSION['eMsg'] = "Fetcher Successfully Deleted";
  2123.  
  2124.     }
  2125.  
  2126.     function getCurrentSy () {
  2127.         $str_date = str_replace("-", "_", $_SESSION['current_sy']);
  2128.         return $str_date;
  2129.     }
  2130.  
  2131.     //TODO get the student if details if his/her college | done
  2132.     //TODO get student course
  2133.     //TODO get semester
  2134.     //TODO get student by year
  2135.     //TODO get block by semester and by course
  2136.     //TODO store block in to databse student id, course, sem year
  2137.  
  2138.     function determineIfcollegeIsValid($college_student_id){
  2139.         $isValid = true;
  2140.  
  2141.         $sql = "SELECT cc_student_id FROM college_student_course_headers WHERE cc_student_id = '$college_student_id'";
  2142.         $collegeArrayDetails = $this->conn->Execute($sql);
  2143.  
  2144.         foreach ($collegeArrayDetails as $value){
  2145.  
  2146.             $is_college_data = $value['cc_student_id'];
  2147.  
  2148.         }
  2149.  
  2150.         if(empty($is_college_data)){
  2151.  
  2152.             $isValid = false;
  2153.  
  2154.         }
  2155.  
  2156.         return $isValid;
  2157.  
  2158.     }
  2159.  
  2160.     function getStudentCourse($college_student_id) {
  2161.         $sql = "SELECT * FROM college_student_course_headers WHERE cc_student_id='$college_student_id'";
  2162.         $dataArray = $this->conn->Execute($sql);
  2163.  
  2164.         foreach ($dataArray as $value){
  2165.  
  2166.             //$course_details[] =  array(
  2167.             /*'student_id'=>$value['cc_student_id'],*/
  2168.             //'student_course'=>$value['cc_student_course'],
  2169.             //'student_track'=>$value['cc_student_track'],
  2170.             //'student_strand'=>$value['cc_student_strand']
  2171.             //);
  2172.  
  2173.             $course_details = $value['cc_student_course'];
  2174.  
  2175.         }
  2176.  
  2177.         return $course_details;
  2178.     }
  2179.  
  2180.  
  2181.  
  2182.     function getSemDetails(){
  2183.         $sql = "SELECT * FROM college_semester";
  2184.         $dataArray = $this->conn->Execute($sql);
  2185.  
  2186.         foreach ($dataArray as $value){
  2187.  
  2188.             $semester_details[] = array(
  2189.                 'semester_name'=>$value['cs_name'],
  2190.                 'semester_id'=>$value['cs_id']
  2191.             );
  2192.         }
  2193.  
  2194.         return $semester_details;
  2195.     }
  2196.  
  2197.     function getBlockPerSemesterAndCourse($course_id, $year_level_id, $semester_id){
  2198.  
  2199.         //noted get the profer year level id
  2200.  
  2201.         $sql = "SELECT * FROM college_course_block WHERE cc_id = '$course_id' AND yl_id = '$year_level_id' AND csm_id ='$semester_id'";
  2202.         $dataArray = $this->conn->Execute($sql);
  2203.         foreach ($dataArray as $value){
  2204.  
  2205.             $block_details[] = array(
  2206.                 'college_block_id'=>$value['ccb_id'],
  2207.                 'college_block_shortname'=>$value['ccb_shortname'],
  2208.                 'college_block_name'=>$value['ccb_name']
  2209.             );
  2210.  
  2211.         }
  2212.  
  2213.         return $block_details;
  2214.  
  2215.     }
  2216.  
  2217.     function getYearLevelId($college_student_id){
  2218.  
  2219.         $sql = "SELECT * FROM college_student_course_headers WHERE cc_student_id=$college_student_id";
  2220.         $dataArray = $this->conn->Execute($sql);
  2221.  
  2222.         foreach ($dataArray as $value){
  2223.  
  2224.             $year_level_id_details =$value['yl_id'];
  2225.  
  2226.  
  2227.         }
  2228.  
  2229.         return $year_level_id_details;
  2230.  
  2231.     }
  2232.  
  2233.  
  2234.     //get all subjects base asign
  2235.  
  2236.     function getSubjectData(){
  2237.  
  2238.         //cs_id  is to get the schedule
  2239.  
  2240.         $sql = "SELECT subjname_shortname,subjname_name,cs_unit,cs_id,cs_subject_id  FROM college_subjects cs
  2241.                 INNER JOIN dps_registrar_db.file_subject_name fsn on fsn.subjname_id = cs.cs_subject_id";
  2242.         $rsResult = $this->conn->Execute($sql);
  2243.  
  2244.         foreach ($rsResult as $value){
  2245.  
  2246.             $subjectDetails[] = array(
  2247.                 'cs_id' => $value['cs_id'],
  2248.                 'cs_subject_id' => $value['cs_subject_id'],
  2249.                 'subjname_shortname'=> $value['subjname_shortname'],
  2250.                 'subjname_name'=> $value['subjname_name'],
  2251.                 'cs_unit'=> $value['cs_unit'],
  2252.                 'sched'=> $this->getScheduleAll($value['cs_id'])
  2253.  
  2254.             );
  2255.  
  2256.         }
  2257.  
  2258.         return $subjectDetails;
  2259.     }
  2260.  
  2261.     function getScheduleAll($college_subject_id){
  2262.  
  2263.         $sql = "SELECT * FROM college_subject_schedule css
  2264.                 INNER JOIN dps_hris_db.hris_emp_personalinfo hep on hep.pi_id = css.college_professor_id
  2265.                 INNER JOIN file_building fb on fb.bldg_id = css.college_room_id
  2266.                 WHERE college_subject_id =$college_subject_id";
  2267.         $rsResult = $this->conn->Execute($sql);
  2268.         foreach ($rsResult as $value) {
  2269.  
  2270.             $temp = json_decode($value['college_day'],true);
  2271.  
  2272.             if($temp[0]['sunday']==0){
  2273.                 $temp_days_sunday = $temp[0]['sunday']='';
  2274.             } else {
  2275.                 $temp_days_sunday = $temp[0]['sunday']='Sun';
  2276.             }
  2277.             if($temp[0]['monday']==0){
  2278.                 $temp_days_monday = $temp[0]['monday']='';
  2279.             } else {
  2280.                 $temp_days_monday = $temp[0]['monday']='M';
  2281.             }
  2282.             if($temp[0]['tuesday']==0){
  2283.                 $temp_days_tuesday = $temp[0]['tuesday']='';
  2284.             } else {
  2285.                 $temp_days_tuesday = $temp[0]['tuesday']='T';
  2286.             }
  2287.             if($temp[0]['wednesday']==0){
  2288.                 $temp_days_wendsday = $temp[0]['wednesday']='';
  2289.             } else {
  2290.                 $temp_days_wendsday = $temp[0]['wednesday']='W';
  2291.             }
  2292.             if($temp[0]['thursday']==0){
  2293.                 $temp_days_thursday = $temp[0]['thursday']='';
  2294.             } else {
  2295.                 $temp_days_thursday = $temp[0]['thursday']='TH';
  2296.             }
  2297.             if($temp[0]['friday']==0){
  2298.                 $temp_days_friday = $temp[0]['friday']='';
  2299.             } else {
  2300.                 $temp_days_friday = $temp[0]['friday']='F';
  2301.             }
  2302.             if($temp[0]['saturday']==0){
  2303.                 $temp_days_saturday = $temp[0]['saturday']='';
  2304.             } else {
  2305.                 $temp_days_saturday = $temp[0]['saturday']='Sat';
  2306.             }
  2307.  
  2308.             $temp_days = $temp_days_monday." ".$temp_days_tuesday." ".$temp_days_wendsday." ".$temp_days_thursday." ".$temp_days_friday." ".$temp_days_saturday." ".$temp_days_sunday." ";
  2309.  
  2310.             $subjectDetailsSchedule[] = array(
  2311.                 'college_subject_schedule_id'=>$value['college_subject_schedule_id'],
  2312.                 'college_day'=>$value['college_day'],
  2313.                 'professor'=>$value['pi_lastname']." ".$value['pi_firstname'],
  2314.                 'college_time_in'=>$value['college_time_in'],
  2315.                 'college_time_out'=>$value['college_time_out'],
  2316.                 'combine_time' => $value['college_time_in'].'|'.$value['college_time_out'],
  2317.                 'extracteddays'=> $temp_days,
  2318.                 'bldg_name'=> $value['bldg_name'],
  2319.                 'schedsummary'=> $temp_days." | ".$value['college_time_in'].' | '.$value['college_time_out']." | ".$value['bldg_name'] ." | ".$value['pi_firstname']." ".$value['pi_lastname']
  2320.  
  2321.             );
  2322.  
  2323.         }
  2324.  
  2325.         return $subjectDetailsSchedule;
  2326.     }
  2327.    
  2328.     function addAnotherSubjectRow($data = array()) {
  2329.  
  2330.         $count = count($_SESSION['custom_short_name']);
  2331.  
  2332.         foreach ($data as $value){
  2333.             $_SESSION['custom_short_name'] = $value['subjname_shortname'];
  2334.         }
  2335.  
  2336.     }
  2337.  
  2338.     function getAdditionalSubjects(){
  2339.         $sql = "SELECT * FROM college_subject_schedule css
  2340.                 INNER JOIN dps_hris_db.hris_emp_personalinfo hep on hep.pi_id = css.college_professor_id
  2341.                 INNER JOIN file_building fb on fb.bldg_id = css.college_room_id";
  2342.         $rsResult = $this->conn->Execute($sql);
  2343.  
  2344.         return $rsResult;
  2345.     }
  2346.  
  2347.  
  2348. }
  2349. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement