<style>
    .myresult {
        -webkit-print-color-adjust: exact;
    }
</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[78]->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="tripsReport.php" method="post">
                    <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>


                    <div class="form-group">
                        <label class="sr-only">نوع الرحلة</label>
                        <input type="hidden" name="triptypeid" id="triptypeid"/>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">الرحلة</label>
                        <input type="hidden" name="tripid" id="tripid"/>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">خط السير</label>
                        <input type="hidden" name="pathid" id="pathid"/>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">مواعيد الرحلات</label>
                        <input type="hidden" name="tripdateid" id="tripdateid"/>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">الاتوبيس</label>
                        <input type="hidden" name="busid" id="busid"/>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">السائق</label>
                        <input type="hidden" name="driverid" id="driverid"/>
                    </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">بحث</button>
                </form>
            </div>

            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body">



                    <div class="panel panel-default panel-m" style="width: 49%;display: inline;float: right">
                        <!-- Default panel contents -->
                        <div class="panel-heading">ايرادات الرحلة</div>
                        <div class="panel-body">
                            <table class="table table-black dataTableClass">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>التاريخ</th>
                                        <th>نوع الايراد</th>
                                        <th>القيمة</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=totalIncome value=0}
                                    {assign var=i value=1}
                                    {foreach $billData as $data}
                                    <tr>
                                        <td>{$i}</td>
                                        <td>{$data['sellbilldate']}</td>
                                        <td>دفع فى الفاتورة</td>
                                        <td><a href="sellbillController.php?do=showDetail&sellbillid={$data['sellbillid']}" target="_blank" style="color:blue">{$data['sellbilltotalpayed']}</a></td>
                                    </tr>
                                    {assign var=totalIncome value=$totalIncome + $data['sellbilltotalpayed']}
                                    {assign var=i value=$i+1}
                                    {/foreach}
                                    {foreach $paymentData as $data}
                                    <tr>
                                        <td>{$i}</td>
                                        <td>{$data['clientdebtchangedate']}</td>
                                        <td>تحصيل على الفاتورة</td>
                                        <td><a href="clientPayedDeptSellBillsController.php?do=show_details&id={$data['billid']}" target="_blank" style="color:blue">{$data['clientdebtchangeamount']}</a></td>
                                    </tr>
                                    {assign var=totalIncome value=$totalIncome + $data['clientdebtchangeamount']}
                                    {assign var=i value=$i+1}
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="panel panel-default panel-m" style="width: 49%;display: inline;float: left">
                        <!-- Default panel contents -->
                        <div class="panel-heading">مصروفات الرحلة</div>
                        <div class="panel-body">
                            <table class="table table-black dataTableClass">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>التاريخ</th>
                                        <th>المصروف</th>
                                        <th>القيمة</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=totalExpense value=0}
                                    {assign var=i value=1}
                                    {foreach $expenses as $data}
                                    <tr>
                                        <td>{$i}</td>
                                        <td>{$data['expensesdate']}</td>
                                        <td>{$data['expensesname']}</td>
                                        <td><a href="expensesController.php?do=show&id={$data['expensesid']}" target="_blank" style="color:blue">{$data['expensesValue']}</a></td>
                                    </tr>
                                    {assign var=totalExpense value=$totalExpense + $data['expensesValue']}
                                    {assign var=i value=$i+1}
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div class="clear"></div>
                    <div class="col-lg-4 ">
                        <div class="well well-sm">
                            <h4 class="text-center">مجموع الايرادات <span>{$totalIncome}</span></h4>
                        </div>
                    </div>
                    <div class="col-lg-4 ">
                        <div class="well well-sm">
                            <h4 class="text-center">مجموع المصروفات: <span>{$totalExpense}</span></h4>
                        </div>
                    </div>
                    <div class="col-lg-4 ">
                        <div class="well well-sm">
                            <h4 class="text-center">صافى الرحلة: <span>{$totalIncome-$totalExpense}</span></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 hidden-print">طباعة</button>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>

                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</div>

{literal}
<script>
    $(function () {
        $("#triptypeid").select2({
            placeholder: "اختر",
            width: '100%',
            minimumInputLength: 0, //document.getElementById("searchvalue").value,
            multiple: false,
            quietMillis: 100,
            allowClear: true,
            ajax: {
                url: "expensesControllerajex.php?do=triptype",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
        $("#tripid").select2({
            placeholder: "اختر",
            width: '100%',
            minimumInputLength: 0, //document.getElementById("searchvalue").value,
            multiple: false,
            quietMillis: 100,
            allowClear: true,
            ajax: {
                url: "expensesControllerajex.php?do=trips",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
        $("#pathid").select2({
            placeholder: "اختر",
            width: '100%',
            minimumInputLength: 0, //document.getElementById("searchvalue").value,
            multiple: false,
            quietMillis: 100,
            allowClear: true,
            ajax: {
                url: "expensesControllerajex.php?do=paths",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
        $("#tripdateid").select2({
            placeholder: "اختر",
            width: '100%',
            minimumInputLength: 0, //document.getElementById("searchvalue").value,
            multiple: false,
            quietMillis: 100,
            allowClear: true,
            ajax: {
                url: "expensesControllerajex.php?do=dateid",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10,
                        tripid: $('#tripid').val(),
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
        $("#busid").select2({
            placeholder: "اختر",
            width: '100%',
            minimumInputLength: 0, //document.getElementById("searchvalue").value,
            multiple: false,
            quietMillis: 100,
            allowClear: true,
            ajax: {
                url: "expensesControllerajex.php?do=bus",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
        $("#driverid").select2({
            placeholder: "اختر",
            width: '100%',
            minimumInputLength: 0, //document.getElementById("searchvalue").value,
            multiple: false,
            quietMillis: 100,
            allowClear: true,
            ajax: {
                url: "expensesControllerajex.php?do=driver",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });

    });
</script>
{/literal}
