<?php	
       

require_once('../include/tc_calendar.php');
$return_date = strtotime($_SESSION['return_date']);
$d1 = date("d", $return_date ) ;
$m1 = date("m", $return_date ) ;
$y1 = date("Y", $return_date ) ;

$table_name2 = $_SESSION['db_prefix']."_employee_issue";
$employee_query = "SELECT emp_id, store_item_id FROM $table_name2 WHERE emp_id = '".$_SESSION['emp_id']."' AND return_date = '0000-00-00' ";

	$employee_result = execsql($employee_query);
	$employee_num = mysql_num_rows($employee_result);
	$v = 0;
	$arrId1 = array ();
	$arrName1 = array ();
	while ($v < $employee_num) {
		$arrId1[$v] = mysql_result($employee_result, $v, "store_item_id");
		$table_name = $_SESSION['db_prefix']."_store_items";
		$name_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$arrId1[$v]."' ";
		$name_result = mySQL_query($name_query);
		$arrName1[$v] = mysql_result($name_result, 0, "item_name");
		$v++;
	}
   
?>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<link rel="stylesheet" type="text/css" href="../css/main.css" />

<script type="text/javascript">
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>

<body >
<div class="wizard_page_middle_frame">   
<form id="feedbackform" method="get" action="returnFromWizbase.php">
             
            <?php if ($_SESSION['error2']==1) { ?>
            
        <?php 
	 $_SESSION['item_name'] = "";
	   } ?>

   <div class="wizard_frame">         
              <table width="613"  id="table_display_wizard">
                <tr>
                  <td width="175"  valign="middle"><label class="label_std">Date of return:</label>
&nbsp;&nbsp;
<label class="star">*</label></td>
                  <td colspan="2" valign="middle"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("return_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d1, $m1, $y1);
		$myCalendar->setYearInterval(2010, 2020);
		//output the calendar
		$myCalendar->writeScript();
?></td>
                  </tr>
                <tr>
                  <td valign="middle">Select item to return:</td>
                  <td width="202" valign="middle"><select name="item_select" id="item_select" class="select200" >
                    <option selected> </option>
                    <?php
    	for ($j = 0; $j < count($arrId1); $j++) {
		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
		}
     ?>
                  </select></td>
                  <td width="220" valign="bottom"><label class="label_small">(Select from the list. If the list remains empty, there is no item borrowed by this employee.)</label></td>
                  </tr>
                <tr>
                  <td valign="middle">&nbsp;</td>
                  <td valign="middle"><input type="checkbox" name="return_checkbox" id="return_checkbox"> 
                    return to stock</td>
                  <td valign="middle">&nbsp;</td>
                </tr>
              </table>
  </div>          
<div class="wizard_spacer_frame" style="height:170px;"></div>          
            <div class="wizard_frame">
              <table width="645" height="50" align="center" id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_goToURL('parent','returnFromWizbase.php?s=&amp;p=1');return document.MM_returnValue" /></td>
                  <td width="115">&nbsp;</td>
                  <td width="99">
                    <input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                  </td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../hr_module/hr_main.php?date=0');" value="Cancel" /></td>
                  <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; " /></td>
                </tr>
              </table>
    </div>
              
</form>
</div>
<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("item_select","req","Please select an item.");
</script>


	
 </body>