<html>
    <head>
        <meta charset="utf-8">
        <title>تحديث البيانات</title>
        <style>
            .center {
                display: block;
                margin-left: auto;
                margin-right: auto;
                width: 50%;
                text-align: center;
                color: #900026;
                font-weight: bold;
                direction: rtl;
            }
        </style>
    </head>
    <body>
        <!--<div class="row">
            <div class="container">
                <ol class="breadcrumb">
                    <li><a href="#">خصائص عامة</a></li>
                    <li><a href="programsettingsController.php">اعدادات المنجر اون لاين</a></li>
                    <li class="active">تعديل اعدادات المنجر اون لاين</li>
                </ol>
                <div class="panel panel-default panel-m">
                     Default panel contents
                    <div class="panel-heading">
                        <h3 class="panel-title">تعديل المنجر اون لاين</h3>
                    </div>
                    <div class="panel-body">


                    </div>
                </div>
            </div>
        </div>-->
        <div class="frame" style="height: 100%;">
            <img src="../views/default/images/upload/cart.gif" class="center" alt="" style="width: 25%;height: 35%;vertical-align: central"/>
            <p><span class="center">جارى ارسال البيانات للمتجر الالكترونى</span></p>
            <p><span class="center">{$onlineStoreSetting_head->url}</span></p>
            <p><span class="center"> قاعدة البيانات الحالية :{$db}</span></p>
        </div>


        <input type="hidden" name="catprohour_head" id="catprohour_head" value="{$onlineStoreSetting_head->catprohour}"/>
        <input type="hidden" name="catprominute_head" id="catprominute_head" value="{$onlineStoreSetting_head->catprominute}"/>
        <input type="hidden" name="proquantityhour_head" id="proquantityhour_head" value="{$onlineStoreSetting_head->proquantityhour}"/>
        <input type="hidden" name="proquantityminute_head" id="proquantityminute_head" value="{$onlineStoreSetting_head->proquantityminute}"/>
        <input type="hidden" name="clientshour_head" id="clientshour_head" value="{$onlineStoreSetting_head->clientshour}"/>
        <input type="hidden" name="clientsminute_head" id="clientsminute_head" value="{$onlineStoreSetting_head->clientsminute}"/>
        <input type="hidden" name="ordershour_head" id="ordershour_head" value="{$onlineStoreSetting_head->ordershour}"/>
        <input type="hidden" name="ordersminute_head" id="ordersminute_head" value="{$onlineStoreSetting_head->ordersminute}"/>
        <input type="hidden" name="updatetype_head" id="updatetype_head" value="{$onlineStoreSetting_head->updatetype}"/>





        {literal}
        <script type="text/javascript" charset="utf-8" src="media/js/jquery.js"></script>
        <script>
            //shop2 ajax
            //$(document).ready(function () {
            var updatetype_head = Number($('#updatetype_head').val());
            if (updatetype_head == 1) {
                //1-sync CatsAndProductsOnline
                var catprohour = Number($('#catprohour_head').val()) * 60 * 60;//20000;  // 1000 = 1 second, 20000 = 20 seconds
                var catprominute = Number($('#catprominute_head').val()) * 60;
                var catproInterval = catprohour + catprominute;//in second
                catproInterval = catproInterval * 1000;
                function syncCatsAndProductsOnline() {
                    //console.log(interval);
                    $.ajax({
                        type: 'POST',
                        url: 'onlinestoresync.php?do=syncCatAndProducts',
                        async: false,
                        success: function (data) {
                            //alert(data);
                        },
                        complete: function (data) {
                            // Schedule the next********************************
                            setTimeout(syncCatsAndProductsOnline, catproInterval);
                        }
                    });
                }
                setTimeout(syncCatsAndProductsOnline, catproInterval);



                //2-sync syncProductQuantityAndStoreReport
                var proquantityhour = Number($('#proquantityhour_head').val()) * 60 * 60;//20000;  // 1000 = 1 second, 20000 = 20 seconds
                var proquantityminute = Number($('#proquantityminute_head').val()) * 60;
                var proquantityInterval = proquantityhour + proquantityminute;//in second
                proquantityInterval = proquantityInterval * 1000;
                function syncProductQuantityAndStoreReportOnline() {
                    //console.log(interval);
                    $.ajax({
                        type: 'POST',
                        url: 'onlinestoresync.php?do=syncProductQuantityAndStoreReport',
                        async: false,
                        success: function (data) {
                            //alert(data);
                        },
                        complete: function (data) {
                            // Schedule the next********************************
                            setTimeout(syncProductQuantityAndStoreReportOnline, proquantityInterval);
                        }
                    });
                }
                setTimeout(syncProductQuantityAndStoreReportOnline, proquantityInterval);



                //3-sync syncClientsDeptOnline
                var clientshour = Number($('#clientshour_head').val()) * 60 * 60;//20000;  // 1000 = 1 second, 20000 = 20 seconds
                var clientsminute = Number($('#clientsminute_head').val()) * 60;
                var clientsInterval = clientshour + clientsminute;//in second
                clientsInterval = clientsInterval * 1000;
                function syncClientsDeptOnline() {
                    //console.log(interval);
                    $.ajax({
                        type: 'POST',
                        url: 'onlinestoresync.php?do=syncClientsDeptOnline',
                        async: false,
                        success: function (data) {
                            //alert(data);
                        },
                        complete: function (data) {
                            // Schedule the next********************************
                            setTimeout(syncClientsDeptOnline, clientsInterval);
                        }
                    });
                }
                setTimeout(syncClientsDeptOnline, clientsInterval);



                //4-sync orders
                var ordershour = Number($('#ordershour_head').val()) * 60 * 60;//20000;  // 1000 = 1 second, 20000 = 20 seconds
                var ordersminute = Number($('#ordersminute_head').val()) * 60;
                var ordersminuteInterval = ordershour + ordersminute;//in second
                ordersminuteInterval = ordersminuteInterval * 1000;
                function syncOrdersFromOnline() {
                    //console.log(interval);
                    $.ajax({
                        type: 'POST',
                        url: 'onlinestoresync.php?do=saveOnlineOrders',
                        async: false,
                        success: function (data) {
                            //alert(data);
                        },
                        complete: function (data) {
                            // Schedule the next********************************
                            setTimeout(syncOrdersFromOnline, ordersminuteInterval);
                        }
                    });
                }
                setTimeout(syncOrdersFromOnline, ordersminuteInterval);
            }
            //});
        </script>
        {/literal}
    </body>
</html>