improvements to test suite to allow it to run from a clean repository
[openemr.git] / controllers / C_Pharmacy.class.php
blob69d2d62085fb959ee7220fbcb8bd1a93b51e4581
1 <?php
3 require_once ($GLOBALS['fileroot'] . "/library/classes/Controller.class.php");
4 require_once($GLOBALS['fileroot'] ."/library/classes/Pharmacy.class.php");
6 class C_Pharmacy extends Controller {
8 var $template_mod;
9 var $pharmacies;
11 function C_Pharmacy($template_mod = "general") {
12 parent::Controller();
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'] );
21 function default_action() {
22 return $this->list_action();
25 function edit_action($id = "",$patient_id="",$p_obj = null) {
26 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
27 $this->pharmacies[0] = $p_obj;
29 elseif (get_class($this->pharmacies[0]) != "pharmacy" ) {
30 $this->pharmacies[0] = new Pharmacy($id);
33 if (!empty($patient_id)) {
34 $this->pharmacies[0]->set_patient_id($patient_id);
35 $this->pharmacies[0]->set_provider($this->pharmacies[0]->patient->get_provider());
37 $this->assign("pharmacy", $this->pharmacies[0]);
38 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_edit.html");
41 function list_action($sort = "") {
43 if (!empty($sort)) {
44 $this->assign("pharmacies", Pharmacy::pharmacies_factory("",$sort));
46 else {
47 $this->assign("pharmacies", Pharmacy::pharmacies_factory());
49 //print_r(Prescription::prescriptions_factory($id));
50 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
54 function edit_action_process() {
55 if ($_POST['process'] != "true")
56 return;
57 //print_r($_POST);
58 if (is_numeric($_POST['id'])) {
59 $this->pharmacies[0] = new Pharmacy($_POST['id']);
61 else {
62 $this->pharmacies[0] = new Pharmacy();
64 parent::populate_object($this->pharmacies[0]);
65 //print_r($this->pharmacies[0]);
66 //echo $this->pharmacies[0]->toString(true);
67 $this->pharmacies[0]->persist();
68 //echo "action processeed";
69 $_POST['process'] = "";