public function listJsAction() { //$unitTypeDAO = new RM_UnitTypes(); //$unitType = $unitTypeDAO->find($this->_defaultUnitType)->current(); $fieldsDAO = new RM_UnitConfig(); //$configFields = $fieldsDAO->getAdminList($unitType->id)->toArray(); $configFields = $fieldsDAO->fetchAll()->toArray(); foreach ($configFields as $key => $configField) { if ($configField['admin_list_preferences'] !== '') { $metainfo[] = $configField['admin_list_preferences']; } } // unit types translation from numbers to text $rmUnitTypes = new RM_UnitTypes(); $language = RM_Environment::getInstance()->getLocale(); $unittypes = $rmUnitTypes->getAll(); $type = array(); foreach ($unittypes as $unittype) { $type[$unittype->id] = $unittype->{$language}; } $type = Zend_Json::encode($type); $retVar = "RM.Common.Units_List_Setup([" . implode(',', $metainfo) . "]);"; $retVar .= "RM.Common.Units_Types_Translation = " . $type . ";"; return $retVar; }
public function configJsonAction() { $rmUnitTypes = new RM_UnitTypes(); $language = RM_Environment::getInstance()->getLocale(); $unittypes = $rmUnitTypes->getAll(); $type = array(); foreach ($unittypes as $unittype) { $type[] = array('id' => $unittype->id, 'name' => $unittype->{$language}, 'price' => $unittype->price); } $json = new stdClass(); $json->unitTypes = $type; $systems = RM_Prices_Manager::getAllPriceSystems(); $json->systems = array(); foreach ($systems as $system) { $json->systems[] = array('value' => $system->name, 'text' => $system->getName(RM_Environment::getInstance()->getLocale())); } $module = new RM_Module_UnitTypeManager(); $defaultUnitType = $module->getDefaultUnitType(); $json->defaultUnitType = $defaultUnitType->id; return array('data' => $json, 'encoded' => false); }