7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 class C_Pharmacy
extends Controller
22 function __construct($template_mod = "general")
24 parent
::__construct();
25 $this->pharmacies
= array();
26 $this->template_mod
= $template_mod;
27 $this->assign("FORM_ACTION", $GLOBALS['webroot'] . "/controller.php?" . attr($_SERVER['QUERY_STRING']));
28 $this->assign("CURRENT_ACTION", $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&pharmacy&");
29 $this->assign("STYLE", $GLOBALS['style']);
30 $this->Pharmacy
= new Pharmacy();
31 $this->totalpages
= $this->Pharmacy
->totalPages();
32 $this->pageno
= $this->Pharmacy
->getPageno();
35 function default_action()
37 return $this->list_action();
40 function edit_action($id = "", $patient_id = "", $p_obj = null)
42 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
43 $this->pharmacies
[0] = $p_obj;
44 } elseif (empty($this->pharmacies
[0]) ||
!is_object($this->pharmacies
[0]) ||
get_class($this->pharmacies
[0]) != "pharmacy") {
45 $this->pharmacies
[0] = new Pharmacy($id);
48 if (!empty($patient_id)) {
49 $this->pharmacies
[0]->set_patient_id($patient_id);
50 $this->pharmacies
[0]->set_provider($this->pharmacies
[0]->patient
->get_provider());
53 $this->assign("pharmacy", $this->pharmacies
[0]);
54 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod
. "_edit.html");
57 function list_action($sort = "")
61 $this->assign("pharmacies", $this->Pharmacy
->pharmacies_factory("", $sort));
63 $this->assign("pharmacies", $this->Pharmacy
->pharmacies_factory());
66 //print_r(Prescription::prescriptions_factory($id));
67 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod
. "_list.html");
71 function edit_action_process()
73 if ($_POST['process'] != "true") {
78 if (is_numeric($_POST['id'])) {
79 $this->pharmacies
[0] = new Pharmacy($_POST['id']);
81 $this->pharmacies
[0] = new Pharmacy();
84 parent
::populate_object($this->pharmacies
[0]);
85 //print_r($this->pharmacies[0]);
86 //echo $this->pharmacies[0]->toString(true);
87 $this->pharmacies
[0]->persist();
88 //echo "action processeed";
89 $_POST['process'] = "";
90 header('Location:' . $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H