<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{
        /* .table-black{
            border : 1px solid black;
        }
        td,th ,.mytotal {
            border: 1px solid #000 !important;
        } */

        label {
            padding-top: 20px;
        }
        /* p,h4,h3,h2,h1,span,label,td,th,div.dataTables_info,a,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
        div.dataTables_wrapper div.dataTables_info, tr.odd td.sorting_1{
            color:#000!important
        } */
        .white tr,.white td{
            color:white!important;
        }
        .borderwhite{
            border:0!important;
        }
        .mytotal{
            float: left!important;
        }
    }

</style>

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">التقارير</a></li>
            <li><a href="savedailyController.php?do=showdailywithoptic">تقرير يومية الخزنة بالبصريات</a></li>
            <li class="active">عرض التقرير</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير يومية الخزنة بالبصريات
                <a href="{$youtubes[145]->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="savedailyController.php?do=showdailywithoptic" method="post">


                    {if $searchinonesave eq 0}
                    <div class="form-group">
                        <label class="sr-only">الخزنة</label>
                        <select class="select2 wdt100"  name="saveId" id="saveid" >
                            <option value="-1">اختر خزنة</option>


                            {foreach $saveData as $save}


                            <option value="{$save->saveid}">{$save->savename}</option>


                            {/foreach}


                        </select>
                    </div>

                    <div class="form-group">
                        <label class="sr-only">المخزن</label>
                        <select class="select2 wdt100"  name="storeId" id="storeId" >
                            <option value="-1">اختر مخزن</option>


                            {foreach $storeData as $store}


                            <option value="{$store->storeId}">{$store->storeName}</option>


                            {/foreach}


                        </select>
                    </div>

                    <div class="form-group">
                        <label class="sr-only">الفرع</label>
                        <select class="select2 wdt100"  name="storeId" id="storeId" >
                            <option value="-1">اختر الفرع</option>


                            {foreach $branchData as $branch}


                            <option value="{$branch->branchId}">{$branch->branchName}</option>


                            {/foreach}


                        </select>
                    </div>

                    {/if}

                    <div class="form-group">
                        <label class="sr-only">كاش</label>
                        <input type="checkbox" name="cash" checked="checked" id="cash" value="1">
                        <label for="cash"></label>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">تأمين</label>
                        <input type="checkbox" name="insurance" checked="checked" id="insurance" value="1">
                        <label for="insurance"></label>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">شبكة</label>
                        <input type="checkbox" name="network" checked="checked" id="network" value="1">
                        <label for="network"></label>
                    </div>

                    <br/>
                    {if $savedailydate eq 1}
                    <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" 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" 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 id="dateOnlyDiv">
                        <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="from" >
                        </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="to" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="sr-only">بحث بـ</label>
                        <div  class="input-group">
                            <label>  <input value="dateOnly" name="search" id="searchdateOnly" type="radio" checked onclick='localStorage.setItem("search", "dateOnly");
                                    window.location.reload();'>
                                تاريخ</label>
                            <label>
                                <input value="dateTime" name="search" id="searchdateTime" type="radio" onclick='localStorage.setItem("search", "dateTime");
                                        window.location.reload();'>
                                تاريخ ووقت</label>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    {/if}
                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>
            </div>

            <div class="clearfix"></div>
            <hr/>
            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                {if count($savedailyData)>0}
                <div class="panel-body"> {if {count($savedailyData)} > 0}
                    <div class="col-lg-offset-8 col-lg-4 hidden-print">
                        {if $savedailydate eq 1}
                        <div class="well well-sm mytotal">
                            <h4 class="text-center">الاجمالى {$sumValue} {$currency}</h4>
                        </div>

                        {/if}
                    </div>

                    <div class="col-lg-offset-8 col-lg-4 hidden-print">
                        <div class="well well-sm mytotal">
                            <h4 class="text-center">قيمة التغير {$changeAmountSum} {$currency}</h4>
                        </div>
                    </div>
                    {/if}
                    <div class="clearfix"></div>
                    <table class="table table-black">
                        <thead>
                            <tr>
                                <th> رقم الفاتورة</th>
                                <th> اسم العميل</th>
                                <th> اسم المستخدم</th>

                                <th>اسم الخزينة</th>
                                <th>اسم العملية</th>
                                <th>التاريخ</th>
                                <th>نوع العمليه</th>

                                <th> <table   class="table table-black white" border="1" width="100%"  style="text-align:center" >
                            <tr ><td colspan="2" > القيمة المتغيرة</td></tr>
                            <tr><td>ايراد</td><td>سحب</td></tr>

                        </table>
                        </th>

                        <th class="hidden-print ">تفاصيل </th>
                        <th class="hidden-print ">تفاصيل العملية بالخزنة</th>
                        </tr>
                        </thead>
                        <tbody>
                            {assign var=j value=0}
                            {assign var=k value=0}
                            {assign var=x value=1}

                            {foreach $savedailyData as $savedaily}


                            {if {$savedaily->savedailyid} > 0}
                            {if {$savedaily->savedailychangetype} eq 0}
                            {capture assign=j}{$j+{$savedaily->savedailychangeamount}}{/capture}
                            {elseif {$savedaily->savedailychangetype} eq 1 && {$savedaily->tablename} eq "returnsellbillController.php"}
                            {capture assign=k}{$k-{$savedaily->savedailychangeamount}}{/capture}

                            {else}
                            {capture assign=k}{$k+{$savedaily->savedailychangeamount}}{/capture}
                            {/if}

                            {if {$savedaily->savedailychangetype} eq 1}
                            <tr class="danger"> {elseif {$savedaily->savedailychangetype} eq 0}

                            <tr> {/if}

                                <td>{$x}</td>
                                <td>{if $savedaily->clientname neq ''}{$savedaily->clientname} {else} {$savedaily->personName} {/if}</td>
                                <td>{$savedaily->userName}</td>


                                <td>{$savedaily->savename}</td>
                                <td>
                                    {$savedaily->processname}
                                    {if $savedaily->personName <> '0' && $savedaily->personName <> '' }
                                    -- ({$savedaily->personName})
                                    {/if}
                                </td>
                                <td nowrap="nowrap">{$savedaily->savedailydate}</td>


                                <td>{if $savedaily->savedailychangetype eq 1}سحب {else} ايداع{/if}</td>
                                <td> <table border="1" width="100%"  style="text-align:center " class="borderwhite" >

                                        <tr><td width="50%">   {if {$savedaily->savedailychangetype} eq 0}{$savedaily->savedailychangeamount}{/if}</td><td width="50%">{if {$savedaily->savedailychangetype} eq 1}{$savedaily->savedailychangeamount}{/if}</td></tr>

                                    </table> </td>
                                <td class="hidden-print ">
                                    {if {$savedaily->tablename} eq "buyBillController.php" || {$savedaily->tablename} eq "returnBuyBillController.php"  || {$savedaily->tablename} eq "buyAndReturnBillController.php"}
                                    <a href="{$savedaily->tablename}?do=details&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>


                                    {elseif {$savedaily->tablename} eq "sellbillController.php" || {$savedaily->tablename} eq "sellbillandruternController.php"}

                                    <a href="{$savedaily->tablename}?do=showDetail&sellbillid={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>


                                    {elseif {$savedaily->tablename} eq "returnsellbillController.php"}

                                    <a href="{$savedaily->tablename}?do=showDetail&returnsellbillid={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {elseif {$savedaily->tablename} eq "bills.php" || {$savedaily->tablename} eq "billsreturn.php"}

                                    <a href="{$savedaily->tablename}?do=details&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {else}
                                    <a href="{$savedaily->tablename}?do=editprint&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {/if}


                                </td>
                                <td class="hidden-print ">
                                    {if $savedaily->link != "nosave"}
                                    <a href="savedailyController.php?do=showDetail&savedailyid={$savedaily->savedailyid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {/if}
                                </td>
                            </tr>
                            {/if}
                            {capture assign=x}{$x+1}{/capture}
                            {/foreach}
                            <tr>
                                {if $burex <> 1}
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                {else}
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                {/if}
                                <td> <table border="1" width="100%"  style="text-align:center" class="table-black">
                                        <tr><td width="50%">  {$j}</td><td width="50%">{$k}</td></tr>

                                    </table>
                                </td>
                                {if $burex <> 1}
                                <td></td>
                                {/if}
                                <!-- <td></td>
                                <td></td> -->
                            </tr>
                        </tbody>



                    </table>
                    <div class="col-lg-offset-8 col-lg-4">
                        {if $savedailydate eq 1}
                        <div class="well well-sm mytotal">

                            <h4 class="text-center ">الاجمالى {$sumValue} {$currency}</h4>

                        </div>
                        {/if}
                    </div>
                    <div class="col-lg-offset-8 col-lg-4">
                        <div class="well well-sm mytotal">
                            <h4 class="text-center">قيمة التغير {$changeAmountSum} {$currency}</h4>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <hr />
                    <div  class="hidden-print ">
                        <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">طباعة</button>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
            {else}
            <div class="nodata">عفوا لا توجد نتائج</div>
            {/if}
        </div>

        {literal}
        <script>
            var search = localStorage.getItem("search");
            if (search == "dateTime") {
                $('#searchdateTime').attr('checked', 'checked');
                $('#searchdateOnly').removeAttr('checked');
                //
                $('#dateTimeDiv').show();
                $('#dateOnlyDiv').remove();
            } else {
                $('#searchdateOnly').attr('checked', 'checked');
                $('#searchdateTime').removeAttr('checked');
                //
                $('#dateOnlyDiv').show();
                $('#dateTimeDiv').remove();
            }
        </script>
        {/literal}