<div class="container">
    <ol class="breadcrumb">
        <li><a href="#">الفواتير</a></li>
        <li><a href="#">فواتير</a></li>
        <li class="active">عرض الفواتير</li>
    </ol>
    <div class="panel panel-default panel-m">
        <!-- Default panel contents -->
        <div class="panel-heading">الفواتير   <br /></div>
        <div class="panel-body">
            <ul class="nav nav-tabs">
                <li class="active"><a href="#allbills_tab" data-toggle="tab">كل الفواتير</a></li>
                <li><a href="#decide_tab" data-toggle="tab">فواتير تأمين تنتظر الموافقة</a></li>
                <li><a href="#accepted_tab" data-toggle="tab">فواتير تأمين تم اعتمادها</a></li>
                <li><a href="#rejeted_tab" data-toggle="tab">فواتير تأمين تم رفضها</a></li>
            </ul>
            <div class="tab-content">
                <!-- tab1 ------------------------------------>
                <div class="tab-pane active" id="allbills_tab">
                    <form class="form-inline hidden-print" action="#" method="post">
                        <div class="form-group wds20">
                            <label class="sr-only">إسم العميل</label>
                            <select id="client1" name="client" class="select2" data-placeholder="اختر " class=" wdt100 ">
                                <option value="-1"></option>
                                {foreach $clientData as $client}
                                <option value="{$client->clientid}">{$client->clientname} </option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds20">
                            <label class="sr-only">رقم الفاتورة</label>
                            <select data-placeholder="اختر رقم الفاتورة" class=" wdt100 select2" id="billNo" >
                                <option value="-1"></option>
                                {foreach $billsNo as $no}
                                <option value="{$no->billno}">{$no->billno}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">من التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="fromDate" >
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">إلى التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="toDate" >
                        </div>
                        <button type="button" class="btn btn-primary noprint searchBills">بحث</button>
                    </form>
                    <hr/>
                    <!------------------------------------------>
                    <form class="form-inline" action="bills.php?do=executeOperation" method="post">
                        <div id="searchResult">
                            <div class="col-lg-offset-8 col-lg-4 ">
                                <div class="well well-sm">
                                    <h4 class="text-center">إجمالي الفواتير    {$totalBalance}</h4>
                                </div>
                            </div>
                            <div class="clearfix"></div>

                            <!-- Table -->
                            <table class="table table-black">
                                <thead>
                                    <tr>
                                        <th class="hidden-print">
                                            <label>
                                                <input type="checkbox" name="checkAll" id="checkAll"/>
                                            </label>
                                        </th>
                                        <th>رقم المسلسل</th>
                                        <th>اسم العميل</th>
                                        <th>رقم الفاتورة</th>
                                        <th>إجمالي الفاتورة</th>
                                        <th>التاريخ</th>
                                        <th>المستخدم</th>
                                        <th>مكان  الاضافه </th>
                                        {if $usergroup->allowEditDelInBills eq 0}<th class="hidden-print">التعديل</th>{/if}
                                        <th class="hidden-print">تفاصيل الفاتورة</th>
                                        {if $usergroup->allowEditDelInBills eq 0}<th class="hidden-print">حذف</th>{/if}
                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=i value=1}
                                    {foreach $bills as $data}
                                    {if {$data->deleted} eq 1}
                                    <tr class="danger"> {elseif {$data->deleted} eq 0}
                                    <tr> {/if}
                                        <td class="hidden-print">
                                            <label>
                                                <input type="checkbox" name="choosedItem[]" id="checked{$i}" class="choosenItem" value="{$data->id}" />
                                            </label>
                                        </td>
                                        <td>{$i}</td>
                                        <td> {$data->clientname} </td>
                                        <td>{$data->billno}</td>
                                        <td>{$data->finalnetbillvalue}</td>
                                        <td>{$data->billdate}</td>
                                        <td>{$data->username}</td>
                                        <td>{if $data->offline == 1 }محليا   {else}  على السيرفر الرئيسى مباشرة  {/if}</td>
                                        {if $usergroup->allowEditDelInBills eq 0}
                                        <td  class="hidden-print">
                                            {if ($data->insurance == 1 && $data->approved == 0)||$data->insurance != 1}
                                            {if {$data->deleted} eq 0}
                                            <a href="bills.php?do=edit&id={$data->id}" type="button" class="btn btn-default btn-lg editicon"></a>
                                            {else}
                                            تم حذف الفاتوره
                                            {/if}
                                            {else}
                                            {if $data->approved == 1}تم الموافقة على الفاتورة{else}تم رفض الفاتورة{/if}
                                            {/if}
                                        </td>{/if}
                                        <td  class="hidden-print"><a href="bills.php?do=details&id={$data->id}" type="button" class="btn btn-default btn-lg notesicon"></a></td>

                                        {if $usergroup->allowEditDelInBills eq 0}
                                        <td  class="hidden-print">
                                            {if ($data->insurance == 1 && $data->approved == 0)||$data->insurance != 1}
                                            {if {$data->deleted} eq 0}
                                            <a href="bills.php?do=delete&id={$data->id}" type="button" class="btn btn-default btn-lg deleteicon"></a>
                                            {elseif $data->deleted eq 1 }
                                            تم حذف الفاتورة
                                            {/if}
                                            {else}
                                            {if $data->approved == 1}تم الموافقة على الفاتورة{else}تم رفض الفاتورة{/if}
                                            {/if}
                                        </td>
                                        {/if} </tr>
                                    {capture assign=i}{$i+1}{/capture}
                                    {/foreach}
                                </tbody>

                            </table>
                            <div  class="hidden-print">

                                <div class="col-lg-offset-8 col-lg-4 ">
                                    <div class="well well-sm">
                                        <h4 class="text-center">إجمالي الفواتير    {$totalBalance}</h4>
                                    </div>
                                </div>
                                <div class="clearfix"></div>
                            </div>
                        </div>

                        <div class="col-lg-12">
                            <div class="well well-sm">
                                <div class="form-group col-lg-4">
                                    <div class="col-lg-12">
                                        <label for="operation"></label>
                                        <span id="spryselect2">
                                            <select name="operation" id="operation"  data-placeholder="اختر العملية" class=" wdt100">
                                                <option value="-1"></option>
                                                <option value="1">حذف</option>
                                            </select>
                                            <span class="selectInvalidMsg">اختر العملية</span></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-4">
                                        <input name=""  class="noprint btn btn-primary" type="submit" value="تنفيذ"/>
                                    </div>
                                </div>

                                <!-----------  start noElementsError alert ------------->
                                <div class="clearfix"></div>
                                <div id="noElementsError" class="alert alert-danger fade in" style="display:none;">
                                    <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">×</button>
                                    <p>يجب اختيار العناصر أولاً</p>
                                    <div class="clearfix"></div>
                                </div>
                                <!----------  end noElementsError alert -------------->

                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </form>
                    <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>
                <!-- tab2 ------------------------------------>
                <div class="tab-pane" id="decide_tab">
                    <form class="form-inline hidden-print" action="#" method="post">
                        <div class="form-group wds20">
                            <label class="sr-only">إسم العميل</label>
                            <select id="client2" name="client2" class="select2" data-placeholder="اختر " class=" wdt100 ">
                                <option value="-1"></option>
                                {foreach $clientData as $client}
                                <option value="{$client->clientid}">{$client->clientname} </option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds20">
                            <label class="sr-only">رقم الفاتورة</label>
                            <select data-placeholder="اختر رقم الفاتورة" class=" wdt100 select2" id="billNo2" >
                                <option value="-1"></option>
                                {foreach $billsNo2 as $no}
                                <option value="{$no->billno}">{$no->billno}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">من التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="fromDate2" >
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">إلى التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="toDate2" >
                        </div>
                        <button type="button" class="btn btn-primary noprint searchBills2">بحث</button>
                    </form>
                    <hr/>
                    <!------------------------------------------>
                    <div id="searchResult2"></div>
                </div>
                <!-- tab3 ------------------------------------>
                <div class="tab-pane" id="accepted_tab">
                    <form class="form-inline hidden-print" action="#" method="post">
                        <div class="form-group wds20">
                            <label class="sr-only">إسم العميل</label>
                            <select id="client3" name="client3" class="select2" data-placeholder="اختر " class=" wdt100 ">
                                <option value="-1"></option>
                                {foreach $clientData as $client}
                                <option value="{$client->clientid}">{$client->clientname} </option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds20">
                            <label class="sr-only">رقم الفاتورة</label>
                            <select data-placeholder="اختر رقم الفاتورة" class=" wdt100 select2" id="billNo3" >
                                <option value="-1"></option>
                                {foreach $billsNo3 as $no}
                                <option value="{$no->billno}">{$no->billno}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">من التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="fromDate3" >
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">إلى التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="toDate3" >
                        </div>
                        <button type="button" class="btn btn-primary noprint searchBills3">بحث</button>
                    </form>
                    <hr/>
                    <div id="searchResult3"></div>
                </div>
                <!-- tab4------------------------------------>
                <div class="tab-pane" id="rejeted_tab">
                    <form class="form-inline hidden-print" action="#" method="post">
                        <div class="form-group wds20">
                            <label class="sr-only">إسم العميل</label>
                            <select id="client4" name="client4" class="select2" data-placeholder="اختر " class=" wdt100 ">
                                <option value="-1"></option>
                                {foreach $clientData as $client}
                                <option value="{$client->clientid}">{$client->clientname} </option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds20">
                            <label class="sr-only">رقم الفاتورة</label>
                            <select data-placeholder="اختر رقم الفاتورة" class=" wdt100 select2" id="billNo4" >
                                <option value="-1"></option>
                                {foreach $billsNo4 as $no}
                                <option value="{$no->billno}">{$no->billno}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">من التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="fromDate4" >
                        </div>
                        <div class="form-group wds10">
                            <label class="sr-only">إلى التاريخ</label>
                            <input type="text" class="form-control awdatepicker "    data-date-format="yyyy-mm-dd" id="toDate4" >
                        </div>
                        <button type="button" class="btn btn-primary noprint searchBills4">بحث</button>
                    </form>
                    <hr/>
                    <div id="searchResult4"></div>
                </div>
            </div>

        </div>

    </div>
