improved prior 8.2 fix
[openemr.git] / controllers / C_X12Partner.class.php
blob9f0eaea9ee4932755161b5daf1d0320cd867bc2a
1 <?php
3 /**
4 * controller class for x-12 partner screen
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Ken Chapple <ken@mi-squared.com>
9 * @author Daniel Pflieger <daniel@mi-squared.com>, <daniel@growlingflea.com>
10 * @copyright Copyright (c) 2021 Ken Chapple <ken@mi-squared.com>
11 * @copyright Copyright (c) 2021 Daniel Pflieger <daniel@mi-squared.com>, <daniel@growlingflea.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 use OpenEMR\Common\Crypto\CryptoGen;
17 class C_X12Partner extends Controller
20 var $template_mod;
21 var $providers;
22 var $x12_partners;
24 function __construct($template_mod = "general")
26 parent::__construct();
27 $this->x12_partners = array();
28 $this->template_mod = $template_mod;
29 $this->assign("FORM_ACTION", $GLOBALS['webroot'] . "/controller.php?" . attr($_SERVER['QUERY_STRING']));
30 $this->assign("CURRENT_ACTION", $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&x12_partner&");
31 $this->assign("STYLE", $GLOBALS['style']);
34 function default_action()
36 return $this->list_action();
39 function edit_action($id = "", $x_obj = null)
41 if ($x_obj != null && get_class($x_obj) == "x12partner") {
42 $this->x12_partners[0] = $x_obj;
43 } elseif (is_numeric($id)) {
44 $this->x12_partners[0] = new X12Partner($id);
45 } else {
46 $this->x12_partners[0] = new X12Partner();
49 // If we have an SFTP password set, decrypt it
50 if ($this->x12_partners[0]->get_x12_sftp_pass()) {
51 $cryptoGen = new CryptoGen();
52 $this->x12_partners[0]->set_x12_sftp_pass($cryptoGen->decryptStandard($this->x12_partners[0]->get_x12_sftp_pass()));
55 $this->assign("partner", $this->x12_partners[0]);
56 return $this->fetch($GLOBALS['template_dir'] . "x12_partners/" . $this->template_mod . "_edit.html");
59 function list_action()
62 $x = new X12Partner();
63 $this->assign("partners", $x->x12_partner_factory());
64 return $this->fetch($GLOBALS['template_dir'] . "x12_partners/" . $this->template_mod . "_list.html");
68 function edit_action_process()
70 if ($_POST['process'] != "true") {
71 return;
74 //print_r($_POST);
75 if (is_numeric($_POST['id'])) {
76 $this->x12_partners[0] = new X12Partner($_POST['id']);
77 } else {
78 $this->x12_partners[0] = new X12Partner();
81 parent::populate_object($this->x12_partners[0]);
83 // If we are setting the SFTP password, encrypt it
84 if (!empty($_POST['x12_sftp_pass'])) {
85 $cryptoGen = new CryptoGen();
86 $this->x12_partners[0]->x12_sftp_pass = $cryptoGen->encryptStandard($this->x12_partners[0]->x12_sftp_pass);
89 $this->x12_partners[0]->persist();
90 //insurance numbers need to be repopulated so that insurance_company_name recieves a value
91 $this->x12_partners[0]->populate();
93 //echo "action processeed";
94 $_POST['process'] = "";
95 $this->_state = false;
96 header('Location:' . $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&x12_partner&action=list");//Z&H
97 //return $this->edit_action(null,$this->x12_partner[0]);