Merge branch 'master' of https://github.com/openemr/openemr into signer-templates
[openemr.git] / controllers / C_InsuranceCompany.class.php
blob400569a12212e2174c6a5b6c3515cced2ff950c0
1 <?php
4 class C_InsuranceCompany extends Controller
7 var $template_mod;
8 var $icompanies;
10 function __construct($template_mod = "general")
12 parent::__construct();
13 $this->icompanies = array();
14 $this->template_mod = $template_mod;
15 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . attr($_SERVER['QUERY_STRING']));
16 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_company&");
17 $this->assign("STYLE", $GLOBALS['style']);
18 $this->assign("SUPPORT_ENCOUNTER_CLAIMS", $GLOBALS['support_encounter_claims']);
19 $this->assign("SUPPORT_ELIGIBILITY_REQUESTS", $GLOBALS['enable_oa']);
20 $this->InsuranceCompany = new InsuranceCompany();
23 function default_action()
25 return $this->list_action();
28 function edit_action($id = "", $patient_id = "", $p_obj = null)
30 if ($p_obj != null && get_class($p_obj) == "insurancecompany") {
31 $this->icompanies[0] = $p_obj;
32 } elseif (get_class($this->icompanies[0]) != "insurancecompany") {
33 $this->icompanies[0] = new InsuranceCompany($id);
36 $x = new X12Partner();
37 $this->assign("x12_partners", $x->_utility_array($x->x12_partner_factory()));
39 $this->assign("insurancecompany", $this->icompanies[0]);
40 return $this->fetch($GLOBALS['template_dir'] . "insurance_companies/" . $this->template_mod . "_edit.html");
43 function list_action($sort = "")
46 if (!empty($sort)) {
47 $this->assign("icompanies", $this->InsuranceCompany->insurance_companies_factory("", $sort));
48 } else {
49 $this->assign("icompanies", $this->InsuranceCompany->insurance_companies_factory());
52 return $this->fetch($GLOBALS['template_dir'] . "insurance_companies/" . $this->template_mod . "_list.html");
56 function edit_action_process()
58 if ($_POST['process'] != "true") {
59 return;
62 //print_r($_POST);
63 if (is_numeric($_POST['id'])) {
64 $this->icompanies[0] = new InsuranceCompany($_POST['id']);
65 } else {
66 $this->icompanies[0] = new InsuranceCompany();
69 parent::populate_object($this->icompanies[0]);
71 $this->icompanies[0]->persist();
72 $this->icompanies[0]->populate();
74 //echo "action processeed";
75 $_POST['process'] = "";
76 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_company&action=list");//Z&H