<?php
$url = explode('=', $_SERVER['REQUEST_URI']);
$error_code = empty($_GET['errorcode']) ? '' : $_GET['errorcode']; //here the errorcode variable
//if(Session::isAlive()){
//    header('Location: '.SITE_LINK.smc_session()['user_details']['landing']);
//}
?>
<!DOCTYPE html>
<html>

<head>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />

<link rel="apple-touch-icon" sizes="180x180" href="img/apple-touch-icon.png">
<link rel="icon" type="img/png" sizes="32x32" href="img/favicon-32x32.png">
<link rel="icon" type="img/png" sizes="16x16" href="img/favicon-16x16.png">
<link rel="mask-icon" href="img/safari-pinned-tab.svg" color="#5bbad5">

    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <meta charset="utf-8" />
    <title>Trusto | Login</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <script type="text/javascript">
        //<![CDATA[
        try {
            if (!window.CloudFlare) {
                var CloudFlare = [{
                    verbose: 0,
                    p: 0,
                    byc: 0,
                    owlid: "cf",
                    bag2: 1,
                    mirage2: 0,
                    oracle: 0,
                    paths: {
                        cloudflare: "/cdn-cgi/nexp/dok3v=1613a3a185/"
                    },
                    atok: "33e786da1e0c6905e3e3556fd96f67a1",
                    petok: "1bee5a2e1a43af1a0b17318d80182e1dddf30200-1435577837-1800",
                    zone: "revox.io",
                    rocket: "0",
                    apps: {
                        "ga_key": {
                            "ua": "UA-56895490-1",
                            "ga_bs": "1"
                        }
                    }
                }];
                CloudFlare.push({
                    "apps": {
                        "ape": "a390798cadf05d6376214c701e291319"
                    }
                });
                ! function(a, b) {
                    a = document.createElement("script"), b = document.getElementsByTagName("script")[0], a.async = !0, a.src = "Theme/js/cloudflare.min.js", b.parentNode.insertBefore(a, b)
                }()
            }
        } catch (e) {};
        //]]>
    </script>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="default">
    <meta content="" name="description" />
    <meta content="" name="author" />

    <link href="Theme/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css" />
    <link href="Theme/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="Theme/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css" />
    <link href="Theme/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="Theme/plugins/bootstrap-select2/select2.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="Theme/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="Theme/plugins/nvd3/nv.d3.min.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="Theme/plugins/mapplic/css/mapplic.css" rel="stylesheet" type="text/css" />
    <link href="Theme/plugins/rickshaw/rickshaw.min.css" rel="stylesheet" type="text/css" />
    <link href="Theme/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" type="text/css" media="screen">
    <link href="Theme/plugins/jquery-metrojs/MetroJs.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="Theme/css/pages-icons.css" rel="stylesheet" type="text/css">
    <link class="main-stylesheet" href="Theme/css/pages.css" rel="stylesheet" type="text/css" />
    <script src="Theme/plugins/jquery/jquery-2.1.1.js" type="text/javascript"></script>

    <!--[if lte IE 9]>
<link href="pages/css/ie9.css" rel="stylesheet" type="text/css" />
<![endif]-->
    <!--[if lt IE 9]>
<link href="Theme/plugins/mapplic/css/mapplic-ie.css" rel="stylesheet" type="text/css" />
<![endif]-->
    <script type="text/javascript">
        window.onload = function() {
            // fix for windows 8
            if (navigator.appVersion.indexOf("Windows NT 6.2") != -1)
                document.head.innerHTML += '<link rel="stylesheet" type="text/css" href="pages/css/windows.chrome.fix.css" />'
        }
    </script>

</head>
<style type="text/css">
    .company_link{
        color: #000000;
    }
    .company_link :hover{
        color: #ed9421;
    }
    .demo {

        padding: 15px 0;
    }

    .hide {
        visibility: hidden;
    }

    .login-wrapper {
        height: 100%;

    }

    .btn-success,
    .btn-success:hover {
        background-color: #642d92;

        color: white;
    }

    .btn-success,
    .btn-success:focus {
        color: #ffffff;
        border-radius: 20px;
        background-color: #e19421;

    }
	.test{
		margin-top: 8%;
    margin-left: 20%;
		width: 20%;
  height: auto;
	}
</style>

