Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 13
CRAP
0.00% covered (danger)
0.00%
0 / 375
DataImportService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 13
13572.00
0.00% covered (danger)
0.00%
0 / 375
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 __clone
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 getInstance
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 5
 getAllDataImportTables
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 9
 createDataImport
0.00% covered (danger)
0.00%
0 / 1
90.00
0.00% covered (danger)
0.00%
0 / 14
 getStudentAccountColumns
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 11
 searchStudentForDataImport
0.00% covered (danger)
0.00%
0 / 1
30.00
0.00% covered (danger)
0.00%
0 / 20
 getDataImportDetailsById
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 16
 updateDataImportProperties
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 9
 InsertUpdateExcelContents
0.00% covered (danger)
0.00%
0 / 1
72.00
0.00% covered (danger)
0.00%
0 / 34
 constructStudentRequest
0.00% covered (danger)
0.00%
0 / 1
182.00
0.00% covered (danger)
0.00%
0 / 102
 getDataImportDetails
0.00% covered (danger)
0.00%
0 / 1
12.00
0.00% covered (danger)
0.00%
0 / 19
 updateStudent
0.00% covered (danger)
0.00%
0 / 1
4422.00
0.00% covered (danger)
0.00%
0 / 132
<?php
namespace com\linways\core\ams\professional\service;
use com\linways\core\ams\professional\dto\SettingsConstents;
use com\linways\core\ams\professional\exception\ProfessionalException;
use com\linways\core\ams\professional\util\S3Utils;
use stdClass;
use com\linways\core\ams\professional\dto\Student;
use com\linways\core\ams\professional\service\BatchService;
use com\linways\core\ams\professional\constant\FailedReason;
use com\linways\core\ams\professional\service\CommonService;
use com\linways\core\ams\professional\service\AmsCustomFieldsService;
class DataImportService extends BaseService
{
    private static $_instance = null;
    // /Condition 2 - Locked down the constructor
    private function __construct()
    {
    }
    // Prevent any oustide instantiation of this class
    // /Condition 3 - Prevent any object or instance of that class to be cloned
    private function __clone()
    {
    }
    // Prevent any copy of this object
    // /Condition 4 - Have a single globally accessible static method
    public static function getInstance()
    {
        if (!is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null )
            self::$_instance = new self ();
        return self::$_instance;
    }
    /**
     * @return Array
     * @throws ProfessionalException
     */
    public function getAllDataImportTables()
    {
        $sql = "SELECT id, name, code from dynamic_report_tables
                where use_for_data_import = 1";
        try {
            return $this->executeQueryForList($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
     /**
     * @return Array
     * @throws ProfessionalException
     */
    public function createDataImport($request)
    {
        try {
            if(!$request->fileName || !$request->userType || !$request->staffId ||
                !$request->tableType || !$request->resourceId || !$request->properties ||
                !$request->staffId){
                    throw new ProfessionalException(ProfessionalException::INVALID_DATA,"INVALID_DATA");
            }
            $sql = "INSERT INTO data_import (`file_name`, `user_type`, `user_id`, `table_type`, `resource_id`, `properties`, `created_by`) 
                    VALUES ('$request->fileName', '$request->userType', '$request->staffId', '$request->tableType', '$request->resourceId', '$request->properties', '$request->staffId')";
        
            return $this->executeQuery($sql,true);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
    /**
     * @return Array
     * @throws ProfessionalException
     */
    public function getStudentAccountColumns()
    {
        try {
            $sql = "SELECT drc.code from dynamic_report_columns drc 
                inner join dynamic_report_tables drt on drt.id = drc.table_id
                where drt.code = 'STUDENTACCOUNT' and drc.use_for_data_import =1
                order by drc.order";
            return $this->executeQueryForList($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
    public function searchStudentForDataImport($request)
    {
        $cond = '';
        if($request->rollNo){
            $cond .= " AND rollNo = '$request->rollNo";
        }
        if($request->admissionNo){
            $cond .= " AND admissionNo = '$request->admissionNo";
        }
        if($request->regNo){
            $cond .= " AND regNo = '$request->regNo";
        }
        try {
            $sql = "SELECT studentID from studentaccount 
                    WHERE 1=1 $cond";
            $result = $this->executeQueryForList($sql);
            return $result;
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
    public function getDataImportDetailsById($Id)
    {
        
        try {
            $sql = "SELECT di.file_name as fileName,di.properties, di.user_type,drt.name, lr.storage_object as storageObj ,lr.path,backend_type,lr.id as resourceId
                    from data_import di
                    inner join lin_resource lr on lr.id = di.resource_id
                    inner join dynamic_report_tables drt on drt.code = di.table_type
                    where di.id = $Id";
            $result = $this->executeQueryForObject($sql);
            $result->properties = json_decode($result->properties);
            $fileObj = json_decode(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $result->storageObj));
            $result->docpath=S3Utils::getPreSignedURL($fileObj->bucket, $fileObj->key);
            return $result;
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
    public function updateDataImportProperties($request)
    {
        
        try {
            $sql = "UPDATE data_import SET properties = '$request->properties', import_completed = '1'
                    WHERE id = $request->id";
            $this->executeQuery($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
    public function InsertUpdateExcelContents($fileObj){
        $excelHeaders = $fileObj->excelHeaders;
        $studentRequest = [];
        $pkColumnname = $fileObj->excelPk[0];
        try{
            $this->beginTransaction();
            foreach($fileObj->excelDataMapper as $rowIdx => $row){
                foreach($row as $colIdx => $obj){
                    $studentRequest[$excelHeaders[$colIdx]] = $obj->value;
                }
                $student = $this->constructStudentRequest($studentRequest,$fileObj->excelPk[0]);
                
                if(in_array($rowIdx,$fileObj->insertQueryIdx)){
                    $studentId = StudentService::getInstance()->createStudent($student);
                }
                else{
                    $pkIdx = array_search($pkColumnname,$excelHeaders);
                    $student->studentId = getStudentDetails($row[$pkIdx],$pkColumnname)[0]->studentID;
                    $studentDetails = StudentService::getInstance()->getStudentDetailsById($student->studentId);
                    $oldBatchId = $studentDetails->batchID;
                    $newBatchId = $student->batchID;
                    $studentId = $student->studentId;
                    if(empty($student->batchID))
                    $student->batchID = $oldBatchId;
    
                    if (empty($oldBatchId)|| empty($studentId))
                        throw new ProfessionalException(ProfessionalException::INVALID_DATA,"Cannot Find Batch/ StudentId For Student: $studentDetails->name");
                    
                    $this->updateStudent($student);
                }
                
            }
            $this->commit();
        }catch (\Exception $e) {
            $this->rollBack();
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
        return $fileObj;
    }
    
    public function constructStudentRequest($request,$excelPk)
    {
        $student = new Student();
        $student->studentAccount = $request[$excelPk];
        $student->studentPassword = $request[$excelPk];
        $student->rollNo = $request['ROLLNO'];
        $student->regNo = $request['REGNO'];
        $student->admissionNo = $request['ADMISSIONNO'];
        $student->deptID = $request['DEPARTMENTNAME'];
        $student->batchID = $request['BATCHNAME'];
        $student->exitType = $request['exitType'];
        $student->studentName = $request['NAME'];
        $student->studentEmail = $request['STUDENTEMAIL'];
        $student->studentGender = $request['STUDENTGENDER'];
        //$student->myImage = $request['myImage'];
        //$student->studentSignImage = $request['studentSignImage'];
        $student->myImageResourceId = $request['uploadedProfileImgResourceId']?$request['uploadedProfileImgResourceId']:NULL;
        $student->studentSignImgResourceId = $request['uploadedSignImgResourceId']?$request['uploadedSignImgResourceId']:NULL;
    
        $student->studentBirthday = $request['STUDENTBIRTHDAY'];
        $student->studentAddress = $request['STUDENTADDRESS'];
        $student->parentPincode = $request['PARENTZIPCODE'];
        $student->studentPhone = $request['STUDENTPHONE'];
        $student->parentPhone = $request['PARENTPHONE'];
        $student->religion = $request['RELIGION'];
        $student->casteId = $request['CASTENAME'];
        // $student->community = $request['community'];
        $student->category = $request['CATEGORY'];
        $student->bloodGroup = $request['BLOODGROUP'];
        // $student->admissionType= $request['admissionType'];
        $student->quotaId = $request['QUOTANAME'];
        $student->lateral = $request['LATERAL'];
        $student->nri = $request['NRI'];
        $student->studentSurname = $request['STUDENTSURNAME'];
        $student->studentFather = $request['STUDENTFATHER'];
        $student->studentMother = $request['STUDENTMOTHER'];
        // $student->feeReservationId = $request['feeReservationId'];
        $joinDate = $request['STUDENTJOINDATE'];
        $studentJoinday = "";
        if ($joinDate) {
            $studentJoinday = $joinDate;
        } else {
            //$studentJoinday = date("$joinYear-$joinMonth-$joinDate");
            $studentJoinday = date("Y-m-d");
        }
        $student->studentJoindate = $studentJoinday;
        $student->plustwo = $request['PLUSTWO'] == "" ? "" : $request['PLUSTWO'];
        $student->sslc = $request['SSLC'] == "" ? "" : $request['SSLC'];
        $student->ugPercentage = $request['UGPERCENTAGE'] == "" ? "" : $request['UGPERCENTAGE'];
        $student->feewaiverScheme = $request['FEEWAIVERSCHEME'];
        $student->hosteller = $request['hosteller'] ? $request['hosteller'] : 0;
        $student->rfId = $request['RFID'];
        $student->nationalityId = $request['NATIONALITY'];
        $student->previousSchool = $request['PREVIOUSSCHOOL'];
        $student->highestExamPassed = $request['HIGHESTEXAMPASSED'];
        $passingDate = $request['PREV_INSTITUTE_DATEOFPASSING'];
        $student->previousPassDate = $passingDate;
        $student->prevRegNo = $request['PREV_INSTITUTE_REGINO'];
        $student->admittedSemester = $request['admittedSemester'];
        $student->admissionTCNo = $request['ADMISSIONTCNO'];
        // $student->degree = $request['degree'];
        $student->busroute = $request['BUSROUTE'];
        $student->stateId = $request['STATE'];
        $student->districtId = $request['DISTRICT'];
        $student->talukId = $request['TALUK'];
        $student->annualIncome = $request['ANNUALINCOME'];
        $student->aadharNo = $request['AADHAAR_NO'];
        $student->povertyLineId = $request['POVERTY_LINE'];
        $student->campusTypeId = $request['CAMPUSTYPE'];
        $student->secondLanguageId = $request['secondLanguageId'];
        $student->joiningSemId = $request['JOININGSEMNAME'];
        $student->reservID = $request['SEATRESERVATION'];
        $student->studentReservationID = $request['STUDENTRESERVATION'];
        $student->phpTopicName = $request['PHDTOPICNAME'];
        $student->guideId = $request['PHDGUIDENAME'];
        $student->currentStatus = $request['PHDCURRENTSTATUS'];
        $student->isBatchShuffle = $request['isBatchShuffle'];
        $student->parentAddress1 = $request['PARENTADDRESS1'];
        $student->parentAddress2 = $request['PARENTADDRESS2'];
        $student->parentState = $request['PARENTSTATE'];
        $student->parentCity = $request['PARENTCITY'];
        $student->parentCountry = $request['PARENTCOUNTRY'];
        $student->parentZipCode = $request['PARENTZIPCODE'];
        $student->applicationNo = $request['APPLICATIONNO'];
        $student->entranceTest = $request['ENTRANCETEST'];
        $student->matScore = $request['MATSCORE'];
        $student->capID = $request['capID'];
        $student->domicileId = $request['domicileId'];
        $student->aadharNo = $request['AADHAAR_NO'];
        $student->annualIncome = $request['ANNUALINCOME'];
        $admissionEntriTypeGivenProperly = true;
        $admissionEntriTypes =json_decode(CommonService::getInstance()->getSettings(SettingsConstents::STUDENT_DETAILS, SettingsConstents::STUDENT_ADMISSION_TYPE));
        if($admissionEntriTypes->isAdmissionQuotaEnabled){
            $student->admissionEntryType = $request['admissionEntryType'];
            if((int)$student->admissionEntryType){
                $admissionEntriTypeGivenProperly = false;
                foreach($admissionEntriTypes->values as $entriType){
                    if($entriType->id == $student->admissionEntryType)
                        $admissionEntriTypeGivenProperly = true;
                }
                if(!$admissionEntriTypeGivenProperly)
                {
                    $student->admissionEntryType = null;
                }
            }
            else {
                $student->admissionEntryType = null;
            }
        }
        return $student;
    }
    /**
     * @return Array
     * @throws ProfessionalException
     */
    public function getDataImportDetails()
    {
        
        try {
            $sql = "SELECT di.file_name as fileName,di.properties, di.user_type,drt.name, lr.storage_object as storageObj ,lr.path,backend_type,lr.id as resourceId
                    from data_import di
                    inner join lin_resource lr on lr.id = di.resource_id
                    inner join dynamic_report_tables drt on drt.code = di.table_type
                    where import_completed = 1
                    order by di.created_at" ;
            $result = $this->executeQueryForList($sql);
            foreach($result as $res){
                $res->properties = json_decode($res->properties);
                $fileObj = json_decode(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $res->storageObj));
                $res->docpath=S3Utils::getPreSignedURL($fileObj->bucket, $fileObj->key);
            }
            return $result;
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
    }
    /**
     * update student
     * @param Student $student
     * @return \com\linways\base\dto\MySqlResult
     * @throws ProfessionalException
     */
    public function updateStudent($student)
    {
        if (!empty($student->customFields))
            $customFields = clone $student->customFields;
        $student = $this->realEscapeObject($student);
        $student->customFields = $customFields;
        unset($customFields);
        $updateexitType = "";
        $faileBatchId = BatchService::getInstance()->getFailedBatchId();
        $failed = 0;
        $staffId = $_SESSION['staffID'];
        $sql = "select sa.batchID, ba.semID, sa.joiningSemId,sem.type,sem.orderNo ,sa.student_lock
        from studentaccount sa 
        inner join batches ba on sa.batchID = ba.batchID 
        left join semesters sem on sem.semID = ba.semID 
        where studentID =$student->studentId";
        $batchDetails = $this->executeQueryForObject($sql);
        $batchId = $batchDetails->batchID;
        $semID = $batchDetails->semID;
        $currentJoiningSemId = $batchDetails->joiningSemId;
        $student->joiningSemId = ($student->joiningSemId) ? $student->joiningSemId : $currentJoiningSemId;
        $shouldAttendanceBatchIdBeChanged = true;
        if ($student->batchID == $faileBatchId) {
            if ($batchId != $faileBatchId) {
                $updateexitType = " exitType = '$student->exitType', ";
                $sql = "call move_failedstudents(\"$student->studentId\",$semID,0)";
                //echo $sql;
                $this->executeQuery($sql);
                $failed = 1;
                $student_lock = 1;
                $studentPreviousSemesters = StudentService::getInstance()->getPreviousSemestersOfThisBatch($student->studentId,$batchDetails);
                $previousBatchId = $batchId;
                $sqlForUpdatingFailedStudents = "UPDATE  failed_students SET reason ='" . FailedReason::FAILED . "',hisSemestersInThisbatch = '$studentPreviousSemesters',updated_by = '$staffId',userType = 'ACADEMICS_DATA_IMPORT_STAFF'  WHERE studentID=$student->studentId AND previousBatch = '$previousBatchId'";
                $this->executeQuery($sqlForUpdatingFailedStudents);
            }
        } else {
            if ($student->isBatchShuffle == "true") {
                $shouldAttendanceBatchIdBeChanged = false;
                $sqlForBatchShuffle = "call move_failedstudents(\"$student->studentId\",$semID,0)";
                $this->executeQuery($sqlForBatchShuffle);
                $studentPreviousSemesters = StudentService::getInstance()->getPreviousSemestersOfThisBatch($student->studentId,$batchDetails);
                $previousBatchId = $batchId;
                $sqlForUpdatingReason = "UPDATE  failed_students SET reason ='" . FailedReason::BATCH_SHUFFLE . "',hisSemestersInThisbatch = '$studentPreviousSemesters',updated_by = '$staffId',userType = 'ACADEMICS_DATA_IMPORT_STAFF'  WHERE studentID=$student->studentId AND previousBatch = '$previousBatchId'";
                $this->executeQuery($sqlForUpdatingReason);
            }
            $updateexitType = " exitType = '', ";
            $sql_update = "UPDATE failed_students SET isFailNow = 0 WHERE studentID = \"$student->studentId\"";
            $this->executeQuery($sql_update);
        }
        if ($batchId != $student->batchID && $failed == 0 && $shouldAttendanceBatchIdBeChanged) {
            $sql = "UPDATE attendance SET batchID=\"" . $student->batchID . "\" WHERE studentID=\"" . $student->studentId . "\" AND batchID=\"" . $batchId . "\"";
            $this->executeQuery($sql);
            $sql = "INSERT INTO admin_who_migarte_batch (adminID, studentID) VALUES(\"" . $student->updatedBy . "\", \"" . $student->studentId . "\")";
            $this->executeQuery($sql);
        }
        $student_lock = $batchDetails->student_lock;
        // $feeReservations = !empty($student->feeReservationId)?"fee_reservations_id=\"$student->feeReservationId\",":"";
        $showCapID = CommonService::getInstance()->getSettings(SettingsConstents::STUDENT_PROFILE_EDIT, SettingsConstents::SHOW_CAP_ID);
        $admissionEntryTypes =json_decode(CommonService::getInstance()->getSettings(SettingsConstents::STUDENT_DETAILS, SettingsConstents::STUDENT_ADMISSION_TYPE));
        $condition = "";
        $condition = $showCapID?",cap_id='$student->capID'":"";
        $condition = $admissionEntryTypes->isAdmissionQuotaEnabled? ",admission_entry_type = '$student->admissionEntryType'":"";
        $sql = "UPDATE studentaccount SET ";
        $sql .= !empty($student->studentAccount)? "studentAccount='$student->studentAccount'," : "";
        $sql .= !empty($student->rollNo)? "rollNo='$student->rollNo'," : "";
        $sql .= !empty($student->regNo)? "regNo='$student->regNo'," : "";
        $sql .= !empty($student->deptID)? "deptID='$student->deptID'," : "";
        $sql .= !empty($student->studentEmail)? "studentEmail='$student->studentEmail'," : "";
        $sql .= !empty($student->studentEmail2)? "studentEmail2='$student->studentEmail2'," : "";
        $sql .= !empty($student->studentGender)? "studentGender='$student->studentGender'," : "";
        $sql .= !empty($student->studentAddress)? "studentAddress='$student->studentAddress'," : "";
        $sql .= !empty($student->studentPhone)? "studentPhone='$student->studentPhone'," : "";
        $sql .= !empty($student->parentPhone)? "parentPhone='$student->parentPhone'," : "";
        $sql .= !empty($student->religion)? "religion=$student->religion," : "";
        $sql .= !empty($student->casteId)? "casteID=$student->casteId," : "";
        $sql .= !empty($student->category)? "category='$student->category'," : "";
        $sql .= !empty($student->bloodGroup)? "bloodGroup='$student->bloodGroup'," : "";
        $sql .= !empty($student->quotaId)? "quotaID = $student->quotaId," : "";
        $sql .= !empty($student->admissionType)? "admissionType='$student->admissionType'," : "";
        $sql .= !empty($student->lateral)? "lateral='$student->lateral'," : "";
        $sql .= !empty($student->nri)? "NRI='$student->nri'," : "";
        $sql .= !empty($student->studentSurname)? "studentSurname='$student->studentSurname'," : "";
        $sql .= !empty($student->studentFather)? "studentFather='$student->studentFather'," : "";
        $sql .= !empty($student->studentMother)? "studentMother='$student->studentMother'," : "";
        $sql .= !empty($student->studentJoindate)? "studentJoindate='$student->studentJoindate'," : "";
        $sql .= !empty($student->studentJoindate)? "admissionNo='$student->admissionNo'," : "";
        $sql .= "$updateexitType";
        $sql .= !empty($student->studentBirthday)? "studentBirthday='$student->studentBirthday'," : "";
        $sql .= !empty($student->nationalityId)? "nationality_id = $student->nationalityId," : "";
        $sql .= !empty($student->previousSchool)? "previousSchool =  '$student->previousSchool'," : "";
        $sql .= !empty($student->highestExamPassed)? "highestExamPassed =  '$student->highestExamPassed'," : "";
        $sql .= !empty($student->previousPassDate)? "prev_institute_dateofpassing =  '$student->previousPassDate'," : "";
        $sql .= !empty($student->prevRegNo)? "prev_institute_regiNo = '$student->prevRegNo'," : "";
        $sql .= !empty($student->stateId)? "state_id = $student->stateId," : "";
        $sql .= !empty($student->districtId)? "district_id = $student->districtId," : "";
        $sql .= !empty($student->talukId)? "taluk_id = $student->talukId," : "";
        $sql .= !empty($student->annualIncome)? "annualIncome = '$student->annualIncome'," : "";
        $sql .= !empty($student->aadharNo)? "aadhaar_no = '$student->aadharNo'," : "";
        $sql .= !empty($student->povertyLineId)? "poverty_line = $student->povertyLineId," : "";
        $sql .= !empty($student->campusTypeId)? "campus_type_id = $student->campusTypeId," : "";
        $sql .= !empty($student->secondLanguageId)? "secondlangaugeID = $student->secondLanguageId," : "";
        $sql .= !empty($student->secondLanguage2Id)? "secondlanguage2ID = $student->secondLanguage2Id," : "";
        $sql .= !empty($student->joiningSemId)? "joiningSemId = $student->joiningSemId," : "";
        $sql .= !empty($student->reservID)? "reservID = $student->reservID," : "";
        $sql .= !empty($student->studentReservationID)? "reservationID = $student->studentReservationID," : "";
        $sql .= !empty($student->phpTopicName)? "phdTopicName='$student->phpTopicName'," : "";
        $sql .= !empty($student->currentStatus)? "phdCurrentStatus='$student->currentStatus'," : "";
        $sql .= !empty($student->guideId)? "guideId=$student->guideId," : "";
        $sql .= !empty($student->parentAddress1)? "parentAddress1='$student->parentAddress1'," : "";
        $sql .= !empty($student->parentAddress2)? "parentAddress2='$student->parentAddress2'," : "";
        $sql .= !empty($student->parentCity)? "parentCity='$student->parentCity'," : "";
        $sql .= !empty($student->parentZipCode)? "parentZipCode='$student->parentZipCode'," : "";
        $sql .= !empty($student->parentCountry)? "parentCountry='$student->parentCountry', " : "";
        $sql .= !empty($student->parentState)? "parentState='$student->parentState'," : "";
        $sql .= !empty($student->applicationNo)? "applicationNo='$student->applicationNo'," : "";
        $sql .= !empty($student->domicileId)? "domicile_id=$student->domicileId," : "";
        $sql .= !empty($student->batchID)? "batchID='$student->batchID'" : "";
        $sql .= " WHERE studentID='$student->studentId'";
        try {
            $this->executeQuery($sql);
            if (!empty($student->customFields)) {
                $saveCustomFieldsRequest = new SaveAmsCustomFieldsValueRequest();
                $saveCustomFieldsRequest->entityId = $student->studentId;
                $saveCustomFieldsRequest->entity = AmsCustomFieldsEntities::STUDENT;
                $saveCustomFieldsRequest->fieldValues = $student->customFields;
                $saveCustomFieldsRequest->createdBy = $student->createdBy;
                $saveCustomFieldsRequest->updatedBy = $student->updatedBy;
                AmsCustomFieldsService::getInstance()->saveAmsCustomFieldValue($saveCustomFieldsRequest);
            }
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
        StudentService::getInstance()->updateStudentExtraFields($student);
        return true;
    }
 
}