<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../../includes/topmenunewest.php');
$id = $company_id = $_SESSION['id'];
?>

<html><head><meta charset="utf-8"><title>pmAnywhere - Monitoring Module</title>
<link href="03-00Scope-Styles0.css" rel="stylesheet" type="text/css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="03-InterfacePlan01-initiate01-JS1.js"></script>
</head>

<style>
.actionTD a{	text-decoration:none; }
</style>
<script>

    function loadProjectPhases(projectID){

        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("interface-stage").innerHTML = xmlhttp.responseText;
            }

        }

        xmlhttp.open("GET", "getProjectPhases1.php?projectID=" + projectID, true);

        xmlhttp.send();


    }

    function sendforinitiate(bid)

    {

        var c = confirm("Are you sure you want to send this document for review? It will show in the list of Initiated Documents");

        if (c)

        {

            window.location.href = "03-InterfacePlan01-initiate01-DB.php?send=" + bid;

        }

        else

        {

            return false;

        }

    }

</script>
<body style="backgrond-color:#E8E8E8">
<div>

    <h5 class="msg">

        <?php if (isset($_REQUEST["msg"])) { ?>

            <?php echo $_REQUEST["msg"]; ?>

        <?php } ?>

    </h5>

</div>
<div style="overflow-x:auto;">
    <?php if ($uacc == "Full Control" || $uacc == "Consolidate" ) {

    $editUrl = null;
    if(isset($_GET['Edit']) && !empty($_GET['Edit'])) {

        $company_id = $_SESSION['id'];
        $result2 = mysql_query("SELECT * FROM interfaceinitiate where interface_plan_id=".$_GET['Edit']);

        $rowEdit = mysql_fetch_array($result2, MYSQL_ASSOC);

        $editUrl = "?Edit=" . $_GET['Edit'];

    }
?>

<div id="formdiv" > <!--div for the form (style="display:none;")-->

<form align="center" action="03-InterfacePlan01-initiate01-DB.php<?php echo $editUrl; ?>"  method="post" style="margin-top:20px">
  <fieldset>
  <legend align="center">
  <button id="hideformdiv" class="button1">&nbsp;&nbsp;&nbsp;INTERFACE MANAGEMENT PLAN&nbsp;&nbsp;&nbsp;</button></legend>

<table name="entryform" align="center" class="table1" width="80%" border="0" cellpadding="0">
    <tr>
      <td width="13%" align="left"><strong>Project <a href="http://pm4.pmanywhere.co/Interface/02-options/02-03Options-01Projects01.php"></a></strong></td>
      <td width="20%" align="left"><select name="interface_projectname"  id="interface_projectname" onchange="loadProjectPhases(this.value)" required >
        
        <option value="">Select</option>
        <?php
                                            $result = mysql_query("SELECT projectSerial,projectCode, projectName FROM projects 
											where companySerial = '$id' AND projStatus=1 ORDER by projectCode");
                                            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                                $projectSerial = $row['projectSerial'];
												if($rowEdit['interface_plan_pid']==$projectSerial)
												 echo "<option value='$projectSerial' selected>" . $row["projectCode"] . " - " . $row["projectName"] . "</option>";
												else
                                                echo "<option value='$projectSerial'>" . $row["projectCode"] . " - " . $row["projectName"] . "</option>";
                                            }
                                ?>
        </select>
        <a href="http://pm4.pmanywhere.co/Interface/02-options/02-03Options-01Projects01.php"><img src="img/Adding.png" width="8" height="8" alt=""/></a></strong></td>
      
      <td align="left"><strong>Stage/ Phase <a href="http://pm4.pmanywhere.co/Interface/02-options/02-03Options-01Projects03.php"></a></strong></td>
      <td align="left"><select name="interface-stage" id="interface-stage">
   <!--     <option <?php /*if(isset($rowEdit)) if ($rowEdit['interface_stage'] == 'Preliminary Studies') echo 'selected'; */?> value="Preliminary Studies">Preliminary Studies</option>
        <option <?php /*if(isset($rowEdit)) if ($rowEdit['interface_stage'] == 'Preliminary Design') echo 'selected'; */?> value="Preliminary Design">Preliminary Design</option>
        <option <?php /*if(isset($rowEdit)) if ($rowEdit['interface_stage'] == 'Detailed Design') echo 'selected'; */?> value="Detailed Design">Detailed Design</option>
        <option <?php /*if(isset($rowEdit)) if ($rowEdit['interface_stage'] == 'Execution') echo 'selected'; */?> value="Execution">Execution</option>
        <option <?php /*if(isset($rowEdit)) if ($rowEdit['interface_stage'] == 'Completion') echo 'selected'; */?> value="Completion">Completion</option>
        <option <?php /*if(isset($rowEdit)) if ($rowEdit['interface_stage'] == 'Operations') echo 'selected'; */?> value="Operations">Operations</option>-->
              <option value="">Select</option>
              <?php
              if (isset($rowEdit)) {
                  $phaseID = $rowEdit['interface_stage'];
                  $proID = $rowEdit['interface_plan_pid'];
                  $result21 = mysql_query("SELECT  Phase_id,Phase_name FROM projects, projectphases where
                                                                    projects.companySerial = '$id' AND projects.projStatus=1 AND projectphases.Phase_status=1 AND
                                                                     projects.projectSerial=projectphases.project_id AND projectphases.project_id='$proID'
                                                                      ORDER BY projects.projectCode ASC");

                  while ($row21 = mysql_fetch_array($result21, MYSQL_ASSOC)) {
                      $i = $row21['Phase_id'];
                      $n = $row21['Phase_name'];

                      if( $i == $phaseID)
                          echo " <option selected='selected' value='$i'> $n </option>";
                      else
                          echo " <option value='$i'> $n </option>";
                  }
              }
              ?>
        </select>
        <strong><a href="http://pm4.pmanywhere.co/Interface/02-options/02-03Options-01Projects03.php"><img src="img/Adding.png" width="8" height="8" alt=""/></a></strong></td>
      <td width="14%" align="left"><strong> Title</strong></td>
      <td width="20%" align="left"><input type="text" name="interface-title" id="interface-title" value="<?php if(isset($rowEdit)) echo $rowEdit['interface_title'];?>">        <button style="vertical-align: bottom" class="button1" title="Save">&#x25ba;</button></td>
      
      
      
    </tr>
    </table>
  </fieldset></form>


  <br></div>
    <?php } else{
        echo '<br>';
    } ?>
</div>


<a name="activeanchor"></a>
<div style="overflow-x:auto;">
<div>
<table align="center" name="tabletitle" class="table1 tableActiveFilter" width="80%" border="0" cellpadding="0">
<tr>
<th>

<div style='float: left; text-align: left'>
<!--<button id="showhiddendiv" class="button1" title="Show Hidden">&#x25bc;</button>-->
<a href="#archiveanchor"><button class="button1" title="View Archived">&#x25bc;</button></a><button id="showformdiv" class="button1" title="Add">&#x25b2;&#x25bc;</button>&nbsp;Active Interface Management Plans</div>

<div style='float: right; text-align: right'>
<select id="findProject" style="width:30%">  	<option value="">Select a Project</option>
    <?php
    $result = mysql_query("SELECT DISTINCT(projectSerial),projectCode, projectName FROM projects JOIN interfaceinitiate ON projectSerial=interface_plan_pid
											where companySerial = '$id' AND projStatus=1 AND (interface_status='1') ORDER BY projectCode");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        ?>

        <option value='<?php  echo $row["projectCode"] . " - " . $row["projectName"];  ?>'> <?php   echo $row["projectCode"] . " - " . $row["projectName"]; ?></option>
        <?php     }     ?>

</select>

<select style="width:30%" id="PagingRows">  	

	<option value="10">Show 10 Rows</option>
      <option value="20"> Show 20 Rows</option>
      <option value="30"> Show 50 Rows</option>
      <option selected value="100"> Show 100 Rows</option>
      <option value="all"> Show All Rows</option>
</select>

<input style="width:30%" type="search" id="SearchMeasure" placeholder="Type to Search">
</div>
</th>
</tr>
</table>
</div>
</div>


<div style="overflow-x:auto;">

<table align="center" class="table2 tableActive"  name="datatable" border="0" width="80%" cellpadding="1">
   <tr>
     <th width="20%" align="left" class="sorting" sorting="projectCode" bgcolor="#AAAAAA">Project<br>
     Name &#x21c5;</th>
     <th width="30%" align="left" class="sorting intData" sorting="hazardID" bgcolor="#AAAAAA">Plan<br>Title&nbsp;&#x21c5;</th>
     <th width="10%" align="left" class="sorting" sorting="TitleRevision" bgcolor="#AAAAAA">Plan<br>Stage</th>
     <th width="10%" align="left" class="sorting" sorting="Date2" bgcolor="#AAAAAA">Initiated<br>By</th>
     <th width="15%" align="left" class="sorting" sorting="Date22" bgcolor="#AAAAAA">Sent<br />Status&nbsp;&nbsp;&#x21c5;</th>
     <th width="15%" align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
  </tr>

   <?php
	  $company_id = $_SESSION['id'];
	  $result2 = mysql_query("SELECT * FROM interfaceinitiate where companyID = '$company_id'  AND (interface_status= '1') ORDER BY interface_plan_id DESC");
	  while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
		  $project = mysql_query("SELECT projectCode, projectName FROM projects where projectSerial = ".$row2['interface_plan_pid']." AND projStatus=1");
		  $row3 = mysql_fetch_array($project, MYSQL_ASSOC);
		  ?>

   <tr class="tableData" trid="<?php echo $row2['interface_plan_id']; ?>">
      <td align="left" class="tdData projectCode"><?php echo $row3["projectCode"] . " - " . $row3["projectName"]; ?></td>
      <td align="left" class="tdData hazardID"><?php echo $row2['interface_title']; ?></td>
      <td align="left" class="tdData TitleRevision">&nbsp;<?php //echo $row2['interface_stage'];
          $result21 = mysql_query("SELECT  Phase_id,Phase_name FROM projectphases where projectphases.Phase_status=1 and projectphases.Phase_id='".$row2['interface_stage']."'");
          if ($row21 = mysql_fetch_array($result21, MYSQL_ASSOC)) {
              echo $n = $row21['Phase_name'];
          }

      ?></td>
      <td align="left" class="tdData Date2"><?php echo $row2['interface_createdby']; ?></td>
      <td align="left" class="tdData Date22"><?php if($row2["review_status"]==3){?>Sent for Review<?php } else if($row2["review_status"]==1) {?>Not Sent for Review<?php }?></td>
      <td align="center" class="table2 sortable actionTD">
		 <!-- <button id="addformdiv" class="button3"> <img src="img/add.png" width="13" height="13" alt="" title="Add"/></button>  -->


          <?php if( $row2['review_status'] == 3 ){
              ?>
		  <a href="javascript:void(0)"><img src="../05-monitor/img/edit.png" width="13" height="13" alt="" title="Edit"/></a>
		  &nbsp;&nbsp;&nbsp;
              <?php
          } else{
              ?>
             <a href="03-InterfacePlan01-initiate01.php?Edit=<?php echo $row2['interface_plan_id']; ?>"><img src="../05-monitor/img/edit.png" width="13" height="13" alt="" title="Edit"/></a> &nbsp;&nbsp;&nbsp;

        <?php   } ?>


<?php if( $row2['review_status'] == 3 ){
    ?>         <a href="javascript:void(0);">
		  <img src="../05-monitor/img/send.png" width="13" height="14" alt="" title="Sent and Locked"/>
		  </a> &nbsp;&nbsp;&nbsp;
    <?php
} else{
    ?>
  <a onclick="sendforinitiate('<?php echo $row2['interface_plan_id']; ?>')" href="javascript:void(0);">
	 <img src="img/send_black.png" width="13" height="14" alt="" title="Send for Assignments"/></a>&nbsp;&nbsp;&nbsp;

    <?php } ?>

        <a href="03-InterfacePlan01-details01.php?interface_plan_id=<?php echo $row2['interface_plan_id'] ?>"> <img src="../05-monitor/img/expand.png" width="13" height="13" alt="" title="Expand"/></a>&nbsp;&nbsp;&nbsp;
          <?php if( $row2['review_status'] == 3 ){ ?>
              <a href="javascript:void(0);">
                  <img src="../05-monitor/img/hide.png" width="13" height="13" alt="" title="Archive"/></a>
    <?php
} else{
          ?>
              <a href="03-InterfacePlan01-initiate01-DB.php?InActive=<?php echo $row2['interface_plan_id']; ?>">
                  <img src="../05-monitor/img/hide.png" width="13" height="13" alt="" title="Archive"/></a>
          <?php } ?>
</td>
   </tr>

    <tr class="trid<?php echo $row2['interface_plan_id']; ?>">
      <td colspan="6" align="left"><em><img src="../05-monitor/img/information.png" width="12" height="12" alt=""/></em></td>
    </tr>

    <?php } ?>
