<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/upper_case.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script>    
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>  
<?php
include('../include/session.php');
require_once('../include/tc_calendar.php');

date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$vehicle_id = $_GET['vehicle_id'];

$today = date("Y-m-d");
$record_date = strtotime($today);
$d = date("d", $record_date ) ;
$m = date("m", $record_date ) ;
$y = date("Y", $record_date ) ;

$table_name = $_SESSION['db_prefix']."_vehicle";
$select_query = "SELECT vehicle_id, registration_no, make, model FROM $table_name WHERE disposal_date = '2030-01-01'  ORDER BY registration_no ASC ";
  $arrId = array ();
  $arrName = array ();
  $select_result = execsql($select_query);
  $select_num = mysql_num_rows($select_result);
  $a = 0;
  while ($a < $select_num) {
    $arrId[$a] = mysql_result($select_result, $a, "vehicle_id");
    $arrName[$a] = mysql_result($select_result, $a, "registration_no").' '.mysql_result($select_result, $a, "make").' '.mysql_result($select_result, $a, "model");
    $a++;
  }
  
$table_name = $_SESSION['db_prefix']."_list_transport_admin";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
  $arrId1 = array ();
  $arrName1 = array ();
  $position_result = execsql($position_query);
  if ($position_result!="") {
  $position_num = mysql_num_rows($position_result);
  $b = 0;
  while ($b < $position_num) {
    $arrId1[$b] = mysql_result($position_result, $b, "item_name");
    $arrName1[$b] = mysql_result($position_result, $b, "item_name");
    $b++;
  }
  }  
  
$table_name = $_SESSION['db_prefix']."_list_transport_admin_provider";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
  $arrId2 = array ();
  $arrName2 = array ();
  $position_result = execsql($position_query);
  if ($position_result!="") {
  $position_num = mysql_num_rows($position_result);
  $b = 0;
  while ($b < $position_num) {
    $arrId2[$b] = mysql_result($position_result, $b, "item_name");
    $arrName2[$b] = mysql_result($position_result, $b, "item_name");
    $b++;
  }
  }  
  
  
if ($vehicle_id!='') {
$table_name = $_SESSION['db_prefix']."_vehicle";
$vehicle_query = "SELECT vehicle_id, registration_no, make, model, fuel FROM $table_name WHERE vehicle_id ='".$vehicle_id."' ";
$vehicle_result = mySQL_query($vehicle_query);
$vehicle_num = mysql_num_rows($vehicle_result);  
$vehicle_name = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
$fuel = mysql_result($vehicle_result, 0, "fuel");   
}
else {
  $vehicle_name='';
}
?>
</head>



<?php
include ("../navigation/header.php");
$page_name = "Transport-admin";
include ("../navigation/access.php");
if ($permission_num==1) {
  include ("../navigation/transport_sidebar.php");
?>

<body onload="<?php if ($vehicle_id=='') { ?> document.getElementById('hidden_frame').style.display = 'none'; <?php } else { ?> document.getElementById('hidden_frame').style.display = 'block'; <?php } ?>">


<div class="main_frame"  style="height:auto; min-height:570px;">

<div class="page_head_frame">
        <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><label class="label_page_head">Admin recording</label></td>
            </tr>
        </table>
      </div>
        <br /><br />
        <div class="page_middle_frame">
<div class="page_inside_frame"><form name="form1" id="form1" action="service_rec.php" method="get"> <label class="label_std">Select vehicle:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  <select name="vehicle_select" class="select200" onchange="needToConfirm = false; window.location.href= this.form.vehicle_select.options[this.form.vehicle_select.selectedIndex].value" >
    <option value=""></option>
    <?php
          for ($i = 0; $i < count($arrId); $i++) {
        echo "<option value=admin_rec.php?vehicle_id=".$arrId[$i].">".$arrName[$i]."</option>";
  }
?>
  </select>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</form>
</div>
<div class="hidden_frame" id="hidden_frame">
<form action="admin_rec_save.php" method="GET" name="form2" id="form2">
<div class="page_inside_frame">
  Admin for:&nbsp;&nbsp; 
  <label class="label_caption_green"> <?php echo $vehicle_name; ?></label>
  <br><br>
  <table width="645"  id="table_display">
    <tr>
      <td width="158" height="29">Admin  date: 
        <label class="star">*</label></td>
      <td colspan="3"><?php 
          //instantiate class and set properties
    $myCalendar = new tc_calendar("admin_date", true);
    $myCalendar->setIcon("../images/iconCalendar.gif");
    $myCalendar->setDate($d, $m, $y);
    $myCalendar->setYearInterval(2020, 2099);
    //output the calendar
    $myCalendar->writeScript();
?></td>
      </tr>
    <tr>
      <td height="43">Type: 
        <label class="star">*</label></td>
      <td colspan="3"><p>
          <input type="radio" name="type_group" value="Road license" id="type_group_0" onClick="document.getElementById('type_other_text').disabled=true; document.getElementById('type_other_text').value=''; ">
          Road license
          <input type="radio" name="type_group" value="BA license" id="type_group_1">
          BA license
          <input type="radio" name="type_group" value="Insurance" id="type_group_2">
          Insurance
        <br>
          <input type="radio" name="type_group" value="Other" id="type_group_3" onClick="document.getElementById('type_other_text').disabled=false;">
          Other: 
          <input name="type_other_text" type="text" disabled="disabled" class="text300" id="type_other_text">
<br>
      </p></td>
      </tr>
    <tr>
      <td height="43">Km reading:
        <label class="star">*</label></td>
      <td><input name="km_reading_text" type="text" class="text60" id="km_reading_text" onKeyPress="return numbersonly(this, event)">
        km</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="43">Provider: 
        <label class="star">*</label></td>
      <td><select name="provider_select" class="select200"  id="provider_select" >
        <option value="  " selected> </option>
        <?php
          for ($j = 0; $j < count($arrId2); $j++) {
        echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
  }
?>
      </select></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="43">Admin costs: 
        <label class="star">*</label></td>
      <td width="164">P 
        <input name="admin_cost_text" type="text" class="text60" id="admin_cost_text" onKeyPress="return isNumberKey(event)" onchange=" this.value = this.value.replace (/(\...).*/, '$1')"></td>
      <td width="93">&nbsp;</td>
      <td width="210">&nbsp;</td>
    </tr>
    <tr>
      <td height="43">Expiry date: 
        <label class="star">*</label></td>
      <td colspan="3"><?php 
          //instantiate class and set properties
    $myCalendar = new tc_calendar("expiry_date", true);
    $myCalendar->setIcon("../images/iconCalendar.gif");
    $myCalendar->setDate($d, $m, $y);
    $myCalendar->setYearInterval(2012,2099);
    //output the calendar
    $myCalendar->writeScript();
?></td>
    </tr>
    <tr>
      <td height="43">Document no: 
        <label class="star">*</label></td>
      <td><input name="document_no_text" type="text" class="text100" id="document_no_text" onkeyup="ToUpper(this)"></td>
      <td>Receipt no:</td>
      <td><input name="reference_text" type="text" class="text100" id="reference_text" onKeyUp="ToUpper(this)"></td>
    </tr>
    <tr>
      <td height="43">Notes:</td>
      <td colspan="3"><textarea name="notes_text" cols="50" rows="3" class="text_box" id="notes_text"></textarea></td>
    </tr>
    </table>
  
</div>
<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="vehicle_id_text" id="vehicle_id_text" value="<?php echo $vehicle_id ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onclick="needToConfirm = false; cancel_confirmation(3, '../transport/transport_main.php?date=0');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save &amp; New" onclick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>
</form> 
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form2");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("type_group","selone","- type.");
  /*frmvalidator.addValidation("type_other_text","req","- type other.");*/
  frmvalidator.addValidation("km_reading_text","req","- km reading.");
  frmvalidator.addValidation("provider_select","req","- provider.");
  frmvalidator.addValidation("admin_cost_text","req","- costs.");
  frmvalidator.addValidation("document_no_text","req","- document no.");
  
  
</script>
</div>     
</div>
</div>





<?php } else {
    $_SESSION['denied_return'] = "transport/transport_main.php?date=";  
    include ("../navigation/transport_sidebar.php");?>
  <body onLoad="accessdenied(); return false">  
  </body>
<?php }
?>


<?php include ('../navigation/side_bar.php'); ?>
</body>
</html>