public function postIndex()
 {
     $user_type = Input::get("userTypeA");
     $user_name = Input::get("userNameText");
     $password = Input::get("password");
     //$deadline = Input::get("deadline");
     if ($user_type == 2) {
         $guardian = DBGuardianController::getGuardian($user_name);
         if ($guardian->getPassword() == $password) {
             //if (Hash::check($password, $guardian->getPassword())){
             return View::make('G1SAS/userpage')->with('guardian', $guardian)->with('username', $user_name)->with('labelText', 'Your Child-Your School');
         } else {
             return View::make('G1SAS/login')->with('greet', 'Applications for this year is closed.')->with('message', 'Password you enttered is incorrect');
         }
     } elseif ($user_type == 0) {
         $user = DBAdminController::getAdmin($user_name);
         if ($user->getPassword() == $password) {
             // if (Hash::check($password, $user->getPassword())){
             return View::make('G1SAS/adminpage')->with('title', "You are logged in as:" . $user_name);
         } else {
             return View::make('G1SAS/login')->with('greet', 'Applications for this year is closed.')->with('message', 'Password you enttered is incorrect');
         }
     } else {
         $school = DBSchoolController::getSchoolByEmail($user_name);
         if ($school->getPassword() == $password) {
             //if (Hash::check($password, $school->getPassword())){
             return View::make('G1SAS/schoolpage')->with('school', $school)->with('notice', 'School information here');
         } else {
             return View::make('G1SAS/login')->with('greet', 'Applications for this year is closed.')->with('message', 'Password you enttered is incorrect');
         }
     }
 }
 public function getSchoolapplicantsfind()
 {
     $schoolid = Input::get("schoolid");
     $school = DBSchoolController::getSchool($schoolid);
     $schools = DBSchoolController::getAllSchool();
     $selected = Input::get("school");
     $selectedSchool = DBSchoolController::getSchool($selected);
     $pieces = explode("-", $selected);
     $schoolId = $pieces[0];
     $applicants = DBStudentApplicantController::getSelectedApplicantsForSchool($schoolId);
     return View::make('G1SAS/showSchoolApplicants')->with('selectedSchool', $selectedSchool)->with('schools', $schools)->with('school', $school)->with('selected', $selected)->with('applicants', $applicants);
 }
 public function getNext()
 {
     $applicant_id = Input::get("applicant_id");
     $username = Input::get("username");
     $school1 = Input::get("school_name1");
     $school2 = Input::get("school_name2");
     $school3 = Input::get("school_name3");
     $school4 = Input::get("school_name4");
     $school5 = Input::get("school_name5");
     $school6 = Input::get("school_name6");
     $ar = array($school1, $school2, $school3, $school4, $school5, $school6);
     $uni_ar = array_unique($ar);
     if (sizeof($uni_ar) != 6) {
         return Redirect::back()->withInput()->with('error', 'please select diffrent 6 schools');
     }
     $school7 = Input::get("school_name7");
     $school8 = Input::get("school_name8");
     $school9 = Input::get("school_name9");
     $school10 = Input::get("school_name10");
     $school11 = Input::get("school_name11");
     $school12 = Input::get("school_name12");
     $school13 = Input::get("school_name13");
     $school14 = Input::get("school_name14");
     $school15 = Input::get("school_name15");
     $school16 = Input::get("school_name16");
     $ar = array($school7, $school8, $school9, $school10, $school11, $school12, $school13, $school14, $school5, $school6);
     $uni_ar = array_unique($ar);
     if (sizeof($uni_ar) != 10) {
         return Redirect::back()->withInput()->with('error', 'please select diffrent 10 schools for close school set');
     }
     $division1 = Input::get("Year1d");
     $division2 = Input::get("Year2d");
     $division3 = Input::get("Year3d");
     $division4 = Input::get("Year4d");
     $division5 = Input::get("Year5d");
     $division6 = Input::get("Year6d");
     $year1 = Input::get("year1");
     $year2 = Input::get("year2");
     $year3 = Input::get("year3");
     $year4 = Input::get("year4");
     $year5 = Input::get("year5");
     $year6 = Input::get("year6");
     $ar = array($year1, $year2, $year3, $year4, $year5, $year6);
     $uni_ar = array_unique($ar);
     if (sizeof($uni_ar) != 6) {
         return Redirect::back()->withInput()->with('error', 'please select diffrent 6 years');
     }
     $dArray = array($division1, $division2, $division3, $division4, $division5, $division6);
     $yArray = array($year1, $year2, $year3, $year4, $year5, $year6);
     $schoolid_array = array($school1, $school2, $school3, $school4, $school5, $school6, $school7, $school8, $school9, $school10, $school11, $school12, $school13, $school14, $school15, $school16);
     $schools = array();
     $guardian = DBGuardianController::getGuardian($username);
     $applicant = DBStudentApplicantController::getApplicantById($applicant_id);
     foreach ($schoolid_array as $schoolid) {
         $schools[] = DBSchoolController::getSchool($schoolid);
     }
     return View::make('G1SAS/SelectionType')->with('username', $username)->with('schools', $schools)->with('dArray', $dArray)->with('yArray', $yArray)->with('guardian', $guardian)->with('applicant', $applicant);
 }
 public function postChangep1()
 {
     $applicantId = Input::get("applicant_id");
     $schools = DBSchoolController::getApplySchoolSet($applicantId);
     return View::make('G1SAS/changeSchoolPiority')->with('schools', $schools)->with('applicantId', $applicantId);
 }
 public static function addCategory3($application, $schoolIds, $yArray, $dArray, $guardianNic, $ppo, $achievements, $donations, $siblings)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $mysqli->autocommit(FALSE);
     $applicantResult = DBApplicationController::addApplication($application);
     if ($applicantResult) {
         $resultSchoolSet = true;
         $isApplicanthasCSS = DBSchoolController::isApplicanthasCSS($application->getApplicant_id());
         if ($isApplicanthasCSS) {
             //do not need add school set
         } else {
             // return $schoolIds[1];
             $resultSchoolSet = DBSchoolController::addCloseSchoolSet($application->getApplicant_id(), $schoolIds);
         }
         if ($resultSchoolSet) {
             $resultEL = true;
             $isGuardianHasEL = DBGuardianController::isGuardianHasEL($guardianNic);
             if ($isGuardianHasEL) {
             } else {
                 $resultEL = DBElectrocalListController::addElectrocalListDetail($dArray, $yArray, $guardianNic);
             }
             if ($resultEL) {
                 for ($i = 0; $i < 3; $i++) {
                     $resultC = true;
                     $resultEA = true;
                     $resultD = true;
                     $resultS = true;
                     $resultCD = DBGuardianController::hasCategory3Detail($ppo[$i]->getAdmissionNumber(), $application->getSchool_id());
                     if ($resultCD == false) {
                         $resultC = DBCategory3Controller::addCategory3($ppo[$i]);
                         $resultEA = DBCPAchievementController::addCPAchievement($achievements[$i]);
                         $resultD = DBCurPupilDonationController::addCPDonation($donations[$i]);
                         $resultS = DBSiblingController::addSibling($siblings[$i]);
                     }
                     if ($resultD and $resultEA and $resultC and $resultS) {
                     } else {
                         $mysqli->rollback();
                         $mysqli->commit();
                         return false;
                     }
                 }
                 $mysqli->commit();
                 return true;
             } else {
                 $mysqli->rollback();
                 $mysqli->commit();
                 return FALSE;
             }
         } else {
             $mysqli->rollback();
             $mysqli->commit();
             return FALSE;
         }
     } else {
         $mysqli->rollback();
         $mysqli->commit();
         return FALSE;
     }
 }
 public static function getApplySchoolSet($applicantId)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $query = "select distinct schoolId from application where applicantId='{$applicantId}' order by orderOfPreference";
     $result = $mysqli->query($query);
     $schools = array();
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             $schoolId = $row["schoolId"];
             $school = DBSchoolController::getSchool($schoolId);
             $schools[] = $school;
         }
     }
     return $schools;
 }
 public function postAddschool()
 {
     $schoolid = Input::get('schoolidtext');
     $schoolname = Input::get('schoolnametext');
     $category = Input::get('category');
     $no_of_classes = Input::get('capacitytext');
     $contact_number = Input::get('contacttext');
     $male_per = Input::get('malepertext');
     $sinhala_per = Input::get('sinhalapertext');
     $email = Input::get('emailtext');
     $password = Input::get('passwordtext');
     $school = new school();
     $school->setSchool_id($schoolid);
     $school->setSchool_name($schoolname);
     $school->setCategory($category);
     $school->setContact_no($contact_number);
     $school->setNo_of_classes($no_of_classes);
     $school->setMale_percentage($male_per);
     $school->setSinhala_percentage($sinhala_per);
     $school->setEmail($email);
     //$school->setPassword(Hash::make($password));
     $school->setPassword($password);
     $result = DBSchoolController::addSchool($school);
     if ($result) {
         return View::make('G1SAS/adminpage')->with('title', 'School added successfully');
     } else {
         return View::make('G1SAS/adminpage')->with('title', 'School was not added');
     }
 }