<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;
    }
    th,td{
            text-align: center;
        }

    @media print {
        .table-black {
            // border : 1px solid black;
        }

        td,
        th{
            border: 1px solid #000 !important;
        }


        label {
            padding-top: 20px;
        }
        th,td{
            text-align: center;
        }

        .table thead{
            background-color:#3276b1!important;
        color:#fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        }

        /* 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,
        .panel-heading,
        tr.odd td.sorting_1 {
            color: #000 !important
        } */
    }
</style>

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

                    {/if}

                    <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">
                        {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>
                    {/if}
                    <div class="clearfix"></div>
                    <table class="table table-black" style="text-align:center">
                        <thead>
                            <tr>
                                <th>اسم الخزينة</th>
                                <th>اسم العملية</th>
                                <th>اسم المستخدم</th>
                                <th>التاريخ</th>
                                <th>نوع العمليه</th>

                                <th>
                                    <table class="table table-black " 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}

                            {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>{$savedaily->savename}</td>
                                <td>
                                    {$savedaily->processname}
                                    {if ($savedaily->personName <> '0' && $savedaily->personName <> '')
                                            ||$savedaily->savecurrentvalue !=""}
                                            -- ({$savedaily->savecurrentvalue}){*$savedaily->personName*}
                                            {/if}
                                            {if {$savedaily->tablename} eq "buyBillController.php" ||
                                            {$savedaily->tablename} eq "returnBuyBillController.php" ||
                                            {$savedaily->tablename} eq "buyAndReturnBillController.php"
                                            || {$savedaily->tablename} eq "sellbillController.php" ||
                                            {$savedaily->tablename} eq "sellbillandruternController.php"
                                            ||{$savedaily->tablename} eq "returnsellbillController.php"}
                                            رقم الفاتورة {$savedaily->savedailymodelid}
                                            {/if}
                                </td>
                                <td>{$savedaily->username}</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="table-black">

                                        <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 "> <a
                                        href="savedailyController.php?do=showDetail&savedailyid={$savedaily->savedailyid}"
                                        type="button" class="btn btn-default btn-lg editicon"></a> </td>
                            </tr>
                            {/if}
                            {/foreach}
                            <tr>
                                {if $burex <> 1}
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    {else}
                                    <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 class="hidden-print "></td>
                                        {/if}
                                        <td class="hidden-print "></td>
                                        <td class="hidden-print "></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}