3 require_once ($GLOBALS['fileroot'] . "/library/classes/Controller.class.php");
4 require_once($GLOBALS['fileroot'] ."/library/classes/Pharmacy.class.php");
6 class C_Pharmacy
extends Controller
{
11 function __construct($template_mod = "general") {
12 parent
::__construct();
13 $this->pharmacies
= array();
14 $this->template_mod
= $template_mod;
15 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
16 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&");
17 $this->assign("STYLE", $GLOBALS['style']);
18 $this->assign("WEB_ROOT", $GLOBALS['webroot'] );
19 $this->Pharmacy
= new Pharmacy();
22 function default_action() {
23 return $this->list_action();
26 function edit_action($id = "",$patient_id="",$p_obj = null) {
27 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
28 $this->pharmacies
[0] = $p_obj;
30 elseif (get_class($this->pharmacies
[0]) != "pharmacy" ) {
31 $this->pharmacies
[0] = new Pharmacy($id);
34 if (!empty($patient_id)) {
35 $this->pharmacies
[0]->set_patient_id($patient_id);
36 $this->pharmacies
[0]->set_provider($this->pharmacies
[0]->patient
->get_provider());
38 $this->assign("pharmacy", $this->pharmacies
[0]);
39 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod
. "_edit.html");
42 function list_action($sort = "") {
45 $this->assign("pharmacies", $this->Pharmacy
->pharmacies_factory("",$sort));
48 $this->assign("pharmacies", $this->Pharmacy
->pharmacies_factory());
50 //print_r(Prescription::prescriptions_factory($id));
51 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod
. "_list.html");
55 function edit_action_process() {
56 if ($_POST['process'] != "true")
59 if (is_numeric($_POST['id'])) {
60 $this->pharmacies
[0] = new Pharmacy($_POST['id']);
63 $this->pharmacies
[0] = new Pharmacy();
65 parent
::populate_object($this->pharmacies
[0]);
66 //print_r($this->pharmacies[0]);
67 //echo $this->pharmacies[0]->toString(true);
68 $this->pharmacies
[0]->persist();
69 //echo "action processeed";
70 $_POST['process'] = "";
71 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H