
<?php
	session_start();
	$user_id=$_SESSION['LOGIN_USERID'];
	extract($_REQUEST);
	include("../../php_crud/my_class.php");
	$obj = new my_class();
	
	//$id="";
	if($id!=''){
		$func = "update_equipment_failure";
		$button = "Update Equipment Failure";
		$zone_info = $obj->Details_By_Cond_aquatic("TBLPGCB_FAILURESTUDY","ID=$id");
	} else {
		$func = "save_equipment_failure";
		$button = "Save Equipment Failure";
	}
?>
<style>
	input[type="text"], textarea, select{
		width: 100%;
	}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<div class="row-fluid" id="form_data">
<?php
if ($_SESSION['add'] == 'Y') {
    ?>
        <form action="" id="equipmentFailureForm" method="post">    
			<div class="row-fluid">
				<div class="row-fluid">
					<legend>Equipment Failure Study</legend> 	
				</div>
				<div class="row-fluid">
					<table style="width: 100%; margin-top: -10px;">
						<tr>
							<td style="padding-left: 10px; padding-bottom: 10px;"><b>Device Sl No:</b></td>
							<td>
								<input style="width: 90%;" type="text" name="device_sl_no" id="device_sl_no" class="form-control" placeholder="Device Sl No." readonly />
							</td>
							<td style="padding-left: 10px; padding-bottom: 10px;">
								<b>
								<a href="#modal_device_list" data-toggle="modal" data-target="#modal_device_list" onclick="load_device_info()" style="border-bottom: 1px solid blue; color: blue;">
									Pick</a>
								</b>
							</td>
							<td>
								<input style="width: 90%;" type="text" name="pick_no" id="pick_no" class="form-control" readonly />
							</td>
						</tr>
						<tr>
							<td style="padding-left: 10px; padding-bottom: 10px;"><b>New ID:</b></td>
							<td>
								<input style="width: 90%;" type="text" name="new_id" id="new_id" class="form-control" placeholder="" readonly />
							</td>
							<td style="padding-left: 10px; padding-bottom: 10px;"><b>Old ID:</b></td>
							<td>
								<input style="width: 90%;" type="text" name="old_id" id="old_id" class="form-control" placeholder="" readonly />
							</td>
						</tr>
						<tr>
							<td style="padding-left: 10px; padding-bottom: 10px;"><b>Upazila:</b></td>
							<td>
								<input style="width: 90%;" type="text" name="upazila" id="upazila" class="form-control" placeholder="" readonly />
							</td>
							<td style="padding-left: 10px; padding-bottom: 10px;"><b>District:</b></td>
							<td>
								<input style="width: 90%;" type="text" name="district" id="district" class="form-control" placeholder="" readonly />
							</td>
						</tr>
					</table>
				</div>
                
				<div class="row-fluid">
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1"><b>Upazila <font color="#FF0000">*</font></b></label>
							<div class="controls" id="upz_code_holder">
								<select class="form_control">
									<option value="">---</option>
								</select>
							</div> 
						</div>
					</div>
				</div>
				<div class="row-fluid">
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Device Name<font color="#FF0000">*</font></label>
							<div class="controls">
								<select id="device_name" name="device_name" class="form_control" >
									<option value="">SELECT DEVICE</option>
									<?php
										$table_name = "TBLGWH_DEVICENAME";
										$where_cond = "FLAG='A' ORDER BY ID ASC";
										$row = $obj->View_all_data_row_column_By_Cond_aquatic($table_name,' * ',$where_cond);
										foreach($row AS $index=>$value){?>
											<option value="<?php echo $value['ID']; ?>"><?php echo $value['DEVICENAME'];?></option>
										<?php }
									?>
								</select>
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Test By (Geologist)<font color="#FF0000">*</font>
							</label>

							<div class="controls">
								<input type="text" name="test_by" id="test_by" class="form-control" placeholder="Test by (Geologist)" >
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Test Date and Time<font color="#FF0000">*</font>
							</label>

							<div class="controls">
								<input type="text" name="test_date" id="test_date" class="form-control date-picker" data-date-format="dd-mm-yyyy" placeholder="Test Date and Time">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Note Details
							</label>

							<div class="controls">
								<textarea name="note_detail" id="note_detail" class="form-control" placeholder="Note Details"></textarea>
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Year of Maintenance</label>
								
							<div class="controls">
								<select id="year_maintenance" name="year_maintenance" >
									<option value="2000">2000</option>
									<option value="2000">2001</option>
									<option value="2000">2002</option>
									<option value="2000">2003</option>
									<option value="2000">2004</option>
									<option value="2000">2005</option>
									<option value="2000">2006</option>
									<option value="2000">2007</option>
									<option value="2000">2008</option>
									<option value="2000">2009</option>
									<option value="2000">2010</option>
									<option value="2000">2011</option>
									<option value="2000">2012</option>
									<option value="2000">2013</option>
									<option value="2000">2014</option>
									<option value="2000">2015</option>
									<option value="2000">2016</option>
									<option value="2000">2017</option>
									<option value="2000">2018</option>
									<option value="2000">2019</option>
									<option value="2000">2020</option>
									<option value="2000">2021</option>
								</select>
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Year of Commissioning
							</label>

							<div class="controls">
								<select id="year_commission" name="year_commission" >
									<option value="2000">2000</option>
									<option value="2000">2001</option>
									<option value="2000">2002</option>
									<option value="2000">2003</option>
									<option value="2000">2004</option>
									<option value="2000">2005</option>
									<option value="2000">2006</option>
									<option value="2000">2007</option>
									<option value="2000">2008</option>
									<option value="2000">2009</option>
									<option value="2000">2010</option>
									<option value="2000">2011</option>
									<option value="2000">2012</option>
									<option value="2000">2013</option>
									<option value="2000">2014</option>
									<option value="2000">2015</option>
									<option value="2000">2016</option>
									<option value="2000">2017</option>
									<option value="2000">2018</option>
									<option value="2000">2019</option>
									<option value="2000">2020</option>
									<option value="2000">2021</option>
								</select>
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Date and Time of Occurance/Discovery of fault

							<div class="controls">
								<input type="text" name="occurance_date" class="date-picker" data-date-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" id="occurance_date" class="form-control" />
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Information Received in BWDB
							</label>

							<div class="controls">
								<input type="text" name="info_receive" id="info_receive" class="form-control" placeholder="Information Received in BWDB" />
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Fault Discovery During
							</label>

							<div class="controls">
								<input type="text" name="fault_discover" id="fault_discover" class="form-control" placeholder="Fault Discovery During" />
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Present Condition of Equipment
							</label>

							<div class="controls">
								<textarea name="present_condition" id="present_condition" class="form-control" placeholder="Present Condition of Equipment"></textarea>
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Details of Previous Maintenance
							</label>

							<div class="controls">
								<textarea name="prev_maintenance" rows="5" id="prev_maintenance" class="form-control" placeholder="Details of Previous Maintenance"></textarea>
							</div> 
						</div>
					</div>
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">Details of Previous Failure
							</label>

							<div class="controls">
								<textarea name="prev_failure" id="prev_failure" class="form-control" placeholder="Details of Previous Failure"></textarea>
							</div> 
						</div>
					</div>
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">Sequence of events/Description of fault
							</label>

							<div class="controls">
								<textarea name="seq_events" id="seq_events" class="form-control" placeholder="Sequence of events/Description of fault"></textarea>
							</div> 
						</div>
					</div>
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">Details of Tests Done After
							</label>

							<div class="controls">
								<textarea name="details_test" id="details_test" class="form-control" placeholder="Details of Tests Done After"></textarea>
							</div> 
						</div>
					</div>
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">Conclusions/Recommendations
							</label>

							<div class="controls">
								<textarea name="conclusion" id="conclusion" class="form-control" placeholder="Conclusions/Recommendations"></textarea>
							</div> 
						</div>
					</div>
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">Status<font color="#FF0000">*</font></label>
							<div class="controls">
								<select name="status" id="status" class="form-control">
									<option value="A" <?php if($devcie_info['FLAG']=='A'){echo "selected";}?>>Active</option>
									<option value="I" <?php if($devcie_info['FLAG']=='I'){echo "selected";}?>>Inactive</option>
								</select>
							</div> 
						</div>
					</div>
                </div>
				
				<div class="row-fluid">
                    <div class="span5">
                    </div>

                    <div class="span4">

                        <div class="control-group">
                            <label class="control-label" for="form-field-1">&nbsp;</label>

                            <div class="controls">
                                <button class="btn btn-small btn-success" type="button" id="btn_save" onclick="save_equipment_failure()">
                                    <i class="icon-ok bigger-100"></i>
                                    Save
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn btn-small btn-danger" type="reset" id="btn_reset">
                                    <i class="icon-undo bigger-100"></i>
                                    Reset
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
		</form>
<?php } ?>		
</div>

<script>
	$('.date-picker').datepicker().next().on(ace.click_event, function(){
     	$(this).prev().focus();
    });	
</script>