/** * * @param string $modelName Hopefully unique model name * @param string $modelField The name of the field used to store the sub model */ public function __construct($modelName = 'fields_maintenance', $modelField = 'sub') { parent::__construct($modelName, $modelField); $modelF = new \MUtil_Model_TableModel('gems__respondent2track2field'); \Gems_Model::setChangeFieldsByPrefix($modelF, 'gr2t2f'); $this->addUnionModel($modelF, null, FieldMaintenanceModel::FIELDS_NAME); $modelA = new \MUtil_Model_TableModel('gems__respondent2track2appointment'); \Gems_Model::setChangeFieldsByPrefix($modelA, 'gr2t2a'); $mapBase = $modelA->getItemsOrdered(); $map = array_combine($mapBase, str_replace('gr2t2a_', 'gr2t2f_', $mapBase)); $map['gr2t2a_id_app_field'] = 'gr2t2f_id_field'; $map['gr2t2a_id_appointment'] = 'gr2t2f_value'; $this->addUnionModel($modelA, $map, FieldMaintenanceModel::APPOINTMENTS_NAME); }
/** * * @param string $modelName Hopefully unique model name * @param string $modelField The name of the field used to store the sub model */ public function __construct($modelName = 'fields_maintenance', $modelField = 'sub') { parent::__construct($modelName, $modelField); $model = new \MUtil_Model_TableModel('gems__track_fields'); \Gems_Model::setChangeFieldsByPrefix($model, 'gtf'); $this->addUnionModel($model, null, self::FIELDS_NAME); $model = new \MUtil_Model_TableModel('gems__track_appointments'); \Gems_Model::setChangeFieldsByPrefix($model, 'gtap'); $map = $model->getItemsOrdered(); $map = array_combine($map, str_replace('gtap_', 'gtf_', $map)); $map['gtap_id_app_field'] = 'gtf_id_field'; $this->addUnionModel($model, $map, self::APPOINTMENTS_NAME); $model->addColumn(new \Zend_Db_Expr("'appointment'"), 'gtf_field_type'); $model->addColumn(new \Zend_Db_Expr("NULL"), 'gtf_field_values'); $model->addColumn(new \Zend_Db_Expr("NULL"), 'gtf_calculate_using'); $this->setKeys(array(\Gems_Model::FIELD_ID => 'gtf_id_field', \MUtil_Model::REQUEST_ID => 'gtf_id_track')); $this->setClearableKeys(array(\Gems_Model::FIELD_ID => 'gtf_id_field')); $this->setSort(array('gtf_id_order' => SORT_ASC)); }