<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[102]->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">

                <!---------- start outputString alert ----------->
                <div id="outputString" class="alert alert-block alert-success fade in" style="display:none">
                    <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <p id="outputStringValue">{$outputString}</p>
                    <div class="clearfix"></div>
                </div>
                <!---------  end outputString alert ------------>

                <form class="form-inline hidden-print" method="post" action="expensesReportController.php">
                    <div class="form-group">
                        <label class="sr-only">إسم نوع المصروف</label>
                        <select data-placeholder="اختر نوع المصروف"  class="select2 wdt100"  name="expensestypeid" id="expensestypeid" >
                            <option value="-1">اختر نوع المصروف</option>


                            {foreach $alldata as $type}

                            <option value="{$type->expensestypeid}">{$type->expensestypename}</option>

                            {/foreach}

                        </select>

                    </div>
                    <div class="form-group"   {if $Programsettingdata->expensesproduct eq 0} {else} style="display:none" {/if}>
                        <label class="sr-only ">المنتجات</label>
                        <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>
                        <input type="text" name="productid" id="productid" class="select2product wdt100 clas_offerproduct" data-itr='1'  data-placeholder="اختر منتج" tabindex="301"/>
                    </div>
                    <div class="form-group" {if $Programsettingdata->costcenter eq 0} {else} style="display:none" {/if}  >
                        <label class="sr-only">مركز التكلفه</label>
                        <select class="select2 wdt100" name="Costcenterid" id="Costcenterid" >
                            <option value="-1" >اختر مركز التكلفه</option>
                            {foreach $allCostcenter as $myallCostcenter}
                            <option value="{$myallCostcenter->id}" {if $myallCostcenter->id eq $projectid}selected=""{/if}>{$myallCostcenter->name}</option>
                            {/foreach}
                        </select>
                    </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="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>
                    <button type="submit" class="btn btn-primary hidden-print">بحث</button>
                </form>
                <div class="panel panel-default">
                    <!-- Default panel contents -->
                    <div class="panel-heading">{$message}</div>
                    <div class="panel-body">
                        <div class="col-lg-2">
                            <table style="border-spacing: 5px; border-collapse: separate;">
                                <tr>
                                    <td><div style="background-color: #f2dede;width: 22px;height: 20px"></div></td>
                                    <td>المصروف محذوف</td>
                                </tr>
                                <tr class="hidden-print">
                                    <td><div style="background-color: #ce93d8;width: 22px;height: 20px"></div></td>
                                    <td>نوع المصروف محذوف</td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-lg-offset-6 col-lg-4 hidden-print">
                            <div class="well well-sm">
                                <h4 class="text-center">إجمالي المصروفات:  {$sum}</h4>

                            </div>

                        </div>
                        <br /><br /><br /><br /><br />
                        <!-- Table -->
                        <table class="table table-black">
                            <thead>
                                <tr>

                                    <th>إسم المصروف</th>
                                    <th>نوع المصروف</th>
                                    <th>الخزنة / البنك</th>
                                    {if $Programsettingdata->expensesproduct eq 0}
                                    <th>المنتج</th>
                                    {/if}
                                    {if $Programsettingdata->costcenter eq 0}
                                    <th>مركز التكلفه</th>
                                    {/if}
                                    <th>التاريخ</th>
                                    <th>المبلغ</th>
                                    <th style="width: 20%">التعليق</th>
                                </tr>
                            </thead>
                            <tbody>

                                {foreach $expenseData as $data}
                                {if {$data->conditions} eq 1}
                                <tr class="danger">
                                    {elseif $data->expensestypeConditions == 1}
                                <tr style="background-color: #ce93d8">
                                    {else}
                                <tr>
                                    {/if}

                                    <td> {$data->expensesname} </td>
                                    <td>{$data->expensestypename}</td>
                                    <td>{if $data->saveid > 0} {$data->savename} {else} {$data->bankname}/{$data->accountname} {/if}</td>
                                    {if $Programsettingdata->expensesproduct eq 0}
                                    <td>{$data->productName}</td>
                                    {/if}
                                    {if $Programsettingdata->costcenter eq 0}
                                    <td>{$data->name}</td>
                                    {/if}
                                    <td>{$data->expensesdate}</td>
                                    <td>{$data->expensesValue}</td>
                                    <td>{if {$data->expensesdetails} <> ""}
                                        {$data->expensesdetails}
                                        {else } لا يوجد تعليق
                                        {/if} </td>

                                </tr>
                                {/foreach}

                            </tbody>

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

                            <div class="col-lg-offset-8 col-lg-4 ">
                                <div class="well well-sm">
                                    <h4 class="text-center">إجمالي المصروفات:  {$sum}</h4>
                                </div>
                            </div>
                            <div class="clearfix"></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>
                </div>
            </div>
        </div>


        {literal}

        <script type="text/javascript">

            $(document).ready(function () {
                $(".positiveNo").forcepositiveNum();
                var formatResult;
                formatResult = function (data) {

                    return  data.text;
                }
                $("#productid").select2({
                    placeholder: "إسم المنتج",
                    width: '100%',
                    minimumInputLength: document.getElementById("searchvalue").value,
                    multiple: false,
                    quietMillis: 100,
                    ajax: {
                        url: "sellbillAjaxController.php?do=getProductsexpenses",
                        dataType: 'json',
                        data: function (term, page) {
                            return {
                                term: term, //search term
                                page_limit: 10,

                            };
                        },
                        results: function (data) {
                            return {results: data};
                        }
                    },
                    formatResult: formatResult,
                    initSelection: function (element, callback) {
                        var item = element.val().split(':');
                        var data = {id: item[0], text: item[1]};
                        callback(data);
                    }
                });

            });
        </script>
        {/literal}