<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

include_once("../../../../../lib/phpmailer/Exception.php");
include_once("../../../../../lib/phpmailer/PHPMailer.php");
include_once("../../../../../lib/phpmailer/SMTP.php");
session_start();
include_once("../../../../../lib/konfig.php");
include_once("../../../../../lib/function.php");
$MySQLi = new MySQLi($strDBHostName, $strDBUsername, $strDBPassword, $strDBName);

//if (isset($_GET['id']) && $_GET['opt'] == "done") {

$query = "UPDATE tpc_h_lpbj
    SET stsDone = 1,
    dtUpdate = NOW(),
    usrUpdate='" . $_SESSION['strEmail'] . "' WHERE ID='" . $_GET['id'] . "';";

$MySQLi->query($query);
if ($MySQLi->affected_rows == 1) {
    $strBuffer = str_replace('"', '`', str_replace("'", "`", $query));
    $query = "INSERT INTO tpc_log
        SET strPCHostname='" . gethostbyaddr(getIPv4()) . "',
        strIPv4='" . getIPv4() . "',
        strPort='" . $_SERVER['REMOTE_PORT'] . "',
        strTable='tpc_h_lpbj',
        strQuery='" . $strBuffer . "',
        strKeterangan='" . $_SESSION['strEmail'] . " klik done untuk nomor ID LPBJ : " . $_GET['id'] . "',
        dtCreate=NOW(),
        usrCreate='" . $_SESSION['strEmail'] . "'";

    $MySQLi->query($query);

    echo '<script type="text/javascript">';
    echo 'alert(\'LPBJ Done\');';
    echo 'location.href = \'http://' . $strNmDomain . '/home/index.php?menu=laporan-lpbj\';';
    echo '</script>';
}
//}
