@extends('layouts.app') @section('title', __('lang_v1.edit_offer')) @section('content')

@lang( 'lang_v1.edit_offer' )

@lang('lang_v1.offer_on_item')

@can('offer.create') @endcan
@can('offer.create') {!! Form::open(['url' => action([\App\Http\Controllers\OfferController::class, 'update'], [$offerData->id]), 'method' => 'put', 'id' => 'offer_form' ]) !!}
{!! Form::label('offer_type', __( 'lang_v1.select_offer_type' ) . ':*') !!} {!! Form::select('offer_type', [''=> 'Select Offer Type', '1'=> 'Individual Item', '2'=> 'Bill Amount', '3' => 'Based On Qty' ], isset($offer_type) ? $offer_type : '', ['onchange' => 'javascript:onChange(this.value)', 'class' => 'form-control select2', 'id' => 'unit_id']); !!}
{!! Form::label('calculation_type', 'Calculation Method:*') !!} {!! Form::select('calculation_type', ['1'=> 'General', '2'=> 'Advance'], $offerData->cal_type, ['class' => 'form-control select2', 'id' => 'calculation_type']); !!}

For General Example : 100x11/100 = 11.00, For Advance Example : 100/1.11 = 90.09

{!! Form::label('offer_for', 'Offer For:*') !!} {!! Form::select('offer_for', ['' => 'Select offer for','1'=> 'All Stores', '2'=> 'Specific Store'], $offerData->offer_for, ['onchange' => "javascript:($(this).val() == 2) ? $('#divStore').show() : $('#divStore').hide();", 'class' => 'form-control select2', 'id' => 'offer_for']); !!}
offer_for == 2) style="display:block" @endif>
{!! Form::label('location_id', 'Store Name:*') !!} {!! Form::select('location_id', $locations, $offerData->business_for, ['placeholder' => __('messages.please_select'), 'class' => 'form-control select2']); !!}
{!! Form::label('name', 'Offer Name:*') !!} {!! Form::text('name', $offerData->name, ['class' => 'form-control', 'required', 'placeholder' => 'Name' ]); !!}
@php($offerItem = \App\OfferItem::where(['offer_id' => $offerData->id])->first()) @php($itemName = \App\Product::select('id','name')->where(['id' => $offerItem->item_id])->first())
{!! Form::label('variation_ids', __('report.products') . ':') !!} {!! Form::select('variation_ids', [], $itemName->id, ['id' => "variation_ids", 'class' => 'form-control']); !!}

Offer Item

{{ $itemName->name ?? '' }}

{!! Form::label('offer_start_date', 'Offers Start Date:*') !!} {!! Form::text('offer_start_date', $start_date, ['class' => 'form-control', 'required', 'placeholder' => __( 'lang_v1.starts_at' ), 'readonly', 'required' => 'required' ]); !!}
{!! Form::label('offer_end_date', 'Offers End Date:*') !!} {!! Form::text('offer_end_date', $end_date, ['class' => 'form-control', 'required', 'placeholder' => __( 'lang_v1.ends_at' ), 'readonly', 'required' => 'required' ]); !!}
{!! Form::label('status', 'Status') !!}
{!! Form::checkbox('status', 1, $offerData->status == 1 ? true : '', ['class' => 'input-icheck']); !!} @lang('lang_v1.is_active')
{!! Form::label('offer_type_check', 'Offer Type') !!}   
{!! Form::checkbox('free_qty', 1, $offerItem->is_free_qty == 1 ? true : '', ['id' => 'free_qty','class' => 'input-icheck']); !!} {!! Form::label('free_qty', 'Free Qty') !!}    {!! Form::checkbox('discount', 1, $offerItem->is_discount == 1 ? true : '', ['id' => 'discount','class' => 'input-icheck']); !!} {!! Form::label('discount', 'Discount') !!}

is_free_qty == 1) style="display:block" @else style="display:none" @endif> @php($offerItemFree = \App\OfferItemFree::where(['offer_id' => $offerData->id])->first())

FREE ITEM

{!! Form::label('purchase_qty', 'Purchase Qty') !!} {!! Form::text('purchase_qty', isset($offerItemFree->purchase_qty) ? $offerItemFree->purchase_qty : 0, ['class' => 'form-control input_number' ]); !!}
{!! Form::label('item_free_qty', 'Free Qty') !!} {!! Form::text('item_free_qty', isset($offerItemFree->free_qty) ? $offerItemFree->free_qty : 0, ['class' => 'form-control input_number']); !!}
is_free_qty == 1) style="display:block" @endif>
@if(isset($offerItemFree->free_item_id) && $offerItemFree->free_item_id !='') @php($freeItemName = \App\Product::join('variations', 'products.id', '=', 'variations.product_id')->select('products.id','products.name', 'product_mrp', 'dpp_inc_tax', 'sell_price_inc_tax')->where(['products.id' => $offerItemFree->free_item_id])->first()) @else @php($freeItemName = \App\Product::join('variations', 'products.id', '=', 'variations.product_id')->select('products.id','products.name', 'product_mrp', 'dpp_inc_tax', 'sell_price_inc_tax')->where(['products.id' => $offerItem->item_id])->first()) @endif {!! Form::label('free_item_id', __('report.products') . ':') !!} {!! Form::select('free_item_id', [], isset($freeItemName->id) ? $freeItemName->id : null, ['id' => "free_item_id", 'class' => 'form-control']); !!}
Free Item: {{ isset($freeItemName->name) ? $freeItemName->name : '' }}
is_discount == 1) style="display:block" @else style="display:none" @endif> @php($offerItemDis = \App\OfferItemDiscount::where(['offer_id' => $offerData->id])->first())

Discount

{!! Form::label('discount_type_check', 'Discount Type') !!}   
{!! Form::radio('discount_type', 1, isset($offerItemDis->discount_type) && $offerItemDis->discount_type == 1 ? true : '', ['class' => 'discount_type input-icheck']); !!} {!! Form::label('discount_type', 'Amount') !!}    {!! Form::radio('discount_type', 2, isset($offerItemDis->discount_type) && $offerItemDis->discount_type == 2 ? true : '', ['class' => 'discount_type input-icheck']); !!} {!! Form::label('discount_type', 'Percentage') !!}

Discount Amount {!! Form::text('discount_amount', isset($offerItemDis->discount_amount) ? $offerItemDis->discount_amount : 0, ['id' => 'discount_amount','placeholder' => 'Enter discount amount/Percentage','class' => 'form-control input_number']) !!}
Base Offer Price {!! Form::radio('base_price', 1, isset($offerItemDis->base_offer_type) && $offerItemDis->base_offer_type == 1 ? true : '', ['id' => 'rdoBase0','class' => 'input-icheck']); !!}    {!! Form::radio('base_price', 2, isset($offerItemDis->base_offer_type) && $offerItemDis->base_offer_type == 2 ? true : '', ['id' => 'rdoBase1','class' => 'input-icheck']); !!}    {!! Form::radio('base_price', 3, isset($offerItemDis->base_offer_type) && $offerItemDis->base_offer_type == 3 ? true : '', ['id' => 'rdoBase2','class' => 'input-icheck']); !!}   
New Price After Discount {!! Form::text('new_sale_price', isset($offerItemDis->new_price_after_discount) ? $offerItemDis->new_price_after_discount : 0, ['id' => 'new_sale_price','class' => 'form-control input_number']) !!}

{!! Form::close() !!} @endcan
@stop @section('javascript') @endsection