<style>
    @media print{

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


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

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


    }
</style>

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">إدارة الفواتير</a></li>
            <li><a href="#">فاتورة الشراء</a></li>
            <li class="active">عرض فاتورة</li>
        </ol>
        <h3>{$billnameAddData->name}</h3>
        <hr/>
        <form class="form-horizontal" role="form" action="buyAndReturnBillController.php?do=show" method="post" id="billform">

            <!-- =========================== START BUY BILL SETTINGS ================================== -->
            <input name="printingpapersize" id="printingpapersize" type="hidden" value="{$Programsettingdata->printingpapersize}" />
            <input type="hidden" name="billnameid" id="billnameid" value="{$billnameid}"/>
            <input type="hidden" name="returnBillSetting" id="returnBillSetting" value="{$billsettingsData[0]->billsettingsvalue}"/>
            <input type="hidden" name="storeSetting" id="storeSetting" value="{$billsettingsData[2]->billsettingsvalue}"/>
            <input type="hidden" name="parcodeSetting" id="parcodeSetting" value="{$billsettingsData[4]->billsettingsvalue}"/>
            <input type="hidden" name="dateSetting" id="dateSetting" value="{$billsettingsData[5]->billsettingsvalue}"/>
            <input type="hidden" name="newProductSetting" id="newProductSetting" value="{$billsettingsData[6]->billsettingsvalue}"/>
            <input type="hidden" name="noteSetting" id="noteSetting" value="{$billsettingsData[7]->billsettingsvalue}"/>
            <input type="hidden" name="productDiscountSetting" id="productDiscountSetting" value="{$billsettingsData[8]->billsettingsvalue}"/>
            <!-- ==========================  END BUY BILL SETTINGS ============================ -->

            <!-- =========================== START GENERAL INFO PANEL =====================-->
            <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 myleft">رقم الفاتورة</label>
                        <div class="col-lg-4">
                            <p class="form-control-static"> {$buyBillData->buybillSerial} </p>
                        </div>
                    </div>



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

                            {foreach $allCostcenter as $myallCostcenter}

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


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

                    {if $Programsettingdata->clientserial eq 1}
                    <!-- end of form-group-->
                    <div class="form-group">
                        <label class="col-lg-3 control-label myleft">رقم تسلسل الفاتورة</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$buyBillData->buybillid} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    {/if}
                    <div class="clearfix"></div>

                    <div class="form-group" {if $billsettingsData[5]->billsettingsvalue eq 0} {else} style="display:none !important;" {/if}>
                        <label class="col-lg-3 control-label myleft">تاريخ الفاتورة</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$buyBillData->buybilldate} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of bill no-->
                <div class="col-lg-4">
                    <div class="form-group mg-bt5">
                        <label class="col-lg-3 control-label myleft">اسم المورد</label>
                        <div class="col-lg-9">
                            <div id="supplierIdDiv">
                                <p class="form-control-static"> {$buyBillData->suppliername} </p>
                            </div>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[56]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-3 control-label ">رصيد الدين</label>
                        <div class="col-lg-9">
                            <div id="debt" class="form-control-static"> {$buyBillData->buybilltotaldeptbefor} </div>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-bt5 mg-tp5 hidden-print"/>
                    <div class="form-group mg-bt5" {if $billsettingsData[2]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                        <label class="col-lg-3 control-label myleft">المخزن</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$buyBillData->storeName} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if  $buyBillData->comment eq ''} hidden-print{/if}" >
                        <label class="col-lg-3 control-label myleft">التعليق</label>
                        <div class="col-lg-9">
                            <p class="form-control-static"> {$buyBillData->comment} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of client info-->

            </div>
            <!-- =========================== END GENERAL INFO PANEL ====================== -->
            <div class="clearfix"></div>

            <!-- =========================== START BUY BILL PANEL ======================= -->
            <div class="row">
                <div class="row">
                    <hr/>
                    <div class="col-lg-6">
                        <h4>المشتريات</h4>
                    </div>
                    <div class="col-lg-6"> </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive">
                    <table class="table billtable table-bordered table-black" id="containerpros">
                        <thead>
                            <tr>
                                <th class="wdt120 myblack hidden-print" {if $billSettingsData[59]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>الباركود</th>
                                <th class="wdt120 myblack">اسم المنتج</th>
                                <th class="wdt240 myblack hidden-print" {if $billsettingsData[7]->billsettingsvalue eq 0} {else} style="display:none !important;" {/if}>ملاحظات</th>
                                <th class="wdt100n myblack" {if {$billSettingsData[53]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>الوحدة</th>
                                <th class="wdt100n myblack" {if {$billSettingsData[64]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if} >العدد</th>
                                <th class="wdt100n myblack"  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if} >{$Programsettingdata->scunitname}</th>

                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">السعر</th>
                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[57]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>الخصم</th>
                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[96]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>ضريبة</th>
                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">الاجمالى
                                    <input name="hidden_itr" id="hidden_itr" type="hidden" value="0" />
                                </th>
                            </tr>
                        </thead>
                        <tbody>

                            {foreach $buyBillDetails as $detail}
                            {if $detail->billtype eq 0}
                            <tr class="aw_td" id="newProduct1">
                                <td class="myblack {if  $detail->parcode eq ''} hidden-print{/if}" {if $billSettingsData[59]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <div id="parcodeDiv1">
                                        <p class="form-control-static"> {$detail->parcode} </p>
                                    </div>
                                </td>
                                <td class="myblack" >
                                    <div id="productdiv1" class="aw_width aw_mt5">
                                        <p class="form-control-static"> {$detail->productName} / {$detail->productCatName}
                                            {if {$billSettingsData[79]->billsettingsvalue} eq 0}
                                            {if isset($detail->sizeName) && $detail->sizeName !=""}/{$detail->sizeName}{/if}
                                            {if isset($detail->colorName) && $detail->colorName !=""}/{$detail->colorName}{/if}
                                            {/if}
                                        </p>
                                    </div>
                                </td>
                                <td class="myblack {if  $detail->note eq ''} hidden-print{/if}"  {if $billsettingsData[7]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <p class="form-control-static"> {$detail->note} </p>
                                </td>
                                <td class="myblack"  {if {$billSettingsData[53]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                                    <div id="unitDiv1">
                                        <p class="form-control-static">{$detail->unitName} </p>
                                    </div>
                                </td>
                                <td class="myblack" {if {$billSettingsData[64]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if} >
                                    <p class="form-control-static"> {$detail->buybilldetailquantity}</p>
                                </td>

                                <td class="myblack" {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}>
                                    <p class="form-control-static"> {$detail->otherdetailquantity}</p>
                                </td>
                                <td class="myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" >
                                    <div id="propricechange1">
                                        <p class="form-control-static">{$detail->buybilldetailprice} </p>
                                    </div>
                                </td>
                                <td class="myblack {if $usergroup->hideBillPrices == 1}hidden{/if}"  {if $billSettingsData[57]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <p class="form-control-static"> {$detail->discountvalue}</p>
                                </td>
                                <td class="myblack {if $usergroup->hideBillPrices == 1}hidden{/if}"  {if $billSettingsData[96]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <p class="form-control-static"> {$detail->rowtaxper}%</p>
                                </td>
                                <td class="aw_totalprice myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <div id="prototal1" class="aw_mt">
                                        <p class="form-control-static">{$detail->buybilldetailtotalprice}</p>
                                    </div>
                                </td>
                            </tr>
                            {/if}
                            {/foreach}

                        </tbody>

                    </table>
                </div>
                <button type="button" class="btn btn-primary pull-left ft-nor {if $usergroup->hideBillPrices == 1}hidden{/if}"> إجمالي المشتريات <span class="badge wht-clo"><div id="buyBillTotal">{$totalBuyPrice}</div></span></button>
            </div>
            <!-- end of second row-->
            <!-- =========================== END BUY BILL PANEL ==================== -->
            <div class="clearfix"></div>

            <!-- =========================== START RETURN BUY BILL PANEL ====================== -->
            <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 class="col-lg-6"> </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive">
                    <table class="table billtable table-bordered table-black" id="containerpros_re">
                        <thead>
                            <tr>
                                <th class="wdt120 myblack hidden-print" {if $billSettingsData[59]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>الباركود</th>
                                <th class="wdt120 myblack">اسم المنتج</th>
                                <th class="wdt240 myblack hidden-print" {if $billsettingsData[7]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>ملاحظات</th>
                                <th class="wdt100n myblack" {if {$billSettingsData[53]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>الوحدة</th>
                                <th class="wdt100n myblack">العدد</th>
                                <th class="wdt100n myblack"  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if} >{$Programsettingdata->scunitname}</th>

                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">السعر</th>
                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[57]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>الخصم</th>
                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[96]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>ضريبة</th>
                                <th class="wdt100n myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">الاجمالى
                                    <input name="hidden_itr_re" id="hidden_itr_re" type="hidden" value="0" />
                                </th>
                            </tr>
                        </thead>
                        <tbody>

                            {foreach $buyBillDetails as $detail}
                            {if $detail->billtype eq 1}
                            <tr class="aw_td" id="newProduct1">
                                <td class="myblack {if  $detail->parcode eq ''} hidden-print{/if}" {if $billSettingsData[59]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <div id="parcodeDiv1">
                                        <p class="form-control-static">{$detail->parcode} </p>
                                    </div>
                                </td>
                                <td class="myblack">
                                    <div id="productdiv1" class="aw_width aw_mt5">
                                        <p class="form-control-static"> {$detail->productName} / {$detail->productCatName}
                                            {if {$billSettingsData[79]->billsettingsvalue} eq 0}
                                            {if isset($detail->sizeName) && $detail->sizeName !=""}/{$detail->sizeName}{/if}
                                            {if isset($detail->colorName) && $detail->colorName !=""}/{$detail->colorName}{/if}
                                            {/if}
                                        </p>
                                    </div>
                                </td>
                                <td class="myblack {if  $detail->note eq ''} hidden-print{/if}" {if $billsettingsData[7]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <p class="form-control-static"> {$detail->note}</p>
                                </td>
                                <td class="myblack" {if {$billSettingsData[53]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                                    <div id="unitDiv1">
                                        <p class="form-control-static"> {$detail->unitName} </p>
                                    </div>
                                </td>
                                <td class="myblack" >
                                    <p class="form-control-static"> {$detail->buybilldetailquantity}</p>
                                </td>
                                <td class="myblack" {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}>
                                    <p class="form-control-static"> {$detail->otherdetailquantity}</p>
                                </td>

                                <td class="myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <div id="propricechange1">
                                        <p class="form-control-static">{$detail->buybilldetailprice} </p>
                                    </div>
                                </td>
                                <td class="myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billSettingsData[57]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <p class="form-control-static"> {$detail->discountvalue}</p>
                                </td>
                                <td class="myblack {if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billSettingsData[96]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                                    <p class="form-control-static"> {$detail->rowtaxper}%</p>
                                </td>
                                <td class="aw_totalprice myblack {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <div id="prototal1" class="aw_mt">
                                        <p class="form-control-static"> {$detail->buybilldetailtotalprice} </p>
                                    </div>
                                </td>
                            </tr>
                            {/if}
                            {/foreach}

                        </tbody>

                    </table>
                </div>
                <button type="button" class="btn btn-primary pull-left ft-nor {if $usergroup->hideBillPrices == 1}hidden{/if}"> إجمالي مردودات المشتريات <span class="badge wht-clo"><div id="buyBillTotal_re">{$totalReturnBuyPrice}</div></span></button>
            </div>
            <!-- =========================== END RETURN BUY BILL PANEL ======================== -->

            <!-- =========================== START TOTAL VALUES PANEL ======================= -->
            <div class="row">
                <div class="col-lg-9"> </div>
                <!-- end of calucation center-->

                <div class="col-lg-3">
                    <hr class="hidden-print"/>
                    <div class="form-group mg-bt5" {if {$billSettingsData[58]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-6 control-label">عدد القطع</label>
                        <div class="col-lg-6">
                            <p class="form-control-static" id="totalQty">{$countBillDetails_buy}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if $billsettingsData[0]->billsettingsvalue eq 0}  {else} style="display:none !important;" {/if}>
                        <label class="col-lg-6 control-label">عدد القطع المرتجعة</label>
                        <div class="col-lg-6">
                            <p class="form-control-static" id="returnTotalQty">{$countBillDetails_return}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-6 control-label">الاجمالى العام</label>
                        <div class="col-lg-6">
                            <p class="form-control-static" id="gentotal">{$buyBillData->buybilltotalbill}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[57]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-6 control-label">نوع الخصم</label>
                        <div class="col-lg-6">
                            <p class="form-control-static"> {if $buyBillData->buybilldiscountrype eq 0}
                                خصم مباشر
                                {else}
                                خصم بنسبه مئويه
                                {/if} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[57]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-6 control-label">قيمة الخصم</label>
                        <div class="col-lg-6">
                            <p class="form-control-static"> {$buyBillData->buybilldiscount} </p>
                        </div>
                    </div>

                    <!------------------------------------------------------>
                    <div class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[36]->billsettingsvalue} eq "0"} {else}  style="display:none"    {/if}>
                        <hr class="mg-tp5 mg-bt5 hidden-print"/>
                        <div class="form-group mg-bt5">
                            <label class="col-lg-6 control-label">ضريبه القيمة المضافة</label>
                            <div class="col-lg-6">
                                <div class="input-group">
                                    {$buyBillData->payedtax} %
                                </div>
                                <div class="input-group" style="padding-top: 1px;">
                                    {$taxvalue}
                                    {$Programsettingdata->currancy}
                                </div>
                            </div>
                        </div>


                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5 hidden-print"/>
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[51]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-6 control-label">الصافى</label>
                        <div class="col-lg-6">
                            <p class="form-control-static" id="gen2total">{$buyBillData->buybillaftertotalbill}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[54]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-6 control-label">المدفوع</label>
                        <div class="col-lg-6">
                            <p class="form-control-static"> {$buyBillData->buybilltotalpayed} </p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5 hidden-print"/>
                    <div class="form-group mg-bt5 bg-yel {if $usergroup->hideBillPrices == 1}hidden{/if}" {if {$billSettingsData[55]->billsettingsvalue} eq 0} {else}  style="display:none"    {/if}>
                        <label class="col-lg-6 control-label">المتبقى</label>
                        <div class="col-lg-6">
                            <p class="form-control-static" id="gen3total">{$buyBillData->buybillfinalbill}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                        <label class="col-lg-6 control-label">باقى الدين</label>
                        <div class="col-lg-6">
                            <p class="form-control-static" id="gen4total">{$buyBillData->buybilltotaldeptafter}</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 {$buyBillData->deletedbuyid} > 0 && {$buyBillData->deletedbuyid} <> NULL && {$buyBillData->deletedbuyid} <> ''}
                <a target="_new" href="{$buyBillData->controlname}?do=editprint&id={$buyBillData->deletedbuyid}">
                    <button type="button" class="btn btn-primary">الايصال القديم</button></a>
                {/if}
                <input name="buybillid" id="buybillid" type="hidden" value="{$buyBillData->buybillid}" />
                {if {$Programsettingdata->printingpapersize} eq 0}
                <a target="_new" href="buyBillprintController.php?do=buyandreturneditprint1&id={$buyBillData->buybillid}">
                    <button type="button" class="btn btn-info">طباعه ايصال كبير</button>
                </a>
                {/if}
                {if {$Programsettingdata->printingpapersize} eq 1} <a target="_new" href="buyBillprintController.php?do=buyandreturneditprint&id={$buyBillData->buybillid}">
                    <button type="button" class="btn btn-info">طباعه ايصال</button>
                </a> {/if}


                <a href="buyAndReturnBillController.php?do=addoneserial&id={$buyBillData->buybillid}&type=3" >  <button type="button" class="btn btn-info">تكويد المنتجات</button></a>

                <a href="buyAndReturnBillController.php?do=addserial&id={$buyBillData->buybillid}&type=3" >  <button type="button" class="btn btn-info">تكويد منتجات متعدد</button></a></div>
            <!-- end of fifth row-->

            <!-- =========================== END TOTAL VALUESPANEL ====================== -->
        </form>
    </div>
</div>
