4 * controller class for x-12 partner screen
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
23 function __construct($template_mod = "general")
25 parent
::__construct();
26 $this->x12_partners
= array();
27 $this->template_mod
= $template_mod;
28 $this->assign("FORM_ACTION", $GLOBALS['webroot'] . "/controller.php?" . attr($_SERVER['QUERY_STRING']));
29 $this->assign("CURRENT_ACTION", $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&x12_partner&");
30 $this->assign("STYLE", $GLOBALS['style']);
33 function default_action()
35 return $this->list_action();
38 function edit_action($id = "", $x_obj = null)
40 if ($x_obj != null && get_class($x_obj) == "x12partner") {
41 $this->x12_partners
[0] = $x_obj;
42 } elseif (is_numeric($id)) {
43 $this->x12_partners
[0] = new X12Partner($id);
45 $this->x12_partners
[0] = new X12Partner();
48 // If we have an SFTP password set, decrypt it
49 if ($this->x12_partners
[0]->get_x12_sftp_pass()) {
50 $cryptoGen = new CryptoGen();
51 $this->x12_partners
[0]->set_x12_sftp_pass($cryptoGen->decryptStandard($this->x12_partners
[0]->get_x12_sftp_pass()));
54 $this->assign("partner", $this->x12_partners
[0]);
55 return $this->fetch($GLOBALS['template_dir'] . "x12_partners/" . $this->template_mod
. "_edit.html");
58 function list_action()
61 $x = new X12Partner();
62 $this->assign("partners", $x->x12_partner_factory());
63 return $this->fetch($GLOBALS['template_dir'] . "x12_partners/" . $this->template_mod
. "_list.html");
67 function edit_action_process()
69 if ($_POST['process'] != "true") {
74 if (is_numeric($_POST['id'])) {
75 $this->x12_partners
[0] = new X12Partner($_POST['id']);
77 $this->x12_partners
[0] = new X12Partner();
80 parent
::populate_object($this->x12_partners
[0]);
82 // If we are setting the SFTP password, encrypt it
83 if (!empty($_POST['x12_sftp_pass'])) {
84 $cryptoGen = new CryptoGen();
85 $this->x12_partners
[0]->x12_sftp_pass
= $cryptoGen->encryptStandard($this->x12_partners
[0]->x12_sftp_pass
);
88 $this->x12_partners
[0]->persist();
89 //insurance numbers need to be repopulated so that insurance_company_name recieves a value
90 $this->x12_partners
[0]->populate();
92 //echo "action processeed";
93 $_POST['process'] = "";
94 $this->_state
= false;
95 header('Location:' . $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&x12_partner&action=list");//Z&H
96 //return $this->edit_action(null,$this->x12_partner[0]);