
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">طلبات الاونلاين  </a></li>
            <li><a href="sellbillController.php?do=show">طلبات تنتظر الموافقة</a></li>
            <li class="active">عرض </li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">عرض الطلبات <br />
                {if $message != ""}
                {$message}
                {/if} </div>
            <div class="panel-body">
                <div id="outputString" class="alert alert-block alert-success fade in hidden-print" style="display:none">
                    <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <p id="outputStringValue">{$outputString}</p>
                    <div class="clearfix"></div>
                </div>
                <form class="form-inline hidden-print" action="onlinestoresetting.php?do=onlineOrders" method="post">
                    <div class="form-group">
                        <label class="sr-only">العميل</label>
                        <select class="select2 wdt100"  name="clientid" id="clientid" >
                            <option value="-1">اختر عميل</option>
                            {foreach $clientData as $client}
                            <option value="{$client->clientid}">{$client->clientname}</option>
                            {/foreach}
                        </select>
                    </div>


                    <div class="form-group"{if {$Programsettingdata->billid} eq 1}  style="display:none" {/if}>
                        <label class="sr-only">رقم الفاتورة</label>
                        <input type="text" class="form-control" placeholder="رقم الفاتورة" name="orderid" id="orderid">
                    </div>


                    <div id="dateTimeDiv">
                        <div class="form-group">
                            <label class="sr-only">من التاريخ</label>
                            <div  class="input-group date form_datetime col-md-5" data-date="" data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                <input class="form-control search_bill" size="16" type="text" value="" name="from" id="from" readonly="" >
                                <span class="input-group-addon " style="width: 0%;"><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                <span class="input-group-addon"  style="width: 0%;"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="sr-only">إلى التاريخ</label>
                            <div  class="input-group date form_datetime col-md-5" data-date="" data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                <input class="form-control search_bill" size="16" type="text" value="" name="to" id="to" readonly="" >
                                <span class="input-group-addon " style="width: 0%;"><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                <span class="input-group-addon" style="width: 0%;"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                            </div>
                        </div>
                    </div>

                    <div class="clearfix"></div>
                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>
            </div>
            <hr/>
            <div  id="tableWrap">

                <div class="clearfix"></div>
                <div class="message-table"> {$message}</div>

                <table class="table table-black dataTableClass" id="excelTable">
                    <thead>
                        <tr>
                            <th>م </th>
                            <th>رقم الاوردر</th>
                            <th>العميل</th>
                            <th>الموبايل</th>
                            <th>تاريخ الاوردر</th>
                            <th class="hidden-print">تفاصيل </th>
                            <th class="hidden-print">تعديل الفاتورة </th>
                            <th class="hidden-print">موافقة </th>
                            <th class="hidden-print">رفض </th>
                        </tr>
                    </thead>
                    <tbody>
                        {assign var=i value=1}
                        {foreach $onlineTempOrders as $data}
                        <tr>
                            <td>{$i}</td>
                            <td>{$data->onlineorderid}</td>
                            <td>{$data->clientname}</td>
                            <td>{$data->clientmobile}</td>
                            <td>{$data->createdatetime}</td>


                            <td class="hidden-print"> <a href="onlinestoresetting.php?do=onlineOrderDetails&id={$data->id}" type="button" class="btn btn-default btn-lg bookicon"></a> </td>
                            <td class="hidden-print"> <a href="{$onlineStoreSetting->url}/orders/edit/{$data->onlineorderid}" target="_blank" type="button" class="btn btn-default btn-lg editicon"></a> </td>


                            <td class="hidden-print">
                                <a data-link="sellbillController.php?do=onlineOrderConfirm&id={$data->onlineorderid}" data-erpid="{$data->erpid}" id="{$data->onlineorderid}" type="button" class="btn btn-default btn-lg correcticon chooseClientDialoge"></a>
                            </td>
                            <td class="hidden-print">
                                <a data-link="sellbillController.php?do=onlineOrderRefuse&id={$data->onlineorderid}" type="button" class="btn btn-default btn-lg removeicon confiDialog"></a>
                            </td>
                        </tr>
                        {assign var=i value=$i+1}
                        {/foreach}

                    </tbody>

                </table>
            </div>

            <div class="clearfix"></div>
            <!--            <hr />
                        <div  class="hidden-print">

                            <div class="col-lg-4 "> col-lg-offset-8
                                <div class="well well-sm">
                                    <h4 class="text-center">إجمالي المبيعات:  <span id="totalBills">{$totalBills}</span></h4>
                                </div>
                            </div>

                        </div>-->


        </div>
    </div>
</div>













<!------------------------Client Model----------------------------->
<!-- Modal -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">اختيار العميل</h4>
            </div>
            <div class="modal-body">
                <form id="clientInfo" action="#" method="post" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-lg-4 control-label">اسم العميل</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="supplier" id="supplier" >
                                <option></option>
                                {foreach $clientData as $client}

                                {if $client->clientid == 1}
                                <option  value="-2"  class="newoption">اضافة عميل جديد</option>
                                {else}
                                <option value="{$client->clientid}" data-mobile="{$client->clientmobile}">{$client->clientname}</option>
                                {/if}

                                {capture assign=y}{$y+1}{/capture}
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <input type="hidden" id="choosenOrderid" value=""/>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default savemodel2" data-dismiss="modal">لا</button>
                <button type="button" class="btn btn-primary savemodel1" onClick="yesfunction();">نعم</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
{literal}
<script>
    function yesfunction() {
        var client = Number($('#supplier').val());
        if (client > 0 || client == -2) {
            var id = $('#choosenOrderid').val();
            var link = $('#' + id).data('link');
            link += '&client=' + client;
            window.location = link;
        } else {
            alert('اختر عميل اولا');
        }
    }
    $('.chooseClientDialoge').click(function () {
        var erpid = Number($(this).data('erpid'));
        if (erpid > 0) {
            var txt;
            var r = confirm("هل انت متأكد ؟");
            if (r == true) {
                //txt = "You pressed OK!";
                window.location = $(this).data('link');
            }
        } else {
            $('#choosenOrderid').val($(this).attr('id'));
            $('#myModal1').modal('show');
        }
    });
    $('.confiDialog').click(function () {
        var txt;
        var r = confirm("هل انت متأكد ؟");
        if (r == true) {
            //txt = "You pressed OK!";
            window.location = $(this).data('link');
        }
//        else {
//            txt = "You pressed Cancel!";
//        }
    });
</script>
{/literal}