</table>
</div>

<table width="80%" class="table1 ActiveTablePaging" align="center" border="0" cellpadding="1">
  <tbody>
    <tr>
      <td align="right" > 
      <span class="pagingInfo"></span>
        &nbsp;
        <button class="button2 BtnPrev" title="Previous Page">&#9668;</button>
        &nbsp;
        <button class="button2 BtnNext" title="Next Page">&#x25ba;</button>
       <div id="pagination"></div>
        </td>
    </tr>
  </tbody>
</table>

<!-- HIDDEN TABLE-->
<br>
<hr class="hrstyle1">
<a name="archiveanchor"></a>
<br>

<div style="overflow-x:auto;">
<div id="hiddendiv" > <!--- style="display:none" ------>
<table align="center" name="tabletitle" class="table1 tableInActiveFilter" width="80%" border="0" cellpadding="1">
<tr>
<th>
<div style='float: left; text-align: left'>

<!--<button id="hidehiddendiv" class="button1" title="Hide">&#x25b2;</button>-->
 <button id="hidehiddendiv" class="button1" title="Hide">&nbsp;&nbsp;&nbsp;</button><a href="#activeanchor"><button class="button1" title="Show Active">&#x25b2;</button></a>&nbsp;Archived Interface Management Plans</div>

<div style='float: right; text-align: right'>
<select id="findProjectHide" style="width:30%">  	<option value="">Select a Project</option>
    <?php
    $result = mysql_query("SELECT DISTINCT(projectSerial),projectCode, projectName FROM projects JOIN interfaceinitiate ON projectSerial=interface_plan_pid
											where companySerial = '$id' AND projStatus=1 AND interface_status='0' ORDER BY projectCode");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        ?>
        <option value='<?php  echo $row["projectCode"] . " - " . $row["projectName"];  ?>'> <?php   echo $row["projectCode"] . " - " . $row["projectName"]; ?></option>

	<?php     }    ?>

