public static function addCategory2($application, $category2, $schoolIds, $yArray, $dArray, $guardianNic, $eAchievement, $cAchievement)
 {
     $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) {
                 $resultC = true;
                 $resultEA = true;
                 $resultCA = true;
                 $resultCD = DBGuardianController::hasCategory2Detail($guardianNic, $application->getSchool_id());
                 if ($resultCD == false) {
                     $resultC = DBCategory2Controller::addCategory2($category2);
                     $resultEA = DBPPAchievementController::addPPAchievement($eAchievement);
                     $resultCA = DBPPAchievementController::addPPAchievement($cAchievement);
                 }
                 if ($resultC and $resultEA and $resultCA) {
                     $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;
         }
     } else {
         $mysqli->rollback();
         $mysqli->commit();
         return FALSE;
     }
 }
 public function postEditcategory2()
 {
     $gradeOfAdmission = Input::get("gradeOfAdmission");
     $gradeOfLeaving = Input::get("gradeOfLeaving");
     $pastPupilOrganizationMembership = Input::get("pastPupilOrganizationMembership");
     $eAchievementDetail = Input::get("eAchievementDetail");
     $cAchievementDetail = Input::get("cAchievementDetail");
     $eAchievementId = Input::get("eAchievementId");
     $cAchievementId = Input::get("cAchievementId");
     $schoolId = Input::get("schoolId");
     $nic = Input::get("nic");
     $category2 = new PastPupil();
     $category2->setSchoolId($schoolId);
     $category2->setNIC($nic);
     $category2->setGradeOfAdmission($gradeOfAdmission);
     $category2->setGradeOfLeaving($gradeOfLeaving);
     $category2->setPastPupilOrganizationMembership($pastPupilOrganizationMembership);
     $eAchievement = new PastPupil_achievement();
     $eAchievement->setSchoolId($schoolId);
     $eAchievement->setNIC($nic);
     $eAchievement->setAchievementID($eAchievementId);
     $eType = 'Education';
     $eAchievement->setType($eType);
     $eAchievement->setAchievementDetail($eAchievementDetail);
     $cAchievement = new PastPupil_achievement();
     $cAchievement->setSchoolId($schoolId);
     $cAchievement->setNIC($nic);
     $cAchievement->setAchievementID($cAchievementId);
     $cType = 'Co_curricular';
     $cAchievement->setType($cType);
     $cAchievement->setAchievementDetail($cAchievementDetail);
     $result = DBCategory2Controller::editCategory2($category2, $eAchievement, $cAchievement);
     if ($result) {
         return "category 1 editted well";
     } else {
         return "category 1 not editted well";
     }
 }
 public function postVerifytype2()
 {
     $application_id = Input::get('type');
     $schoolid = Input::get('school_id');
     $school = DBSchoolController::getSchool($schoolid);
     $application = DBApplicationController::getApplication($application_id);
     $applicant_id = $application->getApplicant_id();
     $applicant = DBStudentApplicantController::getApplicantById($applicant_id);
     $NIC = $applicant->getGuardianNIC();
     $guardian = DBGuardianController::getGuardianByNic($NIC);
     $category = DBCategory2Controller::getCategory2($schoolid, $NIC);
     $pp_ach_set = DBPPAchievementController::getPastPupilAch($schoolid, $NIC);
     $pp_con_set = DBPPContributionController::getPastPupilCon($schoolid, $NIC);
     return View::make('G1SAS/verifycategoryset/VerifyCategory2')->with('application_id', $application_id)->with('guardian', $guardian)->with('school', $school)->with('application', $application)->with('applicant', $applicant)->with('category', $category)->with('ach_set', $pp_ach_set)->with('con_set', $pp_con_set);
 }