<?
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"];
$pubsubcons = $_REQUEST["subcons"];
$selected=explode(";",$pubsubcons);
/* **************************************************************************************************** */
?>
<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 acceptSelect() {
  var subcons="";
  var subpkeys="";
  var j=0;
  for (i=1;i<=5000;i++) {
    var subcheck=document.getElementById('check'+i);
    var subname=document.getElementById('sname'+i);
    if (subcheck!=null) {
      if (subcheck.checked) {
        j++;
        subpkeys=subpkeys+";"+subcheck.value;
        subcons=subcons+j+". "+subname.value+"\r\n";
      }
    }
  }
  subpkeys=subpkeys.substr(1);
  subcons="Debit to:\r\n"+subcons;
  opener.document.mroform.mro_subcons.value = subpkeys;
  opener.document.mroform.mro_remarks.value = subcons;
  self.close();
}

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

</script>

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

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

  <?
  include_once('../models/subconModel.php');
  $mysubconModel=new subconModel;

  $subcon_list = $mysubconModel->getlist_subcons();
  ?>

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

  <tr valign=top>
  <td valign=top width=48 class=listheader>No.</td>
  <td valign=top width=280 class=listheader>Sub-contractor Name</td>
  <td valign=top width=280 class=listheader>Contact Person</td>
  <td valign=top width=120 class=listheader>Contact No</td>
  <td valign=top width=120 class=listheader>Mobile No</td>
  <td valign=top width=80 class=listheader>Select</td>
  </tr>

  <? foreach ($subcon_list as $mysubcon) { ?>

    <?
    $mychecked="";
    $mycolor="#ffffff";
    foreach ($selected as $mysel) {
      if ($mysubcon['subconmasterpkey']==$mysel) {
        $mychecked="checked";
        $mycolor="#80ffff";
      }
    }
    ?>

    <tr valign=top style="background: $dddddd;">
    <td valign=top width=48 class=listnumber style="background: <?=$mycolor;?>"><?=$mysubcon['recordno'];?></td>
    <td valign=top width=280 class=listcontent style="background: <?=$mycolor;?>"><?=$mysubcon['subconname'];?></td>
    <td valign=top width=280 class=listcontent style="background: <?=$mycolor;?>"><?=$mysubcon['subconpic'];?>&nbsp;</td>
    <td valign=top width=120 class=listcontent style="background: <?=$mycolor;?>"><?=$mysubcon['subconphone1'];?>&nbsp;</td>
    <td valign=top width=120 class=listcontent style="background: <?=$mycolor;?>"><?=$mysubcon['subconpicmobile'];?>&nbsp;</td>
    <td valign=top width=80 class=listcontent style="background: <?=$mycolor;?>">
    <input name="check<?=$mysubcon['recordno'];?>" id="check<?=$mysubcon['recordno'];?>" type="checkbox" value="<?=$mysubcon['subconmasterpkey'];?>" <?=$mychecked;?>>
    <input name="sname<?=$mysubcon['recordno'];?>" id="sname<?=$mysubcon['recordno'];?>" type="hidden" value="<?=$mysubcon['subconname'];?>">
    </td>
    </tr>

  <? } ?>

  </table>

  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=928>
  <tr valign=top>
  <td valign=top width=460 class=listcontent>
  <button name="update" id="update" onClick="acceptSelect();">Accept Selections</button>&nbsp;
  <button name="cancel" id="cancel" onClick="cancelSelect();">Cancel</button>
  </td>
  </tr>
  </table>

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

</body>
</html>