<script>
    $(document).ready(function (e) {
        var printingpapersize = document.getElementById("printingpapersize").value;
        var id = document.getElementById("sellbillid").value;
        window.open("sellbillprintController.php?do=showDetail2&id=" + id);
        // alert(printingpapersize)
        /*if (printingpapersize == 1)
         {

         //alert("sellbillprintController.php?do=showDetail2&id="+id);
         window.open("sellbillprintController.php?do=showDetail2&id=" + id);
         }
         else
         {
         window.open("sellbillprintController.php?do=showDetail3&id=" + id);
         }*/

    });

</script>


<div class="myresult">

    <div class="row">
        <div class="container">
            <ol class="breadcrumb">
                <li><a href="#">ادارة الفواتير</a></li>
                <li><a href="sellbillController.php?do=show">فواتير المبيعات</a></li>
                <li class="active">تفاصيل فاتورة مبيعات</li>
            </ol>
            <h3>{$billnameAddData->name}</h3>
            <hr/>

            <form class="form-horizontal " role="form" action="sellbillController.php?do=show" method="post">

                <div class="row">
                    <div class="col-lg-8">
                        <div class="form-group" {if {$billsettingsData[61]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>
                            <label class="col-lg-2 control-label">رقم الفاتورة</label>
                            <div class="col-lg-4">
                                <p class="form-control-static">
                                    {$sellbillData->sellbillserial}
                                </p>
                            </div>
                        </div><!-- end of form-group-->
                        {if $Programsettingdata->clientserial eq 1}
                        <div class="form-group" >
                            <label class="col-lg-2 control-label">رقم تسلسل الفاتورة</label>
                            <div class="col-lg-4">
                                <p class="form-control-static">
                                    {if $sellbillData->taxBillNumber > 0}{$sellbillData->taxBillNumber}{else}{$sellbillData->sellbillid}{/if}
                                </p>
                            </div>
                        </div><!-- end of form-group-->
                        {/if}


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

                                {foreach $allCostcenter as $myallCostcenter}

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


                            </div>
                        </div>

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


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

                        <div class="form-group" >
                            <label class="col-lg-2 control-label">نوع السيارة</label>
                            <div class="col-lg-4">
                                <p class="form-control-static">
                                    {$sellbillData->cartype}
                                </p>
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-lg-2 control-label">شاسية السيارة</label>
                            <div class="col-lg-4">
                                <p class="form-control-static">
                                    {$sellbillData->carchase}
                                </p>
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-lg-2 control-label">موتور السيارة</label>
                            <div class="col-lg-4">
                                <p class="form-control-static">
                                    {$sellbillData->carmotor}
                                </p>
                            </div>
                        </div>
                    </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-4 control-label">اسم العميل</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {$sellbillData->tempclientName}
                                </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-4 control-label">رصيد الدين</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {$sellbillData->sellbilltotaldeptbefor}
                                </p>
                            </div>
                        </div><!-- end of form-group-->



                        <div class="form-group mg-bt5">
                            <label class="col-lg-4 control-label">نوع السعر</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {if {$sellbilldetailData[0]->pricetype} eq 1}
                                    تجزئة
                                    {elseif {$sellbilldetailData[0]->pricetype} eq 0}
                                    جملة
                                    {elseif {$sellbilldetailData[0]->pricetype} eq 2}
                                    نصف جملة
                                    {/if}
                                </p>
                            </div>
                        </div><!-- end of form-group-->


                        <hr class="mg-bt5 mg-tp5"/>
                        <div class="form-group mg-bt5" {if {$billsettingsData[2]->billsettingsvalue} eq 0}  {else} style="display:none" {/if}>
                            <label class="col-lg-4 control-label">المخزن</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {$sellbillData->storeName}
                                </p>
                            </div>
                        </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">اسم {if $Programsettingdata->delegate_seller eq 0} بائع {elseif $Programsettingdata->delegate_seller == 1}مندوب {elseif $Programsettingdata->delegate_seller == 2}طبيب {/if}</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {$sellbillData->employeename}
                                </p>
                            </div>
                        </div><!-- end of form-group-->




                        <div class="form-group mg-bt5" >
                            <label class="col-lg-4 control-label">اسم  المستخدم</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {$sellbillData->useremployeename}
                                </p>
                            </div>
                        </div><!-- end of form-group-->
                        <div class="form-group mg-bt5" {if {$billsettingsData[22]->billsettingsvalue} eq 0} style="display:block" {else} style="display:none" {/if}>
                            <label class="col-lg-4 control-label">التعليق</label>
                            <div class="col-lg-8">
                                <p class="form-control-static">
                                    {$sellbillData->comment}
                                </p>
                            </div>
                        </div><!-- end of form-group-->
                    </div><!-- end of client info-->

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

                            <div class="form-group" >
                                <label class="col-lg-2 control-label">رقم التليفون</label>
                                <div class="col-lg-4">
                                    <p class="form-control-static">   {$myclientdata->clientphone}</p>
                                </div>


                            </div>


                            <div class="form-group" >
                                <label class="col-lg-2 control-label">كود العميل</label>
                                <div class="col-lg-4">
                                    <label>
                                        {$myclientdata->clientcode}
                                    </label>
                                </div>


                            </div>

                        </div>

                    </div>

                </div><!-- end of frist row-->
                <!-- hidden ===============================-->
                <input name="printingpapersize" id="printingpapersize" type="hidden" value="{$Programsettingdata->printingpapersize}" />
                <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="row">
                    <div class="row">
                        <hr/>
                        <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" {if {$billsettingsData[40]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>رقم</th>
                                    <th {if {$billsettingsData[59]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if} class="wdt120">الباركود</th>

                                    <th class="wdt120">اسم المنتج</th>
                                    {if {$billsettingsData[26]->billsettingsvalue} eq 0}

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

                                    {/if}

                                    <th {if {$billsettingsData[7]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if} class="wdt240">ملاحظات</th>

                                    <th {if {$billsettingsData[53]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}  class="wdt100n">الوحدة</th>


                                    <th class="wdt100n"  {if {$billsettingsData[64]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>العدد</th>
                                    <th   class="wdt100n"   {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if} >{$Programsettingdata->scunitname}</th>

                                    <th class="wdt100n {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">السعر</th>
                                    <th {if {$billsettingsData[57]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if} class="wdt100n {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">الخصم</th>
                                    <th class="wdt100n {if $Usergroupdata->hideBillPrices == 1}hidden{/if}"> الاجمالى</th>


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

                                    <td>
                                        <div id="productdiv1">
                                            <p class="form-control-static">
                                                {$sellbilldetail->productName}/ {$sellbilldetail->productCatName}
                                            </p>
                                        </div>
                                    </td>

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

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


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


                                    <td {if {$billsettingsData[53]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/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="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                        <div id="propricechange1">
                                            <p class="form-control-static">
                                                {$sellbilldetail->sellbilldetailprice}
                                            </p>
                                        </div>
                                    </td>


                                    <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[57]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>
                                        <p class="form-control-static">

                                            {$sellbilldetail->discountvalue}
                                        </p>
                                    </td>


                                    <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                        <p class="form-control-static">
                                            {$sellbilldetail->sellbilldetailtotalprice}
                                        </p>
                                    </td>





                                </tr>
                                {capture assign=x}{$x+1}{/capture}
                                {/foreach}
                            </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 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 $Usergroupdata->hideBillPrices == 1}hidden{/if}" {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>
                    </div>

                    <div class="col-lg-3">
                        <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">عدد القطع المباعة</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><!-- 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 {$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">
                                    {$sellbillData->sellbilldiscount}
                                </p>
                            </div>
                        </div><!-- end of form-group-->

                        <div class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {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">ضريبه القيمة المضافة</label>
                                <div class="col-lg-7">
                                    <label>
                                        {$sellbillData->tax}
                                    </label>
                                </div>
                            </div>

                        </div>
                        <hr class="mg-tp5 mg-bt5"/>
                        <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="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">
                                <p class="form-control-static">
                                    {$sellbillData->sellbilltotalpayed}
                                </p>
                            </div>
                        </div><!-- end of form-group-->


                        <hr class="mg-tp5 mg-bt5"/>
                        <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-->


                <div class="row hidden-print">
                    <!--<button type="submit"  class="btn btn-primary">رجوع</button>-->

                    {if {$sellbillData->deletedsellid} > 0}
                    <a target="_new" href="{$sellbillData->controlname}.php?do=editprint&id={$sellbillData->deletedsellid}">
                        <button type="button" class="btn btn-primary">الايصال القديم</button></a>
                    {/if}
                    <input name="sellbillid" type="hidden" value="{$sellbillData->sellbillid}"  id="sellbillid"/>
                    {if {$Programsettingdata->printingpapersize} eq 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}">
                        <button type="button" class="btn btn-info">طباعه ايصال</button></a>
                    {*/if*}
                    <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>
                </div><!-- end of fifth row-->




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

</div>
<!--<meta http-equiv="refresh" content="0;URL=sellbillController.php?do=show" />-->
<!--<meta http-equiv="refresh" content="0;URL=sellbillController.php?do=addsellBill&billnameid={$sellbillData->billnameid}" />-->