4 class C_Pharmacy
extends Controller
10 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()
24 return $this->list_action();
27 function edit_action($id = "", $patient_id = "", $p_obj = null)
29 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
30 $this->pharmacies
[0] = $p_obj;
31 } elseif (get_class($this->pharmacies
[0]) != "pharmacy") {
32 $this->pharmacies
[0] = new Pharmacy($id);
35 if (!empty($patient_id)) {
36 $this->pharmacies
[0]->set_patient_id($patient_id);
37 $this->pharmacies
[0]->set_provider($this->pharmacies
[0]->patient
->get_provider());
40 $this->assign("pharmacy", $this->pharmacies
[0]);
41 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod
. "_edit.html");
44 function list_action($sort = "")
48 $this->assign("pharmacies", $this->Pharmacy
->pharmacies_factory("", $sort));
50 $this->assign("pharmacies", $this->Pharmacy
->pharmacies_factory());
53 //print_r(Prescription::prescriptions_factory($id));
54 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod
. "_list.html");
58 function edit_action_process()
60 if ($_POST['process'] != "true") {
65 if (is_numeric($_POST['id'])) {
66 $this->pharmacies
[0] = new Pharmacy($_POST['id']);
68 $this->pharmacies
[0] = new Pharmacy();
71 parent
::populate_object($this->pharmacies
[0]);
72 //print_r($this->pharmacies[0]);
73 //echo $this->pharmacies[0]->toString(true);
74 $this->pharmacies
[0]->persist();
75 //echo "action processeed";
76 $_POST['process'] = "";
77 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H