fix auto create of group's encounters and warning message
[openemr.git] / controllers / C_Pharmacy.class.php
blob588b4c757d415e661d0159a81b4f0cdf3d5f1e02
1 <?php
4 class C_Pharmacy extends Controller
7 var $template_mod;
8 var $pharmacies;
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?" . attr($_SERVER['QUERY_STRING']));
16 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&");
17 $this->assign("STYLE", $GLOBALS['style']);
18 $this->Pharmacy = new Pharmacy();
21 function default_action()
23 return $this->list_action();
26 function edit_action($id = "", $patient_id = "", $p_obj = null)
28 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
29 $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());
39 $this->assign("pharmacy", $this->pharmacies[0]);
40 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_edit.html");
43 function list_action($sort = "")
46 if (!empty($sort)) {
47 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory("", $sort));
48 } else {
49 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory());
52 //print_r(Prescription::prescriptions_factory($id));
53 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
57 function edit_action_process()
59 if ($_POST['process'] != "true") {
60 return;
63 //print_r($_POST);
64 if (is_numeric($_POST['id'])) {
65 $this->pharmacies[0] = new Pharmacy($_POST['id']);
66 } else {
67 $this->pharmacies[0] = new Pharmacy();
70 parent::populate_object($this->pharmacies[0]);
71 //print_r($this->pharmacies[0]);
72 //echo $this->pharmacies[0]->toString(true);
73 $this->pharmacies[0]->persist();
74 //echo "action processeed";
75 $_POST['process'] = "";
76 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H