<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[136]->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="saleswithdetaileddiscount.php" method="post">
                    <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 />
                    <div class="form-group">
                        <label class="sr-only">المحافظة</label>
                        <select class="select2 wdt300 governmentId"  name="governmentId" id="governmentId" >
                            <option value="-1">اختر محافظة</option>
                            <option value="0">كل المحافظات</option>
                            {foreach $governmentData as $govern}
                            <option value="{$govern->governmetid}">{$govern->governmentname}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div id="manyareas">

                    </div>
                    <br>
                    <!--if $user->userstoreid == 0-->
                    <div class="form-group">
                        <label class="sr-only">المخزن</label>
                        <select class="select2 wdt300"  name="storeId" id="storeId" >
                            <option value="-1">اختر مخزن</option>
                            <option value="0">كل المخازن</option>
                            {foreach $storeData as $store}
                            <option value="{$store->storeId}">{$store->storeName}</option>
                            {/foreach}
                        </select>
                    </div><br>
                    <!--/if-->
                    {if $user->branchId == 0}
                    <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>
                    {/if}
                    <div class="form-group">
                        <label class="sr-only">{if $Programsettingdata->delegate_seller eq 0} البائعين {elseif $Programsettingdata->delegate_seller == 1}المندوبين {elseif $Programsettingdata->delegate_seller == 2}الاطباء {/if}</label>
                        <select class="select2 wdt300"  name="sellerid" id="sellerid" >
                            <option value="-1">اختر {if $Programsettingdata->delegate_seller eq 0} البائعين {elseif $Programsettingdata->delegate_seller == 1}المندوبين {elseif $Programsettingdata->delegate_seller == 2}الاطباء {/if}</option>
                            <option value="0">كل >{if $Programsettingdata->delegate_seller eq 0} البائعين {elseif $Programsettingdata->delegate_seller == 1}المندوبين {elseif $Programsettingdata->delegate_seller == 2}الاطباء {/if}</option>
                            {foreach $sellerData as $user}
                            <option value="{$user->userid}">{$user->employeename}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">المستخدم</label>
                        <select class="select2 wdt300"  name="userid" id="userid" >
                            <option value="-1">اختر المستخدم</option>
                            <option value="0">كل المستخدمين</option>
                            {foreach $userData as $user}
                            <option value="{$user->userid}">{$user->employeename}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div style="clear: both"></div>
                    <br />

                    <div class="form-group col-lg-3">
                        <label class="sr-only">تصنيف المنتج</label>
                        <select class="select2 wdt300 productCat" data-level="0"  name="productCatId0" id="productCatId0" >
                            <option value="-1">اختر تصنيف</option>
                            {foreach $catDataReport as $data}
                            <option value="{$data->productCatId}">{$data->productCatName}</option>
                            {/foreach}
                        </select>
                        <input type="hidden" id="level" name="level" value="0">
                    </div>
                    <div id="manyParents">

                    </div>
                    <input type="hidden" name="searchtype" value="0"/>

                    <div style="clear: both"></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>
                <div class="panel-body">
                    {if $resultsCount > 0}
                    <div class=" col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى المبيعات {$totalsObj->soldVal - $totalsObj->returnVal} {$currency}</h4>
                        </div>
                    </div>
                    <div class=" col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى الخصومات {$totalsObj->discount} {$currency}</h4>
                        </div>
                    </div>
                    <div class=" col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى صافى المبيعات {$totalsObj->soldVal - $totalsObj->returnVal - $totalsObj->discount} {$currency}</h4>
                        </div>
                    </div>
                    <style>
                        @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>
                    <table class="dataTableClass willprint table-black" style="width: 100%">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>اسم المنتج</th>
                                <th>عدد </th>
                                <th>سعر البيع </th>
                                <th>قيمة الخصم </th>
                                <th>صافى المبيعات </th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=1}
                            {foreach $allDataArr as $data}
                            <tr>
                                <td>{$i}</td>
                                <td>{$data->productName}</td>
                                <td>{$data->soldNo - $data->returnNo}</td>
                                <td>{$data->soldVal - $data->returnVal}</td>
                                <td>{$data->discount}</td>
                                <td>{$data->soldVal - $data->returnVal - $data->discount}</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 - $totalsObj->returnNo}</td>
                                <td>{$totalsObj->soldVal - $totalsObj->returnVal}</td>
                                <td>{$totalsObj->discount}</td>
                                <td>{$totalsObj->soldVal - $totalsObj->returnVal - $totalsObj->discount}</td>

                            </tr>
                        </tbody>

                    </table>

                    <div class=" col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى القيم {$totalsObj->soldVal - $totalsObj->returnVal} {$currency}</h4>
                        </div>
                    </div>
                    <div class=" col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى الخصومات {$totalsObj->discount} {$currency}</h4>
                        </div>
                    </div>
                    <div class=" col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">الصافى {$totalsObj->soldVal - $totalsObj->returnVal - $totalsObj->discount} {$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>
