<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.4
 * @ Decoder version: 1.0.2
 * @ Release: 10/08/2022
 */

// Decoded file for php version 74.
if(!defined("IN_SITE")) {
    exit("The Request Not Found");
}
require_once __DIR__ . "/../../models/is_user.php";
if(isset($_GET["id"])) {
    $id = check_string($_GET["id"]);
    if(!($cron = $CMSNT->get_row("SELECT * FROM `cron_jobs` WHERE `trans_id` = '" . $id . "' AND `user_id` = '" . $getUser["id"] . "'  "))) {
        redirect(base_url("cron-jobs"));
    }
} else {
    redirect(base_url("cron-jobs"));
}
$body = ["title" => __("Gia hạn link CRON JOB") . " | " . $CMSNT->site("title"), "desc" => $CMSNT->site("description"), "keyword" => $CMSNT->site("keywords")];
$body["header"] = "\n<link rel=\"stylesheet\" href=\"" . BASE_URL("public/client/") . "css/wallet.css\">\n<link rel=\"stylesheet\" href=\"" . BASE_URL("mod/css/cronjob.css") . "\">\n";
$body["footer"] = "\n\n";
require_once __DIR__ . "/header.php";
require_once __DIR__ . "/nav.php";
echo "\n\n<section class=\"py-5 inner-section profile-part\">\n    <div class=\"container\">\n        <div class=\"row\">\n            <div class=\"col-lg-7\">\n                <div class=\"home-heading mb-3\">\n                    <h3><i class=\"fa-solid fa-rotate-right m-2\"></i>";
echo mb_strtoupper(__("Gia hạn link CRON"));
echo "                        <span style=\"float: right;\">\n                            <a class=\"btn btn-danger btn-sm\" href=\"";
echo base_url("cron-jobs");
echo "\"><i\n                                    class=\"fa-solid fa-arrow-left me-1\"></i>";
echo mb_strtoupper(__("Quay lại"));
echo "</a>\n                        </span>\n                    </h3>\n                </div>\n                <div class=\"account-card pt-3\">\n                    <fieldset>\n                        <legend>";
echo __("Thông tin chi tiết");
echo "</legend>\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-3 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Liên kết cần CRON");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-9 fv-row\">\n                                <input type=\"hidden\" id=\"trans_id\" class=\"form-control\" value=\"";
echo $cron["trans_id"];
echo "\" />\n                                <input type=\"hidden\" id=\"token\" class=\"form-control\" value=\"";
echo $getUser["token"];
echo "\" />\n                                <input type=\"text\" class=\"form-control\" id=\"link_cron\" value=\"";
echo $cron["link_cron"];
echo "\" disabled>\n                                <small id=\"link-error\" class=\"text-danger\" style=\"display: none;\">\n                                    ";
echo __("Vui lòng nhập liên kết hợp lệ.");
echo "                                </small>\n                            </div>\n                        </div>\n                        <script>\n                        function isValidURL(url) {\n                            // Biểu thức chính quy để kiểm tra URL hợp lệ\n                            const pattern = new RegExp('^(https?:\\\\/\\\\/)?' + // protocol\n                                '((([a-zA-Z0-9\\\\-]+\\\\.)+[a-zA-Z]{2,})|' + // domain name\n                                '((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))' + // OR ip (v4) address\n                                '(\\\\:\\\\d+)?(\\\\/[-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)?\$', 'i'); // port and path\n                            return !!pattern.test(url);\n                        }\n\n                        document.getElementById('link_cron').addEventListener('input', function() {\n                            const linkValue = this.value;\n                            const errorElement = document.getElementById('link-error');\n\n                            if (!isValidURL(linkValue)) {\n                                errorElement.style.display = 'block'; // Hiển thị lỗi\n                            } else {\n                                errorElement.style.display = 'none'; // Ẩn lỗi\n                            }\n                        });\n                        </script>\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-8 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Vòng lặp");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-4 fv-row\">\n                                <div class=\"input-group mb-3\">\n                                    <input type=\"number\" class=\"form-control\" id=\"timeloop\" value=\"";
echo $cron["timeloop"];
echo "\" value=\"60\" disabled>\n                                    <span class=\"input-group-text\">";
echo __("giây");
echo "</span>\n                                </div>\n                                <small id=\"timeloop-error\" class=\"text-danger\" style=\"display: none;\">";
echo __("Vòng lặp phải lớn\n                                    hơn hoặc bằng 10 giây.");
echo "</small>\n                            </div>\n                        </div>\n\n                        <script>\n                        document.getElementById('timeloop').addEventListener('input', function() {\n                            const timeloopValue = parseInt(this.value);\n                            const errorElement = document.getElementById('timeloop-error');\n\n                            if (timeloopValue < 10) {\n                                errorElement.style.display = 'block'; // Hiển thị lỗi\n                            } else {\n                                errorElement.style.display = 'none'; // Ẩn lỗi\n                            }\n                        });\n                        </script>\n\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-8 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Phương thức");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-4 fv-row\">\n                                <select class=\"form-control\" id=\"method\" disabled>\n                                    <option ";
echo $cron["method"] == "GET" ? "selected" : "";
echo " value=\"GET\">GET</option>\n                                    <option ";
echo $cron["method"] == "POST" ? "selected" : "";
echo " value=\"POST\">POST</option>\n                                </select>\n                            </div>\n                        </div>\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-4 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Máy chủ");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-8 fv-row\">\n                                <select class=\"form-control\" id=\"server_id\" onchange=\"totalPrice()\" disabled>\n                                    ";
foreach ($CMSNT->get_list(" SELECT * FROM `cron_server` WHERE `status` = 1 ") as $server) {
    echo "                                    <option ";
    echo $server["id"] == $cron["server_id"] ? "selected" : "";
    echo " value=\"";
    echo $server["id"];
    echo "\" data-price=\"";
    echo $server["price"];
    echo "\">\n                                        ";
    echo $server["name"];
    echo " - ";
    echo format_currency($server["price"]);
    echo "</option>\n                                    ";
}
echo "                                </select>\n                            </div>\n                        </div>\n                    </fieldset>\n                    <fieldset>\n                        <legend>";
echo __("Gia hạn thêm");
echo "</legend>\n                        <div class=\"form-group row\">\n                            <div class=\"col-lg-4 col-form-label required fw-bold fs-6\">\n                                <label class=\"form-label\">";
echo __("Thời hạn");
echo " (<span\n                                        class=\"text-danger\">*</span>)</label>\n                            </div>\n                            <div class=\"col-xl-8 fv-row\">\n                                <select class=\"form-control\" id=\"rental_period\" onchange=\"totalPrice()\">\n                                ";
foreach (explode(PHP_EOL, $CMSNT->site("cronjob_billing_cycle")) as $option) {
    echo "                                    ";
    $option = explode("|", $option);
    echo "                                    <option value=\"";
    echo $option[0];
    echo "\">";
    echo __($option[1]);
    echo "</option>\n                                    ";
}
echo "                                </select>\n                                <small>";
echo __("Thời hạn sẽ được cộng thêm tính từ ngày hết hạn + thời gian gia hạn mới");
echo "</small>\n                            </div>\n                        </div>\n                    </fieldset>\n                    <div class=\"form-group text-center\">\n                        <div class=\"alert bg-white alert-info\" role=\"alert\">\n                            <div class=\"iq-alert-icon\">\n                                <i class=\"ri-alert-line\"></i>\n                            </div>\n                            <div class=\"iq-alert-text\">";
echo __("Số tiền cần thanh toán");
echo ": <b id=\"ketqua\"\n                                    style=\"color: red;\">0đ</b></div>\n                        </div>\n                    </div>\n                    <script>\n                    totalPrice();\n\n                    function totalPrice() {\n                        \$.ajax({\n                            url: \"";
echo BASE_URL("ajaxs/client/cronjob.php");
echo "\",\n                            method: \"POST\",\n                            dataType: \"JSON\",\n                            data: {\n                                action: 'totalPayment',\n                                server_id: \$(\"#server_id\").val(),\n                                rental_period: \$(\"#rental_period\").val(),\n                                token: \$(\"#token\").val()\n                            },\n                            success: function(data) {\n                                if (data.status == 'success') {\n                                    const ketqua = \$(\"#ketqua\");\n                                    ketqua.html(data.money);\n                                } else {\n                                    showMessage(data.msg, data.status);\n                                }\n                            },\n                            error: function() {\n                                showMessage('";
echo __("Vui lòng liên hệ Developer");
echo "', 'error');\n                            }\n                        });\n                    }\n                    </script>\n                \n                     \n\n                    <button class=\"btn-buy\" id=\"btnBuy\" onclick=\"renewCron()\">\n                        <i class=\"fa-solid fa-cart-shopping\"></i>\n                        <span>";
echo __("THANH TOÁN");
echo "</span>\n                    </button>\n\n                </div>\n            </div>\n            <div class=\"col-lg-5\">\n                <div class=\"home-heading mb-3\">\n                    <h3><i class=\"fa-solid fa-triangle-exclamation m-2\"></i>";
echo mb_strtoupper(__("Lưu ý"));
echo "                    </h3>\n                </div>\n                <div class=\"account-card pt-3\">\n                    ";
echo $CMSNT->site("cronjob_note");
echo "                </div>\n            </div>\n        </div>\n    </div>\n\n</section>\n\n\n\n<script type=\"text/javascript\">\nfunction renewCron() {\n    Swal.fire({\n        title: '";
echo __("Xác nhận thanh toán");
echo "',\n        text: \"";
echo __("Bạn có chắc chắn muốn thanh toán không?");
echo "\",\n        icon: 'warning',\n        showCancelButton: true,\n        confirmButtonText: '";
echo __("Đồng ý");
echo "',\n        cancelButtonText: '";
echo __("Hủy bỏ");
echo "',\n        reverseButtons: true\n    }).then((result) => {\n        if (result.isConfirmed) {\n            processrenewCron();\n        }\n    });\n}\n\nfunction processrenewCron() {\n    const btnBuy = document.getElementById('btnBuy');\n    const btnContent = btnBuy.innerHTML;\n    \$('#btnBuy').html('<i class=\"fa fa-spinner fa-spin\"></i>')\n        .prop('disabled',\n            true);\n    \$.ajax({\n        url: \"";
echo base_url("ajaxs/client/cronjob.php");
echo "\",\n        method: \"POST\",\n        dataType: \"JSON\",\n        data: {\n            action: 'renewCronJob',\n            token: \$(\"#token\").val(),\n            trans_id: \$(\"#trans_id\").val(),\n            rental_period: \$(\"#rental_period\").val(),\n        },\n        success: function(response) {\n            if (response.status == 'success') {\n                Swal.fire({\n                    title: '";
echo __("Successful!");
echo "',\n                    text: response.msg,\n                    icon: 'success',\n                    confirmButtonText: '";
echo __("Ok");
echo "', // Nút xem đơn hàng\n                    reverseButtons: true\n                }).then((result) => {\n                    if (result.isConfirmed) {\n                        window.location.href = '";
echo base_url("cron-jobs");
echo "';\n                    }\n                });\n            } else {\n                Swal.fire('";
echo __("Failure!");
echo "', response.msg, 'error');\n            }\n            \$('#btnBuy').html(btnContent).prop('disabled', false);\n        },\n        error: function() {\n            showMessage('";
echo __("Không thể xử lý");
echo "', 'error');\n            \$('#btnBuy').html(\n                btnContent\n            ).prop('disabled',\n                false);\n        }\n    });\n}\n</script>\n\n\n\n";
require_once __DIR__ . "/footer.php";

?>