<body class="fixed-header   ">
    <div class="login-wrapper ">
	
        <div style="background-color:white;" class="bg-pic">
                <img class="test" src="img/trusto.png" alt="" >

            <div class="bg-caption pull-bottom sm-pull-bottom text-white p-l-20 m-b-20">
                <h4 class="semi-bold text-white" style="color: black;">

                    Trusto System v<?php echo trusto_VERSION; ?> | Where Data Belongs

                </h4>
                <h3 style="color:black;text-align: left;font-size: 21px;">Aproved from zaka authority</h3>
                <h3 style="color:black;text-align: left;font-size: 21px;">معتمدة من هيئة الزكاة</h3>
                <p class="small text-white" style="color: black;">
                    All the information or images Displayed in this system, are solely for the development company only, © <?php echo Date('Y') ?> <a href="https://trustotech-lb.com/contact.php" target="_blank" style="color:#e19421;text-decoration:none">Trusto Tech.</a>
                </p>
            </div>
        </div>
        <div class="login-container bg-white">
            <div class="p-l-50 m-l-20 p-r-50 m-r-20 p-t-50 m-t-30 sm-p-l-15 sm-p-r-15 sm-p-t-40">
                <img src="img/logo.png" alt="logo" data-src="Theme/img/logo.png" data-src-retina="Theme/img/logo_2x.png" width="78" height="50">
                <?php if ($is_pin_code) { ?>
                    <a href="<?php echo SITE_LINK; ?>pin">
                        <img src="img/keypad.png" class="pull-right" alt="logo" data-src="Theme/img/keypad.png" data-src-retina="Theme/img/logo_2x.png">
                    </a>
                <?php } ?>
                <p class="p-t-35">Sign into your pages account</p>
                <?php if ($open_product_page) { ?>
                    <style>
                        .open{
                            color: black;
                        }
                        .open:hover{
                            color: #f6931c;
                        }

                    </style>
                    <p > <a class="open btn btn-success btn-cons m-t-10" href="<?php echo SITE_LINK; ?>product_page"><i class="fa fa-th-large"></i> Open Product Page </a></p>
                <?php } ?>
                
                <?php if ($open_customer_points_page) { ?>
                    <style>
                        .open{
                            color: black;
                        }
                        .open:hover{
                            color: #f6931c;
                        }

                    </style>
                    <p > <a class="open btn btn-success btn-cons m-t-10" href="<?php echo SITE_LINK; ?>customer_points_page"><i class="fa fa-th-large"></i> Open Customer Points Page </a></p>
                <?php } ?>
                
                <div id="ErrorNotification" class="hidden alert m-b-0"></div>
                <form id="form-login" class="p-t-15" role="form" action="smc/doLogin" method="post">
                    <div class="form-group form-group-default">
                        <label>Login</label>
                        <div class="controls">
                            <input type="text" name="Username" placeholder="User Name" class="form-control" required>
                        </div>
                    </div>
                    <div class="form-group form-group-default">
                        <label>Password</label>
                        <div class="controls">
                            <input type="password" class="form-control" name="Password" placeholder="Credentials" required>
                        </div>
                    </div>
                    <div class="form-group " style="display:flex;">
                        <div class="controls">
                            <input type="checkbox" name="logout_other_device" value="1" />
                        </div>
                        <label>&nbsp;&nbsp;Logout Other Device</label>

                    </div>
                    <?php if (isset($companies)) { ?>
                        <div class="form-group <?php echo empty($companies) ? 'hidden':''; ?>">
                            <label>Company</label>
                            <select id="multi_company" data-init-plugin="select2" class="full-width">
                                <option value="" selected> Choose Company</option>
                                <?php foreach ($companies as $com) { ?>
                                    <option value="<?php echo $com['company_url'] ?>" <?php echo $com['is_default'] == 1 ? 'selected' : '' ?>><?php echo $com['company_name'] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    <?php } ?>
                    <div class="row">
                        <div class="col-md-6 ">
                            <i class="fa fa-question-circle"></i>
                            <a href="https://www.youtube.com/channel/UCXc0tdinNYPibNHqgOtFhpg/playlists" target="_blank" class="text-info small">Help? watch our tutorials</a>
                        </div>
                    </div>
                    <div class="<?php echo empty($expiry_message) ? "hidden" : ""; ?> alert alert-danger text-center m-t-10 m-b-0" style="font-weight:bold;border:1px solid #ed9421;"><?= $expiry_message; ?></div>
                    <div class="<?php echo $is_production ? "hidden" : ""; ?> alert alert-warning text-center m-t-10 m-b-0" style="font-weight:bold;border:1px solid #ed9421;">Development Mode Activated!</div>
                    <button class="btn btn-success btn-cons m-t-10" type="submit">Sign in</button>
                    <input type="hidden" value=<?= json_encode($unique_id); ?> name="unique_id" />
                </form>
                <br><br><br><br>
                <!--
<div class="col-md-12" id="demo"style="border:1px solid #95a5b4 ">
<div class="demo">
<p class="bold">To Make A Tour in trusto System you can login Using:</p>
<label class="bold">Username : demo</label><br>
<label class="bold">Password : 123456</label>
</div>
</div>-->

                <div class="pull-bottom sm-pull-bottom">
                    <div class="m-b-30 p-r-80 sm-m-t-20 sm-p-r-15 sm-p-b-20 clearfix"></div>
                </div>
            </div>
        </div>
    </div>
    <div></div>

    <script src="Theme/plugins/pace/pace.min.js" type="text/javascript"></script>
    <!--   <script src="Theme/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>-->
    <script src="Theme/plugins/modernizr.custom.js" type="text/javascript"></script>
    <script src="Theme/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
    <script src="Theme/plugins/boostrapv3/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="Theme/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script>
    <script type="text/javascript" src="Theme/plugins/bootstrap-select2/select2.min.js"></script>
    <script src="Theme/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
    <script src="Theme/js/pages.min.js"></script>
    <script>
        var URLStatus = <?php echo json_encode($error_code) ?>,
            is_multi_companies = <?php echo json_encode(isset($companies) ? 1 : 0); ?>;
        $(function() {
            $('#form-login').validate();
            if (URLStatus == 1) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html('username or password is invalid')
            } else if (URLStatus == 2) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html('Your account is logged in')
            } else if (URLStatus == 5) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html('This version is expired')
            } else if (URLStatus == 6) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html('failed, Please try again')
            } else if (URLStatus == 7) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html('failed, you are unauthorized to login')
            } else if (URLStatus == 8) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html('failed, Please check that you are at the right branch/server')
            } else if (URLStatus == 9) {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html("multi login is disabled, logout first or check below 'Logout from other devices?'.")
            } else if (URLStatus == 'duplicate') {
                $("#ErrorNotification").removeClass('hidden').addClass('alert-danger').html(<?php echo json_encode(token_unique::duplicate_msg()); ?>);
            }
            //
            $("#multi_company").on("change", function() {
                $("#form-login").attr("action", $(this).val() + 'smc/doLogin');
            });
            //if there is default company
            if ($("#multi_company").val() != '' && is_multi_companies)
                $("#form-login").attr("action", $("#multi_company").val() + 'smc/doLogin');
        });
    </script>
</body>

</html>