</select>
 <select style="width:30%" id="PagingRows">
    <option value="10">Show 10 Rows</option>
    <option value="20"> Show 20 Rows</option>
    <option value="30"> Show 50 Rows</option>
    <option selected value="100"> Show 100 Rows</option>
    <option value="all"> Show All Rows</option>
  </select>

<input style="width:30%" type="search" id="SearchMeasureHide" placeholder="Type to Search">
</div>
</th>
</tr>
</table>


<table align="center" class="table2 tableInActive" name="datatable" border="0" width="80%" cellpadding="1">
    <tr>
      <th width="20%" align="left" class="sorting" sorting="projectCode" bgcolor="#AAAAAA">Project<br>
      Name&nbsp;&#x21c5;</th>
     <th width="30%" align="left" class="sorting intData" sorting="hazardID" bgcolor="#AAAAAA">Plan<br>Title&nbsp;&#x21c5;</th>
     <th width="10%" align="left" class="sorting" sorting="TitleRevision" bgcolor="#AAAAAA">Plan<br>Stage</th>
     <th width="10%" align="left" class="sorting" sorting="Date2" bgcolor="#AAAAAA">Initiated<br>By</th>
     <th width="15%" align="left" class="sorting" sorting="Date22" bgcolor="#AAAAAA">Sent<br />Status&nbsp;&nbsp;&#x21c5;</th>
     <th width="15%" align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
    </tr>

    <?php
    $company_id = $_SESSION['id'];
    $result2 = mysql_query("SELECT * FROM interfaceinitiate where companyID = '$company_id'  AND interface_status= '0' ORDER  BY  interface_plan_id DESC");
    while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
        $project = mysql_query("SELECT projectCode, projectName FROM projects where projectSerial = ".$row2['interface_plan_pid']." AND projStatus=1");
        $row3 = mysql_fetch_array($project, MYSQL_ASSOC);
        ?>


        <tr class="tableDataHide" trid="<?php echo $row2['interface_plan_id']; ?>">
            <td align="left" class="tdDataHide projectCode"><?php echo $row3["projectCode"] . " - " . $row3["projectName"]; ?></td>
           <td align="left" class="tdDataHide hazardID"><?php echo $row2['interface_title']; ?></td>
            <td align="left" class="tdDataHide DateLoction">&nbsp;<?php //echo $row2['interface_stage'];
                $result21 = mysql_query("SELECT  Phase_id,Phase_name FROM projectphases where projectphases.Phase_status=1 and projectphases.Phase_id='".$row2['interface_stage']."'");
                if ($row21 = mysql_fetch_array($result21, MYSQL_ASSOC)) {
                    echo $n = $row21['Phase_name'];
                }
                 ?></td>
            <td align="left" class="tdDataHide Date2"><?php echo $row2['interface_createdby']; ?></td>
            <td align="left" class="tdDataHide Date22"><?php if($row2["review_status"]==3){?>Sent for Review<?php } else if($row2["review_status"]==1) {?>Not Sent for Review<?php }?></td>
            <td width="9%" align="center"><a href="03-InterfacePlan01-initiate01-DB.php?Active=<?php echo $row2['interface_plan_id']; ?>"><img src="img/show.png" width="13" height="13" alt="" title="Unhide"/></a>&nbsp;&nbsp;&nbsp;

                <a href="03-InterfacePlan01-initiate01-DB.php?del=<?php echo$row2['interface_plan_id']; ?>" onClick="return confirm('Are you sure to delete? Press OK to Delete.')">
                    <img src="img/delete.png" width="13" height="13" alt="" title="Delete" />
                </a>
			</td>
    </tr>

    <tr class="trid<?php echo $row2['interface_plan_id']; ?>">
      <td colspan="6" align="left"> <!-- I fixed this  -->
        <em>
       <!--   <div id="div2"></div>        <br> --><img src="../05-monitor/img/information.png" width="12" height="12" alt=""/></em></td>
    </tr>

    <?php }?>
    </table>

   <table width="80%" class="table1 InActiveTablePaging" align="center" border="0" cellpadding="1">
      <tbody>
        <tr>
          <td align="right" > <span class="pagingInfo"></span>
            &nbsp;
            <button class="button2 BtnPrev" title="Previous Page">&#9668;</button>
            &nbsp;
            <button class="button2 BtnNext" title="Next Page">&#x25ba;</button></td>
        </tr>
      </tbody>
    </table>
</div>
</div>
<br>
<br>
</body>
</html>


<SCRIPT> // to show hide the forms and hidden tables
$(document).ready(function(){
    $("#hideformdiv").click(function(){
        $("#formdiv").toggle();
    });
	$("#showformdiv").click(function(){
        $("#formdiv").toggle();
    });
	$("#addformdiv").click(function(){
        $("#formdiv").toggle();
    });
	$("#showhiddendiv").click(function(){
        $("#hiddendiv").toggle();
    });
	$("#hidehiddendiv").click(function(){
        $("#hiddendiv").toggle();
    })
	$("#shownotesdiv").click(function(){
        $("#notesdiv").toggle();
    })
	$("#showremsdiv").click(function(){
        $("#remsdiv").toggle();
    })
	$("#showfilesdiv").click(function(){
        $("#filesdiv").toggle();
    })
});	
</SCRIPT>

<?php include('../includes/footer.php'); ?>