Fix for days translation
[openemr.git] / controllers / C_Pharmacy.class.php
blob9528802d3340187116019394d310f41e75034382
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']);
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", Pharmacy::pharmacies_factory("",$sort));
45 else {
46 $this->assign("pharmacies", 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'] = "";