<?php
/**
 * Description of GrowthBidStartSetting
 *
 * @author user
 */
class GrowthBidStartSetting {
    public function getData() {
        $growthExpWay = new GrowthExpWay();
        //$data_info = $growthExpWay->findByType(1000);
        $growBidStart = new GrowthBidStart();
        $growLevelWayPermission = new GrowthLevelWayPermission();
        $growLevelPermission = new GrowthLevelPermission();
        $growLevel = new GrowthLevel();
        $arrBidStart = $growBidStart->findAllData();
        $arrFormatBidStart = array();
        if (CommonBase::isFullArray($arrBidStart)) {
            foreach($arrBidStart as $key => $value) {
                $arrFormatBidStart[$value['way_alias']] = $value['start_credit'];
            }
        }
        $data_info = $growLevelWayPermission->findAllByDisplay();
        if (CommonBase::isFullArray($data_info)) {
            foreach ($data_info as $key => &$value) {
                $startScore = 0;
                if (isset($arrFormatBidStart[$value['way_alias']])) {
                    $startScore = $arrFormatBidStart[$value['way_alias']];
                }  
                $arrLevel = $growLevelPermission->findByWayId($value['id'], 1);
                $strLevel = '';
				if ($arrLevel) {
					foreach($arrLevel as $k => $v) {
						$levelname = $growLevel->findLeveNameByLevelId($v['level_id']);
						$strLevel .= ',' . $levelname;
					}
				}
                $value['levelnames'] = ltrim($strLevel, ',');
                $value['start_credit'] = $startScore;
            }
        }
        return $data_info;
    }
}