</div>



<!----------------------------------------------------------------------------->
<!-- Modal -->
<div class="modal fade hidden-print" id="rejectBillModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">تأكيد الرفض</h4>
            </div>
            <div class="modal-body">
                <label>
                    هل تريد رفض الفاتورة؟
                </label>
            </div>
            <input type="hidden" id="rejectBillId" name="rejectBillId" value=""/>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">لا</button>
                <button type="button" class="btn btn-primary rejectBill">نعم</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- =================================================   -->

<!-- Modal -->
<div class="modal fade in hidden-print" id="acceptBillModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">ادخال الموافقة</h4>
            </div>
            <div class="modal-body">
                <form id="acceptBillForm">
                    <!-- =================================================   -->
                    <div class="form-group col-lg-12">
                        <label class="col-lg-4 control-label">رقم الموافقة</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" placeholder="رقم الموافقة" id="acceptanceNo" name="acceptanceNo" required="required">
                        </div>
                    </div>
                    <div class="form-group col-lg-12">
                        <label class="col-lg-4 control-label"></label>
                        <div class="col-lg-6">
                            <span id="acceptanceNoError" class=" alert-block alert-danger fade in" style="padding: 3px;display: none ;"></span>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group col-lg-12">
                        <label class="col-lg-4 control-label">ارفاق ملف</label>
                        <div class="col-lg-6">
                            <input type="file" placeholder="الملف" id="acceptedFile" name="acceptedFile">
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <input type="hidden" id="acceptedBillId" name="acceptedBillId" value=""/>
                </form>
                <br/>
                <br/>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">لا</button>
                <button type="button" class="btn btn-primary acceptBill" >نعم</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- =================================================   -->
{literal}<script>
    $(document).ready(function (e) {


        //######################################### search in bills  #########################################
//tab1

//######################################### change discount  #########################################
    });

</script>
{/literal}