@extends('layouts.app') @section('title', __('product.add_new_product')) @section('content')

@lang('product.add_new_product')

@php $form_class = empty($duplicate_product) ? 'create' : ''; $is_image_required = !empty($common_settings['is_product_image_required']); @endphp {!! Form::open(['url' => action([\App\Http\Controllers\ProductController::class, 'store']), 'method' => 'post', 'id' => 'product_add_form','class' => 'product_form ' . $form_class, 'files' => true ]) !!} @component('components.widget', ['class' => 'box-primary'])
{!! Form::label('name', __('product.product_name') . ':*') !!} {!! Form::text('name', !empty($duplicate_product->name) ? $duplicate_product->name : null, ['class' => 'form-control', 'required', 'placeholder' => __('product.product_name')]); !!}
{!! Form::label('sku', __('product.sku') . ':') !!} @show_tooltip(__('tooltip.sku')) {!! Form::text('sku', null, ['class' => 'form-control', 'placeholder' => __('product.sku')]); !!}
{!! Form::label('barcode_type', __('product.barcode_type') . ':*') !!} {!! Form::select('barcode_type', $barcode_types, !empty($duplicate_product->barcode_type) ? $duplicate_product->barcode_type : $barcode_default, ['class' => 'form-control select2', 'required']); !!}
{!! Form::label('unit_id', __('product.unit') . ':*') !!}
{!! Form::select('unit_id', $units, !empty($duplicate_product->unit_id) ? $duplicate_product->unit_id : session('business.default_unit'), ['class' => 'form-control select2', 'required']); !!}
{!! Form::label('sub_unit_ids', __('lang_v1.related_sub_units') . ':') !!} @show_tooltip(__('lang_v1.sub_units_tooltip')) {!! Form::select('sub_unit_ids[]', [], !empty($duplicate_product->sub_unit_ids) ? $duplicate_product->sub_unit_ids : null, ['class' => 'form-control select2', 'multiple', 'id' => 'sub_unit_ids']); !!}
@if(!empty($common_settings['enable_secondary_unit']))
{!! Form::label('secondary_unit_id', __('lang_v1.secondary_unit') . ':') !!} @show_tooltip(__('lang_v1.secondary_unit_help')) {!! Form::select('secondary_unit_id', $units, !empty($duplicate_product->secondary_unit_id) ? $duplicate_product->secondary_unit_id : null, ['class' => 'form-control select2']); !!}
@endif
{!! Form::label('brand_id', __('product.brand') . ':') !!}
{!! Form::select('brand_id', $brands, !empty($duplicate_product->brand_id) ? $duplicate_product->brand_id : null, ['placeholder' => __('messages.please_select'), 'class' => 'form-control select2']); !!}
{!! Form::label('category_id', __('product.category') . ':') !!} {!! Form::select('category_id', $categories, !empty($duplicate_product->category_id) ? $duplicate_product->category_id : null, ['placeholder' => __('messages.please_select'), 'class' => 'form-control select2']); !!}
{!! Form::label('sub_category_id', __('product.sub_category') . ':') !!} {!! Form::select('sub_category_id', $sub_categories, !empty($duplicate_product->sub_category_id) ? $duplicate_product->sub_category_id : null, ['placeholder' => __('messages.please_select'), 'class' => 'form-control select2']); !!}
@php $default_location = null; if(count($business_locations) == 1){ $default_location = array_key_first($business_locations->toArray()); } @endphp
{!! Form::label('product_locations', __('business.business_locations') . ':') !!} @show_tooltip(__('lang_v1.product_location_help')) {!! Form::select('product_locations[]', $business_locations, $default_location, ['class' => 'form-control select2', 'multiple', 'id' => 'product_locations']); !!}

@show_tooltip(__('tooltip.enable_stock'))

@lang('product.enable_stock_help')

{!! Form::label('alert_quantity', __('product.alert_quantity') . ':') !!} @show_tooltip(__('tooltip.alert_quantity')) {!! Form::text('alert_quantity', !empty($duplicate_product->alert_quantity) ? @format_quantity($duplicate_product->alert_quantity) : null , ['class' => 'form-control input_number', 'placeholder' => __('product.alert_quantity'), 'min' => '0']); !!}
@if(!empty($common_settings['enable_product_warranty']))
{!! Form::label('warranty_id', __('lang_v1.warranty') . ':') !!} {!! Form::select('warranty_id', $warranties, null, ['class' => 'form-control select2', 'placeholder' => __('messages.please_select')]); !!}
@endif @if(!empty($pos_module_data)) @foreach($pos_module_data as $key => $value) @if(!empty($value['view_path'])) @includeIf($value['view_path'], ['view_data' => $value['view_data']]) @endif @endforeach @endif
{!! Form::label('product_description', __('lang_v1.product_description') . ':') !!} {!! Form::textarea('product_description', !empty($duplicate_product->product_description) ? $duplicate_product->product_description : null, ['class' => 'form-control']); !!}
{!! Form::label('image', __('lang_v1.product_image') . ':') !!} {!! Form::file('image', ['id' => 'upload_image', 'accept' => 'image/*', 'required' => $is_image_required, 'class' => 'upload-element']); !!}

@lang('purchase.max_file_size', ['size' => (config('constants.document_size_limit') / 1000000)])
@lang('lang_v1.aspect_ratio_should_be_1_1')

{!! Form::label('product_brochure', __('lang_v1.product_brochure') . ':') !!} {!! Form::file('product_brochure', ['id' => 'product_brochure', 'accept' => implode(',', array_keys(config('constants.document_upload_mimes_types')))]); !!}

@lang('purchase.max_file_size', ['size' => (config('constants.document_size_limit') / 1000000)]) @includeIf('components.document_help_text')

