Newer
Older
use CRM_Generalobservation_ExtensionUtil as E;
class CRM_Generalobservation_Page_GenObservations extends CRM_Core_Page {
private $_currentData = [];
public function run() {
CRM_Utils_System::setTitle(E::ts('GenObservations'));
CRM_Core_Session::singleton()
->pushUserContext(CRM_Utils_System::url("civicrm/nbrbarcodeprint/form/general", "reset=1", TRUE));
$entityId = (int) CRM_Utils_Request::retrieveValue('cid', 'Integer');
$this->assign('entityId', $entityId);
$this->assign('editButton', $this->createEditButton($entityId));
$this->assign('deleteButton', $this->createDeleteButton($entityId));
$this->assign('contactObservations', $this->getUserGenObs($entityId));
$observationData = CRM_Generalobservation_BAO_GenObservations::getWithId($entityId);
$userObservation[] = $this->assembleObsRow($observationData);
// Move this to utils
public static function yesOrNo($value) {
if ($value !== NULL) {
$value = ($value) ? "Yes" : "No";
}
return $value;
}
// Convert to readable format, might not even need to change most
$observationTemplate['id'] = ($dao->id) ? $dao->id : "N/A";
$observationTemplate['entity_id'] = $dao->entity_id;
$observationTemplate['nvgo_weight_kg'] = ($dao->nvgo_weight_kg);
$observationTemplate['nvgo_height_m'] = $dao->nvgo_height_m;
$observationTemplate['nvgo_bmi'] = $dao->nvgo_bmi;
// Convert database values to be more readable
$observationTemplate['nvgo_hand_preference'] = CRM_Nihrbackbone_Utils::getOptionValueLabel($dao->nvgo_hand_preference, 'nbr_hand_preference');
$observationTemplate['nvgo_ethnicity_id'] = CRM_Nihrbackbone_Utils::getOptionValueLabel($dao->nvgo_ethnicity_id, 'nihr_ethnicity');
$observationTemplate['nvgo_abo_group'] = CRM_Nihrbackbone_Utils::getOptionValueLabel($dao->nvgo_abo_group, 'nbr_abo_group');
$observationTemplate['nvgo_rhesus_factor'] = CRM_Nihrbackbone_Utils::getOptionValueLabel($dao->nvgo_rhesus_factor, 'nbr_rhesus_factor');
$observationTemplate['nvgo_probably_consanguineous'] = $this->yesOrNo($dao->nvgo_probably_consanguineous);
$observationTemplate['nvgo_proband'] = ($dao->nvgo_proband) ? "Proband" : NULL;
$observationTemplate['nvgo_family_history'] = $this->yesOrNo($dao->nvgo_family_history);
$observationTemplate['show_on_portal_1015'] = $this->yesOrNo($dao->show_on_portal_1015);
protected function createEditButton($entityId) {
$updateUrl = CRM_Utils_System::url('civicrm/generalobservation/form/genobservations', 'reset=1&action=update&cid=' . $entityId, TRUE);
$editButton = '<a class="action-item button" title="Update" href="' . $updateUrl . '">' . E::ts('Edit general observations') . '</a>';
protected function createDeleteButton($entityId) {
$deleteUrl = CRM_Utils_System::url('civicrm/generalobservation/form/genobservations', 'reset=1&action=delete&cid=' . $entityId, TRUE);
$deleteButton = '<a class="action-item button" id="deleteBtn" entity_id="' . $entityId . '" title="Delete"">' . E::ts('Delete general observations') . '</a>';
return $deleteButton;
}