quick minor path updates (#1968)
[openemr.git] / controllers / C_Pharmacy.class.php
blob666cf8d62c9b43f3cf91a3293b721c3242521113
1 <?php
2 /**
3 * C_Pharmacy class
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 class C_Pharmacy extends Controller
16 var $template_mod;
17 var $pharmacies;
19 function __construct($template_mod = "general")
21 parent::__construct();
22 $this->pharmacies = array();
23 $this->template_mod = $template_mod;
24 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . attr($_SERVER['QUERY_STRING']));
25 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&");
26 $this->assign("STYLE", $GLOBALS['style']);
27 $this->Pharmacy = new Pharmacy();
30 function default_action()
32 return $this->list_action();
35 function edit_action($id = "", $patient_id = "", $p_obj = null)
37 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
38 $this->pharmacies[0] = $p_obj;
39 } elseif (!is_object($this->pharmacies[0]) || get_class($this->pharmacies[0]) != "pharmacy") {
40 $this->pharmacies[0] = new Pharmacy($id);
43 if (!empty($patient_id)) {
44 $this->pharmacies[0]->set_patient_id($patient_id);
45 $this->pharmacies[0]->set_provider($this->pharmacies[0]->patient->get_provider());
48 $this->assign("pharmacy", $this->pharmacies[0]);
49 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_edit.html");
52 function list_action($sort = "")
55 if (!empty($sort)) {
56 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory("", $sort));
57 } else {
58 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory());
61 //print_r(Prescription::prescriptions_factory($id));
62 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
66 function edit_action_process()
68 if ($_POST['process'] != "true") {
69 return;
72 //print_r($_POST);
73 if (is_numeric($_POST['id'])) {
74 $this->pharmacies[0] = new Pharmacy($_POST['id']);
75 } else {
76 $this->pharmacies[0] = new Pharmacy();
79 parent::populate_object($this->pharmacies[0]);
80 //print_r($this->pharmacies[0]);
81 //echo $this->pharmacies[0]->toString(true);
82 $this->pharmacies[0]->persist();
83 //echo "action processeed";
84 $_POST['process'] = "";
85 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H