From 3c9d03d2f72668703b7d1f6f4a51f4b8be3d0f95 Mon Sep 17 00:00:00 2001 From: cfapress Date: Wed, 22 Jul 2009 17:57:37 +0000 Subject: [PATCH] fix to display the four-panel link in the prescription list only when CAMOS is installed --- controllers/C_Prescription.class.php | 8 +++++-- library/registry.inc | 36 ++++++++++++++++++++++++++++++++ templates/prescription/general_list.html | 2 ++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/controllers/C_Prescription.class.php b/controllers/C_Prescription.class.php index 2239ddbe1..fc1ee39c3 100644 --- a/controllers/C_Prescription.class.php +++ b/controllers/C_Prescription.class.php @@ -4,6 +4,7 @@ require_once($GLOBALS['fileroot'] . "/library/classes/Controller.class.php"); require_once($GLOBALS['fileroot'] . "/library/classes/Prescription.class.php"); require_once($GLOBALS['fileroot'] . "/library/classes/Provider.class.php"); require_once($GLOBALS['fileroot'] . "/library/classes/RXList.class.php"); +require_once($GLOBALS['fileroot'] . "/library/registry.inc"); class C_Prescription extends Controller { @@ -103,8 +104,11 @@ class C_Prescription extends Controller { else { $this->assign("prescriptions", Prescription::prescriptions_factory($id)); } - //print_r(Prescription::prescriptions_factory($id)); - $this->display($GLOBALS['template_dir'] . "prescription/" . $this->template_mod . "_list.html"); + + // flag to indicate the CAMOS form is regsitered and active + $this->assign("CAMOS_FORM", isRegistered(getIdByDirectory("CAMOS"))); + + $this->display($GLOBALS['template_dir'] . "prescription/" . $this->template_mod . "_list.html"); } function block_action($id,$sort = "") { diff --git a/library/registry.inc b/library/registry.inc index 2218da06d..037df0705 100644 --- a/library/registry.inc +++ b/library/registry.inc @@ -76,4 +76,40 @@ function installSQL ( $dir ) }else return false; } + + +/* + * is a form registered + * (optional - and active) + * in the database? + * + * INPUT = id => form ID + * state => 0=inactive / 1=active + * OUTPUT = true or false + */ +function isRegistered ( $id, $state = 1) +{ + $sql = "select id from registry where ". + "id=".$id. + " and state=".$state; + $result = sqlQuery($sql); + if ($result['id'] != '') return true; + return false; +} + + +/* + * given a form directory return the unique ID + * for the associated form + * NOTE - sometimes the Name of a form has a line-break at the end, thus this function might be better + */ +function getIdByDirectory ( $directory ) +{ + $sql = "select id from registry where ". + " directory = '".$directory."'"; + $result = sqlQuery($sql); + if ($result['id'] != '') return $result['id']; + return null; +} + ?> diff --git a/templates/prescription/general_list.html b/templates/prescription/general_list.html index 26361cff4..02dab854d 100644 --- a/templates/prescription/general_list.html +++ b/templates/prescription/general_list.html @@ -37,8 +37,10 @@ function changeLinkHref(id,addValue,value) { Print Multiple
Print Multiple To Fax +{if $CAMOS_FORM == true}
Print Four Panel +{/if} -- 2.11.4.GIT