Improved Code Sniffing (#928)
[openemr.git] / controllers / C_Pharmacy.class.php
blob793fd16a61fffa7d959bb63298d622ec00b42330
1 <?php
4 class C_Pharmacy extends Controller {
6 var $template_mod;
7 var $pharmacies;
9 function __construct($template_mod = "general")
11 parent::__construct();
12 $this->pharmacies = array();
13 $this->template_mod = $template_mod;
14 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
15 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&");
16 $this->assign("STYLE", $GLOBALS['style']);
17 $this->assign("WEB_ROOT", $GLOBALS['webroot'] );
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;
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());
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));
49 else {
50 $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;
61 //print_r($_POST);
62 if (is_numeric($_POST['id'])) {
63 $this->pharmacies[0] = new Pharmacy($_POST['id']);
65 else {
66 $this->pharmacies[0] = new Pharmacy();
68 parent::populate_object($this->pharmacies[0]);
69 //print_r($this->pharmacies[0]);
70 //echo $this->pharmacies[0]->toString(true);
71 $this->pharmacies[0]->persist();
72 //echo "action processeed";
73 $_POST['process'] = "";
74 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H