<?
include_once('../hdr_general.php');
/* **************************************************************************************************** */
if (!isset($_REQUEST["module"])) $_REQUEST["module"] = "general";
if (!isset($_REQUEST["task"])) $_REQUEST["task"] = "main";
$pubmodule = $_REQUEST["module"];
$pubtask = $_REQUEST["task"];
$pubitemid = $_REQUEST["itemid"];
$pubtrades = $_REQUEST["trades"];
$tradepkeys = "'".str_replace(";","','",$pubtrades)."'";
/* **************************************************************************************************** */
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/<?=$_SESSION['Xcssfile'];?>" type="text/css" media=all>
<title>Purchasing Online (ZIKAY)</title>

<script type="text/javascript">

function trade_tree_select(node) {
  var parentfield = document.getElementById('parent'+node);
  var tradefield = document.getElementById('trade'+node);
  var codefield = document.getElementById('code'+node);
  var descfield = document.getElementById('desc'+node);
  var unitfield = document.getElementById('unit'+node);
  opener.document.forms[0].item_subsubtradepkey.value = tradefield.value;
  //opener.document.forms[0].item_code.value = codefield.value;
  opener.document.forms[0].item_description.value = descfield.value;
  opener.document.forms[0].item_unit.value = unitfield.value;
  self.close();
}

function updateSelect(seedurl) {
}

function cancelSelect() {
  self.close();
}

</script>

</head>
<body leftmargin=5 topmargin=5 style="background: #dddddd;">
<table border=0 cellspacing=0 cellpadding=0 width=578>

<tr valign=top>
<td valign=top width=100%>

  <?
  include_once('../models/tradeModel.php');
  $mytradeModel=new tradeModel;

  $trade_list = $mytradeModel->getlist_tradesbypkeys($tradepkeys);
  ?>

  <table border=1 cellspacing=1 cellpadding=2 width=568 style="border: 1px inset;">

  <tr valign=top>
  <td valign=top width=928 class=listheader style="border-bottom: 1px solid;">
  Select Trade :
  </td>
  </tr>

  <? $catindex=0; ?>
  <? foreach ($trade_list as $mytrade) { ?>

    <tr valign=top>
    <td valign=top width=928 class=newscontent style="border-bottom: 1px solid;">

      <table border=0 cellspacing=0 cellpadding=0 width=558>
      <tr valign=top>
      <td valign=top class=newscontent width=498>
      <input name="parent<?=$mytrade['tradepkey'];?>" type="hidden" value="<?=$mytrade['tradeparentpkey'];?>">
      <input name="trade<?=$mytrade['tradepkey'];?>" type="hidden" value="<?=$mytrade['tradepkey'];?>">
      <input name="code<?=$mytrade['tradepkey'];?>" type="hidden" value="<?=$mytrade['tradecode'];?>">
      <input name="desc<?=$mytrade['tradepkey'];?>" type="hidden" value="<?=$mytrade['tradedescription'];?>">
      <input name="unit<?=$mytrade['tradepkey'];?>" type="hidden" value="<?=$mytrade['tradeunit'];?>">
      <img id="item<?=$mytrade['tradepkey'];?>" src="../gfx/tree/item.png" border=0 width=16 height=16 title="Item" alt="Item" align=left style="display: block;">
      &nbsp;&nbsp;<b><?=$mytrade['tradecode']."</b> - ".$mytrade['tradedescription'];?>&nbsp;&nbsp;
      </td>
      <td valign=top class=newscontent width=60>
      <img src="../gfx/tree/b_select.png" border=0 width=16 height=16 title="Select" alt="Select" style="display: inline; cursor: pointer;" onClick="javascript:trade_tree_select('<?=$mytrade['tradepkey'];?>');">&nbsp;<br>
      </td>
      </tr>
      </table>

    </td>
    </tr>

  <? } ?>

  </table>

</td>
</tr>
</table>

</body>
</html>