@endcomponent @component('components.widget', ['class' => 'box-primary'])
@if(session('business.enable_product_expiry')) @if(session('business.expiry_type') == 'add_expiry') @php $expiry_period = 12; $hide = true; @endphp @else @php $expiry_period = null; $hide = false; @endphp @endif
{!! Form::label('expiry_period', __('product.expires_in') . ':') !!}
{!! Form::text('expiry_period', !empty($duplicate_product->expiry_period) ? @num_format($duplicate_product->expiry_period) : $expiry_period, ['class' => 'form-control pull-left input_number', 'placeholder' => __('product.expiry_period'), 'style' => 'width:60%;']); !!} {!! Form::select('expiry_period_type', ['months'=>__('product.months'), 'days'=>__('product.days'), '' =>__('product.not_applicable') ], !empty($duplicate_product->expiry_period_type) ? $duplicate_product->expiry_period_type : 'months', ['class' => 'form-control select2 pull-left', 'style' => 'width:40%;', 'id' => 'expiry_period_type']); !!}
@endif

@show_tooltip(__('lang_v1.tooltip_sr_no'))

@show_tooltip(__('lang_v1.tooltip_not_for_selling'))
@if(session('business.enable_racks') || session('business.enable_row') || session('business.enable_position'))

@lang('lang_v1.rack_details'): @show_tooltip(__('lang_v1.tooltip_rack_details'))

@foreach($business_locations as $id => $location)
{!! Form::label('rack_' . $id, $location . ':') !!} @if(session('business.enable_racks')) {!! Form::text('product_racks[' . $id . '][rack]', !empty($rack_details[$id]['rack']) ? $rack_details[$id]['rack'] : null, ['class' => 'form-control', 'id' => 'rack_' . $id, 'placeholder' => __('lang_v1.rack')]); !!} @endif @if(session('business.enable_row')) {!! Form::text('product_racks[' . $id . '][row]', !empty($rack_details[$id]['row']) ? $rack_details[$id]['row'] : null, ['class' => 'form-control', 'placeholder' => __('lang_v1.row')]); !!} @endif @if(session('business.enable_position')) {!! Form::text('product_racks[' . $id . '][position]', !empty($rack_details[$id]['position']) ? $rack_details[$id]['position'] : null, ['class' => 'form-control', 'placeholder' => __('lang_v1.position')]); !!} @endif
@endforeach @endif
{!! Form::label('weight', __('lang_v1.weight') . ':') !!} {!! Form::text('weight', !empty($duplicate_product->weight) ? $duplicate_product->weight : null, ['class' => 'form-control', 'placeholder' => __('lang_v1.weight')]); !!}
@php $custom_labels = json_decode(session('business.custom_labels'), true); $product_custom_fields = !empty($custom_labels['product']) ? $custom_labels['product'] : []; $product_cf_details = !empty($custom_labels['product_cf_details']) ? $custom_labels['product_cf_details'] : []; @endphp
@foreach($product_custom_fields as $index => $cf) @if(!empty($cf)) @php $db_field_name = 'product_custom_field' . $loop->iteration; $cf_type = !empty($product_cf_details[$loop->iteration]['type']) ? $product_cf_details[$loop->iteration]['type'] : 'text'; $dropdown = !empty($product_cf_details[$loop->iteration]['dropdown_options']) ? explode(PHP_EOL, $product_cf_details[$loop->iteration]['dropdown_options']) : []; @endphp
{!! Form::label($db_field_name, $cf . ':') !!} @if(in_array($cf_type, ['text', 'date'])) @elseif($cf_type == 'dropdown') {!! Form::select($db_field_name, $dropdown, !empty($duplicate_product->$db_field_name) ? $duplicate_product->$db_field_name : null, ['placeholder' => $cf, 'class' => 'form-control select2']); !!} @endif
@endif @endforeach
{!! Form::label('preparation_time_in_minutes', __('lang_v1.preparation_time_in_minutes') . ':') !!} {!! Form::number('preparation_time_in_minutes', !empty($duplicate_product->preparation_time_in_minutes) ? $duplicate_product->preparation_time_in_minutes : null, ['class' => 'form-control', 'placeholder' => __('lang_v1.preparation_time_in_minutes')]); !!}
@include('layouts.partials.module_form_part')
@endcomponent @component('components.widget', ['class' => 'box-primary'])
{!! Form::label('tax', __('product.applicable_tax') . ':') !!} {!! Form::select('tax', $taxes, !empty($duplicate_product->tax) ? $duplicate_product->tax : null, ['placeholder' => __('messages.please_select'), 'class' => 'form-control select2'], $tax_attributes); !!}
{!! Form::label('tax_type', __('product.selling_price_tax_type') . ':*') !!} {!! Form::select('tax_type', ['inclusive' => __('product.inclusive'), 'exclusive' => __('product.exclusive')], !empty($duplicate_product->tax_type) ? $duplicate_product->tax_type : 'exclusive', ['class' => 'form-control select2', 'required']); !!}
{!! Form::label('type', __('product.product_type') . ':*') !!} @show_tooltip(__('tooltip.product_type')) {!! Form::select('type', $product_types, !empty($duplicate_product->type) ? $duplicate_product->type : null, ['class' => 'form-control select2', 'required', 'data-action' => !empty($duplicate_product) ? 'duplicate' : 'add', 'data-product_id' => !empty($duplicate_product) ? $duplicate_product->id : '0']); !!}
@include('product.partials.single_product_form_part', ['profit_percent' => $default_profit_percent])
@endcomponent
@if($selling_price_group_count) @endif @can('product.opening_stock') @endcan
{!! Form::close() !!}
@endsection @section('javascript') @php $asset_v = env('APP_VERSION'); @endphp @endsection