<input type="hidden" name="printURL" id="printURL" value="{$printURL}"/>
<script>
    var printURL = $('#printURL').val();
    if (printURL != "") {
        window.open(printURL);
    }
</script>
<!-- === here the drop down list that fill the product list === -->
<style>
    .newoption {
        background-color:#CCCCCC !important;
        font-weight:bold !important;
    }

    #manyParents .form-group label{
        margin-left: 11px;
        margin-right: 16px;
    }

    #manyParents .form-group div{
        width: 155px;
    }
    .bg-full{
        direction: ltr
    }

    .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
        float:left!important
    }
    .form-horizontal .control-label {
        text-align: left!important;
    }



    .select2-container .select2-choice .select2-arrow {

        left: auto!important;
        right: 0!important;
    }
    .form-control {
        text-align: left!important;
    }
    .select2-results .select2-result-label {

        text-align: left!important;
    }
    .select2-container .select2-choice > .select2-chosen {
        margin-right: 26px!important;
        margin-left: auto!important
    }


</style>
<script type="application/javascript">
    //$(document).ready(function(e) {
    //
    //	$("#pronum1").keydown(function(e) {
    //   // test for the enter key
    //	   if (e.keyCode == 40) {
    //		   alert(this.name);
    //		  // Do your function
    //		  $("#pronum2").select();
    //	 //    alert("sfdsfds");
    //	   }
    //
    //
    //	});
    //
    //
    //
    //		$("#textfield2").keydown(function(e) {
    //			   // test for the enter key
    //			   if (e.keyCode == 38) {
    //				  // Do your function
    //				  $("#textfield").select();
    //			 //    alert("sfdsfds");
    //			   }
    //
    //		});
    //
    //});
</script>
<div id="addrowcreated" style="display:none">
    <option value="-1"> </option>
    {foreach $productData as $product}
    <option value="{$product->productId}">{$product->productName} </option>
    {/foreach} </div>
<div id="addreturnproduct" style="display:none"> {foreach $returnproductData as $returnproduct}
    <option value="-1"> </option>
    <option value="{$returnproduct->productId}">{$returnproduct->productName} </option>
    {/foreach} </div>
<div id="addProductCat" style="display:none;"> {foreach $categoriesData as $cat}
    <option value="{$cat->productCatId}">{$cat->productCatName}</option>
    {/foreach} </div>
<div id="addNewUnit" style="display:none;"> {foreach $unitsData as $unit}
    <option value="{$unit->unitId}">{$unit->unitName}</option>
    {/foreach} </div>


<div id="addstore" class="clientstore" style="display:none;">
    {foreach $storeData as $store}
    <option value="{$store->storeId}">{$store->storeName}</option>
    {/foreach}

</div>
<div id="addstore2" class="clientstoretxt" style="display:none;">
    {foreach $storeData as $store}
    {if {$store->storeId} eq {$userdata->userstoreid}}{$store->storeName} {/if}
    {/foreach}
</div>
<!-- === end of drop down list === -->
<input type="hidden" name="scunitnamevalue" id="scunitnamevalue" value="{$Programsettingdata->scunitname}"/>

<!-- === here the drop down list that fill the product list === -->

