<style>
    .myresult {
        -webkit-print-color-adjust: exact;
    }
    .nodata{
        background-color: #72B4EC;
        color: white;
        border-radius: 13px;
        margin: 14px;
        font-size: 24px;
        text-align: center;
        padding: 5px;
    }

    @media print {
        @page {
            size: landscape;
            margin: 0;
        }
        .willprint ,.willprint td,.willprint th {
            font-family: arial;
            font-size: 14px;
            border-collapse: collapse;
            border: 1px solid #333 !important;
        }
        /* .willprint th{
            background: #aaa !important;
        } */
        .willprint tr:even-child td{
            background: #333 !important;
            color: #fff !important;
        }
    }

</style>



<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">التقارير</a></li>
            <li class="active">تقرير ترتيب العملاء بصافى المبيعات</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير ترتيب العملاء بصافى المبيعات
                <a href="{$youtubes[137]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
            </div>
            <div class="panel-body">
                <form class="form-inline hidden-print" action="orderClientsWithSelles.php" method="post">
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"  value="{$datefrom}" data-date-format="yyyy-mm-dd" name="datefrom" id="datefrom" >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"  value="{$dateto}" data-date-format="yyyy-mm-dd" name="dateto" id="dateto" >
                    </div>

                    <br />
                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>

            </div>
            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>


                {if $resultsCount > 0 }
                <table class="stable dataTableClass22 willprint table-black" style="width: 100%">
                    <thead>
                        <tr>
                            <th >#</th>
                            <th > اسم العميل</th>
                            <th >المبيعات </th>
                            <th >المرتجعات</th>
                            <th > المبيعات بدون الخصومات</th>
                            <th >   الخصومات</th>
                            <th >   صافى المبيعات</th>
                            <th >مديونيه العميل </th>
                            <th >مدفوعات عميل </th>
                        </tr>

                    </thead>
                    <tbody>

                        {assign var=i value=1}
                        {foreach $sellbillDataArr as $data}
                        {assign var=sum value=0}

                        <tr>
                            <td >{$i}</td>
                            <td >
                                <a href="javascript:;"  data-id="{$data->clientid}" class="getSellersData">{$data->clientname}</a></td>
                            <td >{$data->totalsell}</td>
                            <td >{$data->totalreturn}</td>
                            <td >{if $data->totalreturn <= 0 }
                                {$sum = {$data->totalsell  +   $data->totalreturn} }
                                {$sum}
                                {else}
                                {$sum = {$data->totalsell  -   $data->totalreturn}}
                                {$sum}
                                {/if}
                            </td>
                            <td >{$data->t_dis}</td>
                            <td >{$data->t_bure}</td>
                            <td >{$data->clientdebt}</td>
                            <td >{$data->totalPrice}</td>

                        </tr>
                        {assign var=i value=$i+1}
                        {/foreach}
                        <!--                            <tr>
                                                        <td><span style="display: none">z</span></td>
                                                        <th style="text-align: center;">الاجمالى</th>
                                                        <td>{$totalsObj->soldNo}</td>
                                                        <td>{$totalsObj->soldVal}</td>
                                                        <td>{$totalsObj->returnNo}</td>
                                                        <td>{$totalsObj->returnVal}</td>
                                                        <td>{$totalsObj->netNo}</td>
                                                        <td>{$totalsObj->netVal}</td>
                                                        <td>{$totalsObj->realCost}</td>
                                                        <td>{$totalsObj->netProfit}</td>
                                                        <td>{$totalsObj->currentQuantity}</td>
                                                    </tr>-->
                    </tbody>

                </table>
                <div class="col-lg-4 col-lg-offset-8">
                    <div class="well well-sm ">
                        <h4 class="text-center">اجمالى الخصومات  {$t_discount}</h4>
                    </div>
                </div>
              


              
                {else}
                <div class="nodata">عفوا لا توجد نتائج</div>
                {/if}

                <div class="clearfix"></div>
                <hr />
                <div  class="noprint">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <div class="col-lg-4">
                                <button type="button" onclick="print_Custom('mycustomheader');" class="btn btn-success pull-right hidden-print">طباعة</button>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>


                <div class="clearfix"></div>
            </div>
        </div>
    </div>

    <div  class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog"  style="width:600px;">
            <div class="modal-content">
                <div class="modal-header text-center">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true" class="text-left">&times;</span><span class="sr-only"></span></button>
                    <h3 class="modal-title" id="myModalLabel">تفاصيل البائعين</h3>
                </div>
                <div class="modal-body">
                        <div class="card" id="sellerDataDiv">


                        </div>
                        <!-- end of title row-->


                        <div class="row  hidden-print m10" >
                            <div class="col-lg-12 text-center">
                                <button type="button"  data-dismiss="modal"   class="btn btn-primary">
                                    <i class="glyphicon glyphicon-ok "></i>  رجوع</button>
                            </div>



                        </div>
                        <!-- end of fifth row-->

                </div>

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

    {literal}
    <script>
        $('.getSellersData').on('click',function(){
            var clientid = $(this).data('id');
            var datefrom = $('#datefrom').val();
            var dateto = $('#dateto').val();
            $.post('orderClientsWithSelles.php?do=showsellersajax',{clientid:clientid,datefrom:datefrom,dateto:dateto},function(res){
                $('#myModal').modal('show');
                $('#sellerDataDiv').html(res);
            });
        });
    </script>
    {/literal}
