Initial import
This commit is contained in:
86
application/controllers/fix/Tx_branch.php
Normal file
86
application/controllers/fix/Tx_branch.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
class Tx_branch extends MY_Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
global $_SERVER;
|
||||
$this->print_table_style();
|
||||
|
||||
$sql = "select M_BranchID, M_BranchCode, M_BranchName, TxBranchStatusM_BranchIP TxIpAddress,
|
||||
M_BranchIPAddress, count(*) total
|
||||
from
|
||||
tx_branch_status
|
||||
join m_branch on TxBranchStatusIsSent = 'N'
|
||||
and TxBranchStatusM_BranchID = M_BranchID
|
||||
group by M_BranchCode, TxBranchStatusM_BranchIP ";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $idx => $r) {
|
||||
$branchID = $r["M_BranchID"];
|
||||
$branchIP = $r["M_BranchIPAddress"];
|
||||
$action = "<a href='/one-api/fix/tx_branch/fix/$branchID/$branchIP'>Fix IP and Retry</a>";
|
||||
$rows[$idx]["Action"] = $action;
|
||||
}
|
||||
$this->print_table($rows, array_keys($rows[0]), "Tx Branch Status");
|
||||
}
|
||||
function fix($branchID, $branchIP)
|
||||
{
|
||||
$sql = "update tx_branch_status
|
||||
set TxBranchStatusRetry =1 , TxBranchStatusM_BranchIP = ?
|
||||
where TxBranchStatusIsSent = 'N' and
|
||||
TxBranchStatusM_BranchID = ? ";
|
||||
$qry = $this->db->query($sql, [$branchIP, $branchID]);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "\n";
|
||||
exit();
|
||||
}
|
||||
header("Location: /one-api/fix/tx_branch");
|
||||
exit();
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys, $title = false)
|
||||
{
|
||||
echo "<table>";
|
||||
if ($title) {
|
||||
$col_span = count($keys);
|
||||
echo "<tr>";
|
||||
echo "<th colspan=$col_span>$title</th>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user