
<?php
require_once ('../include/tc_calendar.php');
$start = strtotime($_SESSION['receive_date']);
$d = date("d", $start );
$m = date("m", $start );
$y = date("Y", $start );

$table_name = $_SESSION['db_prefix']."_receive_store_temp";
$delete_query = "DELETE FROM $table_name WHERE   receive_id > 0  "; 
execsql($delete_query);

$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
$delete2_query = "DELETE FROM $table_name WHERE  receive_id > 0 "; 
execsql($delete2_query);

$table_name = $_SESSION['db_prefix']."_suppliers";
$suppliersQuery = "SELECT supplier_id, account_name FROM $table_name  ORDER BY account_name ASC";
	$suppliersResult = execsql($suppliersQuery);
	$suppliersNum = mysql_num_rows($suppliersResult);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $suppliersNum) {
		$arrId2[$w] = mysql_result($suppliersResult, $w, "supplier_id");
		$arrName2[$w] = mysql_result($suppliersResult, $w, "account_name");
		$w++;
	}
?>


</head>
<?php 
$page_name = "Stores-receive";
include ("../navigation/access.php");

if ($permission_num==1) {
	 
	?>

<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="wizard_page_middle_frame">
<form id="form1" method="get" action="receivingWizbase.php">
  <div class="wizard_frame">
          <label class="label_std" >Supplier:&nbsp;&nbsp;</label>
      <label class="star">*</label>

      <select name="supplier_id_select" id="supplier_id_select" class="select160">
        <option value="<?php echo $_SESSION['supplier_id']?>" ><selected="selected"><?php echo $_SESSION['sup_name']?></option>
            <?php 
    	for ($w = 0; $w < count($arrId2); $w++) {
		echo "<option value=\"".$arrId2[$w] . "\"" . ">" . $arrName2[$w] . "</option>";	
	    }
     ?>
          </select>
          &nbsp;&nbsp;
      Del. note / Invoice:
          
          <label class="star">*&nbsp;&nbsp;</label>
          <input type="text" class="text100" name="del_note_text" id="del_note_text"  value="<?php echo $_SESSION['del_note']?>" onKeyUp="ToUpper(this)"/>
  </div>
        <br />
        <br />
   <div class="wizard_frame">
Purchase order for:
  <label class="star">*</label>
&nbsp;&nbsp;
<input type="radio" name="company_group" value="Manase" id="company_group_0" <?php if ($_SESSION['company']=='Manase') { ?> checked=checked <?php } ?> >
      Manase
   <input type="radio" name="company_group" value="M-works" id="company_group_1" <?php if ($_SESSION['company']=='M-works') { ?> checked=checked <?php } ?> >
      M-works

      <br>
      <br>
      Manase purchase order no:&nbsp;&nbsp;
   <input type="text" class="text100" name="purchase_order_text" id="purchase_order_text"  value="<?php echo $_SESSION['purchase_order']?>" onKeyUp="ToUpper(this)"/>
   </div>  
   <div class="wizard_frame">
   Transport cost:&nbsp;&nbsp;
   <input type="text" class="text100" name="transport_text" id="transport_text"  value="<?php echo $_SESSION['transport']?>" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right"/>
   </div>   
        <div class="wizard_frame">
          <table width="500" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="97">Receive date:</td>
              <td width="403"><?php

		$myCalendar = new tc_calendar("receive_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2030);
		//$myCalendar->dateAllow('2009-02-20', "", false);
		$myCalendar->writeScript();
?></td>
            </tr>
          </table>
        </div>
    <div class="wizard_spacer_frame" style="height:130px;"></div>
        <div class="wizard_frame">
        <table width="590" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115">
              <input name="s" type="hidden" id="s" value="1" />
              <input name="p" type="hidden" id="p" value="1" />
              </td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php');" value="Cancel"  tabindex="-1"/></td>
            <td width="110" align="left"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
          </tr>
        </table>
        </div>
</form>
</div>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("supplier_id_select","req","- select a supplier.");
  frmvalidator.addValidation("company_group","selone","- company.");
  frmvalidator.addValidation("del_note_text","req","- delivery note number.");
</script>

<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php?date=";	?>
	<body onLoad="needToConfirm = false; accessdenied(); return false">
</body>
<?php }
?>

<html>