/**
  * Import CSV data to the system
  *
  * @param array data Array containing one row of CSV data
  */
 public function importCSVData($data)
 {
     $empinfo = new EmpInfo();
     $firstName = $this->_getField(CustomImport::FIELD_FIRSTNAME, $data);
     $lastName = $this->_getField(CustomImport::FIELD_LASTNAME, $data);
     if (empty($firstName) || empty($lastName)) {
         $compFields = implode(',', $this->customImport->getCompulsaryFields());
         throw new CSVImportException("Following fields are compulsary: " . $compFields, CSVImportException::COMPULSARY_FIELDS_MISSING_DATA);
     }
     $empinfo->setEmpFirstName($firstName);
     $empinfo->setEmpLastName($lastName);
     $middleName = $this->_getField(CustomImport::FIELD_MIDDLENAME, $data);
     $empinfo->setEmpMiddleName($middleName);
     $empId = $this->_getField(CustomImport::FIELD_EMPID, $data);
     if (empty($empId)) {
         $empId = $empinfo->getLastId();
     }
     // check for duplicate employee ID
     if ($empinfo->checkIfEmpIDInUse($empId)) {
         throw new CSVImportException("Employee ID is in use: {$empId}", CSVImportException::DUPLICATE_EMPLOYEE_ID);
     }
     $empinfo->setEmployeeID($empId);
     // Check for duplicate employee name
     if ($empinfo->checkForEmployeeWithSameName($lastName, $firstName, $middleName)) {
         throw new CSVImportException("Employee with same name exists: {$lastName}, {$firstName} {$middleName}", CSVImportException::DUPLICATE_EMPLOYEE_NAME);
     }
     $dobValue = $this->_getField(CustomImport::FIELD_BIRTHDATE, $data);
     $dob = self::_getFormattedDate($dobValue);
     if ($dob) {
         $empinfo->setEmpDOB($dob);
     }
     $custom1 = $this->_getField(CustomImport::FIELD_CUSTOM1, $data);
     if ($custom1) {
         $empinfo->setCustom1($custom1);
     }
     $custom2 = $this->_getField(CustomImport::FIELD_CUSTOM2, $data);
     if ($custom2) {
         $empinfo->setCustom1($custom2);
     }
     $custom3 = $this->_getField(CustomImport::FIELD_CUSTOM3, $data);
     if ($custom3) {
         $empinfo->setCustom1($custom3);
     }
     $custom4 = $this->_getField(CustomImport::FIELD_CUSTOM4, $data);
     if ($custom4) {
         $empinfo->setCustom1($custom4);
     }
     $custom5 = $this->_getField(CustomImport::FIELD_CUSTOM5, $data);
     if ($custom5) {
         $empinfo->setCustom1($custom5);
     }
     $custom6 = $this->_getField(CustomImport::FIELD_CUSTOM6, $data);
     if ($custom6) {
         $empinfo->setCustom1($custom6);
     }
     $custom7 = $this->_getField(CustomImport::FIELD_CUSTOM7, $data);
     if ($custom7) {
         $empinfo->setCustom1($custom7);
     }
     $custom8 = $this->_getField(CustomImport::FIELD_CUSTOM8, $data);
     if ($custom8) {
         $empinfo->setCustom1($custom8);
     }
     $custom9 = $this->_getField(CustomImport::FIELD_CUSTOM9, $data);
     if ($custom9) {
         $empinfo->setCustom1($custom9);
     }
     $custom10 = $this->_getField(CustomImport::FIELD_CUSTOM10, $data);
     if ($custom10) {
         $empinfo->setCustom1($custom10);
     }
     $joinedValue = $this->_getField(CustomImport::FIELD_JOINEDDATE, $data);
     $joined = self::_getFormattedDate($joinedValue);
     if ($joined) {
         $empinfo->setEmpJoinedDate($joined);
     }
     $genderValues = array(1 => "M", 2 => "F");
     $genderVal = $this->_getField(CustomImport::FIELD_GENDER, $data, false);
     if (!empty($genderVal)) {
         $gender = self::_getKeyFromMap($genderValues, $genderVal);
         if (empty($gender)) {
             throw new CSVImportException("Invalid value for gender: {$genderVal}", CSVImportException::INVALID_TYPE);
         }
         $empinfo->setEmpGender($gender);
     }
     $ssn = $this->_getField(CustomImport::FIELD_SSN, $data);
     if ($ssn) {
         $empinfo->setEmpSSNNo($ssn);
     }
     $street1 = $this->_getField(CustomImport::FIELD_STREET1, $data);
     if ($street1) {
         $empinfo->setEmpStreet1($street1);
     }
     $street2 = $this->_getField(CustomImport::FIELD_STREET2, $data);
     if ($street2) {
         $empinfo->setEmpStreet2($street2);
     }
     $city = $this->_getField(CustomImport::FIELD_CITY, $data);
     if ($city) {
         $empinfo->setEmpCity($city);
     }
     $state = $this->_getField(CustomImport::FIELD_STATE, $data);
     if ($state) {
         $empinfo->setEmpProvince($state);
     }
     $zipCode = $this->_getField(CustomImport::FIELD_ZIP, $data);
     if ($zipCode) {
         $empinfo->setEmpZipCode($zipCode);
     }
     $homePhone = $this->_getField(CustomImport::FIELD_HOME_PHONE, $data);
     if ($homePhone) {
         $empinfo->setEmpHomeTelephone($homePhone);
     }
     $mobile = $this->_getField(CustomImport::FIELD_MOBILE_PHONE, $data);
     if ($mobile) {
         $empinfo->setEmpMobile($mobile);
     }
     $workPhone = $this->_getField(CustomImport::FIELD_WORK_PHONE, $data);
     if ($workPhone) {
         $empinfo->setEmpWorkTelephone($workPhone);
     }
     $workEmail = $this->_getField(CustomImport::FIELD_WORK_EMAIL, $data);
     if ($workEmail) {
         $empinfo->setEmpWorkEmail($workEmail);
     }
     $otherEmail = $this->_getField(CustomImport::FIELD_OTHER_EMAIL, $data);
     if ($otherEmail) {
         $empinfo->setEmpOtherEmail($otherEmail);
     }
     $drivingLicence = $this->_getField(CustomImport::FIELD_DRIVING_LIC, $data);
     if ($drivingLicence) {
         $empinfo->setEmpDriLicNo($drivingLicence);
     }
     $workStation = $this->_getField(CustomImport::FIELD_WORKSTATION, $data);
     if (!empty($workStation)) {
         $workStationID = $this->_getCompStructure($workStation);
         $empinfo->setEmpLocation($workStationID);
     } else {
         $empinfo->setEmpLocation('');
     }
     // First direct debit account
     $routing = $this->_getField(CustomImport::FIELD_DD1ROUTING, $data);
     $account = $this->_getField(CustomImport::FIELD_DD1ACCOUNT, $data);
     $amount = $this->_getField(CustomImport::FIELD_DD1AMOUNT, $data);
     $accountType = $this->_getField(CustomImport::FIELD_DD1CHECKING, $data, false);
     $transactionType = $this->_getField(CustomImport::FIELD_DD1AMOUNTCODE, $data, false);
     $dd1 = $this->_getDirectDeposit($routing, $account, $amount, $accountType, $transactionType);
     // Second direct debit account
     $routing = $this->_getField(CustomImport::FIELD_DD2ROUTING, $data);
     $account = $this->_getField(CustomImport::FIELD_DD2ACCOUNT, $data);
     $amount = $this->_getField(CustomImport::FIELD_DD2AMOUNT, $data);
     $accountType = $this->_getField(CustomImport::FIELD_DD2CHECKING, $data, false);
     $transactionType = $this->_getField(CustomImport::FIELD_DD2AMOUNTCODE, $data, false);
     $dd2 = $this->_getDirectDeposit($routing, $account, $amount, $accountType, $transactionType);
     // Employee Tax information
     $federalTaxStatus = $this->_getField(CustomImport::FIELD_FITWSTATUS, $data);
     $fedEx = $this->_getField(CustomImport::FIELD_FITWEXCEMPTIONS, $data);
     $taxState = $this->_getField(CustomImport::FIELD_SITWSTATE, $data, false);
     $stateTaxStatus = $this->_getField(CustomImport::FIELD_SITWSTATUS, $data);
     $stateEx = $this->_getField(CustomImport::FIELD_SITWEXCEMPTIONS, $data);
     $unemploymentState = $this->_getField(CustomImport::FIELD_SUISTATE, $data, false);
     $workState = $this->_getField(CustomImport::FIELD_WORKSTATE, $data, false);
     $taxInfo = $this->_getTaxInfo($federalTaxStatus, $fedEx, $taxState, $stateTaxStatus, $stateEx, $unemploymentState, $workState);
     $result = $empinfo->addEmpMain();
     if (!$result) {
         throw new CSVImportException("Error inserting employee", CSVImportException::UNKNOWN_ERROR);
     }
     $empNumber = $empinfo->getEmpId();
     $empinfo->setEmpEthnicRace(0);
     $empinfo->setEmpNation(0);
     $result = $empinfo->updateEmpPers();
     if (!$result) {
         throw new CSVImportException("Error inserting personal info", CSVImportException::UNKNOWN_ERROR);
     }
     $result = $empinfo->updateEmpContact();
     if (!$result) {
         throw new CSVImportException("Error inserting contact details", CSVImportException::UNKNOWN_ERROR);
     }
     $empinfo->setEmpStatus('0');
     $empinfo->setEmpJobTitle('0');
     $empinfo->setEmpEEOCat('0');
     $result = $empinfo->updateEmpJobInfo();
     if (!$result) {
         throw new CSVImportException("Error inserting job details", CSVImportException::UNKNOWN_ERROR);
     }
     // Save tax information
     if (!empty($taxInfo)) {
         $taxInfo->setEmpNumber($empNumber);
         $taxInfo->updateEmpTax();
     }
     // Save Direct Debit information
     if (!empty($dd1)) {
         $dd1->setEmpNumber($empNumber);
         $dd1->add();
     }
     if (!empty($dd2)) {
         $dd2->setEmpNumber($empNumber);
         $dd2->add();
     }
     return $empNumber;
 }