@extends('AdminLte.template')
@section('title')
    @php
        if ($poCategory == 'G') {
            $transactionTitle = 'Store Purchase Order';
            if ($poAmendment == 'Y') {
                $transactionTitle = 'Store Purchase Order Amendment';
            }
        } elseif ($purchase_order_type == 'RPO') {
            $transactionTitle = 'Pharmacy PO With Rate Contract';
            if ($poAmendment == 'Y') {
                $transactionTitle = 'Pharmacy PO Amendment With Rate Contract';
            }
        } else {
            $purchase_order_type = 'NPO';
            $transactionTitle = 'Pharmacy Purchase Order';
            if ($poAmendment == 'Y') {
                $transactionTitle = 'Pharmacy Purchase Order Amendment';
            }
        }
    @endphp
    {{ $transactionTitle }}
@endsection
@section('ExternalCss')
    @parent
    
@endsection
@section('Content')
    
    
        @if ($poAmendment == 'Y')
            {{ Form::open(['action' => 'StorePoController@createPoAmendment', 'autocomplete' => 'off', 'id' => 'purchaseForm', 'name' => 'purchaseForm']) }}
        @else
            {{ Form::open(['action' => 'StorePoController@create', 'autocomplete' => 'off', 'id' => 'purchaseForm', 'name' => 'purchaseForm']) }}
        @endif
        @php
            $isClosed = $po_status = "";
            if (isset($poHeader)) {
                $storeCode = $poHeader->store_code;
                $storeName = $poHeader->store_name;
                $isClosed = $poHeader->is_closed;
                $po_status = $poHeader->po_status;
            } else {
                $storeCode = '';
                $storeName = '';
            }
            
        @endphp
        
        
        
        
        @if(isset($purchase_order_type))
            
        @else
            @php $purchase_order_type=''; @endphp
            
        @endif
        
        
        
        
        
        
        
        
        
        @php
            $termsAndCondition = isset($poHeader) ? $poHeader->terms_conditions : '';
            $approvalRemark = isset($poHeader) ? $poHeader->approval_remark : '';
        @endphp
        
        @php
            if (isset($poHeader)) {
                $approvedBy = $poHeader->approved_by;
                $approvedDate = $poHeader->approved_date;
                $createdBy = $poHeader->created_by;
                $createdDate = $poHeader->created_date;
                $isClosed = $poHeader->is_closed;
                $supplierId = $poHeader->supplier_id;
                $supplierName = $poHeader->supplier_name;
                $supplierGstNo = $poHeader->supplier_gstin_no;
                $poNumber = $poHeader->po_type . $poHeader->po_id;
                $poDate = $poHeader->po_date;
                $paymentTermsAfter = $poHeader->payment_terms_after;
                $paymentTermsAfterUnit = $poHeader->payment_terms_after_unit;
                $readOnlyClass = 'readOnlyBackground';
                $readOnly = 'readOnly';
            } else {
                $approvedBy = '';
                $approvedDate = '';
                $createdBy = '';
                $createdDate = '';
                $isClosed = 'N';
                $supplierId = '';
                $supplierName = '';
                $supplierGstNo = '';
                $poNumber = '';
                $poDate = date('Y-m-d');
                $remarks = '';
                $readOnlyClass = '';
                $readOnly = '';
                $paymentTermsAfter = '';
                $paymentTermsAfterUnit = 'days';
            }
        @endphp
        
        
        
        
        
        
        
        
        
        
        
            
            
                
                
                    @if ($purchase_order_type == 'RPO')
                        
                    @else
                        
                    @endif
                
 
                
                    @if ($accessType == 'E')
                        @if ($purchase_order_type == 'RPO')
                              Add
                            
                              Remove
                        @else
                             
                            Add
                            
                              Remove
                        @endif
                        
                        
                    @endif
                
             
         
        
            
            
            
                
                    @if ($accessType == 'E')
                          - Delete
                    @endif
                     
                
                
                    
                
                
                    @php
                        if (session()->get('messageType') == 'success') {
                            $class = 'alert-success';
                        } elseif (session()->get('messageType') == 'error') {
                            $class = 'alert-danger';
                        }
                    @endphp
                    @if (session()->has('message'))
                        
                            ×
                            {{ 'Purchase Order (#' . session()->get('trnType') . session()->get('trnId') . ')' }}
                            {{ session()->get('message') }}
                        
 
                    @endif
                
 
                
                
                    
Payment Terms:
                
                
                    
                    
                     
                    @if ($purchase_order_type == 'RPO')
                        Rate Contract Until: 
                    @endif
                
                
                    
PO Terms & Conditions     
                    
                    
                
                @if ($poAmendment == 'N' && $poUserType == 'S')
                    
                        
Approval Remark
                        
                        
                    
                @endif
            
 
            @php
                if (isset($poHeader)) {
                    $grossTotal = $poHeader->gross_total . '.00';
                    $discountType = $poHeader->discount_type;
                    $discountAmt = $poHeader->discount_amt . '.00';
                    $shippingCharges = $poHeader->shipping_charges . '.00';
                    $otherCharges = $poHeader->other_charges . '.00';
                    $netTaxableAmt = $poHeader->net_taxable_amt . '.00';
                    $cgstAmt = $poHeader->cgst_amt . '.00';
                    $sgstAmt = $poHeader->sgst_amt . '.00';
                    $igstAmt = $poHeader->igst_amt . '.00';
                    $invoiceAmt = $poHeader->invoice_amt . '.00';
                    $roundOff = $poHeader->round_off . '.00';
                    $total = $poHeader->total . '.00';
                } else {
                    $grossTotal = '';
                    $discountType = '';
                    $discountAmt = '';
                    $shippingCharges = '';
                    $otherCharges = '';
                    $netTaxableAmt = '';
                    $cgstAmt = '';
                    $sgstAmt = '';
                    $igstAmt = '';
                    $invoiceAmt = '';
                    $roundOff = '';
                    $total = '';
                }
            @endphp
            
            
            
                @if ($accessType == 'E')
                    @if ($poAmendment == 'N')
                        @if ($poUserType == 'S')
                            
                            
                            
                        @else
                            
                            
                            
                        @endif
                    @else
                        
                    @endif
                @else
                    @if($poUserType == 'S' && $isClosed != 'Y' && $po_status == 'A')
                    
 
                    @endif
                    
                         Back
                    
                @endif
            
            {{ Form::close() }}
        
 
        
     
@endsection
@section('BootstrapModals')
    @include('Components/Bootstrap Modals/product_all_purchase_bill_details_modal')
    @include('Components/Bootstrap Modals/product_all_stock_modal')
    @include('Components/Bootstrap Modals/supplier_modal')
    @include('Components/Bootstrap Modals/product_modal')
    @include('Components/Bootstrap Modals/category_modal')
    @include('Components/Bootstrap Modals/drug_modal')
    @include('Components/Bootstrap Modals/manufacture_modal')
    @include('Components/Bootstrap Modals/unit_modal')
    @include('Components/Bootstrap Modals/productgroup_modal')
    @include('Components/Bootstrap Modals/email_modal')
    @include('Components/Bootstrap Modals/sending_modal')
    @include('Components/Bootstrap Modals/tamplate_create_terms_condition')
@endsection
@section('ExternalJs')
    
    
    
    
    
    
    
    
    
    
@endsection