<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;
    }
</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[142]->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="disountreport.php" method="post" id="salesreportbills-form">
                    <div class="form-group col-lg-2">
                        <label class="sr-only">نسبة الخصم من</label>
                        <input type="text" class="form-control input-small positivefloat percentage"  name="discountfrom">
                    </div>
                    <div class="form-group col-lg-2">
                        <label class="sr-only">نسبة الخصم إلى</label>
                        <input type="text" class="form-control input-small positivefloat percentage"  name="discountto">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">الفرع</label>
                        <select class="select2 wdt300"  name="branchId" id="branchId" >
                            <option value="-1">اختر الفرع</option>
                            <option value="0">كل الفروع</option>
                            {foreach $branchData as $branch}
                            <option value="{$branch->branchId}">{$branch->branchName}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div style="clear: both"></div>
                    <br />
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="datefrom" >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="dateto" >
                    </div>

                    <div style="clear: both"></div>
                    <br />
                    <button type="submit" class="btn btn-primary">بحث</button>
                    <input type="hidden" name="branchIdS" value="{$branchIdS}"/>
                    <input type="hidden" name="clientidS" value="{$clientidS}"/>
                    <input type="hidden" name="billidS" value="{$billidS}"/>
                    <input type="hidden" name="billtypeS" value="{$billtypeS}"/>
                    <input type="hidden" name="day" id="day" value=""/>
                </form>

            </div>
            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body" style="overflow-x: auto;">
                    {if count($allDataArr) > 0}
                    <hr/>
                    <div class="col-lg-offset-8 col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">صافى الربح {$totalsObj->billProfit} {$currency}</h4>
                        </div>
                    </div>
                    <style>
                        @media print {
                            .dataTables_filter , .dataTables_length{
                                display: none;
                            }
                            @page {
                                size: landscape;
                                margin: 0;
                            }
                            .willprint ,.willprint td,.willprint th {
                                padding:  0px !important;
                                font-family: arial;
                                font-size: 10px;
                                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>
                    {if $searchtype == "0"}
                    <table class="dataTableClass willprint table-black" style="width: 100%">
                        <thead>
                            <tr>
                                <th><center>م</center></th>
                        <th><center>  التسلسل</center></th>
                        <!--                                <th><center>رقم الفاتورة</center></th>-->
                        <th><center>نوع الفاتورة</center></th>
                        <th><center>اجمالى الفاتورة</center></th>
                        <th><center>عدد القطع</center></th>
                        <th><center>تاريخ الفاتورة ووقتها</center></th>
                        <th><center>خصم الفاتورة</center></th>
                        <th><center>خصومات الشبكة</center></th>
                        <th><center>ربح الفاتورة</center></th>
                        <th><center>العميل</center></th>
                        <th><center>البائع</center></th>
                        <th><center>المستخدم</center></th>
                        <th class="hidden-print"><center>تفاصيل الفاتورة</center></th>
                        </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=1}
                            {foreach $allDataArr as $data}
                            <tr>
                                <td><center>{$i}</center></td>
                        <td><center>{$data->billno}</center></td>
                        <!--<td><center>{$data->billserial}</center></td>-->
                        <td><center>{$data->billtype}</center></td>
                        <td><center>{$data->totalbill}</center></td>
                        <td><center>{$data->noOfpieces}</center></td>
                        <td><center>{$data->datetime}</center></td>
                        <td><center>{$data->billdiscount}</center></td>
                        <td><center>{$data->networkDiscount}</center></td>
                        <td><center>{$data->billProfit}</center></td>
                        <td><center>{$data->clientName}</center></td>
                        <td><center>{$data->sellerName}</center></td>
                        <td><center>{$data->userName}</center></td>
                        <td class="hidden-print"><center><a href="{$data->billURL}" class="notesicon" target="_blank" ><u>{$data->billId}</u></a></center></td>
                        </tr>
                        {assign var=i value=$i+1}
                        {/foreach}
                        <tr>
                            <td><center><span style="display: none">z</span></center></td>
                        <td></td>
                        <td></td>
                        <th style="text-align: center;"><center>الاجمالى</center></th>
                        <td><center>{$totalsObj->totalbill}</center></td>
                        <td><center>{$totalsObj->noOfpieces}</center></td>
                        <td></td>
                        <td><center>{$totalsObj->billdiscount}</center></td>
                        <td><center>{$totalsObj->networkDiscount}</center></td>
                        <td><center>{$totalsObj->billProfit}</center></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td class="hidden-print"></td>
                        </tr>


                        </tbody>

                    </table>
                    {else}
                    <table class="dataTableClass willprint table-black" style="width: 100%">
                        <thead>
                            <tr>
                                <th>م</th>
                                <th>تاريخ الفاتورة ووقتها</th>
                                <th>اجمالى الفاتورة</th>
                                <th>عدد القطع</th>
                                <th>خصم الفاتورة</th>
                                <th>خصومات الشبكة</th>
                                <th>ربح الفاتورة</th>

                                <th class="hidden-print">تفاصيل الفاتورة</th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=1}
                            {foreach $allDataArr as $data}
                            <tr>
                                <td>{$i}</td>
                                <td>{$data->datetime}</td>
                                <td>{$data->totalbill}</td>
                                <td>{$data->noOfpieces}</td>
                                <td>{$data->billdiscount}</td>
                                <td>{$data->networkDiscount}</td>
                                <td>{$data->billProfit}</td>

                                <td class="hidden-print"><a data-day="{$data->datetime}" style="color: blue;" class="daydetail">التفاصيل</a></td>
                                <!--td class="hidden-print">{$data->billURL}</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->totalbill}</td>
                                <td>{$totalsObj->noOfpieces}</td>
                                <td>{$totalsObj->billdiscount}</td>
                                <td>{$totalsObj->networkDiscount}</td>
                                <td>{$totalsObj->billProfit}</td>
                                <td class="hidden-print"></td>
                            </tr>


                        </tbody>

                    </table>
                    {/if}

                    <div class="col-lg-offset-8 col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">صافى الربح {$totalsObj->billProfit} {$currency}</h4>
                        </div>
                    </div>

                    <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-->
                    {else}
                    <div class="nodata">عفوا لا توجد نتائج</div>
                    {/if}

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


{literal}
<script>
    $(document).ready(function () {
        $('.daydetail').on('click', function () {
            var day = $(this).attr('data-day');
            $('#day').val(day);
            $('#salesreportbills-form').attr("target", "_blank");
            $('#salesreportbills-form').submit();
            $('#day').val("");
            $('#salesreportbills-form').removeAttr("target");
        });
    });

    $('.percentage').live('keyup', function () {
        if ($(this).val() < 0)
        {
            $(this).val(0);
        }
        else if ($(this).val() > 100) {
            $(this).val(100);
        }
    });
</script>
{/literal}
