<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../includes/header_in.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script src="../SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />

<!-- Confirm CSS files -->
<link type='text/css' href='../libraries/dialog/css/confirm.css' rel='stylesheet' media='screen' />

</head>
<body class="a1">
<?php //if ($uacc == "PM-Admin") {?>

<script type="text/javascript">

function ImportWBS(str)

{

	

if (str=="" || str=="3" || str=="-1")

  {

  document.getElementById("import").innerHTML="";

  return;

  } 

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {			

		document.getElementById("import").style.display='';

		document.getElementById("import").innerHTML=xmlhttp.responseText;

		

	}

  }
if (str=="1")

  {
xmlhttp.open("GET","../DB/importPMWBSfield.php",true);
  }
  else
  xmlhttp.open("GET","../DB/importWBSfield.php",true); 
xmlhttp.send();



}

</script>
<span class="a2">
<img src="../images/bulletbox.gif" width="12" height="13" alt="*" /> Create a List of WBS Names </span>

<?php if(!isset($_REQUEST['Edit'])){?>
        
                        
                        
<form action="../DB/UWBSListDB.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

<table width="100%">
  <tr>
    <th width="14%" align="left" class="a1" scope="row">Assign a WBS Code*</th>
    <th width="86%" align="left" scope="row">
      <input name="code" type="text" class="a1" id="code" size="20" required="required"  />
    </th>
    </tr>
  <tr>
    <th align="left" class="a1" scope="row">Choose a WBS Type*</th>
    <th align="left" scope="row"><span id="spryselect1">
      <select name="WBStype" class="a1" id="WBStype" onchange="ImportWBS(this.value)">
        <option value="-1" selected="selected">Select a WBS Type</option>
        <option value="1">Import from PManywhere</option>
        <option value="2">Import from my CSV file</option> 
        <option value="3">New WBS from scratch</option>
        </select>
      <span class="selectInvalidMsg">Please select WBS Type.</span><span class="selectRequiredMsg">Please select WBS Type.</span></span></th>
  </tr>
<tr><th colspan="2"><div id="import">  
  </div></th></tr>
  <tr>
    <th align="left" class="a1" scope="row">Remarks (if any)</th>
    <th align="left" scope="row"><label for="WBSremarks"></label>
      <input name="WBSremarks" type="text" class="a1" id="WBSremarks" size="60" />
      <input type="image" src="../images/icon-save.png" alt="" width="15" height="15" /> <?php if(isset($_REQUEST['msg1'])) echo $_REQUEST['msg1']; ?></th>
    </tr>
  </table>
</form>

<?php } else {
	
	
		$WID = $_REQUEST['Edit'];
   		$result = mysql_query("SELECT WBSList_code, WBSList_remarks FROM wbslist where WBSList_id='$WID'");
   		$row = mysql_fetch_array($result , MYSQL_ASSOC);
		$WBSList_code = $row["WBSList_code"];
		$WBSList_remarks = $row["WBSList_remarks"];
	
	?>


<form action="../DB/UWBSListDB.php?Edit=<?php echo $WID;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">

<table width="100%">
  <tr>
    <th width="14%" align="left" class="a1" scope="row">Assign a WBS Code*</th>
    <th width="86%" align="left" scope="row">
      <input name="code" type="text" class="a1" id="code" size="20" required="required"  value="<?php echo $WBSList_code;?>" />
    </th>
    </tr>
  <tr>
    <th align="left" class="a1" scope="row">Remarks (if any)</th>
    <th align="left" scope="row"><label for="WBSremarks"></label>
      <input name="WBSremarks" type="text" class="a1" id="WBSremarks" size="60"  value="<?php echo $WBSList_remarks;?>"/>
      <input type="image" src="../images/icon-save.png" alt="" width="15" height="15" /> </th>
  </tr>
  </table>
</form>
<?php } ?>
<hr />
<span class="a2"><img src="../images/bulletbox.gif" width="12" height="13" alt="*" /> List of available WBS Names<br />
</span>
<table width="100%" border="0">
  <tr class="a2">
    <th width="8%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Date 
      Created<br />
      (yyyy.mm.dd)
    </th>
    <th width="9%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">WBS<br />
      ID    
    <th width="10%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">WBS<br />
    Type<th width="14%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Import    Filename/ <br />
      Import Filetype   
    <th width="18%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Assigned<br />
      WBS Code
    <th width="28%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">WBS<br />
      Remarks    
    <th width="13%" align="right" valign="top" bgcolor="#E2E2E2" class="a1" scope="col"><span id="yui_3_13_0_1_1384516613597_17667">EDIT/ DEL<br />
       WBS/ ITEMS/ EXPORT</span></tr>
 
<?php
 $resultw = mysql_query("SELECT * FROM wbslist where WBSList_for=1 && WBSList_companyid = '$id'"); 
		while($row = mysql_fetch_array($resultw , MYSQL_ASSOC))
  		{
     ?>   

  <tr>
    <th align="left" valign="top" class="a1" scope="col"><?php echo $row['WBSList_datecreation']; ?></th>
    <th align="left" valign="top" class="a1">WBS - <?php echo $row['WBSList_id']; ?></th>
    <th align="left" valign="top" class="a1"><?php if($row['WBSList_type'] =='2') echo "Imported from CSV-File"; else if($row['WBSList_type'] =='3')  echo "New WBS"; else if($row['WBSList_type'] =='1') echo "Imported from PM-WBS"; ?></th>
    <th align="left" valign="top" class="a1"><?php echo $row['WBSList_file_name']; ?></th>
    <th align="left" valign="top" class="a1" scope="col"><?php echo $row['WBSList_code']; ?></th>
    <th align="left" valign="top" class="a1"><?php echo $row['WBSList_remarks']; ?>&nbsp;</th>
    <th align="right" valign="top" class="a1"><a href="../qsinfo/WBS-Namesg.php?WID=<?php echo $row['WBSList_id']; ?>"></a>
    <a href="WBSlist1.php?Edit=<?php echo $row["WBSList_id"]; ?>"><img src="../images/icon-edit.png" width="15" height="15" border="0" alt="edit" /></a>
    
    <a href="../DB/delwlist.php?del=<?php echo $row["WBSList_id"]; ?>"> <img src="../images/icon-del.png" width="16" height="16" alt="del" border="0" /></a> 
    
    <a href="../qsinfo/ITEM-Namesg.php?WID=<?php echo $row['WBSList_id']; ?>"> </a>
    
    <a href="../qsinfo/WBS-ITEM-G.php?WID=<?php echo $row['WBSList_id']; ?>"><img src="../images/icon-WBS.jpg" alt="view" width="18" height="16" border="0" /></a> 
    
    
    <a id="<?php echo $row["WBSList_id"]; ?>" class='confirm' href="" ><img src="../images/exportfile.jpg" width="15" height="15" border="0" /></a>
    
    </th>
  </tr>
<?php }
//} ?>
</table>
<!-- modal content -->
		<div id='confirm'>
			<div class='header'><span>Confirm</span></div>
			<div class='message'></div>
			<div class='buttons'>
				<div class='no simplemodal-close'>No</div><div class='yes'>Yes</div>
			</div>
		</div>
<!--dialog -->
<script type='text/javascript' src='../libraries/dialog/js/jquery.simplemodal.js'></script>
<script type='text/javascript' src='../libraries/dialog/js/confirm.js'></script>
<script type="text/javascript">
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {invalidValue:"-1"});
</script>
</body>
</html>