<?php /* Smarty version Smarty-3.1.11, created on 2023-10-10 00:33:12
         compiled from "../views/default/buyBillview/show.html" */ ?>
<?php /*%%SmartyHeaderCode:123534383765247198d14685-53300606%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'ad06f5dc6211b9892f4d9815e066d6b27bb8d747' => 
    array (
      0 => '../views/default/buyBillview/show.html',
      1 => 1693253992,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '123534383765247198d14685-53300606',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'message' => 0,
    'youtubes' => 0,
    'Programsettingdata' => 0,
    'usergroup' => 0,
    'suppliersData' => 0,
    'supplier' => 0,
    'storesData' => 0,
    'store' => 0,
    'billSerials' => 0,
    'buybillid' => 0,
    'serial' => 0,
    'totalBills' => 0,
    'buyBillData' => 0,
    'data' => 0,
    'i' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_65247198ddfc44_84032157',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_65247198ddfc44_84032157')) {function content_65247198ddfc44_84032157($_smarty_tpl) {?><div class="container">
    <ol class="breadcrumb">
        <li><a href="#">إدارة الفواتير</a></li>
        <li><a href="#">فاتورة المشتريات</a></li>
        <li class="active">عرض الفواتير</li>
    </ol>
    <div class="row">
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading" style="padding:5px 15px 15px">
                <h3 class="panel-title" style="display: inline-block;">فواتير المشتريات <br />
                    <?php if ($_smarty_tpl->tpl_vars['message']->value!=''){?>
                    <?php echo $_smarty_tpl->tpl_vars['message']->value;?>

                    <?php }?></h3>
                <a href="<?php echo $_smarty_tpl->tpl_vars['youtubes']->value[22]->url;?>
" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a
                <a href="buyBillController.php" class="hidden-print"><input type="button"  id="submit" style="margin-left: 12px" class="btn btn-primary pull-left " value="إضافة جديد"/></a>
            </div>

            <div class="panel-body">
                <input type="hidden" id="searchvalue" value="<?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->searchvalue;?>
">
                <input type="hidden" name="withNakdi" id="withNakdi" value="<?php echo $_smarty_tpl->tpl_vars['usergroup']->value->showClientAndSupplierOne;?>
"/>
                <form class="form-inline hidden-print" action="buyBillController.php?do=show" method="post">
                    <div class="form-group">
                        <label class="sr-only">إسم المورد</label>
                        <!--                        <select id="supplier" name="supplier" data-placeholder="اختر المورد" class="select2 wdt100" onChange="this.form.submit();">
                                                    <option value="-1"></option>



                                                    <?php  $_smarty_tpl->tpl_vars['supplier'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['supplier']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['suppliersData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['supplier']->key => $_smarty_tpl->tpl_vars['supplier']->value){
$_smarty_tpl->tpl_vars['supplier']->_loop = true;
?>



                                                    <option value="<?php echo $_smarty_tpl->tpl_vars['supplier']->value->supplierid;?>
"><?php echo $_smarty_tpl->tpl_vars['supplier']->value->suppliername;?>
</option>



                                                    <?php } ?>



                                                </select>-->
                        <input type="hidden" name="supplier" id="supplier" class="select2Supp" onChange="this.form.submit();"/>
                        <input type="hidden" name="oldsupplierid" id="oldsupplierid" value=""/>
                        <input type="hidden" name="oldsuppliername" id="oldsuppliername" value=""/>
                    </div>
                    <div class="form-group">
                        <label class="sr-only"> المخزن</label>
                        <select id="store" name="store" class="select2 wdt100" onChange="this.form.submit();">
                            <option value="-1"></option>

                            <?php  $_smarty_tpl->tpl_vars['store'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['store']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['storesData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['store']->key => $_smarty_tpl->tpl_vars['store']->value){
$_smarty_tpl->tpl_vars['store']->_loop = true;
?>

                            <option value="<?php echo $_smarty_tpl->tpl_vars['store']->value->storeId;?>
"><?php echo $_smarty_tpl->tpl_vars['store']->value->storeName;?>
</option>

                            <?php } ?>

                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">رقم تسلسل الفاتورة</label>
                        <select data-placeholder="اختر رقم التسلسل" class="select2 wdt100" name="buybillid"  onChange="this.form.submit();">
                            <option value="-1"></option>



                            <?php  $_smarty_tpl->tpl_vars['buybillid'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['buybillid']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['billSerials']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['buybillid']->key => $_smarty_tpl->tpl_vars['buybillid']->value){
$_smarty_tpl->tpl_vars['buybillid']->_loop = true;
?>



                            <option value="<?php echo $_smarty_tpl->tpl_vars['buybillid']->value->buybillid;?>
"><?php echo $_smarty_tpl->tpl_vars['buybillid']->value->buybillid;?>
</option>





                            <?php } ?>



                        </select>
                    </div>
                    <div class="form-group" <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp1=ob_get_clean();?><?php if ($_tmp1==1){?>  style="display:none" <?php }?> >
                        <label class="sr-only">رقم الفاتورة</label>
                        <select data-placeholder="اختر رقم الفاتورة" class="select2 wdt100" name="serial" onChange="this.form.submit();">
                            <option value="-1"></option>




                            <?php  $_smarty_tpl->tpl_vars['serial'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['serial']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['billSerials']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['serial']->key => $_smarty_tpl->tpl_vars['serial']->value){
$_smarty_tpl->tpl_vars['serial']->_loop = true;
?>


                            <option value="<?php echo $_smarty_tpl->tpl_vars['serial']->value->buybillSerial;?>
"><?php echo $_smarty_tpl->tpl_vars['serial']->value->buybillSerial;?>
</option>




                            <?php } ?>



                        </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>
                    <div class="form-group">
                        <label class="sr-only">اخفاء المحذوف
                            <input type="checkbox" class="search_bill" name="hideDel" id="hideDel"  value="1"></label>
                    </div>
                    <button type="submit" class="btn btn-primary noprint">بحث</button>
                </form>
            </div>
            <hr/>
            <div class="col-lg-offset-8 col-lg-4 ">
                <div class="well well-sm">
                    <h4 class="text-center">إجمالي المشتريات:  <?php echo $_smarty_tpl->tpl_vars['totalBills']->value;?>
</h4>
                </div>
            </div>
            <div class="clearfix"></div>
            
            <form id="form1" name="form1" method="post" action="buyBillController.php?do=delete"onsubmit="if (Spry.Widget.Form.validate(this)) {
                        return countChoosenProducts('buyBillController');
                    } else {
                        return false;
                    }" enctype="multipart/form-data">
                
                <!-- Table -->
                <table class="table table-black">
                    <thead>
                        <tr>
                            <th class="hidden-print">
                                <label>
                                    <input type="checkbox" name="checkAll" id="checkAll"/>
                                </label>
                            </th>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->clientserial==1){?><th>رقم تسلسل الفاتورة</th><?php }?>
                            <th>اسم المورد</th>
                            <th <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp2==1){?>  style="display:none" <?php }?>>رقم الفاتورة</th>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showparcode==1){?><th>باركود  المنتجات</th><?php }?>

                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==1){?><th>إجمالي الفاتورة</th><?php }?>
                            <th>التاريخ</th>
                            <th>المستخدم</th>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==1){?><th class="hidden-print">تفاصيل الفاتورة</th><?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->allowEditDelInBuyBills==0){?><th class="hidden-print">تعديل</th><?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==0){?><th class="hidden-print">تكويد المنتجات</th><?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->importproduct==1){?>  <th class="hidden-print">pl</th><?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==0){?><th class="hidden-print">تكويد منتجات متعدد</th><?php }?>
                            <th class="hidden-print">طباعه الباركود </th>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->allowEditDelInBuyBills==0){?><th class="hidden-print">حذف</th><?php }?>
                        </tr>
                    </thead>
                    <tbody>

                        <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['buyBillData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['data']->key => $_smarty_tpl->tpl_vars['data']->value){
$_smarty_tpl->tpl_vars['data']->_loop = true;
?>
                        <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['data']->value->conditions;?>
<?php $_tmp3=ob_get_clean();?><?php if ($_tmp3==1){?>
                        <tr class="danger"> <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['data']->value->conditions;?>
<?php $_tmp4=ob_get_clean();?><?php if ($_tmp4==0){?>
                        <tr> <?php }}?>
                            <td class="hidden-print">
                                <label>
                                    <input type="checkbox" name="choosedItem[]" id="checked<?php echo $_smarty_tpl->tpl_vars['i']->value;?>
" class="choosenItem" value="<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
" />
                                </label>
                            </td>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->clientserial==1){?><td> <?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
 </td><?php }?>
                            <td> <?php echo $_smarty_tpl->tpl_vars['data']->value->suppliername;?>
 </td>
                            <td <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp5=ob_get_clean();?><?php if ($_tmp5==1){?>  style="display:none" <?php }?>><?php echo $_smarty_tpl->tpl_vars['data']->value->buybillSerial;?>
</td>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showparcode==1){?><td><?php echo $_smarty_tpl->tpl_vars['data']->value->parcodepro;?>
</td><?php }?>

                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==1){?><td><?php echo $_smarty_tpl->tpl_vars['data']->value->buybillaftertotalbill;?>
</td><?php }?>
                            <td><?php echo $_smarty_tpl->tpl_vars['data']->value->buybilldate;?>
</td>
                            <td><?php echo $_smarty_tpl->tpl_vars['data']->value->username;?>
 <?php if ($_smarty_tpl->tpl_vars['data']->value->delbyusername){?><br/><span style="color: red"><?php echo $_smarty_tpl->tpl_vars['data']->value->delbyusername;?>
</span><?php }?></td>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==1){?><td  class="hidden-print"><a href="buyBillController.php?do=details&id=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
" type="button" class="btn btn-default btn-lg notesicon"></a></td><?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->allowEditDelInBuyBills==0){?><td  class="hidden-print">
                                <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['data']->value->conditions;?>
<?php $_tmp6=ob_get_clean();?><?php if ($_tmp6==0){?>
                                <a href="buyBillController.php?do=editbill&id=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
" type="button" class="btn btn-default btn-lg notesicon"></a>
                                <?php }else{ ?>
                                الفاتوره محذوفه
                                <?php }?></td><?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==0){?><td  class="hidden-print"><a href="buyBillController.php?do=addoneserial&id=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
&type=2" type="button" class="btn btn-default btn-lg editicon"></a></td><?php }?>

                          <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->importproduct==1){?>  <td  class="hidden-print"><a href="buyBillController.php?do=addpl&id=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
&type=2" type="button" class="btn btn-default btn-lg editicon"></a></td><?php }?>


                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->showSerializeBtn==0){?><td  class="hidden-print"><a href="buyBillController.php?do=addserial&id=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
&type=2" type="button" class="btn btn-default btn-lg editicon"></a></td><?php }?>
                            <td  class="hidden-print"><a href="productController.php?do=showbarcodebuybill&buybillid=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
&type=2" target="_new" type="button"  class="btn btn-default btn-lg editicon printparcode"> </a></td>

                            <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->allowEditDelInBuyBills==0){?><td  class="hidden-print"> <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['data']->value->conditions;?>
<?php $_tmp7=ob_get_clean();?><?php if ($_tmp7==0){?> <a href="#" type="button" class="btn btn-default btn-lg deleteicon conformdel1" data-position="buyBillController.php?do=delete&id=<?php echo $_smarty_tpl->tpl_vars['data']->value->buybillid;?>
"></a> <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['data']->value->conditions;?>
<?php $_tmp8=ob_get_clean();?><?php if ($_tmp8==1){?> تم حذف الفاتورة</td><?php }}?>
                            <?php }?> </tr>
                        <?php } ?>
                    </tbody>

                </table>



                <!-- Modal -->
                <div class="hidden-print">
                    <div class="modal fade " id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close pull-left" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <div class="modal-title">تأكيد حذف الفاتوره</div>
                                </div>
                                <div class="modal-body"> هل تريد حذف هذه الفاتوره؟ </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">لا</button>
                                    <button type="button" class="btn btn-primary savemodel1">نعم</button>
                                </div>
                            </div>
                            <!-- /.modal-content -->
                        </div>
                        <!-- /.modal-dialog -->
                    </div>
                </div>
                <!-- /.modal -->
                <div  class="hidden-print">
                    <div class="col-lg-12">
                        <div class="well well-sm">
                            <div class="form-group">
                                <div class="col-lg-4">
                                    <label for="operation"></label>
                                    <span id="spryselect2">
                                        <select name="operation" id="operation"  data-placeholder="اختر العملية" class="select2 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>
                    <div class="col-lg-offset-8 col-lg-4 ">
                        <div class="well well-sm">
                            <h4 class="text-center">إجمالي المشتريات:  <?php echo $_smarty_tpl->tpl_vars['totalBills']->value;?>
</h4>
                        </div>
                    </div>
                    <div class="clearfix"></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>
    </div>
</div>

<script type="text/javascript">
    var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue: "-1", isRequired: false});
    $('.printparcode').mousedown(function (e) {
        e.preventDefault();
        var href = $(this).attr('href') + '&parcodeTypeToPrint=' + Number(localStorage.getItem("parcodeTypeToPrint"));
        window.open(href)
    });


    $('.conformdel1').click(function (e) {

        e.preventDefault();

        var elemposition = $(this).data('position');

        $("#myModal1").find(".savemodel1").attr('data-position', elemposition);
        $('#myModal1').modal('show');
    });
    $('.savemodel1').on('click', function () {

        $('#myModal1').modal('hide');
        var pos = $(this).attr('data-position');

        window.location.href = pos;
    });


    $(function () {
        $(".select2Supp").select2({
            placeholder: "المورد",
            minimumInputLength: document.getElementById("searchvalue").value,
            //inimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "supplierAjaxController.php?do=select2supplier",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 7, // page size
                        withAddOption: 0,
                        withNakdi: function () {
                            return (Number($('#withNakdi').val()) == 1) ? 0 : 1;
                        },
                        //jsonRowRet: 1,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                if (Number(data.id) == -2) {
                    return  '<span class="newoption">' + data.text + '</span >';
                } else {
                    return  '<span>' + data.text + '</span >';
                }
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                //  var data = {id: item[0], text: item[1]};
                var data = {id: item[0], text: item[1], productquantity: item[2], price: item[3]};
                callback(data);
            },
            //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
        });
        //this is needed for ajax =>to obtain id from it  and use in ajax
        $('#supplier').select2('data', {id: $('#oldsupplierid').val(), text: $('#oldsuppliername').val()});
    });
</script>
<?php }} ?>