<script type="text/javascript">
    var market_places = new Array ();
    @foreach($values as $val)
        market_places[{{ $val->id }}] = {{ $val->commission }};
    @endforeach
</script>
@extends('layout.default')
@section('content')
<div class="row">
    <div class="col-xs-12 col-sm-12">
        @if (Session::has('success'))
            <div class="alert alert-success">
                {{ Session::get('success') }}
            </div>
        @endif
        <div class="box">
            <div class="box-content my_content">
                @if ($errors->has())
                    <div class="alert alert-danger">
                        @foreach ($errors->all() as $error)
                            {!! $error !!}<br>
                        @endforeach
                    </div>
                @endif
                <h5 class="page-header">
                    @if (empty($report_to_edit))
                        <b>Report Entry Form</b>
                    @else
                        <b>Report Edit Form</b>
                    @endif
                </h5>
                        @if (empty($report_to_edit))
                            {!! Form::open(array('id'=>'report_entry_form','class' => 'form-horizontal','role' => 'form','action' => 'WelcomeController@submit_market_place_data','method' => 'POST','accept-charset' => 'ISO-8859-1')) !!}
                        @else
                            {!! Form::open(array('id'=>'report_entry_form','class' => 'form-horizontal','role' => 'form','action' => 'ReportController@update','method' => 'POST','accept-charset' => 'ISO-8859-1')) !!}
                            {!! Form::hidden('report_id',$report_to_edit->report_id,['required'])!!}
                        @endif

                    <div class="form-group">
                        {!! Form::label('date', 'Date', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::text('date',null,array('required'=>'required','class'=>'form-control input_date'))!!}
                            @else
                                {!! Form::text('date',date("m/d/Y",strtotime($report_to_edit->report_date)),array('required'=>'required','class'=>'form-control input_date'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('market_place', 'Market Place', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::select('market_place',$market_places,null,['required'=>'required','class' => 'select_dropdown','id'=>'market_place']) !!}
                            @else
                                {!! Form::select('market_place',$market_places,$report_to_edit->report_market_place_id,['required'=>'required','class' => 'select_dropdown','id'=>'market_place']) !!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('order_id', 'Order ID', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::text('order_id',null,array('required'=>'required','class'=>'form-control'))!!}
                            @else
                                {!! Form::text('order_id',$report_to_edit->report_order_id,array('required'=>'required','class'=>'form-control'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('sku','SKU', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::text('sku',null,array('required'=>'required','class'=>'form-control'))!!}
                            @else
                                {!! Form::text('sku',$report_to_edit->report_item_sku,array('required'=>'required','class'=>'form-control'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('selling_price', 'Selling Price', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::number('selling_price',null,array('required' => 'required','class'=>'form-control','step' =>'any','min'=>0,'id'=>'selling_price'))!!}
                            @else
                                {!! Form::number('selling_price',number_format($report_to_edit->report_selling_price, 2),array('required' => 'required','class'=>'form-control','step' =>'any','min'=>0,'id'=>'selling_price'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('shipping_cost', 'Shipping Cost', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::number('shipping_cost',null,array('required' => 'required','class'=>'form-control','step' => 'any','min'=>0))!!}
                            @else
                                {!! Form::number('shipping_cost',number_format($report_to_edit->report_shipping_cost, 2),array('required' => 'required','class'=>'form-control','step' => 'any','min'=>0))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('net_cost', 'Net Cost', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::number('net_cost',null,array('required' => 'required','class'=>'form-control','step' =>'any','min'=>0))!!}
                            @else
                                {!! Form::number('net_cost',number_format($report_to_edit->report_net_cost, 2),array('required' => 'required','class'=>'form-control','step' =>'any','min'=>0))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

					<div class="form-group">
                            {!! Form::label('commission_percentage', 'Commission Parcentage', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::text('commission_percentage',null,array('id'=>'commission_rate','class'=>'form-control'))!!}
                            @else
                                {!! Form::text('commission_percentage',number_format($report_to_edit->report_market_place_comminsion, 2),array('id'=>'commission_rate','class'=>'form-control'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('commission', 'Commission', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::number('commission',null,array('readonly'=>'readonly','id'=>'commission','class'=>'form-control'))!!}
                            @else
                                {!! Form::number('commission',number_format($report_to_edit->report_market_place_comminsion, 2),array('readonly'=>'readonly','id'=>'commission','class'=>'form-control'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('quantity', 'Quantity', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::number('quantity',null,array('required' => 'required','step' =>'any','min'=>0,'class'=>'form-control'))!!}
                            @else
                                {!! Form::number('quantity',$report_to_edit->report_item_quantity,array('required' => 'required','step' =>'any','min'=>0,'class'=>'form-control'))!!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                        <div id="tax_div">
                            @if (!empty($report_to_edit) && ($report_to_edit->report_market_place_id == 1 || $report_to_edit->report_market_place_id == 7 || $report_to_edit->report_market_place_id == 8 || $report_to_edit->report_market_place_id == 9 || $report_to_edit->report_market_place_id == 15 ))
                                <label class="col-sm-2 control-label">
                                    <a id="tax_text" href="">Tax</a>
                                </label>
                                @if ($report_to_edit->report_tax != 0)
                                    <div id="tax_html">
                                        <div class="col-sm-4">
                                            <input type="number" id="tax" readonly="readonly" value="{!! number_format($report_to_edit->report_tax, 2) !!}" class="form-control" name="tax" required="required" step ="any" min=0/>
                                        </div>
                                        <div>8.75%</div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                @endif
                            @endif
                        </div>
                    </div>

                    <div class="form-group">
                            {!! Form::label('source', 'Source', array('class' => 'col-sm-2 control-label')) !!}
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::select('source',$sources,18,['id'=>'source','class' => 'select_dropdown','required'=>'required']) !!}
                            @else
                                {!! Form::select('source',$sources,$report_to_edit->report_source_id,['id'=>'source','class' => 'select_dropdown','required'=>'required']) !!}
                            @endif
                        </div>
                        <div class="col-sm-4"></div>
                    </div>

                    <div class="form-group">
                            <div class="col-sm-4"></div>
                        <div class="col-sm-4">
                            @if (empty($report_to_edit))
                                {!! Form::submit('Save', array('class' => 'btn btn-primary btn-label-left')) !!}
                            @else
                                {!! Form::submit('Update', array('class' => 'btn btn-primary btn-label-left')) !!}
                            @endif
                        </div>
                    </div>
                {!! Form::close() !!}
            </div>
        </div>
    </div>
</div>
@stop
