<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
/*include('../includes/header_in.php');*/
/*include('../includes/topmenuin.php');*/

$WID = $_REQUEST['WID'];
?>

<html><head><meta charset="utf-8"><title>pmAnywhere - WBS</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href="../includes/css/bootstrap.min.css" rel="stylesheet">
<script src="../includes/js/bootstrap.min.js" type="text/javascript"></script>

<!--<link href="03-00Scope-Styles0.css" rel="stylesheet" type="text/css" />-->
<link href="03-00Scope-Styles1forWBS.css" rel="stylesheet" type="text/css" />

<script src="03-04Scope-02WBS01.js" type="text/javascript"></script>
<script src="../includes/js/betterinnerhtml.js"></script>
<style>

.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid #3498db;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 2s linear infinite;
}

@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ignore-css{all:unset; cursor:pointer}

#formdiv {
  position: absolute;
  top: 0;
  text-align:center;
  width:99%;
  background-color:#FFFFFF;
}

#formdiv.fixed {
  position: fixed;
  top: 0;
  text-align:center;

}
</style>



<script language="javascript">

$(document).ready(function() {
    var frm = $('#formwbs');
	//var PNode = document.getElementById('PNode').value;

    frm.submit(function (ev) {
        $.ajax({
            type: frm.attr('method'),
            url: frm.attr('action'),
            data: frm.serialize(),
			//dataType:"html",
            success: function (data) {

			document.getElementById("loadWBStable").innerHTML = data;
			 $('#loader').hide();
			 var e = document.getElementById("PNodeIP");
				var value = e.options[e.selectedIndex].value;
				if(value=="")
				value=0;
			 LoadWlist(<?php echo $WID ; ?>,value);
			 document.getElementById('description').value = "";
			 /*alert(value);
			 document.getElementById('PNodeIP').value = value;
			 */
             //frm.trigger("reset");
	            }

        });

        ev.preventDefault();
    });
	  });


 </script>
</head>
<body style="display: block !important; margin: 8px !important;">
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog" id="loadForm">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title" id="loadFormHeading">Loading</h4>
      </div>
      <div align="center" class="modal-body loader">
        <p align="center">Loading...</p>
      </div>
    </div>

  </div>
</div>

<div><br><br><br><br><br><br><br><br><br></div>

	<div id="formdiv" class="fixed" align="center">
    <?php
$resultWBSname = mysql_query("SELECT WBSList_code, WBSList_title FROM wbslist where WBSList_id='$WID'");
$rowWBSname = mysql_fetch_array($resultWBSname, MYSQL_ASSOC);
?>
<br>
 &nbsp;
<!--/////////////////////////////////////////Add WBS form ///////////////////////////////-->
	<form style="margin-bottom: 0px !important;"  id="formwbs" name="formwbs" method="post" action="../../DB/03-scope/GWBSDB-G-simple.php?WID=<?php echo $WID . $var ?>">
        <fieldset>
            <legend style="width: auto !important;" align="center"><?php echo $rowWBSname['WBSList_title']; ?> (<?php echo $rowWBSname['WBSList_code']; ?>)</legend>
    <table name="entryform" align="center" class="table3" width="80%" border="0" cellpadding="0">
    <tr>
      <td width="20%" align="left" valign="top"><strong>Hierarchy/ Codes</strong></td>
      <td width="80%" align="left" valign="middle">
      <select class="" name="PNode" id="PNodeIP">
        <?php
        $result = mysql_query("SELECT * FROM globalwbs where companyID = '$id' && gwbslist_id='$WID' ORDER BY WBSIDA ASC,WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
		echo "<option value=''>Select an element to create hierarchy</option>";
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $WBSIDA = $row["WBSIDA"];
            $WBSIDB = $row["WBSIDB"];
            $WBSIDC = $row["WBSIDC"];
            $WBSIDD = $row["WBSIDD"];
            $WBSIDE = $row["WBSIDE"];
            $WBSID = $row["WBSID"];
            $WBSdes = $row["description"];

            if ($WBSIDE == 0)
                echo "<option value='$WBSID'>" . $WBSIDA . "." . $WBSIDB . "." . $WBSIDC . "." . $WBSIDD . "." . $WBSIDE . " - " . $WBSdes . "</option>";
        	}
        ?>
            </select>
            </td>
          </tr>
          <tr>
      		<td align="left" valign="top"><strong>Description</strong></td>
      		<td align="left" valign="middle"><input name="description" type="text" autofocus required id="description">
            <BUTTON class="button3" name="submit" value="submit" type="submit"><img src="img/add.png" width="16" height="16" alt=""/></BUTTON>
            <a href="03-04Scope-01WBS01.php"><img src="img/cancel.png" width="16" height="16" alt=""/></a></td>

    	</tr>
        </table>
        </fieldset>
	</form>
<!--////////////////////////////////////////Add wbs form End /////////////////////////-->
<br><br>
<table class="table5" style="border-collapse:separate !important; border-spacing:2 !important" width="100%" border="0" cellpadding="1">
  <tbody>
    <tr class="subTitleBG">
        <td valign="middle" width="5%"><strong>#</strong></td>
      <td valign="middle" width="4%"><strong>TYPE</strong></td>
      <td valign="middle" width="6%"><strong>HIERARCHY</strong></td>
      <td valign="middle" width="40%"><strong>DESCRIPTION</strong></td>
      <td valign="middle" width="10%" align="right"><strong>ACTIONS</strong></td>
      <td valign="middle" width="5%">&nbsp;</td>
    </tr>
  </tbody>
</table>
</div>

<div id="loadWBStable">
<?php include ("../../DB/03-scope/loadWBStable-simple.php");?>
</div>
 <script>  function showloader(){

        $("#loader").attr("src", '../images/loader.gif');
    }</script></body>
</html>
