public function postApplication()
 {
     $username = Input::get("username");
     $applicantId = Input::get("applicant_id");
     $orderOfPreference = Input::get("schoolPiority");
     $schoolId = Input::get("schoolId");
     $type = Input::get("type");
     $distance = Input::get("distanceT");
     $medium = '';
     if (Input::get("MediumT") == 0) {
         $medium = 'Sinhala';
     } else {
         $medium = 'Tamil';
     }
     $guardianNic = Input::get("guardianNic");
     $schoolIds = array(Input::get("schoolId1"), Input::get("schoolId2"), Input::get("schoolId3"), Input::get("schoolId4"), Input::get("schoolId5"), Input::get("schoolId6"), Input::get("schoolId7"), Input::get("schoolId8"), Input::get("schoolId9"), Input::get("schoolId10"));
     $yearset = array(Input::get("year1"), Input::get("year2"), Input::get("year3"), Input::get("year4"), Input::get("year5"), Input::get("year6"));
     $divisionSet = array(Input::get("division1"), Input::get("division2"), Input::get("division3"), Input::get("division4"), Input::get("division5"), Input::get("division6"));
     $application = new application();
     $application->setOrderOfPreference($orderOfPreference);
     $application->setType($type);
     $application->setSchool_id($schoolId);
     $application->setDistance($distance);
     $application->setMedium($medium);
     $application->setApplicant_id($applicantId);
     $isStudentApplySchoolFromThisCategory = DBApplicationController::isStudentApplySchoolFromThisCategory($applicantId, $schoolId, $type);
     if ($isStudentApplySchoolFromThisCategory) {
         return "you have allready added  this type of application to this school";
     }
     switch ($type) {
         case 0:
             $resultCD = DBGuardianController::hasCategory1Detail($guardianNic);
             if ($resultCD) {
                 $applicantResult = DBApplicationController::addApplication($application);
                 if ($applicantResult) {
                     return "added successfully";
                 } else {
                     return "not aded successfully";
                 }
             } else {
                 return View::make('G1SAS/category1')->with('application', $application)->with('username', $username)->with('schools', $schoolIds)->with('yArray', $yearset)->with('guardianNic', $guardianNic)->with('dArray', $divisionSet);
             }
             break;
         case 1:
             // never reached because "a" is already matched with 0
             return View::make('G1SAS/category2')->with('application', $application)->with('username', $username)->with('schools', $schoolIds)->with('yArray', $yearset)->with('guardianNic', $guardianNic)->with('dArray', $divisionSet);
             break;
         case 2:
             return View::make('G1SAS/category3')->with('application', $application)->with('username', $username)->with('schools', $schoolIds)->with('yArray', $yearset)->with('guardianNic', $guardianNic)->with('dArray', $divisionSet);
             break;
         case 3:
             // never reached because "a" is already matched with 0
             return View::make('G1SAS/category4')->with('application', $application)->with('username', $username)->with('schools', $schoolIds)->with('yArray', $yearset)->with('guardianNic', $guardianNic)->with('dArray', $divisionSet);
             break;
         case 4:
             return View::make('G1SAS/category5')->with('application', $application)->with('username', $username)->with('schools', $schoolIds)->with('yArray', $yearset)->with('guardianNic', $guardianNic)->with('dArray', $divisionSet);
             break;
         case 5:
             return View::make('G1SAS/category6')->with('application', $application)->with('username', $username)->with('schools', $schoolIds)->with('yArray', $yearset)->with('guardianNic', $guardianNic)->with('dArray', $divisionSet);
             break;
     }
 }
 public static function getApplication($application_id)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $query = "select * from application where application_id='{$application_id}';";
     $result = $mysqli->query($query);
     $application = new application();
     if ($result->num_rows > 0) {
         if ($row = $result->fetch_assoc()) {
             $application->setSchool_id($row["schoolId"]);
             $application->setApplication_id($row["application_id"]);
             $application->setApplicant_id($row["applicantId"]);
             $application->setType($row["typeOfApplication"]);
             $application->setMedium($row["medium"]);
             $application->setOrderOfPreference($row["orderOfPreference"]);
             $application->setDistance($row["distanceToSchool"]);
             $application->setIsverified($row["isverified"]);
         }
     }
     return $application;
 }