<?php
include_once 'includes/processes.php';
$Process = new Login_Process;
$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);
$repairData = $Process->getRepairInfo($_GET['rid']);
?> 
  
  
	<div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3 class="modal-title"><i class="fa fa-cogs"></i> Update Repair</h3>
    </div>
	  <form action="repairs.php" method="post">	  
	  <input type="hidden" name="repair_id" value="<?php echo $repairData->repair_id;  ?>" />
		<div class="modal-body">
			<div class="row">
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="item_name">Item Name.</label>
						<input type="text" id="item_name" name="item_name" value="<?php echo $repairData->item_name;  ?>" class="form-control" required>
					</div>				
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="serial_number">Serial Number</label>
						<input type="text" id="serial_number" name="serial_number" value="<?php echo $repairData->serial_number;  ?>"  class="form-control" required>
					</div>				
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="station_id">Originating Station</label>
						<select name="station_id" class="form-control select2-input" data-required="true">
							<option value=""></option>
							<?php $Process->listStation($repairData->originating_station); ?>
						</select>
					</div>
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="date_sent_in">Date received from Station</label>
						<input type="date" id="date_sent_in" name="date_sent_in" placeholder="dd/mm/yyyy" value="<?php echo $repairData->date_in;  ?>"  class="form-control" required>
					</div>				
				</div>
				
				<div class="col-sm-12">
					<div class="form-group col-sm-12">
						<label for="remark">Item Issue</label>
						<textarea name="item_issue" class="form-control" required><?php echo $repairData->item_issue;  ?></textarea>
					</div>				
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="date_sent_out">Date Sent for Repair</label>
						<input type="date" id="date_sent_out" name="date_sent_out" placeholder="dd/mm/yyyy" value="<?php echo $repairData->repair_sent_date;  ?>"  class="form-control" required>
					</div>				
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="proc_return_date">Procurement return date</label>
						<input type="date" id="proc_return_date" name="proc_return_date" value="<?php echo $repairData->repair_date_returned;  ?>"  placeholder="dd/mm/yyyy" class="form-control" >
					</div>				
				</div>
				
				<div class="col-sm-12">
					<div class="form-group col-sm-12">
						<label for="work_done">Work Done on Item</label>
						<textarea name="work_done" class="form-control"><?php echo $repairData->work_done;  ?></textarea>
					</div>				
				</div>
				
				<div class="col-sm-12">
					<div class="form-group col-sm-12">
						<label for="remark">Remarks</label>
						<textarea name="remark" class="form-control"><?php echo $repairData->remark;  ?></textarea>
					</div>				
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="station_return_date">Date returned to Station</label>
						<input type="date" id="station_return_date" name="station_return_date" value="<?php echo $repairData->station_return_date;  ?>"  placeholder="dd/mm/yyyy" class="form-control" >
					</div>				
				</div>
				
				<div class="col-sm-6">
					<div class="form-group col-sm-12">
						<label for="status">Status</label>
						<select name="status" class="form-control select2-input" data-required="true">
							<option value=""></option>
							<option <?php if($repairData->status=="Sent for Repair") { echo "selected"; }  ?> value="Sent for Repair">Sent for Repair</option>
							<option <?php if($repairData->status=="Returned From Repair") { echo "selected"; }  ?> value="Returned From Repair">Returned From Repair</option>
							<option <?php if($repairData->status=="Sent Back to Station") { echo "selected"; }  ?> value="Sent Back to Station">Sent Back to Station</option>
						</select>
					</div>
				</div>
			</div>			
		</div>
		<div class="modal-footer">
			<button type="submit" name="update-repair" class="btn btn-xs btn-success pull-left"><i class="fa fa-check"></i> Update</button>
			<button type="button" class="btn btn-xs btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
		</div>
	  </form>
    </div><!-- /.modal-content -->