Esempio n. 1
0
 public function createDepartmentsReportFinalArray($dataArray, $columnArray)
 {
     $businessunitArray = array();
     $cityArray = array();
     $stateArray = array();
     $countryArray = array();
     if (!empty($dataArray)) {
         foreach ($dataArray as $key => $curr) {
             if (isset($curr['unitid'])) {
                 if (!in_array($curr['unitid'], $businessunitArray)) {
                     array_push($businessunitArray, $curr['unitid']);
                 }
             }
             if (isset($curr['city'])) {
                 if (!in_array($curr['city'], $cityArray)) {
                     array_push($cityArray, $curr['city']);
                 }
             }
             if (isset($curr['state'])) {
                 if (!in_array($curr['state'], $stateArray)) {
                     array_push($stateArray, $curr['state']);
                 }
             }
             if (isset($curr['country'])) {
                 if (!in_array($curr['country'], $countryArray)) {
                     array_push($countryArray, $curr['country']);
                 }
             }
         }
     }
     if (!empty($businessunitArray)) {
         $businessunitModel = new Default_Model_Businessunits();
         $businessNameArray = $businessunitModel->getBusinessunitNamesByIds($businessunitArray);
     }
     if (!empty($cityArray)) {
         $cityModel = new Default_Model_Cities();
         $cityNameArray = $cityModel->getCityNamesByIds($cityArray);
     }
     if (!empty($stateArray)) {
         $stateModel = new Default_Model_States();
         $stateNameArray = $stateModel->getStateNamesByIds($stateArray);
     }
     if (!empty($countryArray)) {
         $countryModel = new Default_Model_Countries();
         $countryNameArray = $countryModel->getCountryNamesByIds($countryArray);
     }
     $finalArray = array();
     if (!empty($dataArray)) {
         foreach ($dataArray as $key => $curr) {
             $finalArray[$key]['id'] = $curr['id'];
             if (in_array("deptname", $columnArray)) {
                 $finalArray[$key]['deptname'] = $curr['deptname'];
             }
             if (in_array("unitname", $columnArray)) {
                 $finalArray[$key]['unitname'] = isset($businessNameArray[$curr['unitid']]) ? $businessNameArray[$curr['unitid']] : '';
             }
             if (in_array("deptcode", $columnArray)) {
                 $finalArray[$key]['deptcode'] = $curr['deptcode'];
             }
             if (in_array("empcount", $columnArray)) {
                 $finalArray[$key]['empcount'] = $curr['empcount'];
             }
             if (in_array("startdate", $columnArray)) {
                 $finalArray[$key]['startdate'] = $curr['startdate'];
             }
             if (in_array("address", $columnArray)) {
                 $finalArray[$key]['address1'] = $curr['address1'];
                 $finalArray[$key]['address'] = $curr['address1'];
             }
             if (in_array("ccity", $columnArray)) {
                 $finalArray[$key]['ccity'] = isset($cityNameArray[$curr['city']]) ? $cityNameArray[$curr['city']] : '';
             }
             if (in_array("sstate", $columnArray)) {
                 $finalArray[$key]['sstate'] = isset($stateNameArray[$curr['state']]) ? $stateNameArray[$curr['state']] : '';
             }
             if (in_array("ccountry", $columnArray)) {
                 $finalArray[$key]['ccountry'] = isset($countryNameArray[$curr['country']]) ? $countryNameArray[$curr['country']] : '';
             }
             if (in_array("status", $columnArray)) {
                 $finalArray[$key]['status'] = $curr['status'];
             }
         }
     }
     return $finalArray;
 }