<?php /* Smarty version Smarty-3.1.11, created on 2025-12-29 20:59:43
         compiled from "..\views\default\sellbillview\show.html" */ ?>
<?php /*%%SmartyHeaderCode:86806952cf9f2191d6-08114826%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'a389a2713a4129d4634856db46b7e23325c3b354' => 
    array (
      0 => '..\\views\\default\\sellbillview\\show.html',
      1 => 1762403580,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '86806952cf9f2191d6-08114826',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'message' => 0,
    'youtubes' => 0,
    'Programsettingdata' => 0,
    'outputString' => 0,
    'Usergroupdata' => 0,
    'do' => 0,
    'clientData' => 0,
    'client' => 0,
    'allTypeClient' => 0,
    'data' => 0,
    'billsettingsData' => 0,
    'sellerData' => 0,
    'mysellerData' => 0,
    'billOperations' => 0,
    'sellerinsertData' => 0,
    'mysellerinsertData' => 0,
    'stores' => 0,
    'searchinonesave' => 0,
    'saveid' => 0,
    'saves' => 0,
    'userdata' => 0,
    'totalBills' => 0,
    'usergroup' => 0,
    'sellbillData' => 0,
    'sellbill' => 0,
    'piecesCount' => 0,
    'payedTotal' => 0,
    'totalDiscount' => 0,
    'totalBillsNoDiscount' => 0,
    'i' => 0,
    'billsCount' => 0,
    'remainTotal' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_6952cf9fb89153_97151179',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_6952cf9fb89153_97151179')) {function content_6952cf9fb89153_97151179($_smarty_tpl) {?><style>
    .success_f {
        background-color: #befabf !important;
    }

    .error_f {
        background-color: #f8b8b8 !important;
    }

    .hasRemain {
        padding: 8px;
        background-color: black;
        border-radius: 9px;
        color: white;
    }
</style>
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ادارة الفواتير</a></li>
            <li><a href="sellbillController.php?do=show">فواتير البيع</a></li>
            <li class="active">عرض فواتير البيع</li>
        </ol>
        <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[23]->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="sellbillController.php" class="hidden-print"><input type="button" style="margin-left: 12px"
                        id="submit" 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;?>
">
                <div id="outputString" class="alert alert-block alert-success fade in hidden-print"
                    style="display:none">
                    <button type="button" class="close pull-left" data-dismiss="alert"
                        aria-hidden="true">&times;</button>
                    <p id="outputStringValue"><?php echo $_smarty_tpl->tpl_vars['outputString']->value;?>
</p>
                    <div class="clearfix"></div>
                </div>
                <input type="hidden" name="withNakdi" id="withNakdi"
                    value="<?php echo $_smarty_tpl->tpl_vars['Usergroupdata']->value->showClientAndSupplierOne;?>
" />
                <form class="form-inline hidden-print" action="sellbillController.php?do=<?php echo $_smarty_tpl->tpl_vars['do']->value;?>
" method="post">
                    <div class="form-group col-lg-4">
                        <label class="sr-only">العميل</label>
                        <!--                        <select class="select2 wdt100 search_bill"  name="clientid" id="clientid" >
                                                    <option value="-1">اختر عميل</option>



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



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


                                                    <?php } ?>



                                                </select>-->
                        <input type="hidden" name="clientid" id="clientid" class="select2Supp search_bill" />
                        <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 class="select2 wdt100 search_bill" name="typeclient" id="typeclient">
                            <option value="-1">نوع العميل</option>
                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allTypeClient']->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;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['data']->value['typeId'];?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value['typeName'];?>
</option>
                            <?php } ?>
                        </select>
                    </div>

                    <div class="form-group <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[3]->billsettingsvalue;?>
<?php $_tmp1=ob_get_clean();?><?php if ($_tmp1==0){?>  <?php }else{ ?> hidden <?php }?>">
                        <label class="sr-only"><?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==0){?> بائع <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==1){?>مندوب <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==2){?>طبيب <?php }?></label>
                        <select class="select2 wdt100 search_bill" name="sellerid" id="sellerid">
                            <option value="-1">اختر <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==0){?> بائع <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==1){?>مندوب <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==2){?>طبيب <?php }?></option>



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



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


                            <?php } ?>



                        </select>
                    </div>
                    <div class="form-group <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showBillOperationSearch!=1){?> hidden <?php }?>">
                        <label class="sr-only">عملية الفاتورة</label>
                        <select class="select2 wdt100 search_bill" name="billoperationid" id="billoperationid">
                            <option value="-1">اختر عملية</option>
                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['billOperations']->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;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['data']->value->id;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->name;?>
</option>
                            <?php } ?>
                        </select>
                    </div>

                    <div class="form-group">
                        <label class="sr-only">اسم المستخدم</label>
                        <select class="select2 wdt100 search_bill" name="selleruserid" id="selleruserid">
                            <option value="-1">اختر المستخدم</option>



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



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


                            <?php } ?>



                        </select>
                    </div>



                    <div class="form-group col-lg-2" style="float: left;<?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp2==1){?> display:none; <?php }?>">
                        <label class="sr-only">رقم الفاتورة</label>
                        <input type="text" class="form-control search_bill" placeholder="رقم الفاتورة"
                            name="sellbillserial" id="sellbillserial">
                    </div>
                    <div class="form-group col-lg-2" style="float: left;">
                        <label class="sr-only">الرقم تسلسل الفاتورة</label>
                        <input type="text" class="form-control search_bill" placeholder="رقم تسلسل الفاتورة"
                            name="sellbillid" id="sellbillid">
                    </div>

                    <br />


                    <div class="form-group">
                        <label class="sr-only">المخزن</label>
                        <select class="select2 wdt100 search_bill" name="storeid" id="storeid">
                            <option value="-1">اختر المخزن</option>
                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['stores']->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;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['data']->value->storeId;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->storeName;?>
</option>
                            <?php } ?>
                        </select>
                    </div>




                    <?php if ($_smarty_tpl->tpl_vars['searchinonesave']->value==1){?>
                    <input type="hidden" name="saveid" id="saveid" value="<?php echo $_smarty_tpl->tpl_vars['saveid']->value;?>
" />
                    <?php }else{ ?>
                    <div class="form-group">
                        <label class="sr-only">الخزنة</label>
                        <select class="select2 wdt100 search_bill" name="saveid" id="saveid">
                            <option value="-1">اختر الخزنة</option>
                            <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['saves']->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;
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['data']->value->saveid;?>
"><?php echo $_smarty_tpl->tpl_vars['data']->value->savename;?>
</option>
                            <?php } ?>
                        </select>
                    </div>
                    <?php }?>



                    <div class="form-group">
                        <label class="sr-only">نوع السعر</label>
                        <select class="select2 search_bill wdt100" name="pricetype" id="pricetype">
                            <option value="-1"></option>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showpriceall==1){?>
                            <option value="0">جملة</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showpriceunit==1){?>
                            <option value="1">تجزئة</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showpricehalf==1){?>
                            <option value="2">نصف جملة</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice4==1){?>
                            <option value="4">سعر4</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice5==1){?>
                            <option value="5">سعر5</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice6==1){?>
                            <option value="6">سعر6</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice7==1){?>
                            <option value="7">سعر7</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice8==1){?>
                            <option value="8">سعر8</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice9==1){?>
                            <option value="9">سعر9</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice10==1){?>
                            <option value="10">سعر10</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice11==1){?>
                            <option value="11">سعر11</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice12==1){?>
                            <option value="12">سعر12</option>
                            <?php }?>
                            <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice13==1){?>
                            <option value="13">سعر13</option>
                            <?php }?>
                        </select>
                    </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="text" class="form-control awdatepicker search_bill" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="shippingDateFrom" id="shippingDateFrom">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">تاريخ الشحن الى</label>
                        <input type="text" class="form-control awdatepicker search_bill" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="shippingDateTo" id="shippingDateTo">
                    </div>

                    <div class="form-group">
                        <label class="sr-only">تاريخ التسليم من</label>
                        <input type="text" class="form-control awdatepicker search_bill" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="deliverDateFrom" id="deliverDateFrom">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">تاريخ التسليم الى</label>
                        <input type="text" class="form-control awdatepicker search_bill" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="deliverDateTo" id="deliverDateTo">
                    </div>

                    <div class="form-group">
                        <label class="sr-only">Serial</label>
                        <input type="text" class="form-control search_bill" name="proSellTrackingSerial"
                            id="proSellTrackingSerial" value="">
                    </div>
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showBillCollectionSearch==1){?>
                    <br />
                    <div class="form-group">
                        <label class="sr-only">نوع التحصيل</label>
                        <select class="select2 search_bill wdt100" name="collectionType" id="collectionType">

                            <option value="-1"></option>
                            <option value="0">بدون</option>
                            <option value="1">شيك</option>
                            <option value="2">مفتوح</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">تاريخ الاستحقاق من</label>
                        <input type="text" class="form-control awdatepicker search_bill" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="collectionDateFrom" id="collectionDateFrom">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">تاريخ الاستحقاق الى</label>
                        <input type="text" class="form-control awdatepicker search_bill" autocomplete="off"
                            data-date-format="yyyy-mm-dd" name="collectionDateTo" id="collectionDateTo">
                    </div>

                    <?php }?>

                    <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 search_bill" 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 search_bill" 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 search_bill" autocomplete="off"
                                data-date-format="yyyy-mm-dd" name="from" id="from">
                        </div>
                        <div class="form-group">
                            <label class="sr-only">إلى التاريخ</label>
                            <input type="text" class="form-control awdatepicker search_bill" autocomplete="off"
                                data-date-format="yyyy-mm-dd" name="to" id="to">
                        </div>
                        <div class="form-group">
                            <label class="sr-only">التعليق</label>
                            <input type="text" class="form-control search_bill" placeholder="التعليق"
                                name="sellbillcomment" id="sellbillcomment">
                        </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="form-group">
                        <label class="sr-only">نوع الفاتورة</label>
                        <div class="input-group">
                            <label> <input value="1" name="obgyBillType" id="obgyBillType" type="radio">
                                مباشر</label>
                            <label>
                                <input value="2" name="obgyBillType" id="obgyBillType" type="radio">
                                مستهلك</label>
                            <label>
                                <input value="3" name="obgyBillType" id="obgyBillType" type="radio">
                                استقبال</label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">اخفاء المحذوف
                            <input type="checkbox" class="search_bill col-lg-12" name="hideDel" id="hideDel"
                                checked="checked" value="1"></label>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">اخفاء المدفوع
                            <input type="checkbox" class="search_bill col-lg-12" name="hidePayed" id="hidePayed"
                                value="1"></label>
                    </div>
                    <div class="clearfix"></div>
                    <button type="submit" class="btn btn-primary">بحث</button>
                    <input type="hidden" name="getTodayBills" id="getTodayBills" value="0" />
                    <button type="submit" class="btn btn-primary" onclick="$('#getTodayBills').val(1);">فواتير
                        اليوم</button>
                    <?php if ($_smarty_tpl->tpl_vars['userdata']->value->dellaternakdipayed==1){?>
                    <a href="sellbillController.php?do=delLaterNakdiPayed" style="float: left; color: white;" class="btn btn-danger">إلغاء الفواتير الغير مسددة</a>
                    <?php }?>
                </form>

            </div>
            <hr />
            <div id="tableWrap">
                <div class="col-lg-offset-8 col-lg-4 ">
                    <div class="well well-sm">
                        <h4 class="text-center">إجمالي صافى المبيعات: <span id="totalBills2"><?php echo $_smarty_tpl->tpl_vars['totalBills']->value;?>
</span></h4>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="message-table"> <?php echo $_smarty_tpl->tpl_vars['message']->value;?>
</div>
                


                <form method="post" action="sellbillController.php?do=executeOperation" id="excuteOperationForm"
                    onsubmit="if (Spry.Widget.Form.validate(this)) {
                                  return countChoosenProducts('sellbillController');
                              } else {
                                  return false;
                              }">
                    

                    <table class="table table-black dataTableClass" id="excelTable">
                        <thead>
                            <tr>
                                <th class="hidden-print">
                                    <input type="checkbox" name="checkAll" id="checkAll" />
                                </th>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->clientserial==1){?><th>رقم تسلسل الفاتورة</th><?php }?>
                                <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp3=ob_get_clean();?><?php if ($_tmp3!=1){?> <th>رقم الفاتورة</th><?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showparcode==1){?><th>باركود المنتجات</th><?php }?>
                                <th>نوع السعر</th>
                                <th>اجمالى الفاتورة</th>
                                <th>الخصم</th>
                                <th>صافى الفاتورة</th>
                                <th>المدفوع</th>
                                <th>تاريخ الفاتورة</th>
                                <th>العميل</th>
                                <th <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[3]->billsettingsvalue;?>
<?php $_tmp4=ob_get_clean();?><?php if ($_tmp4==0){?> style="display:block" <?php }else{ ?>
                                    style="display:none" <?php }?>><?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==0){?> بائع
                                    <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==1){?>مندوب <?php }elseif($_smarty_tpl->tpl_vars['Programsettingdata']->value->delegate_seller==2){?>طبيب <?php }?></th>
                                <th>المستخدم</th>
                                <th>المخزن</th>
                                <th>الخزنة</th>
                                <th class="hidden-print">تاريخ الشحن</th>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showbilldeliverydate==1){?>
                                <th <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[112]->billsettingsvalue;?>
<?php $_tmp5=ob_get_clean();?><?php if ($_tmp5==1){?>
                                    class="hidden-print"<?php }?>>تاريخ
                                    التسليم</th>
                                <?php }?><?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showbillstatus==1&&$_smarty_tpl->tpl_vars['billsettingsData']->value[110]->billsettingsvalue==0){?>
                                <th class="hidden-print">الحالة</th>
                                <?php }?>
                                <th>الصوره</th>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showBillCollectionSearch==1){?><th class="hidden-print">تاريخ
                                    الاستحقاق</th><?php }?>
                                <th class="hidden-print">تفاصيل الفاتورة</th>
                                <th class="hidden-print">طباعه الباركود </th>
                                <th class="hidden-print">اكسل</th>
                                <th class="hidden-print">PDF</th>

                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->ebill==1){?><th>ارسال الفاتوره</th>
                                <th class="hidden-print">pdf</th><?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->saudielectronicinvoice==1){?><th>ارسال الفاتوره</th><?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->allowEditDelInBills==0){?><th class="hidden-print">تعديل الفاتورة</th>
                                <th class="hidden-print">حذف</th><?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['do']->value!="all"){?><th class="hidden-print">قيد اليومية</th><?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->netprofit==0){?><th class="hidden-print">ربحية الفاتورة</th><?php }?>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $_smarty_tpl->tpl_vars['piecesCount'] = new Smarty_variable(0, null, 0);?>
                            <?php $_smarty_tpl->tpl_vars['payedTotal'] = new Smarty_variable(0, null, 0);?>
                            <?php $_smarty_tpl->tpl_vars['remainTotal'] = new Smarty_variable(0, null, 0);?>
                            <?php $_smarty_tpl->tpl_vars['totalDiscount'] = new Smarty_variable(0, null, 0);?>
                            <?php $_smarty_tpl->tpl_vars['totalBillsNoDiscount'] = new Smarty_variable(0, null, 0);?>
                            <?php  $_smarty_tpl->tpl_vars['sellbill'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['sellbill']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['sellbillData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['sellbill']->key => $_smarty_tpl->tpl_vars['sellbill']->value){
$_smarty_tpl->tpl_vars['sellbill']->_loop = true;
?>


                            <?php if (isset($_smarty_tpl->tpl_vars['sellbill']->value->newSellbillidAfterEdit)&&$_smarty_tpl->tpl_vars['sellbill']->value->newSellbillidAfterEdit>0){?>
                            <!--this bill is deleted for editing-->
                            <tr class="danger">
                                <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->conditions;?>
<?php $_tmp6=ob_get_clean();?><?php if ($_tmp6!=0){?>
                            <tr class="dark">
                                <?php }else{ ?>
                                <?php $_smarty_tpl->tpl_vars['piecesCount'] = new Smarty_variable($_smarty_tpl->tpl_vars['piecesCount']->value+$_smarty_tpl->tpl_vars['sellbill']->value->sellQuantity, null, 0);?>
                                <?php $_smarty_tpl->tpl_vars['payedTotal'] = new Smarty_variable($_smarty_tpl->tpl_vars['payedTotal']->value+$_smarty_tpl->tpl_vars['sellbill']->value->sellbilltotalpayed, null, 0);?>
                                <?php $_smarty_tpl->tpl_vars['totalDiscount'] = new Smarty_variable($_smarty_tpl->tpl_vars['totalDiscount']->value+$_smarty_tpl->tpl_vars['sellbill']->value->sellbilldiscount, null, 0);?>
                                <?php $_smarty_tpl->tpl_vars['totalBillsNoDiscount'] = new Smarty_variable($_smarty_tpl->tpl_vars['totalBillsNoDiscount']->value+($_smarty_tpl->tpl_vars['sellbill']->value->sellbillaftertotalbill+$_smarty_tpl->tpl_vars['sellbill']->value->sellbilldiscount), null, 0);?>
                            <tr>
                                <?php }}?>
                                <td class="hidden-print">
                                    <input type="checkbox" name="choosedItem[]" id="checked<?php echo $_smarty_tpl->tpl_vars['i']->value;?>
" class="choosenItem"
                                        value="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" />
                                </td>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->clientserial==1){?><td><?php if ($_smarty_tpl->tpl_vars['do']->value=="all"){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber;?>
<?php }else{ ?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
<?php }?></td><?php }?>
                                <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['Programsettingdata']->value->billid;?>
<?php $_tmp7=ob_get_clean();?><?php if ($_tmp7==0){?> <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillserial;?>
</td><?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showparcode==1){?> <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->parcodepro;?>
</td> <?php }?>
                                <td><?php if ($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==0){?>جملة<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==1){?>تجزئة<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==2){?>نصف جملة<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==4){?>سعر4<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==5){?>سعر5<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==6){?>سعر6<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==7){?>سعر7<?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->pricetype==8){?>سعر8<?php }?></td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillaftertotalbill+$_smarty_tpl->tpl_vars['sellbill']->value->sellbilldiscount;?>
<!----></td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbilldiscount;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillaftertotalbill;?>
</td>
                                <td><span class="<?php if ($_smarty_tpl->tpl_vars['sellbill']->value->sellbillaftertotalbill!=$_smarty_tpl->tpl_vars['sellbill']->value->sellbilltotalpayed){?>hasRemain<?php }?>"><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbilltotalpayed;?>
</span>
                                </td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbilldate;?>
</td>
                                <td style="font-weight:bold;<?php if ($_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber){?> > 0};color:#0040ff;<?php }?>"> 
                                  
                                    <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->clientname;?>
<?php $_tmp8=ob_get_clean();?><?php if ($_tmp8==''){?>
                                    نقدى
                                    <?php }else{ ?>
                                    <?php echo $_smarty_tpl->tpl_vars['sellbill']->value->clientname;?>

                                    <?php }?> </td>
                                <td <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[3]->billsettingsvalue;?>
<?php $_tmp9=ob_get_clean();?><?php if ($_tmp9==0){?> style="display:block" <?php }else{ ?>
                                    style="display:none" <?php }?>><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->employeename;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->useremployeename;?>
<?php if ($_smarty_tpl->tpl_vars['sellbill']->value->delbyusername){?><br /><span
                                        style="color: red"><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->delbyusername;?>
</span><?php }?></td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->storeName;?>
</td>
                                <td><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->savename;?>
</td>
                                <td><input type="text" readonly
                                        class="form-control awdatepicker shippingDate hidden-print"
                                        data-id="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" autocomplete="off"
                                        data-date-format="yyyy-mm-dd" name="shippingDate" id="shippingDate"
                                        value="<?php if ($_smarty_tpl->tpl_vars['sellbill']->value->shippingDate!='0000-00-00'){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->shippingDate;?>
<?php }?>">
                                </td>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showbilldeliverydate==1){?>
                                <td <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['billsettingsData']->value[112]->billsettingsvalue;?>
<?php $_tmp10=ob_get_clean();?><?php if ($_tmp10==1){?>
                                    class="hidden-print"<?php }?>><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->datestarting;?>
</td>
                                <?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showbillstatus==1&&$_smarty_tpl->tpl_vars['billsettingsData']->value[110]->billsettingsvalue==0){?>
                                <td class="hidden-print">
                                    <a href="javascript:;" type="button" class="btn btn-lm btn-warning showStModal"
                                        data-id="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" data-status="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->billStatus;?>
">
                                        <?php if ($_smarty_tpl->tpl_vars['sellbill']->value->billStatus=="new"){?>
                                        <?php echo @SELL_BILL_STATUS_NEW;?>

                                        <?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->billStatus=="prepare"){?>
                                        <?php if ($_smarty_tpl->tpl_vars['billsettingsData']->value[111]->billsettingsvalue==0){?>
                                        <?php echo @SELL_BILL_STATUS_PREPARE;?>

                                        <?php }else{ ?>
                                        <?php echo @SELL_BILL_STATUS_FACTORY_SEND;?>

                                        <?php }?>
                                        <?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->billStatus=="shipped"){?>
                                        <?php if ($_smarty_tpl->tpl_vars['billsettingsData']->value[111]->billsettingsvalue==0){?>
                                        <?php echo @SELL_BILL_STATUS_SHIPPED;?>

                                        <?php }else{ ?>
                                        <?php echo @SELL_BILL_STATUS_FACTORY_DELIVERED;?>

                                        <?php }?>
                                        <?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->billStatus=="deliver"){?>
                                        <?php echo @SELL_BILL_STATUS_DELIVERED;?>

                                        <?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->billStatus=="refused"){?>
                                        <?php echo @SELL_BILL_STATUS_REFUSED;?>

                                        <?php }?>
                                    </a>
                                </td>
                                <?php }?>
                                <td style="width: 30px;">
                                    <div id="imagesuploadfile<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
">
                                        <img src="../views/default/images/sellbill/<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->images;?>
"
                                            data-sellbill="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" class="clickuploadfile"
                                            style="width: 40px;height: 40px;border: 1px solid;border-radius: 6px;">
                                    </div>
                                    <input type="file" name="file" id="uploadfile<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                        data-sellbill="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                        data-imageid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillimageid;?>
" style="display:none" />

                                </td>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showBillCollectionSearch==1){?><td><?php if ($_smarty_tpl->tpl_vars['sellbill']->value->collectionDate!='0000-00-00'){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->collectionDate;?>
<?php }?></td><?php }?>
                                <td class="hidden-print"> <a
                                        href="sellbillController.php?do=<?php if ($_smarty_tpl->tpl_vars['do']->value=="all"){?>approvedsaleDetail&sellbillid=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber;?>
<?php }else{ ?>showDetail&sellbillid=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
<?php }?>"
                                        type="button" class="btn btn-default btn-lg editicon"></a> </td>
                                <td class="hidden-print"> <a
                                        href="sellbillprintController.php?do=showDetail2&id=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                        target="_blank" type="button" class="btn btn-default btn-lg printicon"></a> </td>
                                <td class="hidden-print"> <a
                                        href="sellbillController.php?do=billToExcel&sellbillid=<?php if ($_smarty_tpl->tpl_vars['do']->value=="all"){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber;?>
<?php }else{ ?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
<?php }?>"
                                        type="button" class="btn btn-default btn-lg excelicon"></a> </td>
                                <td class="hidden-print"> <a target="_blank"
                                        href="sellbillController.php?do=billToPDF&id=<?php if ($_smarty_tpl->tpl_vars['do']->value=="all"){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber;?>
<?php }else{ ?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
<?php }?>"
                                        type="button" class="btn btn-default btn-lg pdficon"></a> </td>
                                <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->ebill==1){?>
                                <?php if ($_smarty_tpl->tpl_vars['sellbill']->value->conditions!=1){?>
                                <td class="hidden-print" id="ebill_<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
">
                                    <?php if (empty($_smarty_tpl->tpl_vars['sellbill']->value->estatus)){?>
                                    <a href="javascript:;" data-sellbillid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" type="button"
                                        class="btn btn-default  sendbill "> ارسال</a>
                                    <?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->estatus=='-1'||$_smarty_tpl->tpl_vars['sellbill']->value->estatus=='-2'){?>
                                    <a href="javascript:;" data-sellbillid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" type="button"
                                        class="btn btn-default  sendbill"> حدث خطأ </a>
                                    <a href="sellbillController.php?do=ebillerrors&sellbillid=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                        type="button" class="btn btn-default"> المشكله</a>
                                    <?php }else{ ?>
                                    <a href="electronicinvoice.php?do=detail&uuid=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->estatus;?>
" type="button"
                                        class="btn btn-default"> تفاصيل</a>
                                    <?php }?>
                                </td>
                                <td id="epdf<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
">
                                    <?php if (!empty($_smarty_tpl->tpl_vars['sellbill']->value->estatus)&&$_smarty_tpl->tpl_vars['sellbill']->value->estatus!='-1'&&$_smarty_tpl->tpl_vars['sellbill']->value->estatus!='-2'){?>
                                    <?php if (!$_smarty_tpl->tpl_vars['sellbill']->value->epdf){?>
                                    <a href="javascript:;" data-uuid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->estatus;?>
"
                                        data-sellbillid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" id="uuid<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                        type="button" class="btn btn-default  downloadepdf"> pdf </a>
                                    <?php }else{ ?>
                                    <a href="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->epdf;?>
" type="button" class="btn btn-default"> pdf</a>
                                    <?php }?>
                                    <?php }?>
                                </td>
                                <?php }else{ ?>
                                <td>
                                    لا يمكن الارسال
                                </td>
                                <td>
                                    لا يمكن الارسال
                                </td>
                                <?php }?>

                                <?php }?>



                                 <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->saudielectronicinvoice==1){?>
                                    <?php if ($_smarty_tpl->tpl_vars['sellbill']->value->conditions!=1){?>
                                    <td class="hidden-print" id="ebill2_<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
">
                                        <?php if (empty($_smarty_tpl->tpl_vars['sellbill']->value->estatus)){?>
                                        <a href="javascript:;" data-sellbillid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" type="button"
                                            class="btn btn-default  sendbill2 "> ارسال</a>
                                        <?php }elseif($_smarty_tpl->tpl_vars['sellbill']->value->estatus=='-1'||$_smarty_tpl->tpl_vars['sellbill']->value->estatus=='-2'){?>
                                        <a href="javascript:;" data-sellbillid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" type="button"
                                            class="btn btn-default  sendbill2"> حدث خطأ </a>
                                        <a href="sellbillController.php?do=ebillerrors&sellbillid=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                            type="button" class="btn btn-default"> المشكله</a>
                                        <?php }else{ ?>
                                        <a href="saudiElectronIcinvoiceView.php?do=detail&uuid=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->estatus;?>
" type="button"
                                            class="btn btn-default"> تفاصيل</a>
                                        <?php }?>
                                    </td>
                                   <!--  <td id="epdf<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
">
                                        <?php if (!empty($_smarty_tpl->tpl_vars['sellbill']->value->estatus)&&$_smarty_tpl->tpl_vars['sellbill']->value->estatus!='-1'&&$_smarty_tpl->tpl_vars['sellbill']->value->estatus!='-2'){?>
                                            <?php if (!$_smarty_tpl->tpl_vars['sellbill']->value->epdf){?>
                                            <a href="javascript:;" data-uuid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->estatus;?>
"
                                                data-sellbillid="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
" id="uuid<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"
                                                type="button" class="btn btn-default  downloadepdf"> pdf </a>
                                            <?php }else{ ?>
                                            <a href="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->epdf;?>
" type="button" class="btn btn-default"> pdf</a>
                                            <?php }?>
                                        <?php }?>
                                    </td> -->
                                    <?php }else{ ?>
                                    <td>
                                        لا يمكن الارسال
                                    </td>
                                    <?php }?>

                                <?php }?>



                                <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->allowEditDelInBills==0){?><td class="hidden-print">
                                    <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->conditions;?>
<?php $_tmp11=ob_get_clean();?><?php if ($_tmp11==0){?>

                                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->noBillEditTillPay==0||($_smarty_tpl->tpl_vars['Programsettingdata']->value->noBillEditTillPay==1&&$_smarty_tpl->tpl_vars['sellbill']->value->sellbilltotalpayed==$_smarty_tpl->tpl_vars['sellbill']->value->sellbillaftertotalbill)){?>
                                    <a <?php if ($_smarty_tpl->tpl_vars['sellbill']->value->billPayments>0&&$_smarty_tpl->tpl_vars['usergroup']->value->noBillEditIfTheirIsPayments==0){?> data-href=<?php }else{ ?>href=<?php }?>"sellbillController.php?do=editsellBill&sellbillid=<?php if ($_smarty_tpl->tpl_vars['do']->value=="all"){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber;?>
<?php }else{ ?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
<?php }?>"
                                        type="button" class="btn btn-default btn-lg editicon <?php if ($_smarty_tpl->tpl_vars['sellbill']->value->billPayments>0&&$_smarty_tpl->tpl_vars['usergroup']->value->noBillEditIfTheirIsPayments==0){?> billHasPayments <?php }?>"></a>
                                    <?php }else{ ?>
                                    سدد الفاتوره اولا
                                    <?php }?>

                                    <?php }else{ ?>


                                    <?php if (isset($_smarty_tpl->tpl_vars['sellbill']->value->newSellbillidAfterEdit)&&$_smarty_tpl->tpl_vars['sellbill']->value->newSellbillidAfterEdit>0){?> <!--this bill is deleted for editing-->
                                    حذف للتعديل
                                    <?php }else{ ?>
                                    تم حذف الفاتورة
                                    <?php }?>



                                    <?php }?>
                                </td>
                                <td class="hidden-print">
                                    <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->conditions;?>
<?php $_tmp12=ob_get_clean();?><?php if ($_tmp12==0){?>


                                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->noBillEditTillPay==0||($_smarty_tpl->tpl_vars['Programsettingdata']->value->noBillEditTillPay==1&&$_smarty_tpl->tpl_vars['sellbill']->value->sellbilltotalpayed==$_smarty_tpl->tpl_vars['sellbill']->value->sellbillaftertotalbill)){?>
                                    <a href="#" type="button" class="btn btn-default btn-lg removeicon <?php if ($_smarty_tpl->tpl_vars['sellbill']->value->billPayments>0&&$_smarty_tpl->tpl_vars['usergroup']->value->noBillEditIfTheirIsPayments==0){?> billHasPayments <?php }else{ ?> conformdel1 <?php }?>" data-href="sellbillController.php?do=delete&sellbillid=<?php if ($_smarty_tpl->tpl_vars['do']->value=="all"){?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->taxBillNumber;?>
<?php }else{ ?><?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
<?php }?>&action=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->dailyentryid;?>
"></a>
                                    <?php }else{ ?>
                                    سدد الفاتوره اولا
                                    <?php }?>



                                    <?php }else{ ?>
                                    <?php if (isset($_smarty_tpl->tpl_vars['sellbill']->value->newSellbillidAfterEdit)&&$_smarty_tpl->tpl_vars['sellbill']->value->newSellbillidAfterEdit>0){?> <!--this bill is deleted for editing-->
                                    حذف للتعديل
                                    <?php }else{ ?>
                                    تم حذف الفاتورة
                                    <?php }?>

                                    <?php }?> </td><?php }?>

                                <?php if ($_smarty_tpl->tpl_vars['do']->value!="all"){?>
                                <td class="hidden-print">
                                    <a href="dailyentry.php?id=<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->dailyentryid;?>
" target="_blank" type="button"
                                        class="btn btn-default btn-lg editicon"></a>
                                </td>
                                <?php }?>
                                <?php if ($_smarty_tpl->tpl_vars['usergroup']->value->netprofit==0){?><td class="hidden-print">
                                    <a type="button" class="btn btn-default btn-lg infoicon calBillProfit"
                                        data-id="<?php echo $_smarty_tpl->tpl_vars['sellbill']->value->sellbillid;?>
"></a>
                                </td><?php }?>
                            </tr>

                            <?php } ?>

                        </tbody>

                    </table>
            </div>


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

            <!-- 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 -->
            <!-- Modal -->
            <div class="hidden-print">
                <div class="modal fade " id="profitModal" 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" id="profitModalBody">

                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">اغلاق</button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </div>
            <!-- /.modal -->


            <hr />
            <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="spryselect1">
                                    <select name="operation" id="operation" data-placeholder="اختر العملية"
                                        class="select2 wdt100">
                                        <option value="-1">اختر عملية</option>
                                        <option value="1">حذف</option>
                                        <option value="2">طباعة مجمعة</option>
                                    </select>
                                    <span class="selectInvalidMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-4">
                                <input name="" id="excuteOperationBtn" class="noprint btn btn-primary" type="button"
                                    value="تنفيذ" />
                            </div>
                        </div>
                        <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>
                        <div class="clearfix"></div>
                    </div>
                </div>
                <div class="col-lg-4 "><!-- col-lg-offset-8 -->
                    <div class="well well-sm">
                        <h4 class="text-center">عدد القطع: <span id="piecesCount"><?php echo $_smarty_tpl->tpl_vars['piecesCount']->value;?>
</span></h4>
                    </div>
                </div>
                <!--                <div class="col-lg-4 "> col-lg-offset-8
                                    <div class="well well-sm">
                                        <h4 class="text-center">عدد الفواتير:  <?php echo $_smarty_tpl->tpl_vars['billsCount']->value;?>
</h4>
                                    </div>
                                </div>-->
                <div class="col-lg-4 "><!-- col-lg-offset-8 -->
                    <div class="well well-sm">
                        <h4 class="text-center">إجمالي المبيعات: <span id="totalBills"><?php echo $_smarty_tpl->tpl_vars['totalBillsNoDiscount']->value;?>
</span>
                        </h4>
                    </div>
                </div>
                <div class="col-lg-4 "><!-- col-lg-offset-8 -->
                    <div class="well well-sm">
                        <h4 class="text-center">إجمالي الخصم: <span id="totalBills"><?php echo $_smarty_tpl->tpl_vars['totalDiscount']->value;?>
</span></h4>
                    </div>
                </div>
                <div class="col-lg-4 "><!-- col-lg-offset-8 -->
                    <div class="well well-sm">
                        <h4 class="text-center">إجمالي صافى المبيعات: <span id="totalBills"><?php echo $_smarty_tpl->tpl_vars['totalBills']->value;?>
</span></h4>
                    </div>
                </div>
                <div class="col-lg-4 "><!-- col-lg-offset-8 -->
                    <div class="well well-sm">
                        <h4 class="text-center">اجمالى المدفوع: <span id="payedTotal"><?php echo $_smarty_tpl->tpl_vars['payedTotal']->value;?>
</span></h4>
                    </div>
                </div>
                <div class="col-lg-4 "><!-- col-lg-offset-8 -->
                    <div class="well well-sm">
                        <h4 class="text-center">اجمالى المؤجل : <span id="remainTotal"><?php echo $_smarty_tpl->tpl_vars['remainTotal']->value;?>
</span></h4>
                    </div>
                </div>

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

            <div class="hidden-print">
                <span><button class="btn btn-success pull-right excelFile" data-tblId="excelTable" data-path="">ملف
                        اكسل</button></span>
                <span id="ExcelStatus"></span>
            </div>
        </div>
    </div>
</div>


<!-- Modal -->
<div class="hidden-print">
    <div class="modal fade " id="statusModal" 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">
                    <form method="post" action="sellbillController.php?do=changeStatus">
                        <input type="hidden" name="sellbillid" id="statusSellbillId" value="" />
                        <select name="status" id="sellbillStatus" data-placeholder="اختر الحالة" class="select wdt90">
                            <option value="new"><?php echo @SELL_BILL_STATUS_NEW;?>
</option>
                            <option value="prepare">
                                <?php if ($_smarty_tpl->tpl_vars['billsettingsData']->value[111]->billsettingsvalue==0){?>
                                <?php echo @SELL_BILL_STATUS_PREPARE;?>

                                <?php }else{ ?>
                                <?php echo @SELL_BILL_STATUS_FACTORY_SEND;?>

                                <?php }?>
                            </option>
                            <option value="shipped">
                                <?php if ($_smarty_tpl->tpl_vars['billsettingsData']->value[111]->billsettingsvalue==0){?>
                                <?php echo @SELL_BILL_STATUS_SHIPPED;?>

                                <?php }else{ ?>
                                <?php echo @SELL_BILL_STATUS_FACTORY_DELIVERED;?>

                                <?php }?>
                            </option>
                            <option value="deliver">
                                <?php echo @SELL_BILL_STATUS_DELIVERED;?>

                            </option>
                            <option value="refused">
                                <?php echo @SELL_BILL_STATUS_REFUSED;?>

                            </option>
                        </select>
                </div>
                <div class="modal-footer">
                    <input type="submit" class="btn btn-success" value="حفظ" />
                    </form>
                    <button type="button" class="btn btn-default" data-dismiss="modal">اغلاق</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
</div>
<!-- /.modal -->


<script type="text/javascript">
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {isRequired: false, invalidValue: "-1"});
    //

    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();
    }

    $('.sendbill').live('click', function (e) {
        var sellbillid = Number($(this).attr('data-sellbillid'));
        $(this).hide();
        $("#ebill_" + sellbillid).html("<span><img style=width:30px;height:30px' src='../views/default/assets/img/icons8-spinner.gif'/></span>");
        var thisIs = $(this);
        if (sellbillid > 0) {

            $.ajax({
                type: "POST",
                url: 'eBillRequests.php?do=etsellbill',
                data: {sellbillid: sellbillid},
                success: function (data) {
                    $("#ebill_" + sellbillid).html("");
                    $(thisIs).show();
                    if (data == 1) {
                        $('#ebill_' + sellbillid).html('تم الارسال ');
                    } else {
                        $('#ebill_' + sellbillid).html(' حدث خطأ');
                        window.open('sellbillController.php?do=ebillerrors&sellbillid=' + sellbillid);
                    }
                }
            });
        }
    });



     $('.sendbill2').live('click', function (e) {
        var sellbillid = Number($(this).attr('data-sellbillid'));
        $(this).hide();
        $("#ebill2_" + sellbillid).html("<span><img style=width:30px;height:30px' src='../views/default/assets/img/icons8-spinner.gif'/></span>");
        var thisIs = $(this);
        if (sellbillid > 0) {

            $.ajax({
                type: "POST",
                url: 'saudiElectronIcinvoiceController.php?do=etsellbill',
                data: {sellbillid: sellbillid},
                success: function (data) {
                    $("#ebill2_" + sellbillid).html("");
                    $(thisIs).show();
                    if (data == 1) {
                        $('#ebill_' + sellbillid).html('تم الارسال ');
                    } else {
                        $('#ebill_' + sellbillid).html(' حدث خطأ');
                        window.open('sellbillController.php?do=ebillerrors&sellbillid=' + sellbillid);
                    }
                }
            });
        }
    });


    $('.downloadepdf').live('click', function (e) {
        var sellbillid = Number($(this).attr('data-sellbillid'));
        var uuid = $(this).attr('data-uuid');
        $(this).hide();
        $("#epdf" + sellbillid).html("<span><img style=width:30px;height:30px' src='../views/default/assets/img/icons8-spinner.gif'/></span>");
        var thisIs = $(this);
        if (uuid) {
            $.ajax({
                type: "POST",
                url: 'eBillRequests.php?do=epdf',
                dataType: 'json',
                data: {uuid: uuid, sellbillid: sellbillid},
                success: function (data) {

                    if (data != 0) {
                        $("#epdf" + sellbillid).html('<a href="' + data + '" type="button" class="btn btn-default"> pdf</a> ');
                        window.open("" + data + "", "_blank");
                    }

                }
            });
        }
    });
    //
    $('#excuteOperationBtn').live('click', function (e) {
        e.preventDefault();
        e.stopPropagation();
        //    $('#excuteOperationForm').
        var ids = '';
        $(".choosenItem:checked").each(function () {
            ids += $(this).val() + ',';
        });

        if (ids != "") {
            if ($('#operation').val() == "2") {
                window.open('sellbillprintController.php?do=showDetail2Bulk&id=' + ids);
            } else if ($('#operation').val() == 1) {
                var arr = ids.split(",");

                for (let i = 0; i < arr.length; i++) {
                    if (arr[i] != "") {
                        const sellbillid = arr[i];
                        $.post('sellbillController.php?do=delete&sellbillid=' + sellbillid, {curlpost: 1}, function (data) {
                            location.reload();
                        }).fail(function (xhr, status, error) {
                            console.log(error);
                        });
                    }
                }
            } else {
                return true;
            }
        } else {
            $("#noElementsError").css("display", "block");
            setTimeout(function () {
                $("#noElementsError").css("display", "none");
            }, 4000);
        }
    });

    $('.shippingDate').live('change', function (e) {
        var id = Number($(this).data('id'));
        var val = $(this).val();
        var thisIs = $(this);
        if (id > 0 && val != "") {
            $.ajax({
                type: "POST",
                url: 'sellbillAjaxController.php?do=updateshippingDate',
                data: {shippingDate: val, id},
                success: function (data) {
                    if (data == 1) {
                        thisIs.addClass('success_f');
                        setTimeout(function () {
                            thisIs.removeClass('success_f');
                        }, 2000);
                    } else {
                        thisIs.addClass('error_f');
                        setTimeout(function () {
                            thisIs.removeClass('error_f');
                        }, 2000);
                    }
                },
                error: function () {
                    thisIs.addClass('error_f');
                    setTimeout(function () {
                        thisIs.removeClass('error_f');
                    }, 2000);
                }
            });
        }
    });

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

        e.preventDefault();

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

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

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

        window.location.href = pos;
    });


    $('.clickuploadfile').live('click', function (e) {
        var sellbill = $(this).attr('data-sellbill');
        uploadfile(sellbill);
        $("#uploadfile" + sellbill).click();

    });
    function uploadfile(sellbill) {
        $("#uploadfile" + sellbill).on('change', (function (e) {
            e.preventDefault();
            var formData = new FormData();
            formData.append('imageid', $(this).attr('data-imageid'));
            formData.append('sellbillid', sellbill);
            formData.append('imageu', $(this)[0].files[0]);
            $.ajax({
                url: 'allajax.php?do=uploadfile',
                type: "POST",
                data: formData,
                contentType: false,
                cache: false,
                processData: false,
                success: function (data) {
                    $('#imagesuploadfile' + sellbill).html(data);
                },
            });
        }));
    }
    $('.calBillProfit').live('click', function () {
        var id = $(this).data('id');
        $.ajax({
            type: "POST",
            url: 'sellbillAjaxController.php?do=billprofit',
            data: {id: id},
            //async: false,
            success: function (data) {
                data = JSON.parse(data);

                $html = '<form class="form-horizontal">';
                if (data.u > 0) {
                    Object.keys(data.cost).forEach(function (index, value) {
                        $cost = Number(Number(data.cost[index]).toFixed(2));
                        $profit = Number(Number(data.totalbill - $cost).toFixed(2));
                        //                        $priceName = getPriceName(index);

                        $html += '<div class="form-group">' +
                            '    <label class="col-lg-3 control-label">صافى الفاتورة</label>' +
                            '    <div class="col-lg-6">' +
                            '        <input class="form-control" type="text" value="' + Number(data.totalbill) + '" readonly/>' +
                            '    </div>' +
                            '</div>';
                        $html += '<div class="form-group">' +
                            '    <label class="col-lg-3 control-label">التكلفة</label>' +
                            '    <div class="col-lg-6">' +
                            '        <input class="form-control" type="text" value="' + $cost + '" readonly/>' +
                            '    </div>' +
                            '</div>';
                        $html += '<div class="form-group">' +
                            '    <label class="col-lg-3 control-label">الربح</label>' +
                            '    <div class="col-lg-6">' +
                            '        <input class="form-control" type="text" value="' + $profit + '"  readonly/>' +
                            '    </div>' +
                            '</div>';
                    });
                } else {
                    $html += '<table class="table">' +
                        '    <thead>' +
                        '        <tr>' +
                        '            <th>صافى الفاتورة</th>' +
                        '            <th>نوع السعر</th>' +
                        '            <th>التكلفة</th>' +
                        '            <th>الربح</th>' +
                        '        </tr>' +
                        '    </thead>' +
                        '    <tbody>';
                    Object.keys(data.cost).forEach(function (index, value) {
                        $cost = Number(Number(data.cost[index]).toFixed(2));
                        $profit = Number(Number(data.totalbill - $cost).toFixed(2));
                        $priceName = getPriceName(index);

                        $html += '        <tr>' +
                            '           <td>' + Number(data.totalbill) + '</td>' +
                            '            <td>' + $priceName + '</td>' +
                            '           <td>' + $cost + '</td>' +
                            '            <td>' + $profit + '</td>' +
                            '        </tr>';

                    });
                    $html += '    </tbody>' +
                        '</table>';
                }
                $html += '</form>';
                $('#profitModalBody').html($html);
                $('#profitModal').modal('show');
            }
        });
        function getPriceName(key) {
            let name = '';
            switch (key) {
                case 'buyprice':
                    name = 'سعر الشراء ';
                    break;
                case 'lastbuyprice':
                    name = 'اخر سعر شراء ';
                    break;
                case 'meanbuyprice':
                    name = 'متوسط سعر الشراء ';
                    break;
                case 'lastbuyprice_withDiscount':
                    name = 'اخر سعر شراء بعد الخصم ';
                    break;
                case 'meanbuyprice_withDiscount':
                    name = 'متوسط سعر الشراء بعد الخصم ';
                    break;
            }
            return name;
        }

    });
    $(function () {
        $(".select2Supp").select2({
            placeholder: "العميل",
            minimumInputLength: document.getElementById("searchvalue").value,
            inimumInputLength: 0,
            multiple: false,
            quietMillis: 100,
            //width: '80%',
            ajax: {
                url: "clientControllerAjax.php?do=select2ClientsAjax",
                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
        $('#clientid').select2('data', {id: $('#oldsupplierid').val(), text: $('#oldsuppliername').val()});

        $("#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: formatResult,
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
        $(".billHasPayments").live("click", function (e) {
            var link = $(this);
            e.preventDefault();
            if (confirm("يوجد دفعات مرتبطة بالفاتوره\n\
    هل تود المتابعه و حذف الدفعات ايضا؟") == true) {
                if (!link.attr('href') || link.attr('href') == "#") {
                    window.location = link.data('href');
                } else {
                    window.location = link.attr('href');
                }
            }
        });

    });
    $('.showStModal').click(function (e) {
        e.preventDefault();
        var id = $(this).data('id');
        var status = $(this).data('status');
        $('#statusModal').modal('show');
        $('#statusSellbillId').val(id);
        $('#sellbillStatus option[value="' + status + '"]').attr("selected", true);
    });
    $('#hideDel').live('click', function (e) {
        localStorage.setItem("hideDelBillSearch", $(this).is(":checked"));
    });
    var hideDelBillSearch = localStorage.getItem("hideDelBillSearch");
    if (hideDelBillSearch === 'true') {
        $('#hideDel').attr('checked', 'checked');
    } else {
        $('#hideDel').removeAttr('checked');
    }

    $('#hidePayed').live('click', function (e) {
        localStorage.setItem("hidePayedBillSearch", $(this).is(":checked"));
    });
    var hidePayedBillSearch = localStorage.getItem("hidePayedBillSearch");
    if (hidePayedBillSearch === 'false') {
        $('#hidePayed').removeAttr('checked');
    } else {
        $('#hidePayed').attr('checked', 'checked');
    }

</script>
<?php }} ?>