added datepicker to immunization gui
[openemr.git] / controllers / C_Pharmacy.class.php
bloba5c18bb1353ab257cc58ce4c4db343577dd913e5
1 <?php
4 class C_Pharmacy extends Controller {
6 var $template_mod;
7 var $pharmacies;
9 function __construct($template_mod = "general") {
10 parent::__construct();
11 $this->pharmacies = array();
12 $this->template_mod = $template_mod;
13 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
14 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&");
15 $this->assign("STYLE", $GLOBALS['style']);
16 $this->assign("WEB_ROOT", $GLOBALS['webroot'] );
17 $this->Pharmacy = new Pharmacy();
20 function default_action() {
21 return $this->list_action();
24 function edit_action($id = "",$patient_id="",$p_obj = null) {
25 if ($p_obj != null && get_class($p_obj) == "pharmacy") {
26 $this->pharmacies[0] = $p_obj;
28 elseif (get_class($this->pharmacies[0]) != "pharmacy" ) {
29 $this->pharmacies[0] = new Pharmacy($id);
32 if (!empty($patient_id)) {
33 $this->pharmacies[0]->set_patient_id($patient_id);
34 $this->pharmacies[0]->set_provider($this->pharmacies[0]->patient->get_provider());
36 $this->assign("pharmacy", $this->pharmacies[0]);
37 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_edit.html");
40 function list_action($sort = "") {
42 if (!empty($sort)) {
43 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory("",$sort));
45 else {
46 $this->assign("pharmacies", $this->Pharmacy->pharmacies_factory());
48 //print_r(Prescription::prescriptions_factory($id));
49 return $this->fetch($GLOBALS['template_dir'] . "pharmacies/" . $this->template_mod . "_list.html");
53 function edit_action_process() {
54 if ($_POST['process'] != "true")
55 return;
56 //print_r($_POST);
57 if (is_numeric($_POST['id'])) {
58 $this->pharmacies[0] = new Pharmacy($_POST['id']);
60 else {
61 $this->pharmacies[0] = new Pharmacy();
63 parent::populate_object($this->pharmacies[0]);
64 //print_r($this->pharmacies[0]);
65 //echo $this->pharmacies[0]->toString(true);
66 $this->pharmacies[0]->persist();
67 //echo "action processeed";
68 $_POST['process'] = "";
69 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&pharmacy&action=list");//Z&H