public function processEditByFieldAction() { $personId = (int) $this->_getParam("personId"); $type = $this->_getParam("type"); $id = (int) $this->_getParam("id"); $field = $this->_getParam("field"); $value = $this->_getParam("value"); $obj = null; switch ($type) { case 'address': $obj = new Address(); $obj->person_id = $personId; break; case 'phone': $obj = new PhoneNumber(); $obj->person_id = $personId; break; case 'note': $obj = new PatientNote(); $obj->patient_id = $personId; if ($id === 0) { // defaults for new note $obj->note_date = date('Y-m-d H:i:s'); $obj->user_id = (int) Zend_Auth::getInstance()->getIdentity()->personId; $obj->priority = 5; $obj->active = 1; } break; default: break; } $retVal = false; if ($obj !== null && in_array($field, $obj->ormFields())) { if ($id > 0) { foreach ($obj->_primaryKeys as $k) { $obj->{$k} = $id; } $obj->populate(); } $obj->{$field} = $value; $obj->persist(); $retVal = true; } if ($retVal) { $data = true; } else { $data = array('error' => __('There was an error attempting to update the selected record.')); } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function processEditByFieldAction() { $personId = (int) $this->_getParam("personId"); $field = $this->_getParam('field'); $value = $this->_getParam('value'); $id = (int) $this->_getParam('id'); $orm = $this->_getParam('orm'); $obj = null; switch ($orm) { case 'patientNote': $obj = new PatientNote(); $obj->patient_id = $personId; if ($id > 0) { $obj->patientNoteId = $id; $obj->populate(); } else { // defaults for new note $obj->note_date = date('Y-m-d H:i:s'); $obj->user_id = (int) Zend_Auth::getInstance()->getIdentity()->personId; $obj->priority = 5; $obj->active = 1; if ($field != 'note') { $obj->note = 'blank'; } } break; } $retVal = false; if ($obj !== null && in_array($field, $obj->ormFields())) { $obj->{$field} = $value; $obj->persist(); $retVal = true; } if ($retVal) { $data = true; } else { $data = array('error' => __('There was an error attempting to update the selected record.')); } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }