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

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

</script>

<style>
    .myresult
    {
        -webkit-print-color-adjust: exact;
    }
</style>


<!--meta http-equiv="refresh" content="0;URL=returnsellbillController.php?do=show" /-->
<!--<meta http-equiv="refresh" content="0;URL=sellbillController.php?do=addsellBill&billnameid={$returnsellbillData->billnameid}" />-->
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ادارة الفواتير</a></li>
            <li>
                <!--                <a href="returnsellbillController.php?do=show">-->
                فواتير مردودات المبيعات
                <!--                    </a>-->

            </li>
            <li class="active">تفاصيل فاتورة مردودات المبيعات</li>
        </ol>
        <h3>{$billnameAddData->name}</h3>
        <hr/>

        <form class="form-horizontal " role="form" action="returnsellbillController.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">
                                {$returnsellbillData->returnsellbillid}

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


                    <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 {$returnsellbillData->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">
                                {$returnsellbillData->returnsellbilldate}
                            </p>
                        </div>
                    </div><!-- end of form-group-->



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

                    <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">
                                    {$myclientdata->clientcode}
                                </div>


                            </div>

                        </div>

                    </div>
                    <div class="form-group" >

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


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


                <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">

                                {$returnsellbillData->returnsellbillclientname}

                            </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">
                                {$returnsellbillData->returnsellbilltotaldeptbefor}
                            </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 {$returnsellbilldetailData[0]->pricetype} eq 1}
                                تجزئة
                                {elseif {$returnsellbilldetailData[0]->pricetype} eq 0}
                                جملة
                                {elseif {$returnsellbilldetailData[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">
                                {$returnsellbillData->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">
                                {$returnsellbillData->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">
                                {$returnsellbillData->useremployeename}
                            </p>
                        </div>
                    </div><!-- end of form-group-->
                </div><!-- end of client info-->

            </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" {if {$billsettingsData[0]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                <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="containerReturn" {if {$billsettingsData[0]->
                        billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}>
                        <thead>
                            <tr>
                                <th class="wdt60" {if {$billsettingsData[40]->billsettingsvalue} eq 0}  {else} style="display:none !important;" {/if}>رقم</th>
                                <th class="wdt120" {if {$billsettingsData[59]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>الباركود</th>
                                <th class="wdt120">اسم المنتج</th>
                                {if {$billsettingsData[26]->billsettingsvalue} eq 0}

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

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


                                <th class="wdt100n" {if {$billsettingsData[53]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/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 class="wdt100n {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" {if {$billsettingsData[8]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>الخصم</th>
                                <th class="wdt100n {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">الاجمالى</th>


                            </tr>
                        </thead>
                        <tbody>
                            {assign var=x value=1}
                            {foreach $returnsellbilldetailData as $returnsellbilldetail}
                            <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"    {/if}>

                                    <div id="returnproductparcode1">
                                        <p class="form-control-static">
                                            {$returnsellbilldetail->parcode}
                                        </p>
                                    </div>
                                </td>

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

                                    </div>
                                </td>

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

                                {else}

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


                                <td {if {$billsettingsData[10]->billsettingsvalue} eq 0}  {else} style="display:none !important" {/if}>
                                    <div id="returnproductunitdiv1">
                                        <p class="form-control-static">
                                            {$returnsellbilldetail->unitName}
                                        </p>
                                    </div>
                                </td>




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

                                <td class="check_tr_quantity  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    {$returnsellbilldetail->otherdetailquantity}
                                </td>

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


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

                                    </p>
                                </td>


                                <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                                    <p class="form-control-static" id="reurnprototal1"> {$returnsellbilldetail->returnsellbilldetailtotalprice}</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}" {if {$billsettingsData[0]->billsettingsvalue} eq 0}  {else} style="display:none !important"  {/if}> اجمالى  مردودات المبيعات<span class="badge wht-clo" id="returnsellbilltotal">{$returnsellbillData->returnsellbilltotalbill}</span>

                </button>
            </div>

            <!-- end of third row-->





            <div class="row">

                <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="returnTotalQty">
                                {if {$returnsellbillData->returnsellQuantity} <= 0}
                                {$quantity}
                                {else}
                                {$returnsellbillData->returnsellQuantity}
                                {/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">{$returnsellbillData->returnsellbilltotalbill}</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">
                                {if {$returnsellbillData->returnsellbilldiscounttype} eq 1}
                                مباشر
                                {else}
                                بنسبة
                                {/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">
                                {$returnsellbillData->returnsellbilldiscount}
                            </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">

                                {$returnsellbillData->tax}
                            </div>
                        </div>
                    </div>
                    <hr class="mg-tp5 mg-bt5 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}"/>
                    <div class="form-group mg-bt5" {if {$billsettingsData[51]->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">{$returnsellbillData->returnsellbillaftertotalbill} </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">
                                {$returnsellbillData->returnsellbilltotalpayed}
                            </p>
                        </div>
                    </div><!-- end of form-group-->


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

                        </div>
                    </div><!-- end of form-group-->
                </div><!-- end of totals center-->
            </div><!-- end of fourth row-->

            <input name="sellbillid" id="sellbillid" type="hidden" value="{$returnsellbillData->returnsellbillid}" />
            <div class="row hidden-print">
                <!--                <button type="submit"  class="btn btn-primary">رجوع</button>-->
                {if {$Programsettingdata->printingpapersize} eq 0}
                <a target="_new" href="sellbillprintController.php?do=returnshowDetail1&id={$returnsellbillData->returnsellbillid}">
                    <button type="button" class="btn btn-info">طباعه ايصال كبير</button></a>
                {/if}
                {*if {$Programsettingdata->printingpapersize} eq 1*}
                <a target="_new" href="sellbillprintController.php?do=returnshowDetail&id={$returnsellbillData->returnsellbillid}">
                    <button type="button" class="btn btn-info">طباعه ايصال</button></a>
                {*/if*}
            </div><!-- end of fifth row-->



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







