@extends('market.layout.master')
@section('ptitle', 'Marketing')
@section('page_title', 'Dashboard')
@section('subpage', 'Graph & Summary Report')
@section('img_profile', asset($user->staffDetail->user_pic))
@section('login_name', $user->staffDetail->name )
@section('last_login', $user->last_login_at )

<?php
Use App\Model\Company;
?>

@section('content')
	<style type="text/css">
		.i_note {color: red;}
	</style>

	<div class="fluid">
		@if(count($errors) > 0)
		<div class="nNote nFailure">
			@foreach($errors->all() as $error)
			<p>{{$error}}</p>
			@endforeach
		</div>
		@endif

		@if(Session::get('error_msg'))
		<div class="nNote nFailure">
			<p>Email or Password is invalid</p>
		</div>
		@elseif(Session::get('success_msg'))
		<div class="nNote nSuccess">
			<p>Add new agent successful</p>
		</div>
		@endif
	</div>

	<div class="fluid">
		<form action="{{url('/marketing/agent/update-agent')}}" class="main cussPayment" method="post" enctype="multipart/form-data">
			<fieldset>
				<div class="widget grid2 widgetH"></div>
				<div class="widget grid8">
					<div class="whead"><h6>Add New Agent's Detail</h6></div>
					
					<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
					<input type="hidden" name="agent_id" value="{{$agentdetail->_id}}">

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Full Name : </b></label></div>
                        <div class="grid6"><input type="text" name="aname" id="aname" value="{{$agentdetail->StaffDetail->name}}" required /></div>
						<div class="grid2">&nbsp;</div>
                    </div>
					
					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>NRIC : </b></label></div>
                        <div class="grid6"><input type="text" name="ic" id="ic"  value="{{$agentdetail->StaffDetail->ic}}" required /></div>
						<div class="grid2">&nbsp;</div>
                    </div>
					
					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid4">
							<label><b>Email : </b></label> 
							<input type="email" name="email" id="email" value="{{$agentdetail->StaffDetail->email}}" required />
						</div>
                        <div class="grid4">
							<label><b>Phone No. : </b></label>
							<input type="text" name="phone" id="phone" required  value="{{$agentdetail->StaffDetail->phone}}"/>
							<small style="color: red"></small>
						</div>
						<div class="grid2">&nbsp;</div>
                    </div>
					
					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Company / Dealer : </b></label></div>
                        <div class="grid6">
							<select class="styled" id="vendor" name="vendor" required>
								<option value="{{$agentdetail->StaffDetail->company_id}}">{{$agentdetail->Company->name}}</option>
								@foreach($company as $a)
									<?php 
										$company1 = $agentdetail->StaffDetail->company_id;
										$company2 = $a->_id; 
									?>
									@if($company1!=$company2)
										<option value="{{ $a->_id}}">{{ $a->name }}</option>
									@else
									@endif
								@endforeach
							</select>
						</div>
						<div class="grid2">&nbsp;</div>
                    </div>
					
					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Password : </b></label></div>
                        <div class="grid6"><input type="password" name="password" id="password1"/><small style="color: red">Let it blank if you dont want change the password!</small></div>
						<div class="grid2">&nbsp;</div>
                    </div>
					
					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Re-Password : </b></label></div>
                        <div class="grid6"><input type="password" name="password_confirmation" id="password2"/><small style="color: red">Let it blank if you dont want change the password!</small></div>
						<div class="grid2">&nbsp;</div>
                    </div>
					
					<div class="formRow noBorderB" id="sendForm"><input type="submit" value="Update Detail" class="buttonM bPurple formSubmit" name="submit" id="submit"></div>
				</div>
				<div class="widget grid2 widgetH"></div>
			</fieldset>
		</form>
	</div>
@endsection

@section('external_js')
@endsection