<style>
    .serial-success {
        background-color: #6ed96e !important;
    }

    .serial-error {
        background-color: #f47c7c !important;
    }

    @media print {

        tr>.myblack {
            border: 1px solid black !important;
        }


        .myleft {
            padding-top: 20px !important;
        }

        .myright {

            margin-top: 50px !important;
            float: right !important;
            margin-bottom: 10px !important;
        }

        .margintop {
            margin-top: 90px !important;
        }
    }
</style>
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ادارة الفواتير</a></li>
            <li><a href="#">فواتير المبيعات</a></li>
            <li class="active">تفاصيل فاتورة مبيعات</li>
        </ol>
        <h3>{$billnameAddData->name}</h3>
        <hr />
        <form class="form-horizontal " role="form" action="sellbillController.php?do=serializeProducts" method="post"
              id="serialsForm">
            <div class="row ">
                <div class="col-lg-8">
                    <div class="form-group" {if {$billsettingsData[61]->billsettingsvalue} eq 0} style="display:block"
                        {else} style="display:none" {/if}>
                        <label class="col-lg-3 control-label  myleft">رقم الفاتورة</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$sellbillData->sellbillserial} </p>
                        </div>
                    </div>
                    {if $Programsettingdata->clientserial eq 1}
                    <div class="form-group">
                        <label class="col-lg-3 control-label myleft">الرقم التسلسلي</label>
                        <div class="col-lg-9">
                            <p class="form-control-static">{if $sellbillData->taxBillNumber >
                                0}{$sellbillData->taxBillNumber}{else}{$billId}{/if}</p>
                        </div>
                    </div>
                    {/if}
                    <!-- end of form-group-->

                    <div class="form-group" {if {$billsettingsData[5]->billsettingsvalue} eq 0} style="display:block"
                        {else} style="display:none" {/if} >
                        <label class="col-lg-3 control-label myleft">تاريخ الفاتورة</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$sellbillData->sellbilldate} </p>
                        </div>
                    </div>

                    <div class="form-group" {if {$billsettingsData[102]->billsettingsvalue} eq 0} style="display:block"
                        {else} style="display:none" {/if} >
                        <label class="col-lg-3 control-label myleft">تاريخ التسليم</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$sellbillData->datestarting} </p>
                        </div>
                    </div>

                    <div class="form-group" {if {$billsettingsData[110]->billsettingsvalue} eq 0} style="display:block"
                        {else} style="display:none" {/if} >
                        <label class="col-lg-3 control-label myleft">{$smarty.const.SELL_BILL_STATUS}</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {if $billStatus == "new"}
                                {$smarty.const.SELL_BILL_STATUS_NEW}
                                {elseif $billStatus == "prepare"}
                                {if $billsettingsData[111]->billsettingsvalue eq 0}
                                {$smarty.const.SELL_BILL_STATUS_PREPARE}
                                {else}
                                {$smarty.const.SELL_BILL_STATUS_FACTORY_SEND}
                                {/if}
                                {elseif $billStatus == "shipped"}
                                {if $billsettingsData[111]->billsettingsvalue eq 0}
                                {$smarty.const.SELL_BILL_STATUS_SHIPPED}
                                {else}
                                {$smarty.const.SELL_BILL_STATUS_FACTORY_DELIVERED}
                                {/if}
                                {elseif $billStatus == "deliver"}
                                {$smarty.const.SELL_BILL_STATUS_DELIVERED}
                                {elseif $billStatus == "refused"}
                                {$smarty.const.SELL_BILL_STATUS_REFUSED}
                                {/if} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div {if {$billsettingsData[35]->billsettingsvalue} eq 0} {else} style="display:none" {/if} >
                        <div class="form-group">
                            <label class="col-lg-3 control-label myleft">رقم السيارة</label>
                            <div class="col-lg-9">
                                <p class="form-control-static">
                                    {$sellbillData->carnumber}
                                </p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-3 control-label myleft">نوع السيارة</label>
                            <div class="col-lg-9">
                                <p class="form-control-static">
                                    {$sellbillData->cartype}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-3 control-label myleft">شاسية السيارة</label>
                            <div class="col-lg-9">
                                <p class="form-control-static">
                                    {$sellbillData->carchase}
                                </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-3 control-label myleft">موتور السيارة</label>
                            <div class="col-lg-9">
                                <p class="form-control-static">
                                    {$sellbillData->carmotor}
                                </p>
                            </div>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-lg-3 control-label myleft">اسم العميل المؤقت</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$sellbillData->tempclientName} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->



                    <div {if {$billsettingsData[39]->billsettingsvalue} eq 0} {else} style="display:none" {/if} >
                        <div id="divclientdata">
                            <div class="form-group">
                                <label class="col-lg-3 control-label myleft">عنوان العميل </label>
                                <div class="col-lg-9">
                                    <p class="form-control-static"> {$myclientdata->clientaddress}</p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-lg-3 control-label myleft">رقم التليفون</label>
                                <div class="col-lg-9">
                                    <p class="form-control-static"> {$myclientdata->clientphone} {if
                                        $myclientdata->clientmobile != ''} - {$myclientdata->clientmobile}{/if}</p>
                                </div>


                            </div>


                            <div class="form-group">
                                <label class="col-lg-3 control-label myleft">كود العميل</label>
                                <div class="col-lg-9 color-white">
                                    {$myclientdata->clientcode}
                                </div>


                            </div>

                        </div>

                    </div>
                </div>
                <!-- end of bill no-->

                <div class="col-lg-4 hidden-print">
                    <div class="form-group mg-bt5" {if {$billsettingsData[45]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">مركز التكلفة </label>
                        <div class="col-lg-7">

                            {foreach $allCostcenter as $myallCostcenter}

                            {if {$sellbillData->costcenterid} eq {$myallCostcenter->id}} {$myallCostcenter->name} {/if}
                            {/foreach}


                        </div>
                    </div>
                    <!-- end of form-group-->

                </div>

                <div class="col-lg-4">
                    <div class="form-group mg-bt5" {if {$billsettingsData[1]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">اسم العميل</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$sellbillData->sellbillclientname} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                         {$billsettingsData[56]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">رصيد الدين</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$sellbillData->sellbilltotaldeptbefor} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5">
                        <!--{if {$billsettingsData[68]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}-->
                        <label class="col-lg-5 control-label">نوع السعر</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {if {$sellbilldetailData[0]->pricetype} eq 1}
                                تجزئة
                                {elseif {$sellbilldetailData[0]->pricetype} eq 0}
                                جملة
                                {elseif {$sellbilldetailData[0]->pricetype} eq 2}
                                نصف جملة
                                {elseif {$sellbilldetailData[0]->pricetype} eq 4}
                                سعر4
                                {elseif {$sellbilldetailData[0]->pricetype} eq 5}
                                سعر5
                                {elseif {$sellbilldetailData[0]->pricetype} eq 6}
                                سعر6
                                {elseif {$sellbilldetailData[0]->pricetype} eq 7}
                                سعر7
                                {elseif {$sellbilldetailData[0]->pricetype} eq 8}
                                سعر8
                                {elseif {$sellbilldetailData[0]->pricetype} eq 9}
                                سعر9
                                {elseif {$sellbilldetailData[0]->pricetype} eq 10}
                                سعر10
                                {elseif {$sellbilldetailData[0]->pricetype} eq 11}
                                سعر11
                                {elseif {$sellbilldetailData[0]->pricetype} eq 12}
                                سعر12
                                {elseif {$sellbilldetailData[0]->pricetype} eq 13}
                                سعر13
                                {/if} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    {if $manyStores neq 1}
                    <hr class="mg-bt5 mg-tp5 hidden-print" />
                    <div class="form-group mg-bt5" {if {$billsettingsData[2]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">المخزن</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$sellbillData->storeName} </p>
                        </div>
                    </div>
                    {/if}
                    {if {$billsettingsData[123]->billsettingsvalue} eq 1}
                    <div class="form-group mg-bt5" {if {$billsettingsData[2]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">بيع للمورد</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$mysupplierdata->suppliername} </p>
                        </div>
                    </div>
                    {/if}
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" {if {$billsettingsData[3]->billsettingsvalue} eq 0}
                        style="display:block" {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">اسم {if $Programsettingdata->delegate_seller eq 0}
                            بائع {elseif $Programsettingdata->delegate_seller == 1}مندوب {elseif
                            $Programsettingdata->delegate_seller == 2}طبيب {/if}</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$sellbillData->employeename} </p>
                        </div>
                    </div>
                    <div class="form-group mg-bt5" {if {$billsettingsData[101]->billsettingsvalue} eq 0}
                        style="display:block" {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">عملية الفاتورة </label>
                        <div class="col-lg-7">
                            {$sellbillData->billoperationName}
                        </div>
                    </div>
                    <div class="form-group mg-bt5" {if {$billsettingsData[101]->billsettingsvalue} eq 0}
                        style="display:block" {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label myleft">نوع الفاتورة </label>
                        <div class="col-lg-7">
                            {if $sellbillData->obgyBillType == 1}مباشر{else if $sellbillData->obgyBillType ==
                            2}مستهلك{else if $sellbillData->obgyBillType == 3}استقبال{/if}
                        </div>
                    </div>



                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label myleft">اسم المستخدم</label>
                        <div class="col-lg-7">
                            <p class="form-control-static">
                                {$sellbillData->useremployeename}
                            </p>
                        </div>
                    </div><!-- end of form-group-->
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label myleft">التعليق</label>
                        <div class="col-lg-7">
                            <p class="form-control-static">
                                {$sellbillData->comment}
                            </p>
                        </div>
                    </div><!-- end of form-group-->
                    {if {$billsettingsData[109]->billsettingsvalue} eq 0}
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label myleft">طرق المعرفة</label>
                        <div class="col-lg-7">
                            <p class="form-control-static">
                                {$sellbillData->wayName}
                            </p>
                        </div>
                    </div>
                    {/if}
                    <!-- end of form-group-->
                </div>
                <!-- end of client info-->

            </div>
            <!-- end of frist row-->
            <!-- hidden ===============================-->
            <input type="hidden" name="billnameid" id="billnameid" value="{$billnameid}" />
            <input type="hidden" name="settingreturn" id="settingreturn"
                   value="{$billsettingsData[0]->billsettingsvalue}" />
            <input type="hidden" name="settingclient" id="settingclient"
                   value="{$billsettingsData[1]->billsettingsvalue}" />
            <input type="hidden" name="settingstore" id="settingstore"
                   value="{$billsettingsData[2]->billsettingsvalue}" />
            <input type="hidden" name="settingseller" id="settingseller"
                   value="{$billsettingsData[3]->billsettingsvalue}" />
            <input type="hidden" name="settingparcode" id="settingparcode"
                   value="{$billsettingsData[4]->billsettingsvalue}" />
            <input type="hidden" name="settingdate" id="settingdate"
                   value="{$billsettingsData[5]->billsettingsvalue}" />
            <input type="hidden" name="settingnewproduct" id="settingnewproduct"
                   value="{$billsettingsData[6]->billsettingsvalue}" />
            <input type="hidden" name="settingcomment" id="settingcomment"
                   value="{$billsettingsData[7]->billsettingsvalue}" />
            <input type="hidden" name="settingdiscount" id="settingdiscount"
                   value="{$billsettingsData[8]->billsettingsvalue}" />
            <input type="hidden" name="settingQuantitiyFocus" id="settingQuantitiyFocus"
                   value="{$billsettingsData[9]->billsettingsvalue}" />
            <input type="hidden" name="settingUnit" id="settingUnit"
                   value="{$billsettingsData[10]->billsettingsvalue}" />

            <!-- end of hidden ===============================-->
            <div class="clearfix"></div>
            <div class="margintop"></div>

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

            <div class="row">
                <div class="row">
                    <hr class='hidden-print' />
                    <div class="col-lg-6">
                        <h4>المبيعات</h4>
                    </div>
                </div>
                <!-- end of title row-->

                <div class="table-responsive">
                    <table class="table billtable table-bordered table-black" id="containerpros">
                        <thead>
                            <tr>
                                <th class="wdt60 myblack" {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important;" {/if}>رقم</th>
                                <th class="wdt60 myblack" {if {$billsettingsData[59]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important" {/if} class="wdt120">الباركود</th>
                                <th class="wdt300 myblack">اسم المنتج</th>
                                {if {$billsettingsData[26]->billsettingsvalue} eq 0}

                                <th class="wdt240 myblack">المخزن</th>


                                {/if}

                                <th class=" myblack hidden-print" {if {$billsettingsData[7]->billsettingsvalue} eq 0}
                                    {else} style="display:none !important" {/if} class="wdt240">ملاحظات</th>
                                <th class=" myblack wdt100n" {if {$billsettingsData[53]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important" {/if}">الوحدة</th>
                                <th class="wdt100n myblack" {if {$billsettingsData[64]->billsettingsvalue} eq 0} {else}
                                    style="display:none" {/if}>العدد</th>
                                <th
                                    class="wdt100n check_tr_unit  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    {$Programsettingdata->scunitname}</th>
                                <th
                                    class="wdt100n myblack {if $Usergroupdata->hideBillPrices == 1 || $billsettingsData[116]->billsettingsvalue eq 0}hidden{/if}">
                                    السعر
                                    قبل الخصم
                                </th>
                                <th
                                    class="wdt100n myblack {if {$billsettingsData[116]->billsettingsvalue} eq 0}  hidden {/if}">
                                    {$smarty.const.SELL_BILL_CAT_DISCOUNT}</th>
                                <th class="wdt100n myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">السعر
                                </th>

                                <th class="wdt100n myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                    الاجمالى قبل الخصم</th>
                                <th class=" myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                                    {$billsettingsData[8]->billsettingsvalue} eq 0} {else} style="display:none" {/if}
                                    class="wdt100n">الخصم</th>
                                <th class="wdt100n myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                    الاجمالى</th>
                                <th class="wdt100n myblack"> سريل</th>
                            </tr>
                        </thead>
                        <tbody>

                            {assign var=x value=1}
                            {foreach $sellbilldetailData as $sellbilldetail}
                            <tr>
                                <td class=" myblack" {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important;" {/if}>{$x}</td>
                                <td class=" myblack" {if {$billsettingsData[59]->billsettingsvalue} eq 0} {else}
                                    style="display:none" {/if}>
                                    <div id="productparcode1">
                                        <p class="form-control-static"> {$sellbilldetail->parcode} </p>
                                    </div>
                                </td>
                                <td class=" myblack">
                                    <div id="productdiv1">
                                        <p class="form-control-static"> {$sellbilldetail->productName}/
                                            {$sellbilldetail->productCatName}
                                            {if $sellbilldetail->sizeName != ''}/ {$sellbilldetail->sizeName}{/if}
                                            {if $sellbilldetail->colorName != ''}/ {$sellbilldetail->colorName}{/if}
                                        </p>
                                    </div>
                                </td>

                                {if {$billsettingsData[26]->billsettingsvalue} eq 0}
                                {if {$sellbilldetail->storeName} <> ""}
                                <td class=" myblack">
                                    <div id="productparcode1">
                                        <p class="form-control-static"> {$sellbilldetail->storeName} </p>
                                    </div>
                                </td>
                                {else}
                                <td class=" myblack">
                                    <div id="productparcode1">
                                        <p class="form-control-static">

                                            {$sellbillData->storeName}
                                        </p>
                                    </div>
                                </td>
                                {/if}
                                {/if}



                                <td class=" myblack  {if  $sellbilldetail->note eq ''} hidden-print{/if}" {if
                                    {$billsettingsData[7]->billsettingsvalue} eq 0} {else} style="display:none
                                    !important" {/if}>
                                    <p class="form-control-static"> {$sellbilldetail->note} </p>
                                </td>
                                <td class=" myblack" {if {$billsettingsData[53]->billsettingsvalue} eq 0} {else}
                                    style="display:none" {/if}>
                                    <div id="productunitdiv1">
                                        <p class="form-control-static"> {$sellbilldetail->unitName} </p>
                                    </div>
                                </td>

                                <td class=" myblack" {if {$billsettingsData[64]->billsettingsvalue} eq 0} {else}
                                    style="display:none" {/if}>
                                    <p class="form-control-static"> {$sellbilldetail->sellbilldetailquantity} </p>
                                </td>

                                <td
                                    class="check_tr_quantity  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    {$sellbilldetail->otherdetailquantity}
                                </td>
                                <td
                                    class=" myblack {if $Usergroupdata->hideBillPrices == 1  || $billsettingsData[116]->billsettingsvalue eq 0}hidden{/if}">
                                    <div id="propricechange1">
                                        <p class="form-control-static"> {$sellbilldetail->sellbilldetailprice +
                                            $sellbilldetail->categorydiscount} </p>
                                    </div>
                                </td>

                                <td class=" {if {$billsettingsData[116]->billsettingsvalue} eq 0}  hidden {/if}">
                                    <p class="form-control-static">{$sellbilldetail->categorydiscount}</p>
                                </td>

                                <td class=" myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                    <div id="propricechange1">
                                        <p class="form-control-static"> {$sellbilldetail->sellbilldetailprice} </p>
                                    </div>
                                </td>


                                <td class=" myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                    <p class="form-control-static"> {$sellbilldetail->sellbilldetailtotalprice +
                                        $sellbilldetail->discountvalue} </p>
                                </td>
                                <td class=" myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                                    {$billsettingsData[8]->billsettingsvalue} eq 0} {else} style="display:none"
                                    {/if}>
                                    <p class="form-control-static">
                                        {$sellbilldetail->discountvalue}
                                    </p>
                                </td>
                                <td class=" myblack {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                    <p class="form-control-static"> {$sellbilldetail->sellbilldetailtotalprice} </p>
                                </td>
                                <td class=" myblack">
                                    {if ($sellbilldetail->sizeid == 0 && $sellbilldetail->parcode ==
                                    $sellbilldetail->productParcode)||($sellbilldetail->sizeid > 0 &&
                                    $sellbilldetail->parcode == $sellbilldetail->productParcodeSC)}
                                    {if $sellbilldetail->soldSerialsInDetails != ""}
                                    {$sellbilldetail->soldSerialsInDetails}
                                    {else}
                                    <input type="hidden" name="proSerials{$x}" id="proSerials{$x}"
                                           class="proSerials"
                                           data-pro="{if $sellbilldetail->sizeid > 0 && $sellbilldetail->colorid > 0}hasSizeColor{$sellbilldetail->sellbilldetailproductid}-{$sellbilldetail->sizeid}-{$sellbilldetail->colorid}{else}{$sellbilldetail->sellbilldetailproductid}{/if}"
                                           data-quantity="{$sellbilldetail->sellbilldetailquantity*$sellbilldetail->productnumber}" data-store="{$sellbilldetail->storeid}"/>
                                    <input type="hidden" name="proid{$x}" id="proid{$x}"
                                           value="{if $sellbilldetail->sizeid > 0 && $sellbilldetail->colorid > 0}hasSizeColor{$sellbilldetail->sellbilldetailproductid}-{$sellbilldetail->sizeid}-{$sellbilldetail->colorid}{else}{$sellbilldetail->sellbilldetailproductid}{/if}" />
                                    <input type="hidden" name="requiredQuantity{$x}" id="requiredQuantity{$x}"
                                           value="{$sellbilldetail->sellbilldetailquantity*$sellbilldetail->productnumber}" />
                                    <input type="hidden" name="sellbilldetailid{$x}" id="sellbilldetailid{$x}"
                                           value="{$sellbilldetail->sellbilldetailid}" />
                                    {/if}
                                    {else}
                                    -
                                    {/if}
                                </td>
                            </tr>
                            {capture assign=x}{$x+1}{/capture}
                            {/foreach}
                        <input type="hidden" name="itr" id="itr" value="{$x}" />
                        <input type="hidden" name="sellbillId" id="sellbillId"
                               value="{$sellbillData->sellbillid}" />
                        <input type="hidden" name="sellbillclientId" id="sellbillclientId"
                               value="{$sellbillData->sellbillclientid}" />
                        </tbody>

                    </table>
                </div>
                <button type="button"
                        class="btn btn-primary pull-left ft-nor {if $Usergroupdata->hideBillPrices == 1}hidden{/if}"> اجمالى
                    المبيعات <span class="badge wht-clo">
                        <div id="sellbilltotal">{$sellbillData->sellbilltotalbill}</div>
                    </span> </button>
            </div>
            <!-- end of second row-->

            <div class="row">


                <div class="col-lg-7">

                    <div id="closeebill">
                        {foreach $sellbilldetailtaxdata as $data}
                        <div class="form-group mg-bt5">
                            <label class="col-lg-3 control-label">{$data['subtype']} - {$data['type']}</label>
                            <div class="col-lg-3">{$data['amount']}</div>
                        </div>
                        {/foreach}
                    </div>
                    <div class="form-group" {if {$billsettingsData[80]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-2 control-label">{if {$Programsettingdata->delivery} eq 0}شحن{else} توصيل
                            {/if}</label>
                        <div class="col-lg-4">
                            <p name="delivery" id="delivery">{$sellbillData->delivery}</p>
                            <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل
                                القيمة صحيحة</span>
                        </div>
                    </div>

                    <div class="form-group mg-bt5" {if {$billsettingsData[80]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-2 control-label">الاجمالي العام</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="valdelivery">{$sellbillData->totalafterdelivery}
                            </p>
                            <!--<input type="hidden" name="valdeliveryhidden" id="valdeliveryhidden" value="0"/>-->

                        </div>
                    </div>
                    {if $sellbillimage.images}
                    <div>
                        <img src="../views/default/images/sellbill/{$sellbillimage.images}"
                             style="width: 100px;height: 100px;border: 1px solid;border-radius: 6px;">
                    </div>
                    {/if}

                    <div class="form-group mg-bt5" {if {$billsettingsData[120]->billsettingsvalue} neq 1 || $billsettingsData[121]->billsettingsvalue neq 2}
                        style="display:none" {/if}>
                        <label class="col-lg-2 control-label">رقم القرار</label>
                        <div class="col-lg-7">
                            <p>{$sellbillData->decisionNo}</p>
                        </div>
                    </div>

                    <div class="form-group mg-bt5" {if {$billsettingsData[120]->billsettingsvalue} neq 1 || $billsettingsData[121]->billsettingsvalue neq 2}  style="display:none" {/if}>
                        <label class="col-lg-2 control-label">قيمة القرار</label>
                        <div class="col-lg-7">
                            <p>{$sellbillData->decisionValue}</p>
                        </div>
                    </div>
                </div>


                <div class="col-lg-5 total-bill">
                    <hr />



                    <div class="form-group mg-bt5" {if {$billsettingsData[58]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label" style="font-size:14px;">عدد القطع المباعة</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="totalQty">

                                {if {$sellbillData->sellQuantity} <= 0} {$quantity} {else} {$sellbillData->sellQuantity}
                                {/if}

                            </p>

                        </div>
                    </div><!-- end of form-group-->


                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-5 control-label">قيمة الفاتورة</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gentotal">{$sellbillData->sellbilltotalbill}</p>
                        </div>
                    </div>

                    {if {$billsettingsData[90]->billsettingsvalue} eq 1 && $billnameAddData->extraDiscountPlace == 1}
                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-5 control-label">خصم اضافى </label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$sellbillData->extraDiscountVal} </p>
                        </div>
                    </div>
                    {/if}
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                         {$billsettingsData[57]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">نوع الخصم</label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {if {$sellbillData->sellbilldiscounttype} eq 1}
                                مباشر
                                {else}
                                بنسبة
                                {/if} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}  {if  $sellbillData->sellbilldiscount eq ''} hidden-print{/if}"
                         {if {$billsettingsData[57]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">قيمة الخصم</label>
                        <div class="col-lg-7">
                            <div {if $sellbillData->sellbilldiscounttype eq 1} class="input-group"{/if}>
                                <p class="form-control-static"> {$sellbillData->sellbilldiscount} {if
                                    $sellbillData->sellbilldiscounttype eq 1}
                                    <span class=" hidden-print">
                                        ({($sellbillData->sellbilldiscount * 100
                                        /$sellbillData->sellbilltotalbill)|string_format:"%.2f"|rtrim:'0'|rtrim:'.'}
                                        %)</span>
                                    {/if}
                                </p>
                            </div>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    {if {$billsettingsData[90]->billsettingsvalue} eq 1 && $billnameAddData->extraDiscountPlace == 0}
                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-5 control-label">خصم اضافى </label>
                        <div class="col-lg-7">
                            <p class="form-control-static"> {$sellbillData->extraDiscountVal} </p>
                        </div>
                    </div>
                    {/if}
                    <!-- end of form-group-->
                    <div {if {$billsettingsData[31]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <hr class="mg-tp5 mg-bt5 hidden-print {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" />
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label">ضريبه القيمة المضافة</label>
                            <div class="col-lg-7 color-white">
                                <div class="input-group">
                                    {$sellbillData->tax} %
                                </div>
                                <div class="input-group" style="padding-top: 1px;">
                                    {$taxvalue}
                                    {$Programsettingdata->currancy}
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group mg-bt5" {if {$billsettingsData[117]->billsettingsvalue} eq 0}
                        style="display:none"
                        {/if}>
                        <label class="col-lg-5 col-sm-7 control-label"> {$smarty.const.SELL_BILL_PRO_DISCOUNT}</label>
                        <div class="col-lg-7 col-sm-5">
                            <p class="form-control-static mg-tp10" id="productDis">{$sellbillData->totalprodiscount}</p>
                        </div>
                    </div>

                    <!-- end of form-group-->
                    <div class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[89]->
                        billsettingsvalue} eq 0} style="display:none" {/if}>
                        <hr class="mg-tp5 mg-bt5 hidden-print" />
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label"> ضريبه خصم </label>
                            <div class="col-lg-7 color-white">

                                {$sellbillData->taxOfDiscountVal}
                            </div>
                        </div>
                    </div>
                    <hr class="mg-tp5 mg-bt5 hidden-print" />
                    <div class="" {if {$billsettingsData[120]->billsettingsvalue} eq 0} style="display:none" {/if}>
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label"> قيمة المصروفات الإدارية</label>
                            <div class="col-lg-7 color-white">

                                {$sellbillData->manage_ex}
                            </div>
                        </div>
                    </div>
                    <div class="" {if {$billsettingsData[120]->billsettingsvalue} eq 0} style="display:none" {/if}>
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label"> قيمة الدمغة الطبية</label>
                            <div class="col-lg-7 color-white">

                                {$sellbillData->med_hallmark}
                            </div>
                        </div>
                    </div>
                    <div class="" {if {$billsettingsData[120]->billsettingsvalue} eq 0} style="display:none" {/if}>
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label">رقم إيصال الدفع</label>
                            <div class="col-lg-7 color-white">
                                {$sellbillData->pay_rec_no}
                            </div>
                        </div>
                    </div>
                    <div class="" {if {$billsettingsData[120]->billsettingsvalue} eq 0} style="display:none" {/if}>
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label"> قيمة إيصال الدفع</label>
                            <div class="col-lg-7 color-white">

                                {$sellbillData->pay_rec_val}
                            </div>
                        </div>
                    </div>

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

                    <hr class="mg-tp5 mg-bt5 hidden-print" />
                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                         {$billsettingsData[52]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">الصافى</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen2total">{$sellbillData->sellbillaftertotalbill} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="clearfix"></div>

                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                         {$billsettingsData[54]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">المدفوع</label>
                        <div class="col-lg-7">
                            {if {$billsettingsData[86]->billsettingsvalue} eq 0}
                            <p class="form-control-static"> {$sellbillData->sellbilltotalpayed} </p>
                            <input type="hidden" name="genpayvisa" id="genpayvisa" value="0" />
                            <input type="hidden" name="visaAccount" id="visaAccount" value="0" />
                            <input type="hidden" name="isBankAccountTransfer" id="isBankAccountTransfer" value="0" />
                            {else}
                            <div class="form-group mg-bt5" {if {$billsettingsData[54]->billsettingsvalue} eq 0} {else}
                                style="display:none" {/if}>
                                <label class="col-lg-5 control-label">كاش</label>
                                <div class="col-lg-7">
                                    <p class="form-control-static"> {$sellbillData->sellbilltotalpayed -
                                        $sellbillData->visaPayed} </p>
                                </div>
                            </div>
                            <div class="form-group mg-bt5" {if {$billsettingsData[54]->billsettingsvalue} eq 0} {else}
                                style="display:none" {/if}>
                                <label class="col-lg-5 control-label">دفع الكترونى</label>
                                <div class="col-lg-7">
                                    <p class="form-control-static"> {$sellbillData->visaPayed} </p>
                                </div>
                            </div>

                            <div class="form-group mg-bt5" {if {$billsettingsData[54]->billsettingsvalue} eq 0} {else}
                                style="display:none" {/if}>
                                <label class="col-lg-5 control-label">حساب الدفع</label>
                                <div class="col-lg-7">
                                    <p class="form-control-static"> {$bankAccount->accountname}/{$bankAccount->bankname}
                                    </p>
                                </div>
                            </div>
                            <div class="form-group mg-bt5" {if {$billnameAddData->isBankAccountTransfer} eq 1} {else}
                                style="display:none" {/if}>
                                <label class="col-lg-5 control-label">تحويل بنكى</label>
                                <div class="col-lg-7">
                                    <p class="form-control-static">{if $sellbillData->isBankAccountTransfer == 1} نعم
                                        {else} لا{/if} </p>
                                </div>
                            </div>
                            {/if}
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <hr class="mg-tp5 mg-bt5 hidden-print" />
                    <div class="form-group mg-bt5 bg-yel {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                         {$billsettingsData[55]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-5 control-label">المتبقى</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen3total">{$sellbillData->sellbillfinalbill} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if
                         {$billsettingsData[1]->billsettingsvalue} eq 0} style="display:block" {else} style="display:none
                        !important" {/if}>
                        <label class="col-lg-5 control-label">باقى الدين</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen4total">{$sellbillData->sellbilltotaldeptafter} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of totals center-->
            </div>
            <!-- end of fourth row-->

            {if count($billPayments)>0}
            <div class="row {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                <div class="row">
                    <hr class='hidden-print' />
                    <div class="col-lg-6">
                        <h4>دفعات على الفاتورة</h4>
                    </div>
                </div>
                <table class="table billtable table-bordered table-black" id="billPaymentsTBL">
                    <thead>
                        <tr>
                            <th> م</th>
                            <th> قيمة الفاتورة</th>
                            <th> قيمة الدين قبل</th>
                            <th> القيمة المدفوعة </th>
                            <th> قيمة الدين بعد</th>
                            <th> تاريخ الدفع</th>
                            <th> طريقة الدفع</th>
                            <th> المستخدم</th>
                        </tr>
                    </thead>

                    <tbody>

                        {foreach $billPayments as $data}
                        <tr class="gradeA ">
                            <td> {$data.itra}</td>
                            <td> {$data.finalnetbillvalue} </td>
                            <td> {$data.wait_before}</td>
                            <td> {$data.clientdebtchangeamount} </td>
                            <td> {$data.wait_after}</td>
                            <td> {$data.date} </td>
                            <td> {$data.paytype} </td>
                            <td> {$data.userName} </td>
                        </tr>
                        {/foreach}


                    </tbody>
                </table>
                <br><br>


            </div>
            {/if}

            <div class="row hidden-print">
                {if $ordertype == 1}
                <!-- buttons for offers-->

                {if {$sellbillData->conditions} eq 0 && $sellbillData->orderSavedBillId == 0}
                <a href="sellbillController.php?do=saveOfferAsBill&offerId={$sellbillData->sellbillid}"
                   onclick="$(this).hide()"><button type="button" class="btn btn-primary">حفظ كفاتورة</button></a>
                {/if}





                {else if $ordertype != 1}
                <!-- buttons for bills-->




                <!--<button type="submit"  class="btn btn-primary">رجوع</button>-->
                <button type="button" class="btn btn-primary" id="saveSerials">حفظ السريلات </button>

                {if {$sellbillData->deletedsellid} > 0 && $ordertype == 0}
                <a target="_new"
                   href="{$sellbillData->controlname}.php?do=showDetail&sellbillid={$sellbillData->deletedsellid}">
                    <button type="button" class="btn btn-primary">الايصال القديم</button></a>
                {/if}
                {if {$Programsettingdata->printingpapersize} eq 0 &&$ordertype == 0}
                <a target="_new" href="sellbillprintController.php?do=showDetail3&id={$sellbillData->sellbillid}">
                    <button type="button" class="btn btn-info">طباعه ايصال كبير</button></a>
                {/if}


                {*if {$Programsettingdata->printingpapersize} eq 1*}
                <a target="_new"
                   href="sellbillprintController.php?do=showDetail2&id={$sellbillData->sellbillid}&ordertype={$ordertype}">
                    <button type="button" class="btn btn-info">طباعه ايصال</button></a>
                {*/if*}
                {if {$Programsettingdata->sellorder} eq 1}
                <a target="_new"
                   href="sellbillprintController.php?do=showDetail2&id={$sellbillData->sellbillid}&ordertype={$ordertype}&sellorder=1">
                    <button type="button" class="btn btn-info">طباعه ايصال امر بيع</button></a>
                {/if}
                {if $ordertype == 0}
                <a target="_new" href="sellbillprintController.php?do=showpermission&id={$sellbillData->sellbillid}">
                    <button type="button" class="btn btn-info">طباعه اذن صرف كامل</button></a>

                <a target="_new"
                   href="sellbillprintController.php?do=showmorepermission&id={$sellbillData->sellbillid}">
                    <button type="button" class="btn btn-info">طباعه اذن صرف منفرد</button></a>
                {/if}



                {if $Programsettingdata->ebill eq 1 && $sellbillData->conditions != 1}
                <span id="ebill_{$sellbill->sellbillid}">
                    {if empty($sellbillData->estatus)}
                    <a href="javascript:;" data-sellbillid="{$sellbillData->sellbillid}" type="button"
                       class="btn btn-default  sendbill "> ارسال</a>
                    {else if $sellbillData->estatus == '-1' || $sellbillData->estatus == '-2' }
                    <a href="javascript:;" data-sellbillid="{$sellbillData->sellbillid}" type="button"
                       class="btn btn-default  sendbill"> حدث خطأ </a>
                    <a href="sellbillController.php?do=ebillerrors&sellbillid={$sellbillData->sellbillid}" type="button"
                       class="btn btn-default"> المشكله</a>
                    {else}
                    <a href="electronicinvoice.php?do=detail&uuid={$sellbillData->estatus}" type="button"
                       class="btn btn-default"> تفاصيل</a>
                    {/if}
                </span>
                {/if}




                {/if}







            </div>
            <!-- end of fifth row-->

        </form>
    </div>
    <!-- end of container-->
</div>
<!-- end of main row-->
{literal}
<script>


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

    $(function () {
        $(".proSerials").select2({
            placeholder: "",
            //minimumInputLength: document.getElementById("searchvalue").value,
            inimumInputLength: 0,
            multiple: true,
            //maximumSelectionSize: 2,
            quietMillis: 100,
            ajax: {
                url: "sellbillAjaxController.php?do=productAvailableParcodes",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        pro: $(this).data('pro'),
                        store: $(this).data('store')
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: function (data) {
                $html = '<span>' + data.text + '</span >/<span style="color:chocolate">' + parseFloat(data.don) + '</span >';
                if (data.enddate != "0000-00-00")
                    $html += '/<span>' + data.enddate + '</span >';
                return $html;
            },
            formatSelection: function (data) {
                $html = '<span>' + data.text + '</span >/<span style="color:chocolate">' + parseFloat(data.don) + '</span >';
                if (data.enddate != "0000-00-00")
                    $html += '/<span>' + data.enddate + '</span >';
                return $html;
            },
            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]};
                callback(data);
            },
            //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
        });
    }).on('change', function (e) {
        var id = e.target.id;
        var selectedData = $("#" + id).select2('data');
        var requiredQuantity = $("#" + id).data('quantity');//e.target.dataset.quantity;

        var selctedQuantity = 0;
        for (var i = 0; i < selectedData.length; i++) {
            selctedQuantity += Number(selectedData[i].don);
        }

        $("#" + id).parent().find('ul').removeClass('serial-success serial-error');
        $("#" + id).parent().find('li').removeClass('serial-success serial-error');
        $("#" + id).removeClass('serial-success serial-error');
        if (selctedQuantity > 0) {
            if (selctedQuantity >= requiredQuantity) {
                $("#" + id).parent().find('ul').addClass('serial-success');
                $("#" + id).parent().find('li').addClass('serial-success');
                $("#" + id).addClass('serial-success');
            } else {
                $("#" + id).parent().find('ul').addClass('serial-error');
                $("#" + id).parent().find('li').addClass('serial-error');
                $("#" + id).addClass('serial-error');
            }
        }
    });

    $('#saveSerials').on('click', function () {
        var validFlag = 1;
        $(".proSerials").each(function () {
            if ($(this).hasClass('serial-success')) {

            } else {
                validFlag = 0;
                alert('تأكد من ادخال جميع السريلات وبالكميات المطلوبة');
                return false;
            }
        });

        if (validFlag == 1) {
            $('#serialsForm').submit();
        }
    });

</script>
{/literal}