@extends('customer-service.layout.master')
@section('ptitle','Customer Service')
@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 )

@section('content')
<div class="wrapper">	
	<div class="fluid">
		<div class="widget grid2 widgetH"></div>
		<div class="grid8 widgetH">
			<!-- for validation errors -->
			@if(count($errors) > 0)
			<div class="nNote nFailure">
				@foreach($errors->all() as $error)
				<p>{{$error}}</p>
				@endforeach
			</div>
			@endif
			@if(session()->has('success_msg'))
			<div class="nNote nSuccess">
				<p>{!! session()->get('success_msg') !!}</p>
			</div>
			@elseif(Session::get('error_msg'))
			<div class="nNote nFailure">
				<p>{!! session()->get('error_msg') !!}</p>
			</div>
			@endif
		</div>
		<div class="widget grid2 widgetH"></div>
	</div>
	<!-- Work Order Details -->
	<div class="fluid">
		<form action="{{ url('/customer-service/update-work-order-detail') }}" class="main cussPayment" method="POST" enctype="multipart/form-data">
			<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
			<input type="hidden" name="work_order" value="{{ $form->WorkOrder->wo }}" required/>
			<fieldset>
				<div class="widget grid2 widgetH"></div>
				<div class="widget grid8">
					<div class="whead"><h6>Work Order's Detail</h6></div>
					
					<div class="formRow">
						<div class="grid4">
							<span class="grid12"><label><b>Work Order ID : </b></label><input type="text" name="wo" id="wo" value="{{ $form->WorkOrder->wo }}" readonly required /></span>
						</div>
						<div class="grid4">
							@if($form->WorkOrder->dateTimeStart != '') 
								<span class="grid12"><label><b>Appoint Date : </b></label><input type="text" name="date" id="date" value="{{ date('d/m/Y', strtotime($form->WorkOrder->dateTimeStart))}}" readonly="" required=""></span>
							@else
								<span class="grid12"><label><b>Appoint Date : </b></label><input type="text" name="date" id="date" value="{{ $form->WorkOrder->dateTimeStart}}" readonly="" required=""></span>
							@endif
						</div>
						<div class="grid4">
							@if($form->WorkOrder->dateTimeStart != '') 
								<span class="grid12"><label><b>Appoint Time : </b></label><input type="text" name="time" id="time" value="{{ date('h:i A', strtotime($form->WorkOrder->dateTimeStart))}}" readonly="" required=""></span>
							@else
								<span class="grid12"><label><b>Appoint Time : </b></label><input type="text" name="time" id="time" value="{{ $form->WorkOrder->dateTimeStart}}" readonly="" required=""></span>
							@endif
						</div>
                    </div>
					
					<div class="formRow">
						<div class="grid6">
							<span class="grid12"><label><b>Work Order Current Status : </b></label><input type="text" name="status" id="status" value="{{ $form->WorkOrder->status}}" readonly required /></span>
						</div>
						<div class="grid6">
							<span class="grid12"><label><b>Assign to Contractor : </b></label><input type="text" name="contractor" id="contractor" value="{{ $company->name }}" readonly required /></span>
						</div>
                    </div>
					
					<div class="formRow">
						<div class="grid6">
							<span class="grid12">
								<label><b>Nature of Work / Task <small style="color: red">* </small>:</b></label>
								<select class="styled" name="task" id="task" required>
									<option value="">Choose type of task / nature of work</option>
									<option value="Activation" <?php if($form->WorkOrder->nature_work == "Activation") { echo "selected"; } ?>>Activation</option>
									<option value="Rectification" <?php if($form->WorkOrder->nature_work == "Rectification") { echo "selected"; } ?>>Rectification</option>
									<option value="Relocation" <?php if($form->WorkOrder->nature_work == "Relocation") { echo "selected"; } ?>>Relocation</option>
									<option value="Modification" <?php if($form->WorkOrder->nature_work == "Modification") { echo "selected"; } ?>>Modification</option>
									<option value="Cancellation" <?php if($form->WorkOrder->nature_work == "Cancellation") { echo "selected"; } ?>>Cancellation</option>
									<option value="Addition" <?php if($form->WorkOrder->nature_work == "Splitter Addition") { echo "selected"; } ?>>Splitter Addition</option>
									<option value="Fiber" <?php if($form->WorkOrder->nature_work == "Fiber Optic Cable Installation") { echo "selected"; } ?>>Fiber Optic Cable Installation</option>
								</select>
							</span>
						</div>
						<div class="grid6">
							<span class="grid12">
								@if($form->WorkOrder->pppoe_username != '')
									<span class="grid12"><label><b>PPPOE - Username  : </b></label><input type="text" name="pppoe_username" id="pppoe_username" value="{{ $form->WorkOrder->pppoe_username }}"/></span>
								@else
									<span class="grid12"><label><b>PPPOE - Username  : </b></label><input type="text" name="pppoe_username" id="pppoe_username" value=""/></span>
								@endif
							</span>
						</div>
                    </div>
					
					<div class="formRow">
						<span class="grid6">
							<label><b>ONU / ONT <small style="color: red">* </small>:</b></label>
							<select class="styled" name="onu_ont" id="onu_ont" required>
								<option value="">Choose Modern Type</option>
								<option value="N/A" <?php if($form->WorkOrder->onu == "N/A") { echo "selected"; } ?>>N/A</option>
								<option value="Calix 801 G" <?php if($form->WorkOrder->onu == "Calix 801 G") { echo "selected"; } ?>>Calix 801 G</option>
								<option value="Calix 812 G" <?php if($form->WorkOrder->onu == "Calix 812 G") { echo "selected"; } ?>>Calix 812 G</option>
								<option value="Calix 813 G" <?php if($form->WorkOrder->onu == "Calix 813 G") { echo "selected"; } ?>>Calix 813 G</option>
								<option value="Calix 813 GV 2" <?php if($form->WorkOrder->onu == "Calix 813 GV 2") { echo "selected"; } ?>>Calix 813 GV 2</option>
								<option value="Calix 844 G" <?php if($form->WorkOrder->onu == "Calix 844 Ge") { echo "selected"; } ?>>Calix 844 G</option>
								<option value="Calix 844 E" <?php if($form->WorkOrder->onu == "Calix 844 E") { echo "selected"; } ?>>Calix 844 E</option>
								<option value="Calix 804 Mesh" <?php if($form->WorkOrder->onu == "Calix 804 Mesh") { echo "selected"; } ?>>Calix 804 Mesh</option>
								<option value="Core Cess" <?php if($form->WorkOrder->onu == "Core Cess") { echo "selected"; } ?>>Core Cess</option>
								<option value="Zyxell" <?php if($form->WorkOrder->onu== "Zyxell") { echo "selected"; } ?>>Zyxell</option>
								<option value="Huawei - EG8010H" <?php if($form->WorkOrder->onu== "Huawei - EG8010H") { echo "selected"; } ?>>Huawei - EG8010H</option>
								<option value="Huawei - EG8040H5" <?php if($form->WorkOrder->onu== "Huawei - EG8040H5") { echo "selected"; } ?>>Huawei - EG8040H5</option>
								<option value="Nokia - G010GQ" <?php if($form->WorkOrder->onu== "Nokia - G010GQ") { echo "selected"; } ?>>Nokia - G010GQ</option>
								<option value="Nokia - G240GE" <?php if($form->WorkOrder->onu== "Nokia - G240GE") { echo "selected"; } ?>>Nokia - G240GE</option>
							</select>
						</span>
						
						<span class="grid6">
							<label><b>Router <small style="color: red">* </small>:</b></label>
							<select class="styled" name="router" id="router" required>
								<option value="">Choose Router</option>
								<option value="Tenda AC1200" <?php if($form->WorkOrder->router == "Tenda AC1200") { echo "selected"; } ?>>Tenda AC1200</option>
								<option value="TPlink 1750" <?php if($form->WorkOrder->router == "TPlink 1750") { echo "selected"; } ?>>TPlink 1750</option>
								<option value="DLink AC1200" <?php if($form->WorkOrder->router == "DLink AC1200") { echo "selected"; } ?>>DLink AC1200</option>
								<option value="Tenda AP4 Wireless & AP" <?php if($form->WorkOrder->router == "Tenda AP4 Wireless & AP") { echo "selected"; } ?>>Tenda AP4 Wireless & AP</option>
								<option value="Cisco AC1200" <?php if($form->WorkOrder->router == "Cisco AC1200") { echo "selected"; } ?>>Cisco AC1200</option>
								<option value="TPLink AC1200" <?php if($form->WorkOrder->router == "TPLink AC1200") { echo "selected"; } ?>>TPLink AC1200</option>
								<option value="Mercusys AC12G" <?php if($form->WorkOrder->router == "Mercusys AC12G") { echo "selected"; } ?>>Mercusys AC12G</option>
								<option value="N/A" <?php if($form->WorkOrder->router == "N/A") { echo "selected"; } ?>>N/A</option>
							</select>
						</span>
                    </div>
					
					<div class="formRow">
						<span class="grid6">
							<label><b>Phone <small style="color: red">* </small>:</b></label>
							<select class="styled" name="n_phone" id="n_phone" required>
								<option value="">Need Phone?</option>
								<option value="Yes" <?php if($form->WorkOrder->n_phone == "Yes") { echo "selected"; } ?>>Yes</option>
								<option value="No" <?php if($form->WorkOrder->n_phone == "No") { echo "selected"; } ?>>No</option>
							</select>
						</span>
						
						<span class="grid6" id="noPhone">
							<label><b>No. Phone <small style="color: red">* </small>:</b></label>
							<select class="styled" name="no_phone" id="no_phone">
								@if($form->type_application == 'R')
									<option value="1">1</option>
									<option value="2">2</option>
								@elseif($form->type_application == 'B')
								    <option value="1">1</option>
									<option value="2">2</option>
								@endif
							</select>
						</span>
                    </div>
					
					<div class="formRow">
						<span class="grid12">
							<label><b>Remarks : </b></label>
							<textarea rows="3" cols="" name="remark" id="remark" class="auto" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 70px;">{{ $form->WorkOrder->remarks_custservice }}</textarea>
						</span>
                    </div>
					
					<div class="formRow noBorderB">
						<div class="grid4">
							<button name="cancel" id="cancel" class="buttonM bRed">Cancel</button>
						</div>
						<div class="grid8">
							<input type="submit" name="updateWk" id="updateWk" value="Confirm Work Order" class="buttonM bPurple formSubmit">
						</div>
					</div>
					
				</div>
				<div class="widget grid2 widgetH"></div>
			</fieldset>
		</form>

		@if($form->type_application == 'R')
		<form action="{{ url('/customer-service/update-customer-detail') }}" class="main cussPayment" method="POST" enctype="multipart/form-data" id="updateFormR" name="updateFormR">
			<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
			<input type="hidden" name="subscriber_id" value="{{ $form->Subscriber->subscriber_id }}" required/>
			<fieldset>
				<div class="widget grid2 widgetH"></div>
				<div class="widget grid8">
					<div class="whead"><h6>Customer's Details</h6></div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Type Application : </b></label></div>
						<div class="grid6"><input type="text" name="app" id="app" value="{{ $form->type_application }}" readonly required /></div>
						<div class="grid2">&nbsp;</div>
					</div>
					
					<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="name" id="name" value="{{ $form->Subscriber->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">
							<!-- @if($form->Subscriber->ic == "<b>Package Development</b>") 
								<input type="text" name="ic" id="ic"  value="{{ $form->Subscriber->ic }}" readonly />
							@else
								<input type="text" name="ic" id="ic"  value="{{ $form->Subscriber->ic }}" required />
							@endif -->
							<input type="text" name="ic" id="ic" value="{{ $form->Subscriber->ic }}" required />
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid3">&nbsp;</div>
						<div class="grid2">
							<label><b>Citizen : </b></label>
							<input type="text" name="citizen" id="citizen"  value="{{ $form->Subscriber->citizen }}" readonly required />
						</div>
						<div class="grid2">
							<label><b>Gender : </b></label>
							<input type="text" name="gender" id="gender"  value="{{ $form->Subscriber->gender }}" readonly required />
						</div>
						<div class="grid2">
							<label><b>Race : </b></label>
							<input type="text" name="race" id="race"  value="{{ $form->Subscriber->race }}" readonly required />
						</div>
						<div class="grid3">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Email : </b></label></div>
						<div class="grid6">
							<!-- @if($form->Subscriber->email == "<b>Package Development</b>")
								<input type="text" name="email" id="email" value="{{ $form->Subscriber->email }}" readonly />
							@else
								<input type="email" name="email" id="email" value="{{ $form->Subscriber->email }}" required />
							@endif -->
							<input type="text" name="email" id="email" value="{{ $form->Subscriber->email }}" required />
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid4">
							<label><b>Primary Number : </b></label>
							<input type="text" name="phone1" id="phone1" value="{{ $form->Subscriber->phone1 }}" required />
						</div>
						<div class="grid4">
							<label><b>Secondary Number: </b></label>
							<input type="text" name="phone2" id="phone2"  value="{{ $form->Subscriber->phone2 }}"/>
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Building : </b></label></div>
						<div class="grid6">
							<select class="styled" name="building" id="building" required>
								@foreach ($coverage as $c)
									@if($c->building_name == $form->Subscriber->building_name)
										<option value='{{$c->building_name}}' selected>{{$c->building_name}}</option>
									@else {
										<option value='{{$c->building_name}}'>{{$c->building_name}}</option>
									@endif
								@endforeach
							</select>
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid4">
							<label><b>Unit No : </b></label>
							<input type="text" name="unit_no" id="unit_no" value="{{ $form->Subscriber->unit_no }}" required />
						</div>
						<div class="grid4">
							<label><b>Street : </b></label>
							<input type="text" name="street" id="street" value="{{ $form->Subscriber->street }}" />
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid8">
							<span class="grid4">
								<label><b>City : </b></label>
								<input type="text" name="city" id="city" value="{{ $form->Subscriber->city }}" readonly required />
							</span>
							<span class="grid4">
								<label><b>Postcode : </b></label>
								<input type="text" name="postcode" id="postcode" value="{{ $form->Subscriber->postcode }}" readonly required />
							</span>
							<span class="grid4">
								<label><b>State : </b></label>
								<input type="text" name="state" id="state" value="{{ $form->Subscriber->state }}" readonly required />
							</span>
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow noBorderB">
						<div class="grid12">
							<input type="submit" name="update" id="update" class="buttonM bBlue formSubmit" value="Update Customer's Details">
						</div>
					</div>
					
				</div>
				<div class="widget grid2 widgetH"></div>
			</fieldset>
		</form>
		 @elseif($form->type_application == 'B')
		<form action="{{ url('/customer-service/update-customer-detail') }}" class="main cussPayment" method="POST" enctype="multipart/form-data" id="updateFormB" name="updateFormB">
			<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
			<input type="hidden" name="subscriber_id" value="{{ $form->Subscriber->subscriber_id }}" required/>
			<!-- Company Details-->
			<fieldset>
				<div class="widget grid2 widgetH"></div>
				<div class="widget grid8">
					<div class="whead"><h6>Company's Details</h6></div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Type Application : </b></label></div>
						<div class="grid6"><input type="text" name="app" id="app" value="{{ $form->type_application }}" readonly required /></div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid8">
							<span class="grid4">
								<label><b>Company Registration Number : </b></label>
								<input type="text" name="company_reg" id="company_reg" value="{{ $form->Subscriber->company_reg }}" required />
							</span>
							<span class="grid4">
								<label><b>Company Contact Number : </b></label>
								<input type="text" name="company_num" id="company_num" value="{{ $form->Subscriber->company_num }}" required />
							</span>
							<span class="grid4">
								<label><b>Company Fax Number: </b></label>
								<input type="text" name="company_fax" id="company_fax" value="{{ $form->Subscriber->fax }}" />
							</span>
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Company Name : </b></label></div>
						<div class="grid6"><input type="text" name="company_name" id="company_name" value="{{ $form->Subscriber->company_num }}" required /></div>
						<div class="grid2">&nbsp;</div>
					</div>
					
					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Company Address : </b></label></div>
						<div class="grid6"><textarea rows="3" cols="" name="address" id="address" class="auto" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 70px;" required>{{ $form->Subscriber->street }}</textarea></div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid8">
							<span class="grid4">
								<label><b>City : </b></label>
								<input type="text" name="city" id="city" value="{{ $form->Subscriber->city }}" required />
							</span>
							<span class="grid4">
								<label><b>Postcode : </b></label>
								<input type="text" name="postcode" id="postcode" value="{{ $form->Subscriber->postcode }}" required />
							</span>
							<span class="grid4">
								<label><b>State : </b></label>
								<input type="text" name="state" id="state" value="{{ $form->Subscriber->state }}" required />
							</span>
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

				</div>
				<div class="widget grid2 widgetH"></div>
			</fieldset>

			<!-- Customer Details-->
			<fieldset>
				<div class="widget grid2 widgetH"></div>
				<div class="widget grid8">
					<div class="whead"><h6>Technical Contact Person</h6></div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Name : </b></label></div>
						<div class="grid6"><input type="text" name="name" id="name"  value="{{ $form->Subscriber->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="{{ $form->Subscriber->ic }}" /></div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Designation : </b></label></div>
						<div class="grid6"><input type="text" name="designation" id="designation" value="{{ $form->Subscriber->designation }}" required /></div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid2"><label><b>Email : </b></label></div>
						<div class="grid6"><input type="email" name="email" id="email" value="{{ $form->Subscriber->email }}" /></div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow">
						<div class="grid2">&nbsp;</div>
						<div class="grid4">
							<label><b>Primary Number : </b></label>
							<input type="text" name="phone1" id="phone1" value="{{ $form->Subscriber->phone1 }}" required />
						</div>
						<div class="grid4">
							<label><b>Secondary Number: </b></label>
							<input type="text" name="phone2" id="phone2"  value="{{ $form->Subscriber->phone2 }}"/>
						</div>
						<div class="grid2">&nbsp;</div>
					</div>

					<div class="formRow noBorderB">
						<div class="grid12">
							<input type="submit" name="update" id="update" class="buttonM bBlue formSubmit" value="Update Customer's Details">
						</div>
					</div>
					
				</div>
				<div class="widget grid2 widgetH"></div>
			</fieldset>
		</form>
		@endif
	</div>
</div>
@endsection

@section('external_js')
<script>
	$(document).ready(function(){
		var origin   = window.location.origin; 

		//===== Dynamic table toolbars =====//		
			
		$('#dyn1 .tOptions').click(function () {
			$('#dyn .tablePars').slideToggle(200);
		});	
			
		$('.tOptions').click(function () {
			$(this).toggleClass("act");
		});

		var company_selection = '';
		var wo = '{{ $wo }}';

		var x = document.getElementById("noPhone");
		x.style.display = "none";
		
		$('#n_phone').on('change', function() {
			if(this.value === 'Yes'){
				x.style.display = "block";
				$("#no_phone").prop('required',true);
			}else{
				x.style.display = "none";
				$("#no_phone").prop('required',false);
			}
		});
			

		/* Cancel add new schedule */
		$('#cancel').on('click',function(){
			$.ajax({
				type:"POST",
				url: "{{ url('/customer-service/work-order/remove-schedule') }}",
				data:{"wo": wo,  "_token": "{{ csrf_token() }}"},
				success:function(){
					//$('#calendar').fullCalendar('refetchEvents');
					window.location = "{{ url ('/customer-service/work-order/list')}}";
				}
			});
		});
	});
</script>
@endsection