<div id="addunit" style="display:none"> </div>
<!-- === end of drop down list === -->

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#"> Manage Billing
                </a></li>
            <li><a href="sellbillController.php?do=show"> Sales invoice</a></li>
            <li class="active"> Add an invoice</li>


        </ol>



        <h3>{$billnameAddData->name}</h3>
        <h3><a class="color-white" href="sellbillController.php?do=showDetail&sellbillid={$mylastbill->sellbillid}"> Sales invoice</a> </h3>
        <hr/>
        {literal}
        <form class="form-horizontal " role="form" action="sellbillController.php?do=add" method="post" id="sellbillForm" onsubmit="
                //check if muliple clients to make sure user is choosing one client at least then validate form
                if ($('.multiSupp').is(':visible'))
                {
                    var foo = [];
                    $('#supplier :selected').each(function (i, selected) {
                        foo[i] = $(selected).text();
                    });
                    if (foo.length === 0) {
                        alert('من فضلك اختر عميل واحد على الاقل');
                        return false;
                    } else
                    {
                        if (Spry.Widget.Form.validate(this)) {
                            $('#saveAndNew').css('display', 'none');
                            $('#saveBill').css('display', 'none');
                            return true;
                        } else {
                            return false;
                        }
                    }
                } else
                {
                    if (Spry.Widget.Form.validate(this)) {
                        $('#saveAndNew').css('display', 'none');
                        $('#saveBill').css('display', 'none');
                        return true;
                    } else {
                        return false;
                    }
                }
              ">
            {/literal}
            <div class="row bg-full">
                <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">bill number </label>
                        <div class="col-lg-4">
                            <input type="text" name="bns" id="bns"  value="{$unique}"  class="form-control" placeholder="bill number ">
                        </div>
                    </div>
                    <!-- end of form-group-->
                    {if $Programsettingdata->clientserial eq 1}
                    <div class="form-group">
                        <label class="col-lg-3 control-label"> Serial Number</label>
                        <div class="col-lg-4">
                            <input type="text" class="form-control" disabled readonly value="{$nextId}">
                        </div>
                    </div>
                    <!-- end of form-group-->
                    {/if}
                    <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">Date Invoice </label>
                        <div class="col-lg-4"> <span id="sprydate">
                                <!--input type="text" class="form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd" placeholder="Bill Date " {if $Programsettingdata->allowdateedit == 1}disabled="disabled"{/if} value="{$today}" name="bn" id="bn"-->
                                {if $Programsettingdata->allowdateedit == 1}
                                <input type="text" class="form-control" placeholder="تاريخ الفاتورة" readonly value="{$today}" name="bn" id="bn">
                                {else}
                                <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" size="16" type="text" value="{$today}" name="bn" id="bn readonly="" >
                                    <span class="input-group-addon "><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                                </div>{/if}
                                <span class="textfieldRequiredMsg">*</span></span> </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group" {if {$billsettingsData[50]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
                        <label class="col-lg-3 control-label">  Temporary client name</label>
                        <div class="col-lg-4"> <span id="sprytempname">
                                <input type="text" class="form-control"  placeholder=" Temporary client name "  name="tempclientName" id="tempclientName" value="نقدى"  />
                                <span class="textfieldRequiredMsg">*</span></span> </div>
                    </div>
                    <!-- end of form-group-->



                    <!-- ahmed -->

                    <div {if {$billsettingsData[35]->billsettingsvalue} eq 0} {else} style="display:none" {/if} >

                        <div class="form-group" >
                            <label class="col-lg-3 control-label">car number </label>
                            <div class="col-lg-4"> <span id="sprytempname">
                                    <input type="text" class="form-control"  placeholder="car number "  name="carNumber" id="carNumber" />
                                    <span class="textfieldRequiredMsg">*</span></span> </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-3 control-label">Type of car </label>
                            <div class="col-lg-4"> <span id="sprytempname">
                                    <input type="text" class="form-control"  placeholder="Type of car "  name="carType" id="carType" />
                                    <span class="textfieldRequiredMsg">*</span></span> </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-lg-3 control-label"> Car chassis</label>
                            <div class="col-lg-4"> <span id="sprytempname">
                                    <input type="text" class="form-control"  placeholder="Car chassis "  name="carChase" id="carChase" />
                                    <span class="textfieldRequiredMsg">*</span></span> </div>
                        </div>
                        <div class="form-group"  >
                            <label class="col-lg-3 control-label"> Motor vehicle</label>
                            <div class="col-lg-4"> <span id="sprytempname">
                                    <input type="text" class="form-control"  placeholder="Motor vehicle "  name="carMotor" id="carMotor" />
                                    <span class="textfieldRequiredMsg">*</span></span> </div>
                        </div>
                        <!-- end of form-group-->

                    </div>


                    <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">work address </label>
                                <div class="col-lg-4">

                                </div>
                            </div>

                            <div class="form-group" >
                                <label class="col-lg-3 control-label"> phone Number</label>
                                <div class="col-lg-4">

                                </div>


                            </div>


                            <div class="form-group" >
                                <label class="col-lg-3 control-label">agent code </label>
                                <div class="col-lg-4">

                                </div>


                            </div>

                        </div>

                    </div>
                </div>
                <!-- end of bill no-->
                <div class="col-lg-4">
                    <div class="form-group mg-bt5" {if {$billsettingsData[45]->billsettingsvalue} eq 0}  {else} style="display:none" {/if}>
                        <label class="col-lg-4 control-label"> Cost center</label>
                        <div class="col-lg-8">

                            <select class="select2 wdt100" name="Costcenter" id="Costcenter" >


                                <option value="-1">select Cost center  </option>
                                {foreach $allCostcenter as $myallCostcenter}



                                <option value="{$myallCostcenter->id}">{$myallCostcenter->name}</option>

                                {/foreach}


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

                </div>
                <div class="col-lg-4">

                    {if {$billsettingsData[37]->billsettingsvalue} eq 1}
                    <div class="form-group mg-bt5" {if {$billsettingsData[1]->billsettingsvalue} eq 0}  {else} style="display:none" {/if}>
                        <label class="col-lg-4 control-label">Client Name </label>
                        <div class="col-lg-8"> <span id="spryclient">
                                <div id="clientDiv">
                                    <!--                                    <select class="select2 wdt100" name="supplier" id="supplier" >


                                                                            {assign var=y value=1}
                                                                            {foreach $clientData as $client}

                                                                            {if {$y} eq 2}


                                                                            <option  value="-2"  class="newoption">  Add New Client</option>


                                                                            {/if}


                                                                            <option value="{$client->clientid}">{$client->clientname}</option>

                                                                            {capture assign=y}{$y+1}{/capture}
                                                                            {/foreach}


                                                                        </select>-->
                                    <input type="hidden" name="supplier" id="supplier" class="select2Supp"/>
                                    <input type="hidden" name="oldsupplierid" id="oldsupplierid" value="{$myclientdata->clientid}"/>
                                    <input type="hidden" name="oldsuppliername" id="oldsuppliername" value="{$myclientdata->clientname}"/>
                                </div>
                                <span class="selectInvalidMsg">*</span></span> </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" {if {$billsettingsData[56]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-4 control-label">Debt balance </label>
                        <div class="col-lg-8">
                            <p class="form-control-static" id="debt">0 </p>
                            <input name="hidden_debt" id="hidden_debt" type="hidden" value="0" />
                        </div>
                    </div>
                    <!-------------------------->
                    {else}

                    <div class="form-group">
                        <label class="col-lg-4 control-label">Client Name </label>
                        <div class="col-lg-8">
                            <span id="spryselect12">
                                <select  multiple name="supplierX[]"  id="supplier"  class="select2 wdt100 multiSupp">


                                    {foreach $clientData as $client}



                                    <option value="{$client->clientid}">{$client->clientname}</option>


                                    {/foreach}
                                </select>
                                <span class="selectInvalidMsg">****.</span><span class="selectRequiredMsg">****.</span></span>
                        </div>
                    </div>


                    <div class="form-group mg-bt5" style="display:none">
                        <label class="col-lg-4 control-label">Debt balance </label>
                        <div class="col-lg-8">
                            <p class="form-control-static" id="debt">0 </p>
                            <input name="hidden_debt" id="hidden_debt" type="hidden" value="0" />
                        </div>
                    </div>

                    {/if}

                    <!-- 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-4 control-label"> Price type</label>
                        <div class="col-lg-8">
                            <select class="select2 wdt100" name="pricetype" id="pricetype">
                                <option  {if {$billsettingsData[32]->billsettingsvalue} eq 0} selected="selected" {/if} value="0">جملة</option>
                                <option {if {$billsettingsData[32]->billsettingsvalue} eq 1} selected="selected" {/if} value="1">تجزئة</option>
                                <option value="2" {if {$billsettingsData[32]->billsettingsvalue} eq 2} selected="selected" {/if}>نصف جملة</option>
                            </select>
                            <input type="hidden" name="hiddenpricetype" id="hiddenpricetype" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <hr class="mg-bt5 mg-tp5"/>
                    <input type="hidden" name="userstoreid" id="userstoreid" value="{$userdata->userstoreid}"/>
                    <input type="hidden" name="userstoreidForClient" id="userstoreidForClient" value="{$userdata->userstoreid}"/>
                    <div {if {$billsettingsData[2]->billsettingsvalue} eq 0}  {else} style="display:none" {/if} >
                        {if {$billsettingsData[26]->billsettingsvalue} eq 1}

                        <!------ {if {$billsettingsData[2]->billsettingsvalue} eq 0}  {else} style="display:none" {/if}---------------------->
                        <div class="form-group mg-bt5">


                            {if $userdata->userstoreid  eq 0}
                            <label class="col-lg-4 control-label">The store</label>
                            <div class="col-lg-8">
                                <select class="select2 wdt100 clientstore" name="storeid" id="storeid">
                                    {foreach $storeData as $store}
                                    <option value="{$store->storeId}">{$store->storeName}</option>
                                    {/foreach}
                                </select>
                            </div>
                            {else}

                            <div style="display:none">

                                <select class="select2 wdt100 clientstore" name="storeid" id="storeid" >
                                    <option value="-1"> Select Store</option>

                                    {foreach $storeData as $store}


                                    <option {if {$store->storeId} eq {$userdata->userstoreid}} selected="selected"   {/if}value="{$store->storeId}">{$store->storeName}</option>


                                    {/foreach}


                                </select>
                            </div>
                            <!--input name="storeid" id="storeid"  type="hidden" value="{$userdata->userstoreid}" /-->
                            <label class="col-lg-4 control-label">The Store</label>
                            <div class="col-lg-8 clientstoretxt">
                                {foreach $storeData as $store}
                                {if {$store->storeId} eq {$userdata->userstoreid}}{$store->storeName} {/if}
                                {/foreach}
                            </div>
                            {/if}

                        </div>
                        {else}


                        <div  style="display:none">
                            <select class="select2 wdt100 clientstore" name="storeid" id="storeid" >


                                {foreach $storeData as $store}



                                <option {if {$store->storeId} eq {$userdata->userstoreid}} selected="selected"   {/if}value="{$store->storeId}">{$store->storeName}</option>


                                {/foreach}


                            </select>
                        </div>
                        {/if}

                    </div>
                    <!-- 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-4 control-label"> Name {if {$Programsettingdata->delegate_seller} eq 0} seller {else}{if {$Programsettingdata->delegate_seller} eq 0} Seller {else}Delegate {/if} {/if}</label>

                        <div class="col-lg-8">
                            <select class="select2 wdt100" name="sellerid" id="sellerid">

                                <option value="-1">choose</option>
                                {foreach $sellerData as $seller}


                                <option value="{$seller->userid}">{$seller->employeename}</option>


                                {/foreach}


                            </select>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if $billsettingsData[12]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">comment</label>
                        <div class="col-lg-8">
                            <textarea name="comment" id="comment" cols="" rows="" class="form-control" tabindex="6"></textarea>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>

                <!-- end of client info-->

            </div>

            <!-- end of frist row-->
            <!-- hidden ===============================-->
            <input type="hidden" name="newproductItr" id="newproductItr" />
            <input type="hidden" name="newproductTabIndex" id="newproductTabIndex" />
            <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}"/>
            <input type="hidden" name="settingQuantityAlert" id="settingQuantityAlert" value="{$billsettingsData[13]->billsettingsvalue}"/>


            <input type="hidden" name="morestore" id="morestore" value="{$billsettingsData[26]->billsettingsvalue}"/>
            <input type="hidden" name="sumSameProductForStore" id="sumSameProductForStore" value="{$billsettingsData[73]->billsettingsvalue}"/>
            <input type="hidden" name="usePriceTypeOfClient" id="usePriceTypeOfClient" value="{$billsettingsData[74]->billsettingsvalue}"/>
            <input type="hidden" name="saveBtnGoesTo" id="saveBtnGoesTo" value="{$billsettingsData[75]->billsettingsvalue}"/>
            <input type="hidden" name="sellerIsRequired" id="sellerIsRequired" value="{$billsettingsData[76]->billsettingsvalue}"/>

            <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>
            <input type="hidden" name="directDiscount" id="directDiscount" value="{$Usergroupdata->directDiscount}"/>
            <input type="hidden" name="percentageDiscount" id="percentageDiscount" value="{$Usergroupdata->percentageDiscount}"/>
            <input type="hidden" name="searchvalue" id="priceupdate" value="{$Usergroupdata->priceupdate}"/>

            <input type="hidden" name="ordertype" id="ordertype" value="{$billnameData->ordertype}"/>
            <input type="hidden" name="saveeffect" id="saveeffect" value="{$billnameData->saveeffect}"/>
            <input type="hidden" name="discountrowtype" id="discountrowtype" value="{$billsettingsData[34]->billsettingsvalue}"/>
            <input type="hidden" name="multiclient" id="multiclient" value="{$billsettingsData[37]->billsettingsvalue}"/>


            <input type="hidden" name="showdiscountrow" id="showdiscountrow" value="{$billsettingsData[8]->billsettingsvalue}"/>

            <input type="hidden" name="showbouns" id="showbouns" value="{$billsettingsData[38]->billsettingsvalue}"/>
            <input type="hidden" name="showclientdetail" id="showclientdetail" value="{$billsettingsData[39]->billsettingsvalue}"/>
            <input type="hidden" name="showtotal" id="showtotal" value="{$billsettingsData[41]->billsettingsvalue}"/>
            <input type="hidden" name="shownumber" id="shownumber" value="{$billsettingsData[40]->billsettingsvalue}"/>
            <input type="hidden" name="payedSetting" id="payedSetting" value="{$billsettingsData[71]->billsettingsvalue}"/>



            <!-- end of hidden ===============================-->


            <div class="row" {if {$billsettingsData[14]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                <div class="row">
                    <hr/>
                    <div class="col-lg-6">
                        <h4>The sales</h4>
                    </div>
                    <div class="col-lg-6">
                        <button type="button" name="addpro" id="addpro" class="btn btn-primary pull-left ft-nor">  Add New</button>
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive bd-gr">
                    <table class="table billtable table-bordered  table-black" id="containerpros">
                        <thead>
                            <tr>

                                <th class="wdt20" {if {$billsettingsData[6]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>New</th>

                                <th class="wdt20" {if {$billsettingsData[40]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>Number</th>

                                <th   class="wdt120 check_tr_parcode {if {$billsettingsData[59]->billsettingsvalue} eq 1} hidden {/if}" >Barcode</th>
                                <th {if {$billsettingsData[26]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if} class="wdt300" >The Store</th>
                                <th class="wdt400">Product Name </th>
                                <th {if {$billsettingsData[7]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if} class="wdt240">Notes</th>
                                <th  class="wdt100n check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}">Unit</th>
                                <th class="wdt100n check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}" >Number</th>
                                <th class="wdt100n check_tr_unit  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}" >{$Programsettingdata->scunitname}</th>

                                <th class="wdt20" {if {$billsettingsData[38]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>Bouns</th>
                                <th class="wdt80">Price</th>

                                <th class="wdt100n check_tr_discount {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">Discount</th>




                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <!--th {if {$billsettingsData[8]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if} class="wdt80"> نسبة الخصم</th-->
                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <th class="wdt100n">
                                    <input name="hidden_itr" id="hidden_itr" type="hidden" value="1" />
                                    Total</th>
                                <th>Delete</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr  id="productraw1">

                                <td {if {$billsettingsData[6]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}><a onClick="javascript:showProductModal(1, 7);" class="newLink btn btn-primary btn-xs conformdelProduct" >جديد</a></td>
                                <td {if {$billsettingsData[40]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>1</td>
                                <td  class="check_tr_parcode {if {$billsettingsData[59]->billsettingsvalue} eq 1} hidden {/if}"    >
                                    <div id="productparcode1" >
                                        <input type="text" name="parcode1" id="parcode1"  class="form-control txt-nonraduis" tabindex="7"  onkeypress="getproductbyParcode(event, this.value, 1);" size="3"  placeholder="الباركود" />
                                        <input name="parcodeType1" id="parcodeType1" type="hidden"/>
                                        <input name="productserailid1" id="productserailid1" type="hidden" />
                                        <input name="productQty1" id="productQty1" type="hidden" />
                                    </div>
                                </td>
                                <td {if {$billsettingsData[26]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if} >
                                    <div id="prstoridsiv1">

                                        {if $userdata->userstoreid  eq 0}
                                        <select class="select2 wdt100" name="prstorid1" id="prstorid1">
                                            <option value="-1"> Select Store</option>
                                            {foreach $storeData as $store}
                                            <option value="{$store->storeId}">{$store->storeName}</option>
                                            {/foreach}
                                        </select>
                                        {else}
                                        {foreach $storeData as $store}
                                        {if {$store->storeId} eq {$userdata->userstoreid}}{$store->storeName} {/if}
                                        {/foreach}
                                        <input name="prstorid1" id="prstorid1" class="selectstore" type="hidden" value="{$userdata->userstoreid}" />
                                        {/if}
                                    </div>
                                </td>

                                <!--  productdiv -->
                                <td>
                                    <div id="productdiv1">
                                        <input type="hidden" id="product1" name="product1"  class="select2product wdt100"  data-placeholder="Select Product "  tabindex="7" />
                                    </div>
                                </td>

                                <td {if {$billsettingsData[7]->billsettingsvalue} eq 0}  {else}  style="display:none !important"  {/if}>
                                    <textarea class="form-control txt-nonraduis enteraction" name="comment1" id="comment1" rows="1" tabindex="7"></textarea>
                                </td>

                                <!-- productunitdiv -->
                                <td class="check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <div id="productunitdiv1">
                                        <select id="productunit1" name="productunit1" class="select2 wdt100" tabindex="7">
                                            <option value="-1"></option>
                                        </select>
                                    </div>
                                </td>


                                <td class="check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input type="text" name="pronum1" id="pronum1"  class="form-control txt-nonraduis getprototal enteraction numberinput positiveNo" onKeyUp="checkquantity(1, event);" value="1" tabindex="7" />
                                </td>
                                <td class="check_tr_quantity  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    <input name="scunitname1" id="scunitname1" value="0"  class="form-control txt-nonraduis positivefloat" placeholder="number" type="text" tabindex="7" />
                                </td>

                                <td {if {$billsettingsData[38]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>
                                    <input type="text" name="bouns1" id="bouns1"  class="form-control txt-nonraduis getprototal enteraction numberinput positiveNo"  value="0" tabindex="7" />
                                </td>
                                <td>
                                    <div id="propricechange1">
                                        <input type="text" name="proprice1" id="proprice1"  class="form-control getprototal enteraction numberinput txt-nonraduis positivefloat" value="0" tabindex="7" />
                                    </div>
                                </td>


                                <td class="check_tr_discount {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">

                                    <input name="prodis1" id="prodis1"   class="form-control txt-nonraduis getprototal enteraction numberinput positiveNo" value="0" tabindex="7"   {if {$billsettingsData[34]->billsettingsvalue} eq 0} type="text" {else}  type="hidden" {/if}/>
                                    <input  name="discounttype1" id="discounttype1"     class="form-control txt-nonraduis getprototal enteraction numberinput positivefloat" value="0" tabindex="7"    {if {$billsettingsData[34]->billsettingsvalue} eq 1} type="text" {else}  type="hidden" {/if}/>
                                </td>
                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <!--td {if {$billsettingsData[8]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>
                                  <input type="text" name="prodisper1" id="prodisper1"  class="form-control txt-nonraduis getprototal enteraction numberinput" value="0" tabindex="7"  />
                                </td-->
                                <!-------------------------------------discountvalue by hazem---------------------------------------------->
                                <td>
                                    <!--<div id="prototal1" class="form-control-static">0</div>-->
                                    <!--<input name="hidden_prototal1" id="hidden_prototal1" type="hidden" value="0" />-->
                                    <input  name="hidden_prototal1" id="hidden_prototal1" class="editTotal form-control txt-nonraduis enteraction numberinput positiveNo" value="0" type="text"/>
                                </td>
                                <td>
                                    <button id="remove1" type="button" class="close flt-none removeicon removeproduct" aria-hidden="true">&times;</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <button type="button" class="btn btn-primary pull-left ft-nor">
                    Total sales <span class="badge wht-clo">
                        <div id="sellbilltotal">0</div>
                    </span>
                    <input type="hidden" name="sellbillprice" id="sellbillprice" value="0"/>
                </button>
            </div>

            <!-- end of second row-->

            <div class="row" {if {$billsettingsData[0]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                <div class="row">
                    <hr/>
                    <div class="col-lg-6">
                        <h4>Total sales </h4>
                    </div>
                    <div class="col-lg-6">
                        <button type="button" name="addreturn" id="addreturn" class="btn btn-primary pull-left ft-nor">  Add New</button>
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive bd-rd">
                    <table class="table billtable table-bordered table-black" id="containerReturn" {if {$billsettingsData[0]->
                        billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                        <thead>
                            <tr>
                                <th class="wdt20" {if {$billsettingsData[40]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>Number</th>
                                <th class="wdt120 check_tr_parcode {if {$billsettingsData[59]->billsettingsvalue} eq 1} hidden {/if}">Barcode</th>
                                <th class="wdt300 "{if {$billsettingsData[26]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>Store</th>
                                <th class="wdt400">Product Name </th>

                                <th class="wdt240" {if {$billsettingsData[7]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>Notes</th>
                                <th class="wdt100n check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}" >Unit</th>
                                <th class="wdt100n check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}" >Number</th>
                                <th class="wdt100n check_tr_unit  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}" >{$Programsettingdata->scunitname}</th>

                                <th class="wdt80">Price</th>
                                <th class="wdt80 check_tr_discount {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}" >Discount</th>
                                <th class="wdt100n">Total
                                    <input name="returnhidden_itr" id="returnhidden_itr" type="hidden" value="1" />
                                </th>
                                <th>Delete</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td {if {$billsettingsData[40]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>1</td>
                                <td {if {$billsettingsData[59]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                                    <div id="returnproductparcode1">
                                        <input type="text" name="returnparcode1" id="returnparcode1"  class="form-control txt-nonraduis" placeholder="Barcode" onkeypress="getreturnproductbyParcode(event, this.value, 1);" tabindex="301"/>
                                        <input name="returnparcodeType1" id="returnparcodeType1" type="hidden"/>
                                        <input name="returnproductserailid1" id="returnproductserailid1" type="hidden" />
                                        <input name="returnproductQty1" id="returnproductQty1" type="hidden" />
                                    </div>
                                </td>
                                <td {if {$billsettingsData[26]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>

                                    <div id="prstoridsiv1">

                                        {if $userdata->userstoreid  eq 0}
                                        <select class="select2 wdt100" name="reprstorid1" id="reprstorid1">
                                            <option value="-1"> Select Store</option>
                                            {foreach $storeData as $store}
                                            <option value="{$store->storeId}">{$store->storeName}</option>
                                            {/foreach}
                                        </select>
                                        {else}
                                        {foreach $storeData as $store}
                                        {if {$store->storeId} eq {$userdata->userstoreid}}{$store->storeName} {/if}
                                        {/foreach}
                                        <input name="reprstorid1" id="reprstorid1" class="selectstore" type="hidden" value="{$userdata->userstoreid}" />
                                        {/if}
                                    </div>
                                </td>
                                <td>
                                    <div id="returnproductdiv1">

                                        <input type="hidden" id="returnproduct1" name="returnproduct1"  class="select2returnproduct wdt100"  data-placeholder="Select Product " tabindex="301" />
                                    </div>
                                </td>





                                <td {if {$billsettingsData[7]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>
                                    <textarea class="form-control txt-nonraduis returnenteraction"  name="returncomment1" id="returncomment1" rows="1" tabindex="301"></textarea>
                                </td>
                                <td {if {$billsettingsData[53]->billsettingsvalue} eq 0}  {else}  style="display:none !important"  {/if}>
                                    <div id="returnproductunitdiv1">
                                        <select id="returnproductunit1" name="returnproductunit1" class="select2 wdt100" tabindex="301">
                                            <option value="-1"></option>
                                        </select>
                                    </div>
                                </td>
                                <td class="check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input type="text" name="returnpronum1" id="returnpronum1"  class="form-control txt-nonraduis getreurnprototal returnenteraction numberinput positivefloat" onKeyUp="returncheckquantity(1, event);" value="1" tabindex="301"/>
                                </td>
                                <td class="check_tr_quantity  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    <input name="returnscunitname1" id="returnscunitname1" value="0"  class="form-control txt-nonraduis positiveNo" placeholder="العدد" type="text" tabindex="7" />
                                </td>
                                <td>
                                    <div id="returnpropricechange1">
                                        <input type="text" name="returnproprice1" id="returnproprice1"  class="form-control getreurnprototal txt-nonraduis returnenteraction numberinput  positivefloat" value="0" tabindex="301" />
                                    </div>
                                </td>
                                <td class="check_tr_discount {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input  name="returnprodis1" id="returnprodis1"  class="form-control getreurnprototal  txt-nonraduis returnenteraction numberinput positiveNo" value="0" tabindex="301"  {if {$billsettingsData[34]->billsettingsvalue} eq 0} type="text" {else}  type="hidden" {/if}  />



                                    <input  name="returndiscounttype1" id="returndiscounttype1"    class="form-control getreurnprototal  txt-nonraduis returnenteraction numberinput positiveNo" value="0" tabindex="301"    {if {$billsettingsData[34]->billsettingsvalue} eq 1} type="text" {else}  type="hidden" {/if}/>


                                </td>
                                <td>
                                    <!--                                    <p class="form-control-static" id="reurnprototal1">0</p>
                                                                        <input name="returnhidden_prototal1" id="returnhidden_prototal1" type="hidden" value="0" />-->
                                    <input  name="returnhidden_prototal1" id="returnhidden_prototal1" class="returnEditTotal form-control txt-nonraduis enteraction numberinput positiveNo" value="0" type="text"/>
                                </td>
                                <td>
                                    <button type="button" id="returnremove1" class="close flt-none returnremoveproduct" aria-hidden="true">&times;</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <button type="button" class="btn btn-primary pull-left ft-nor" {if {$billsettingsData[0]->
                    billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>    Total sales return <span class="badge wht-clo" id="returnsellbilltotal">0</span>
                    <input type="hidden" name="returnsellbillprice" id="returnsellbillprice" value="0"/>
                </button>
            </div>

            <!-- end of third row-->

            <div class="row">
                <div class="col-lg-7">
                    <div class="form-group mg-bt5" {if {$billsettingsData[49]->billsettingsvalue} eq 0}  {else}  style="display:none !important"  {/if}>
                        <label class="col-lg-1 control-label">paid up</label>
                        <div class="col-lg-3">
                            <input type="text" class="form-control" placeholder="paid up" name="genpay2" id="genpay2"  onkeyup="calculateremain(this.value);">
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" {if {$billsettingsData[49]->billsettingsvalue} eq 0}  {else}  style="display:none !important"  {/if}>
                        <label class="col-lg-1 control-label">The rest</label>
                        <div class="col-lg-3">
                            <p class="form-control-static" id="gen3total2">0 {$currency}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of calucation center-->

                <div class="col-lg-5">
                    <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">
                            Number of sold items </label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="totalQty">0</p>
                            <input type="hidden" name="sellQuantity" id="sellQuantity" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" {if {$billsettingsData[0]->billsettingsvalue} eq 0  && {$billsettingsData[58]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                        <label class="col-lg-5 control-label">Number of pieces returned  </label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="returnTotalQty">0</p>
                            <input type="hidden" name="returnsellQuantity" id="returnsellQuantity" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">
                            Invoice value </label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gentotal">0</p>
                            <input type="hidden" name="sellbilltotalbill" id="sellbilltotalbill" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 check_tr_discount {if {$billsettingsData[42]->billsettingsvalue} eq 1}  hidden {/if}" >
                        <label class="col-lg-5 control-label">
                            Invoice value </label>
                        <div class="col-lg-7">
                            <select id="distype" name="distype"  class="select2 wdt100" onchange="checkdisValue();">
                                <option  {if {$billsettingsData[44]->billsettingsvalue} eq 0} selected="selected" {/if} value="1">direct</option>
                                <option   {if {$billsettingsData[44]->billsettingsvalue} eq 1} selected="selected" {/if} value="2">direct</option>
                            </select>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 check_tr_discount {if {$billsettingsData[42]->billsettingsvalue} eq 1}  hidden {/if}">
                        <label class="col-lg-5 control-label">Discount Value </label>
                        <div class="col-lg-7"> <span id="sprytextfield4">
                                <input type="text" name="gendis" id="gendis" {if {$billsettingsData[57]->billsettingsvalue} neq 0}value="0"{/if}  class="form-control numberclic positivefloat" placeholder="قيمة الخصم"  autocomplete="off" />
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">  Enter the value correctly</span></span> </div>
                    </div>
                    <!-- end of form-group-->
                    <div {if {$billsettingsData[31]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <hr class="mg-tp5 mg-bt5"/>
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label">Value added tax</label>
                            <div class="col-lg-7">

                                <input type="text" name="tax" class="form-control numberinput positiveNo"  id="tax" value="{$Programsettingdata->vatValue}" onkeyup="checkdisValue();"/>
                            </div>
                        </div>


                    </div>


                    <hr class="mg-tp5 mg-bt5"/>
                    <div class="form-group mg-bt5" {if {$billsettingsData[51]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-5 control-label">The net</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gen2total">0</p>
                            <input type="hidden" name="sellbillaftertotalbill" id="sellbillaftertotalbill" value="0"/>
                        </div>
                    </div>

                    <!-- end of form-group-->
                    <div class="form-group mg-bt5"  {if {$billsettingsData[54]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-5 control-label">paid up</label>
                        <div class="col-lg-7">
                            <input type="text" name="genpay" id="genpay"   {if {$billsettingsData[37]->billsettingsvalue} eq 1} "   {/if} class="form-control numberinput positivefloat"  placeholder="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5"/>
                    <div class="form-group mg-bt5 bg-yel" {if {$billsettingsData[55]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-5 control-label">
                            Residual</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gen3total">0</p>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5" {if {$billsettingsData[1]->billsettingsvalue} eq 0} style="display:block" {else} style="display:none !important" {/if}>
                        <label class="col-lg-5 control-label"> The rest of religion</label>
                        <div class="col-lg-7">
                            <p class="form-control-static mg-tp10" id="gen4total">0</p>
                            <input type="hidden" name="gen4totalinput" id="gen4totalinput" value="0"/>

                            <input type="hidden" name="clientdebtafter" id="clientdebtafter" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of totals center-->
            </div>
            <!-- end of fourth row-->
            <input type="hidden" value="{$roundNumbersStatus}" id="round_numbers" name="round_numbers"/>
            <input type="hidden" value="{$previousPriceStatus}" id="previousPriceStatus" name="previousPriceStatus"/>
            <div class="row">
                <button type="submit" id="saveBill" onclick="return addDataOnly();" class="btn btn-primary">Save</button>
                <button type="submit" id="saveAndNew" onclick="return addDataAndReturn();" class="btn btn-success">Save and New</button>

                <!-- <button type="button" onclick="printData();" class="btn btn-info">طباعة</button>-->
            </div>
            <br/>
            <div class="row">
                <style>
                    .unsufficient{
                        background-color: #f59a99 !important;
                    }
                    .note-warning{
                        background-color: #faeaa9;
                        border-color: #f3cc31;
                        color: #000;
                        border-right: 5px solid #f3cc31;
                        border-radius: 4px 0 0 4px;
                        margin: 0 0 20px;
                        padding: 15px 15px 15px 30px;
                    }
                </style>
                <input type="hidden" name="storenegative" id="storenegative" value="{$storenegative}"/>
                <div class="note-warning" style="display: none" id="check_store_div">
                    <h4 class="block" id="check_store_msg"></h4>
                </div>
            </div>
            <!-- end of fifth row-->

        </form>
    </div>
    <!-- end of container-->
</div>
<!-- end of main row-->

<!------------------------Client Model----------------------------->
<!-- Modal -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title"> Add Client</h4>
            </div>
            <div class="modal-body">
                <form id="clientInfo" action="#" method="post" class="form-horizontal">
                    <div class="form-group">
                        <label for="newclientName" class="col-lg-2 control-label"> Client Name</label>
                        <div class="col-lg-4"> <span id="sprytextfield2">
                                <input class="form-control" placeholder=" Client Name" id="newclientName"   name="newclientName" type="text"  required="required"/>
                                <span class="textfieldRequiredMsg">*</span></span>
                            <div id="nameError" class="alert alert-block alert-danger fade in" style="display:none">
                                <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">&times;</button>
                                <h4>Error Message </h4>
                                <p>
                                    That name is already taken</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>




                    <div class="form-group">
                        <label for="clientaddress" class="col-lg-2 control-label">Client Code </label>
                        <div class="col-lg-4">
                            <input class="form-control" placeholder=" Client Code" id="clientcode" name="clientcode" type="text"/>
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="txtAddress" class="col-lg-2 control-label">Company Name: </label>
                        <div class="col-lg-4">

                            <select name="clientareaid" id="clientareaid"  data-placeholder="Select Company: " class="select2 wdt100">
                                <option value="0">Select </option>
                                {foreach $allclientarea as $myallclientarea}
                                <option value="{$myallclientarea->id}">{$myallclientarea->name} </option>
                                {/foreach}
                            </select>

                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label for="newclientdebt" class="col-lg-2 control-label">
                            Indebtedness</label>
                        <div class="col-lg-4"> <!--<span id="sprytextfield3">-->
                            <input class="form-control numberinput" placeholder="
                                   Indebtedness" id="newclientdebt" name="newclientdebt" type="text" required="required"/>
                            <!--<span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل المديونية صحيحة</span></span>--> </div>
                    </div>
                    <div class="form-group">
                        <label for="clientaddress" class="col-lg-2 control-label">Addres</label>
                        <div class="col-lg-4">
                            <input class="form-control" placeholder="Address" id="clientaddress" name="clientaddress" type="text"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="clientphone" class="col-lg-2 control-label">Phone Number </label>
                        <div class="col-lg-4">
                            <input class="form-control numberinput" placeholder=" Phone Number" id="clientphone" name="clientphone" type="text"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="clientmobile" class="col-lg-2 control-label">Mobile Number </label>
                        <div class="col-lg-4">
                            <input class="form-control numberinput" placeholder=" Mobile Number" id="clientmobile"  name="clientmobile" type="text"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="clientdetails" class="col-lg-2 control-label">Comment</label>
                        <div class="col-lg-4">
                            <textarea  class="form-control" rows="3" name="clientdetails" id="clientdetails"></textarea>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label for="textDetails" class="col-lg-2 control-label">المخزن</label>
                        <div class="col-lg-3">
                            <label>
                                <input type="checkbox" class="ckstore" name="store_all" id="store_all" checked="checked" value="1" />
                                كل المخازن
                            </label>
                        </div>
                        {foreach $storeData as $data}
                        <div class="col-lg-3">
                            <label>
                                <input type="checkbox" class="clientStore ckstore" name="store{$data->storeId}" id="store{$data->storeId}" checked="checked" disabled="disabled" value="1" />
                                {$data->storeName}
                            </label>
                        </div>
                        {/foreach}
                    </div>
                    <!-- =================================================   -->
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default savemodel2" data-dismiss="modal">No</button>
                <button type="button" class="btn btn-primary savemodel1" onClick="insertSupplier();">Yes</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!------------------------Product Model----------------------------->

<!-- Modal -->
<div class="modal fade" id="productModal"   role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel3" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title"> Add Product</h4>
            </div>
            <div class="productForm">
                <div class="modal-body ">
                    {literal}
                    <form id="productInfo" action="#" method="post" class="nameToBeChecked form-horizontal" onsubmit="if (Spry.Widget.Form.validate(this)) {
                                checkName(event, 'product', 'productName');
                                insertProduct(event);
                            } else {
                                return false;
                            }">
                        {/literal}
                        <div class="form-group">
                            <label for="productCatId" class="col-lg-2 control-label"> Main Category</label>
                            <div class="col-lg-4"><span id="spryselect1">
                                    <select name="productCatId" id="productCatId0" data-level="0"  class="select2 wdt100 productCat" >
                                        <option value="-1">Select Category </option>
                                        {foreach $catDataReport as $data}
                                        <option value="{$data->productCatId}">{$data->productCatName}</option>
                                        {/foreach}
                                    </select>

                                    <input type="hidden" id="level" name="level" value="0">
                                    <span class="selectInvalidMsg">*</span></span></div>
                            <div id="manyParents" class="col-lg-12">  </div>
                            <span class="selectInvalidMsg">*</span>

                        </div>
                        <!---------------------------->

                        <input name="hide_precentage" id="hide_precentage" type="hidden" value="{$Programsettingdata->precentages}" />
                        <input name="hide_realprice" id="hide_realprice" type="hidden" value="{$Programsettingdata->realprice}" />

                        <div class="form-group">
                            <label for="productName" class="col-lg-2 control-label">Name</label>
                            <div class="col-lg-4"> <span id="sprytextfield1">
                                    <input name="productName" type="text" id="productName" size="50" class=" form-control "    />
                                    <span class="textfieldRequiredMsg">*</span></span>
                                <div id="productnameError" class="alert alert-block alert-danger fade in" style="display:none">
                                    <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">&times;</button>
                                    <h4>Error Message </h4>
                                    <p>that name is already taken</p>
                                    <div class="clearfix"></div>
                                </div>
                            </div>
                        </div>
                        <!---------------------------->

                        <div class="form-group check_tr " {if {$Programsettingdata->parcode} eq 1}  style="display:none;" {/if} >
                            <label for="parcode" class="col-lg-2 control-label">BarCode</label>
                            <div class="col-lg-4">
                                <input name="parcode" type="text" id="parcode"  class=" form-control" size="50"   />
                            </div>
                        </div>
                        <!---------------------------->

                        <div class="form-group">
                            <label for="productBuyPrice" class="col-lg-2 control-label"> Purchasing price</label>
                            <div class="col-lg-4"> <span id="sprytextfield5">
                                    <input name="productBuyPrice" type="text" id="productBuyPrice1" class="numberinput positivefloat buy_price form-control"  data-id="1"  size="50"   />
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل السعر صحيح</span></span></div>
                        </div>
                        <!---------------------------->


                        <div class="form-group" style="{if {$Programsettingdata->realprice} eq 1} display: none; {/if}">
                            <label for="productBuyPrice" class="col-lg-2 control-label">Purchasing price  </label>
                            <div class="col-lg-4"> <span id="sprytextfield5">
                                    <input style="width: 50%;float: left;" name="productbuypricereal" type="text" id="buypricereal1"  data-type="pricereal"  class="form-control prices  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buy_pricereal1" data-id="1" width="10"/></span>
                                <input style="  width: 50%;"  name="buypricereal_precentage1" type="text" id="productBuyPrice1" data-type="pricereal"  class="form-control precentages  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buypricereal_precentage1" data-id="1" width="10" />
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">
                                    Enter the price correct  </span></span></div>
                        </div>
                        <!---------------------------->
                        <div class="form-group">
                            <label for="productSellAllPrice" class="col-lg-2 control-label">
                                Wholesale price</label>
                            <div class="col-lg-4"> <span id="sprytextfield6">
                                    <!--<input name="productSellAllPrice" type="text" id="productSellAllPrice" class="numberinput form-control" onkeyup="populateSellPrice();"  size="50"   />-->
                                    <input style="{if {$Programsettingdata->precentages} eq 1} width: 100%; {else} width: 50%; {/if} float: left;" name="productSellAllPrice" type="text" id="productSellAllPrice" data-type="buytotal"  class="form-control prices aw_m aw_mt aw_pp numberclic positivefloat buy_total1 enteraction numberinput" data-id="1" width="10"/>
                                    <input style="{if {$Programsettingdata->precentages} eq 1} display: none; {/if}  width: 50%;"  name="buytotal_precentage1" type="text" id="productBuyPrice1"   data-type="buytotal" class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages numberinput positivefloat buytotal_precentage1" data-id="1" width="10"/>
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">
                                        Enter the price correct  </span></span></div>
                        </div>
                        <!---------------------------->

                        <div class="form-group">
                            <!--<label for="productSellHalfPrice" class="col-lg-2 control-label">سعر بيع الجمله التجزئة</label>-->
                            <label for="productSellHalfPrice" class="col-lg-2 control-label">  Selling price is half the wholesale  </label>
                            <div class="col-lg-4"> <span id="sprytextfield7">
                                    <!--<input name="productSellHalfPrice" type="text" id="productSellHalfPrice" class=" form-control numberinput"   size="50"   />-->
                                    <input  style="{if {$Programsettingdata->precentages} eq 1} width: 100%; {else} width: 50%; {/if}float: left;"  name="productSellHalfPrice" type="text" data-type="buyhalf" id="productSellHalfPrice"  class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat buy_hafe1" data-id="1" width="10"/>
                                    <input style=" {if {$Programsettingdata->precentages} eq 1} display: none; {/if} width: 50%;"  name="buyhalf_precentage1" type="text" id="productBuyPrice1"  data-type="buyhalf" class="form-control  aw_m aw_mt aw_pp numberclic enteraction  precentages numberinput positivefloat buyhafe_precentage1" data-id="1" width="10"/>
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">
                                        Enter the price correct</span></span></div>
                        </div>
                        <!---------------------------->

                        <div class="form-group">
                            <!--<label for="productSellUnitPrice" class="col-lg-2 control-label">سعر بيع الوحده</label>-->
                            <label for="productSellUnitPrice" class="col-lg-2 control-label">
                                Retail sale price  </label>
                            <div class="col-lg-4"> <span id="sprytextfield8">
                                    <!--<input name="productSellUnitPrice" type="text" id="productSellUnitPrice" class=" form-control numberinput"  size="50"   />-->
                                    <input  style="{if {$Programsettingdata->precentages} eq 1} width: 100%; {else} width: 50%; {/if} float: left;" name="productSellUnitPrice" type="text" data-type="buypart"  id="productSellUnitPrice"  class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat buy_part1" data-id="1"  width="20"/>
                                    <input style=" {if {$Programsettingdata->precentages} eq 1} display: none; {/if} width: 50%;"  name="buypart_precentage1" type="text" id="productBuyPrice1" data-type="buypart"    class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages numberinput positivefloat buypart_precentage1" data-id="1" width="10"/>
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">  Enter the price correct</span></span></div>
                        </div>
                        <!---------------------------->

                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">Amount</label>
                            <div class="col-lg-4"> <span id="sprytextfield9">
                                    <input name="new_productquantity" type="text" id="new_productquantity" class=" form-control numberinput"    value="0" size="50"/>
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">  Enter the price correct</span></span></div>
                        </div>

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

                        <div class="form-group check_tr_limitamount " {if {$Programsettingdata->limitamount} eq 1}  style="display:none;"  {/if}>
                            <label for="limitamount" class="col-lg-2 control-label"> maximum</label>
                            <div class="col-lg-4"> <span id="sprytextfield10">
                                    <input name="limitamount" type="text" id="limitamount"  class=" form-control numberinput"  size="50" />
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">  Enter the price correct</span></span></div>
                        </div>



                        <!---------------------------->
                        <div class="form-group ">
                            <label for="inputEmail1" class="col-lg-2 control-label">in menu</label>
                            <div class="col-lg-4">



                                <label>
                                    <input value="0"  class="radioR" name="inMenu1"  checked="checked"  type="radio" />

                                    yes </label>

                                <label>
                                    <input value="1"  class="noradioR" name="inMenu1"     type="radio" />
                                    no</label>



                            </div>
                        </div>
                        <!---------------------------->
                        <div class="form-group check_tr_production " {if {$Programsettingdata->production} eq 1}  style="display:none;" {/if}>
                            <label for="inputEmail1" class="col-lg-2 control-label">Manufacturing</label>
                            <div class="col-lg-4">



                                <label>
                                    <input value="1"  class="radioR" name="type1"    type="radio" />

                                    yes </label>

                                <label>
                                    <input value="0"  class="noradioR" name="type1"   checked="checked"  type="radio" />
                                    no </label>



                            </div>
                        </div>
                        <!---------------------------->


                        <div class="form-group check_tr_service " {if {$Programsettingdata->service} eq 1} style="display:none;" {/if}>
                            <label for="inputEmail1" class="col-lg-2 control-label">Service</label>
                            <div class="col-lg-4">

                                <label class='color-black'>
                                    <input value="1"  class="radioR isservice" name="isservice1"   type="radio" />
                                    yes </label>

                                <label class='color-black'>
                                    <input value="0"  class="noradioR isservice" name="isservice1"   checked="checked"  type="radio" />
                                    no </label>
                            </div>

                        </div>

                        <div class="form-group check_tr_date " {if {$Programsettingdata->date} eq 1} style="display:none;" {/if}>
                            <label for="productDate" class="col-lg-2 control-label">Date</label>
                            <div class="col-lg-4"> <span id="sprytextfield11">
                                    <input name="productDate" type="text" id="productDate" value="{$today}" class=" form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" size="50"  />
                                    <span class="textfieldRequiredMsg">*</span></span></div>
                        </div>
                        <!---------------------------->

                        <div class="form-group check_tr_period " {if {$Programsettingdata->expiredate} eq 1} style="display:none;" {/if}>
                            <label for="productDate" class="col-lg-2 control-label">  Expiration Period</label>
                            <div class="col-lg-4"> <span id="sprytextfield11">
                                    <input style="width: 83%;" name="expireDate" type="text" id="expireDate"  value="0" class=" form-control numberinput"    size="50"  />
                                    <span style="float: left;margin-top: -27px; color: white;font-size: 15px;font-weight: bold;">يوم</span>
                                    <span class="textfieldRequiredMsg">*</span></span></div>
                        </div>
                        <!--------------------------------  adding units   ----------------------------->

                        <div class="row check_tr_mesurunit " {if {$Programsettingdata->measuringunit} eq 1} style="display:none;" {/if}>
                            <div class="row">
                                <hr/>
                                <div class="col-lg-6">
                                    <h4>
                                        Measurement units</h4>
                                </div>
                                <div class="col-lg-6">
                                    <button type="button" name="addrawUnit" id="addrawUnit" class="btn btn-primary pull-left ft-nor">  Add Unit </button>
                                </div>
                            </div>
                            <!-- end of title row-->
                            <div class="table-responsive">
                                <table class="table billtable table-bordered" id="containerUnit">
                                    <thead>
                                        <tr>
                                            <th class="wdt120">
                                                Measurement unit</th>
                                            <th class="wdt120">number of units </th>
                                            <th>Delete
                                                <input name="unitsItr" id="unitsItr" type="hidden" value="1" />
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>
                                                <select name="newunitid1" id="newunitid1"  class="select2 wdt100">




                                                    {foreach $unitsData as $unit}


                                                    <option value="{$unit->unitId}">{$unit->unitName}</option>


                                                    {/foreach}


                                                </select>
                                            </td>
                                            <td>
                                                <input type="text" name="newproductnumber1" id="newproductnumber1"   class="form-control txt-nonraduis numberinput" value="1" />
                                            </td>
                                            <td>
                                                <button type="button" id="removeUnit1" class="close flt-none removeUnit" aria-hidden="true">&times;</button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default savemodel3"    data-dismiss="modal" >no</button>
                    <button type="submit" class="btn btn-primary">yes</button>
                </div>
                </form>
            </div>
            <!-- /.productForm -->
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- /////////////////////////Store Model/////////////////////////////////-->

<!-- Modal -->
<div class="modal fade" id="storemodel" 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>
                <span style="font-weight:bold">الكمية المتاحة بالمخازن</span>
            </div>
            <div class="modal-body"> لا يوجد كمية بالمخزن كافية <br/>
                الكمية بالمخزن <span id="errorquantity"></span> </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">غلق</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<input type="hidden" id="allowBillDelete" value="{$Usergroupdata->allowBillDelete}"/>
<!------------------------Client Model----------------------------->
<!-- Modal -->
<div class="modal fade" id="ckPassModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">عفوا ليس لديك صلاحية الحذف</h4>
            </div>
            <div class="modal-body">
                <form id="clientInfo" action="#" method="post" class="form-horizontal">
                    <div class="form-group">
                        <label for="newclientName" class="col-lg-4 control-label">هل لديك كلمة مرور للمتابعة</label>
                        <div class="col-lg-4">
                            <input class="form-control" id="pass" name="pass" type="password"  required="required"/>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <input type="hidden" id="delBtnId" value=""/>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">الغاء</button>
                <button type="button" class="btn btn-primary" id="ckPassDel">متابعة</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
{literal}
<script type="text/javascript">
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "real");
    $('#store_all').live('click', function () {
        if ($(this).attr('checked') == 'checked') {
            $('.clientStore').attr('checked', 'checked');
            $('.clientStore').attr('disabled', 'disabled');
        } else
        {
            $('.clientStore').removeAttr('checked');
            $('.clientStore').removeAttr('disabled');
        }
    });

</script>
{/literal}


<!--{literal}
<script type="text/javascript">
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "real");



    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {isRequired: false, invalidValue: "-1"});
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "real");
    var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "real");
    var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "real");
    var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "real");
    var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "integer");
    var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "integer");
    var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");

</script>
{/literal}
<script type="text/javascript">
</script>-->