<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
$id= $company_id = $_SESSION['id'];
$expand_id=$_REQUEST['interface_plan_id'];
/*include('1-Quality-InspectionPlans2DB.php');*/
include("getname.php");
?>

<html><head><meta charset="utf-8"><title>pmAnywhere - Scope Module</title>
<link href="03-00Scope-Styles0.css" rel="stylesheet" type="text/css" />
    <script src="../includes/js/jquery.min.js"></script>
    <script src="../includes/js/betterinnerhtml.js"></script>
    <script src="../includes/ckeditor_new/ckeditor.js"></script>

    <!--<script src="script-select-addressee.js"></script>-->
    <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("input-phase2").innerHTML = xmlhttp.responseText;
                    loadProjectZones(projectID);
                }

            }

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

            xmlhttp.send();


        }

        function loadProjectZones(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("input-zone2").innerHTML = xmlhttp.responseText;
                }

            }

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

            xmlhttp.send();
        }

        function clientvendor(str,loadField) {

            if (str == "")
            {

                document.getElementById(loadField).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(loadField).style.display = '';
                    //BetterInnerHTML( document.getElementById("cv"), xmlhttp.responseText);

                    document.getElementById(loadField).innerHTML = xmlhttp.responseText;

                }

            }

            xmlhttp.open("GET", "client-vendor.php?q=" + str, true);

            xmlhttp.send();

        }

    </script>

    <script type="text/javascript">
        function loaddwgsuffix(str)
        {
            if (str == "")
            {
                document.getElementById("input-dwg2").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("input-dwg2").style.display = '';
                    BetterInnerHTML(document.getElementById("input-dwg2"), xmlhttp.responseText);
                }
            }
            xmlhttp.open("GET", "load-dwg-suffix.php?q=" + str, true);
            xmlhttp.send();
        }

        function loaddwgsuffixedit(str,str2)
        {
            if (str == "")
            {
                document.getElementById("input-dwg2").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("input-dwg2").style.display = '';
                    BetterInnerHTML(document.getElementById("input-dwg2"), xmlhttp.responseText);
                }
            }
            xmlhttp.open("GET", "load-dwg-suffix.php?q="+str+"&p="+str2, true);
            xmlhttp.send();
        }
    </script>
</head>
	<div><br></div>

<?php if ($uacc == "Full Control" || $uacc == "Consolidate" ) {

$result = mysql_query("SELECT * FROM interfaceinitiate LEFT JOIN projects ON interface_plan_pid=projectSerial LEFT JOIN projectphases ON (interfaceinitiate.interface_stage=projectphases.Phase_id AND Phase_status=1) where interface_plan_id='$expand_id'");
if(mysql_num_rows($result)){
    $rowD = mysql_fetch_array($result);
}
?>

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

<input id="interface_plan_id" name="interface_plan_id" type="hidden" value="<?php echo $row['id']; ?>">
  <fieldset>
<legend align="center">INTERFACE MANAGEMENT PLAN / RESPONSIBILITY MATRIX</legend>
<table name="entryform" align="center" class="table3" width="80%" border="0" cellpadding="0">
    <tr>
      <td align="left" valign="top"><strong>Project 1</strong></td>
      <td align="left" valign="top"><input type="text" name="fixfield2" id="fixfield2" readonly style="background-color:gainsboro" value="<?php echo $rowD['projectCode']; ?> - <?php echo $rowD['projectName']; ?>"></td>
		
      <td align="left" valign="top"><strong>Title</strong></td>
      <td align="left" valign="top"><input type="text"  name="fixfield2" id="fixfield2" readonly style="background-color:gainsboro" value="<?php echo $rowD['interface_title']; ?>"></td>
		
      <td align="left" valign="top"><strong>Stage</strong></td>
      <td align="left" valign="top"><input type="text" name="fixfield4" id="fixfield4" readonly style="background-color:gainsboro" value="<?php echo $rowD['Phase_name'];?>"></td>
    </tr>
</table>
	  
	  
	<?php     $editUrl = null;
    if(isset($_GET['Edit']) && !empty($_GET['Edit'])) {

        $company_id = $_SESSION['id'];
        $result2 = mysql_query("SELECT * FROM interfacedetails where interfacedet_id=".$_GET['Edit']);
        $rowEdit = mysql_fetch_array($result2, MYSQL_ASSOC);

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

      <form align="center" name="entryform" method="post" action="03-InterfacePlan01-details01DB.php<?php echo $editUrl; ?>">
<input id="interface_plan_id" name="interface_plan_id" type="hidden" value="<?php echo $expand_id; ?>">
<br>
<table name="entryform" align="center" class="table3" width="100%" border="0" cellpadding="0">
<tr>
  <td align="left" valign="top">
	  <table name="entryform" align="center" class="table3" width="90%" border="0" cellpadding="0">
    <tr>
        <input type="hidden" name="input-project1" value="<?php echo $rowD['projectSerial']; ?>"  id="input-project1" >

        <td width="14%" valign="bottom">Project 1 Phase<br>
          <select name="input-phase1" autofocus="autofocus"  id="input-phase1" >
            <option value="">Select</option>
              <?php

              $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='".$rowD['projectSerial']."' ORDER BY Phase_name ASC");

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

                      if( $i == $rowEdit['interfacedet_phase1'])
                          echo " <option selected='selected' value='$i'> $n </option>";
                      else
                  echo " <option value='$i'> $n </option>";
              }
              ?>
          </select>
          <br>
        </td>

      <td width="14%" valign="bottom">Project 1 Zone<br>
        <select name="input-zone1"  id="input-zone1" >
          <option value="">Select</option>
            <?php

            $result22 = mysql_query("SELECT  Zone_id,Zone_name FROM projects, projectzones where
                                                                    projects.companySerial = '$id' AND projects.projStatus=1 AND projectzones.Zone_status=1 AND
                                                                     projects.projectSerial=projectzones.project_id AND projectzones.project_id='".$rowD['projectSerial']."'
                                                                      ORDER BY projectzones.Zone_name ASC");

            while ($row22 = mysql_fetch_array($result22, MYSQL_ASSOC)) {
                $i = $row22['Zone_id'];
                $n = $row22['Zone_name'];
                if( $i == $rowEdit['interfacedet_stage1'])
                    echo " <option selected='selected' value='$i'> $n </option>";
                else
                echo " <option value='$i'> $n </option>";
            }

            ?>
        </select>
      </td>

      <td width="14%" valign="bottom">Project 2 Name<br>
        <select name="input-project2"  id="input-project2" onchange="loadProjectPhases(this.value)">
          <option value="">Select</option>
          <?php
                                            $result = mysql_query("SELECT projectSerial,projectCode, projectName FROM projects 
											where companySerial = '$id' AND projStatus=1 ORDER BY projects.projectCode");
                                            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                                $projectSerial = $row['projectSerial'];
												if($rowEdit['interfacedet_proj2']==$projectSerial)
												 echo "<option value='$projectSerial' selected>" . $row["projectCode"] . " - " . $row["projectName"] . "</option>";
												else
                                                echo "<option value='$projectSerial'>" . $row["projectCode"] . " - " . $row["projectName"] . "</option>";
                                            }
                                ?>
        </select>
      </td>

      <td width="14%" valign="bottom">Project 2 Phase<br>
        <select name="input-phase2"  id="input-phase2" >
          <option value="">Select</option>
            <?php
if(!empty($rowEdit['interfacedet_phase2'])){
    $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='".$rowEdit['interfacedet_proj2']."' ORDER BY Phase_name ASC");

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

        if( $i == $rowEdit['interfacedet_phase2'])
            echo " <option selected='selected' value='$i'> $n </option>";
        else
            echo " <option value='$i'> $n </option>";
    }
}

            ?>
        </select>
      </td>

      <td width="14%" valign="bottom">Project 2 Zone<br>
        <select name="input-zone2"  id="input-zone2" >
          <option value="">Select</option>
            <?php
            if(!empty($rowEdit['interfacedet_stage2'])) {
                $result22 = mysql_query("SELECT  Zone_id,Zone_name FROM projects, projectzones where
                                                                    projects.companySerial = '$id' AND projects.projStatus=1 AND projectzones.Zone_status=1 AND
                                                                     projects.projectSerial=projectzones.project_id AND projectzones.project_id='" . $rowEdit['interfacedet_proj2'] . "'
                                                                      ORDER BY Zone_name ASC");

                while ($row22 = mysql_fetch_array($result22, MYSQL_ASSOC)) {
                    $i = $row22['Zone_id'];
                    $n = $row22['Zone_name'];
                    if ($i == $rowEdit['interfacedet_stage2']) {
                        echo " <option selected='selected' value='$i'> $n </option>";
                    } else {
                        echo " <option value='$i'> $n </option>";
                    }
                }
            }
            ?>
        </select>
      </td>
<!-- -----------------------------       -->
      <td width="14%" valign="bottom">Interface Priority<br>
        <select name="input-priority" required="required" id="input-priority">
          <option <?php if($rowEdit['interfacedet_priority'] == 'Very High') echo 'selected'; ?>>Very High</option>
          <option <?php if($rowEdit['interfacedet_priority'] == 'High') echo 'selected'; ?>>High</option>
          <option <?php if($rowEdit['interfacedet_priority'] == 'Medium') echo 'selected'; ?>>Medium</option>
          <option <?php if($rowEdit['interfacedet_priority'] == 'Low') echo 'selected'; ?>>Low</option>
          <option <?php if($rowEdit['interfacedet_priority'] == 'Very Low') echo 'selected'; ?>>Very Low</option>
        </select></td>

      <td width="14%" align="left" valign="top">Interface Discipline*<br>
        <select class="" name="input-dicipline" id="input-dicipline" required style="">
          <option value="">Select</option>
          <?php
                    $result = mysql_query("SELECT discipline_id,discipline_name FROM discipline where discipline_company_id = '$id' AND discipline_status=1 order by discipline_name");
                    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        $discipline = $row['discipline_id'];
                        echo "<option value='$discipline' ".(($rowEdit['interfacedet_discipline'] == $discipline) ? "selected" : "").">" . $row["discipline_name"] . "</option>";
                    }
                    ?>
        </select>
      </td>

      <td width="2%" align="left" valign="top">&nbsp;</td>
    </tr>

    <tr>

      <td width="14%" valign="bottom">Party 1 Type*<br>
        <select id="input-party1" name="input-party1" required onChange="clientvendor(this.value, 'input-party11')" style="">
          <option value="" selected="selected">Select</option>
          <option <?php echo (($rowEdit['interfacedet_party1'] == "Associate") ? "selected" : "")?> value="Associate">Associate</option>
          <option <?php echo (($rowEdit['interfacedet_party1'] == "Client") ? "selected" : "")?> value="Client">Client</option>
          <option <?php echo (($rowEdit['interfacedet_party1'] == "Consultant") ? "selected" : "")?> value="Consultant">Consultant</option>
          <option <?php echo (($rowEdit['interfacedet_party1'] == "Team") ? "selected" : "")?> value="Team">Team</option>
          <option <?php echo (($rowEdit['interfacedet_party1'] == "Vendor") ? "selected" : "")?> value="Vendor">Vendor</option>
          </select>
      </td>

      <td width="14%" valign="bottom">Party 1 Name*<br>
        <select name="input-party11" id="input-party11" required style="width:87%;">
          <option value="">Select</option>
          <?php
              if($rowEdit['interfacedet_party1']){
                  echo getName($rowEdit['interfacedet_party1'],$rowEdit['interfacedet_party11'],1);
              }
              ?>
          </select>
      </td>

      <td width="14%" valign="bottom">Party 2 Type*<br>
        <select id="input-party2" name="input-party2" required onChange="clientvendor(this.value,'input-party22')" style="">
          <option value="" selected="selected">Select</option>
          <option <?php echo (($rowEdit['interfacedet_party2'] == "Associate") ? "selected" : "")?> value="Associate">Associate</option>
          <option <?php echo (($rowEdit['interfacedet_party2'] == "Client") ? "selected" : "")?> value="Client">Client</option>
          <option <?php echo (($rowEdit['interfacedet_party2'] == "Consultant") ? "selected" : "")?> value="Consultant">Consultant</option>
          <option <?php echo (($rowEdit['interfacedet_party2'] == "Team") ? "selected" : "")?> value="Team">Team</option>
          <option <?php echo (($rowEdit['interfacedet_party2'] == "Vendor") ? "selected" : "")?> value="Vendor">Vendor</option>
          </select>
      </td>

      <td width="14%" valign="bottom">Party 2 Name*<br>
        <select name="input-party22" id="input-party22" required style="width:87%;">
          <option value="">Select</option>
          <?php
              if($rowEdit['interfacedet_party2']){
                  echo getName($rowEdit['interfacedet_party2'],$rowEdit['interfacedet_party22'],1);
              }
              ?>
          </select>
      </td>

      <td width="14%" valign="bottom">Party 3 Type<br>
        <select id="input-party3" name="input-party3" onChange="clientvendor(this.value,'input-party33')" style="">
          <option value="" selected="selected">Select</option>
          <option <?php echo (($rowEdit['interfacedet_party3'] == "Associate") ? "selected" : "")?> value="Associate">Associate</option>
          <option <?php echo (($rowEdit['interfacedet_party3'] == "Client") ? "selected" : "")?> value="Client">Client</option>
          <option <?php echo (($rowEdit['interfacedet_party3'] == "Consultant") ? "selected" : "")?> value="Consultant">Consultant</option>
          <option <?php echo (($rowEdit['interfacedet_party3'] == "Team") ? "selected" : "")?> value="Team">Team</option>
          <option <?php echo (($rowEdit['interfacedet_party3'] == "Vendor") ? "selected" : "")?> value="Vendor">Vendor</option>
          </select>
      </td>

      <td width="14%" valign="bottom">Party 3 Name<br>
        <select name="input-party33" id="input-party33" style="width:87%;">
          <option value="">Select</option>
          <?php
              if($rowEdit['interfacedet_party3']){
                  echo getName($rowEdit['interfacedet_party3'],$rowEdit['interfacedet_party33'],1);
              }
              ?>
          </select>
      </td>

      <td width="2%" align="left" valign="top">Interface Location*<br>
        <input name="input-location" value="<?php echo $rowEdit['interfacedet_loc']; ?>" type="text" required="required" id="input-location"></td>
      <td width="2%" align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td valign="bottom" class="table1">Interface Resonsibility*<br>
        <select id="input-resp1" name="input-resp1" required onChange="clientvendor(this.value,'input-resp11')" style="">
          <option value="" selected="selected">Select</option>
          <option <?php echo (($rowEdit['interfacedet_resp1'] == "Associate") ? "selected" : "")?> value="Associate">Associate</option>
          <option <?php echo (($rowEdit['interfacedet_resp1'] == "Client") ? "selected" : "")?> value="Client">Client</option>
          <option <?php echo (($rowEdit['interfacedet_resp1'] == "Consultant") ? "selected" : "")?> value="Consultant">Consultant</option>
          <option <?php echo (($rowEdit['interfacedet_resp1'] == "Team") ? "selected" : "")?> value="Team">Team</option>
          <option <?php echo (($rowEdit['interfacedet_resp1'] == "Vendor") ? "selected" : "")?> value="Vendor">Vendor</option>
        </select>
      </td>

      <td valign="bottom" class="table1">Responsible Contact Name*<br>
        <select name="input-resp11" id="input-resp11" required style="width:87%;">
          <option value="">Select</option>
          <?php
              if($rowEdit['interfacedet_resp1']){
                  echo getName($rowEdit['interfacedet_resp1'],$rowEdit['interfacedet_resp11'],1);
              }
              ?>
        </select>
      </td>

      <td align="left" valign="top">Reference DWG List<br>
        <select  name="input-dwg1" id="input-dwg1" onChange="loaddwgsuffix(this.value)">
          <option value="">Select</option>
          <?php 
				$QDWG = "SELECT dwgList_Title, dwgID FROM scope_dwg WHERE  scope_dwg.dwgProject = '".$rowD['projectSerial']."' AND scope_dwg.dwgCompany = '$id' AND scope_dwg.dwgStatus=1 ORDER BY dwgList_Title";
				$resultdwg = mysql_query($QDWG);
       			while ($rowdwg = mysql_fetch_array($resultdwg, MYSQL_ASSOC)) {
				?>
          <option value="<?php echo $rowdwg['dwgID']; ?>" <?php echo (($rowEdit['interfacedet_dwg1'] == $rowdwg['dwgID']) ? "selected" : "");?>><?php echo $rowdwg['dwgList_Title']; ?></option>
          <?php 
				}			
				?>
        </select>

          <script>
              <?php if(isset($rowEdit['interfacedet_dwg1']))
              {
              ?>
              loaddwgsuffixedit(<?php echo $rowEdit['interfacedet_dwg1']?>, <?php echo $rowEdit['interfacedet_dwg11']?>);
              <?php
              }?>
          </script>
      </td>
      <td align="left" valign="top">Ref DWG No/ Title<br>
        <select  name="input-dwg2" id="input-dwg2">
          <option value="">Select</option>
        </select><br></td>
      <td align="left" valign="top">Interface Size/ Dia<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_size']; ?>" name="input-dia" id="input-dia"></td>
      <td align="left" valign="top">Interface Constraints<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_constr']; ?>"  name="input-constraint" id="input-constraint"></td>
      <td align="left" valign="bottom">Interface Coordinates<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_coord']; ?>"  name="input-coord" id="input-coord"></td>
      <td align="left" valign="bottom">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top">Interface Description*<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_descr']; ?>"  name="input-descr" id="input-descr"></td>
      <td align="left" valign="top">Proposed Action<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_action']; ?>"   name="input-action" id="input-action"></td>
      <td align="left" valign="top">Project Responsibility<br>
        <select name="input-resp2" id="input-resp2" required style="width:87%;">
          <option value="">Select</option>
       <?php
       echo getName('Team',$rowEdit['interfacedet_resp22'],1);
       ?>
        </select><br></td>
      <td align="left" valign="top">Time Description<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_timedesc']; ?>"  name="input-time" id="input-time"></td>
      <td align="left" valign="top">Start Date*<br>
        <input  required type="date"  value="<?php if(!isset($rowEdit)) echo date('Y-m-d'); else echo $rowEdit['interfacedet_start']; ?>" name="input-sdate" id="input-sdate"  ></td>
      <td align="left" valign="top">Cut-Off Date*<br>
        <input  required type="date"  value="<?php if(!isset($rowEdit)) echo date('Y-m-d'); else echo $rowEdit['interfacedet_end']; ?>" name="input-edate" id="input-edate"  ></td>
      <td align="left" valign="bottom">Remarks<br>
        <input type="text" value="<?php echo $rowEdit['interfacedet_remarks']; ?>"  name="input-remarks" id="input-remarks"></td>
      <td align="left" valign="bottom"><button class="button3"> <img src="img/add.png" width="13" height="13" alt=""/></button></td>
    </tr>
    </table></td>
</tr>
</table>
      </form>
  </fieldset>

</div>
</div>
<table width="100%">
  <tbody>
    <tr>
      <td align="right"><a href="03-InterfacePlan01-details01-PV01.php?interface_plan_id=<?php echo $expand_id; ?>"><img src="img/print.png" width="12" height="12" alt=""/></a>&nbsp;&nbsp;<a href="03-InterfacePlan01-initiate01.php"><img src="img/deletecb.png" width="12" height="12" alt=""/></a></td>
    </tr>
  </tbody>
</table>

	        <?php
        $resultData = mysql_query("SELECT * FROM interfacedetails WHERE interfacedet_plan_id='$expand_id' AND interfacedet_status='1'");
            ?>
	
	
<table width="100%" class="table2" align="center" border="0" cellpadding="0">
  <tbody>
<tr bgcolor="#D8D8D8">
  <td colspan="16" align="left" valign="top" bgcolor="#E8E8E8"><strong>ACTIVE INTERFACES</strong></td>
  </tr>
<tr bgcolor="#D8D8D8">
  <td width="3%" align="left" valign="top" bgcolor="#E8E8E8"><strong>S<br>#</strong></td>
  <td width="10%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Description<br>(Constraint)</strong></td>
  <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Project<br>1</strong></td>
  <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Project<br>2</strong></td>
  <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>Discipline</strong></td>
  <td width="8%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>DWG</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>Location</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Priority<br>Level</strong></td>
      <td width="10%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Time/<br>Dates</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Party<br>1</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Party<br>2</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Party<br>3</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>Responsibility</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Overall<br>Responsibility</strong></td>
      <td width="10%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Proposed <br>
      Actions</strong></td>
      <td width="3%" align="center" valign="top" bgcolor="#E8E8E8"><strong>Actions<br>Status</strong></td>
    </tr>
	  
        <?php
        $a=1;
        while ($row2 = mysql_fetch_array($resultData, MYSQL_ASSOC)) {
        ?>
<tr>
  <td valign="top"><?php echo $a;//$row2['interfacedet_id']; ?></td>
<td valign="top"><strong><?php echo $row2['interfacedet_descr']; ?></strong><br><br>(<?php echo $row2['interfacedet_constr']; ?>)</td>
    <td valign="top"><?php
        $result = mysql_query("SELECT projectCode, projectName FROM projects where projectSerial='" . $row2['interfacedet_proj1'] . "'");
        if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            echo $row["projectCode"]/* . " - " . $row["projectName"]*/;
        }
        ?><br>
        <?php
        $result21 = mysql_query("SELECT  Phase_name FROM projectphases where Phase_id='" . $row2['interfacedet_phase1'] . "' ");
        if ($row = mysql_fetch_array($result21, MYSQL_ASSOC)) {
            echo $row['Phase_name'];
        }
        ?><br>
        <?php
        $result22 = mysql_query("SELECT  Zone_name FROM projectzones where   Zone_id='" . $row2['interfacedet_stage1'] . "'");
        if ($row22 = mysql_fetch_array($result22, MYSQL_ASSOC)) {
            echo $row22['Zone_name'];
        }
        ?></td>
<td valign="top">
    <?php
    $result = mysql_query("SELECT projectCode, projectName FROM projects where projectSerial='" . $row2['interfacedet_proj2'] . "'");
    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo $row["projectCode"]/* . " - " . $row["projectName"]*/;
    }
    ?><br>
    <?php
    $result21 = mysql_query("SELECT  Phase_name FROM projectphases where Phase_id='" . $row2['interfacedet_phase2'] . "' ");
    if ($row = mysql_fetch_array($result21, MYSQL_ASSOC)) {
        echo $row['Phase_name'];
    }
    ?><br>
    <?php
    $result22 = mysql_query("SELECT  Zone_name FROM projectzones where   Zone_id='" . $row2['interfacedet_stage2'] . "'");
    if ($row22 = mysql_fetch_array($result22, MYSQL_ASSOC)) {
        echo $row22['Zone_name'];
    }
    ?>
</td>
<td valign="top">
    <?php
    $result = mysql_query("SELECT discipline_name FROM discipline where discipline_id='".$row2['interfacedet_discipline']."'");
    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo  $row["discipline_name"];
    }
    ?>
   </td>
<td valign="top">
    <?php
    $QDWG = "SELECT dwgList_Title, dwg_suffix FROM scope_dwg WHERE dwgID='".$row2['interfacedet_dwg1']."'";
    $resultdwg = mysql_query($QDWG);
    if ($rowdwg = mysql_fetch_array($resultdwg, MYSQL_ASSOC)) {
         echo $rowdwg['dwgList_Title'];
    }
    ?>
<br>
  <?php
  $query = "SELECT id, sheet_no, rev_no, dwg_title, dwg_title2, range_no FROM scope_dwg_revisions WHERE id ='".$row2['interfacedet_dwg11']."'";
  $result = mysql_query($query);
      if($rew = mysql_fetch_object($result)){
          echo $rowdwg['dwg_suffix'] ." - ". $rew->range_no; ?> - <?php echo str_pad($rew->sheet_no, 3, '0', STR_PAD_LEFT) . " - " . str_pad($rew->rev_no, 3, '0', STR_PAD_LEFT); ?> - <?php echo $rew->dwg_title ?> - <?php echo $rew->dwg_title2;
      }
 ?> <br></td>
<td valign="top"><?php echo $row2['interfacedet_loc']; ?></td>
<td valign="top"><?php echo $row2['interfacedet_priority']; ?></td>
<td valign="top"><?php echo $row2['interfacedet_timedesc']; ?><br><br>  
  <?php echo $row2['interfacedet_start']; ?><br><?php echo $row2['interfacedet_end']; ?></td>
<td valign="top"><?php echo $row2['interfacedet_party1']; ?><br><?php echo getName($row2['interfacedet_party1'],$row2['interfacedet_party11']); ?></td>
<td valign="top"><?php echo $row2['interfacedet_party2']; ?><br><?php echo getName($row2['interfacedet_party2'],$row2['interfacedet_party22']); ?></td>
<td valign="top"><?php echo $row2['interfacedet_party3']; ?><br><?php echo getName($row2['interfacedet_party3'],$row2['interfacedet_party33']); ?></td>
<td valign="top"><?php echo $row2['interfacedet_resp1']; ?><br><?php echo getName($row2['interfacedet_resp1'],$row2['interfacedet_resp11']); ?></td>
<td valign="top"><?php //echo $row2['interfacedet_resp2']; ?><?php echo getName('Team',$row2['interfacedet_resp22']); ?></td>
<td valign="top"><?php echo $row2['interfacedet_action']; ?><br></td>
  <td align="center" valign="top">

      <a href="03-InterfacePlan01-details01.php?interface_plan_id=<?php echo $expand_id; ?>&Edit=<?php echo $row2['interfacedet_id']; ?>"><img src="img/edit.png" width="12" height="12" alt=""/></a>&nbsp;&nbsp;
      <a href="03-InterfacePlan01-details01DB.php?interface_plan_id=<?php echo $expand_id; ?>&InActive=<?php echo $row2['interfacedet_id']; ?>"><img src="img/hide.png" width="12" height="12" alt=""/></a></td>
  </tr>
<tr>
  <td colspan="16" valign="top">

      <button id="shownotesdiv" class="button3"  onclick="ReverseDisplay('notesdiv<?php echo $row2['interfacedet_id'];?>')">
          <img src="img/comments.png" width="12" height="12" alt="" title="Provide Comments"/></button>&nbsp;&nbsp;

      <button id="showfilesdiv" class="button3"  onclick="ReverseDisplay('filesdiv<?php echo $row2['interfacedet_id'];?>')" >
          <img src="img/attach4.png" width="12" height="12" alt="" title="Attach Files"/></button>&nbsp;&nbsp;

      <button id="showemaildiv" class="button3"  onclick="ReverseDisplay('emaildiv<?php echo $row2['interfacedet_id'];?>')">
          <img src="img/forward.png" width="12" height="12" alt="" title="Send an Email"/></button>


<!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////-->
      <!-- Email Div -->
      <form id="sendEmail<?php echo $row2['interfacedet_id']; ?>" method="post" action="03-InterfacePlan01-details01DB.php?sendEmail=<?php echo $row2['interfacedet_id']; ?>&interface_plan_id=<?php echo $expand_id; ?>">
          <div id="emaildiv<?php echo $row2['interfacedet_id']; ?>" style="display:none">
              <select name="emailto" id="emailto">
                  <option value="">Select a Team Member's Email Address</option>
                  <option value="0">RR</option>
                  <?php

                  $result = mysql_query("SELECT  internal_personnel.internal_personnel_id, internal_personnel.internal_personnel_email, internal_personnel.internal_personnel_firstName,
internal_personnel_lastName,company.abbreviation FROM internal_personnel,company where internal_personnel.internal_personnel_company_id = '$id' AND
 internal_personnel.internal_personnel_status=1 AND internal_personnel.internal_personnel_company_id=company.serial");

                  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

                      $internal_personnel_id = $row['internal_personnel_id'];

                      echo
                          "<option value=
											'$internal_personnel_id'>" . $row["abbreviation"] . " - 
											" . $row["internal_personnel_firstName"] . " " . $row["internal_personnel_lastName"] . " " . $row["internal_personnel_email"] . "</option>";

                  }

                  ?>
              </select>
              <button id="hideemaildiv" class="button3" onclick="$(this).attr('disabled', true);document.getElementById('sendEmail<?php echo $row2['interfacedet_id']; ?>').submit();">
                  <img src="img/add.png" width="15" height="15" alt="" title="Save"/>
          </div>


      </form>


      <!--Attach File -->
      <form id="attachmentForm<?php echo $row2['interfacedet_id']; ?>" method="post" action="03-InterfacePlan01-details01DB.php?attachFile=<?php echo $row2['interfacedet_id']; ?>&interface_plan_id=<?php echo $expand_id; ?>" enctype="multipart/form-data">
          <div id="filesdiv<?php echo $row2['interfacedet_id']; ?>" style="display:none;">
              <input name="attachment112" type="file" accept=".jpg,.jpeg,.png,.doc,.xls,.xlsx,.pdf,.txt,.xer, .csv, .dwg, .dxf, .ppt, .pptx" />
              <button id="hidefilesdiv" class="button3" onclick="$(this).attr('disabled', true);document.getElementById('attachmentForm<?php echo $row2['interfacedet_id']; ?>').submit();">
                  <img src="img/add.png" width="15" height="15" alt="" title="Save"/>
          </div>
      </form>

      <!--Post Comments -->
      <form id="postcomment<?php echo $row2['interfacedet_id']; ?>" method="post" action="03-InterfacePlan01-details01DB.php?postComment=<?php echo $row2['interfacedet_id']; ?>&interface_plan_id=<?php echo $expand_id; ?>">
          <div id="notesdiv<?php echo $row2['interfacedet_id']; ?>" style="display:none; width:97%;">
              <textarea name="comment<?php echo $row2['interfacedet_id']; ?>" placeholder="Post your comments" class="ckeditor" ></textarea>

              <!--          <input class="ckeditor" type="text" name="comment" placeholder="Type your comments">  -->
              <button id="hidenotesdiv" onclick="$(this).attr('disabled', true);document.getElementById('postcomment<?php echo $row2['interfacedet_id']; ?>').submit();"
                      class="" style="width:  100%; margin-top: 4px;">Submit
                  <!--<img src="img/add.png" onclick="document.getElementById('postcomment<?php /*echo $row2['interfacedet_id']; */?>').submit();"
                        width="15" height="15" alt="" title="Save"/>--></button>
          </div>
      </form>



      <!--	<span STYLE="color: black; font-size: 10pt">   -->
      <?php
      // Show Comments
      $commentQ = "SELECT * FROM interface_comments WHERE tktsid =".$row2['interfacedet_id']." ORDER BY id DESC ";
      $resultComment = mysql_query($commentQ);

      $more = false;
      $moreC = 0;
      while ($rowComment = mysql_fetch_array($resultComment, MYSQL_ASSOC)) {
         /* if(++$moreC > 5 ){
              $more = true;
              break;
          }*/

          echo '<span STYLE="color: black; border-bottom: 1px grey dashed; font-size: 8pt">';
          echo  $rowComment['cdate'].':  '.$rowComment['userName'].'</span> '.'<span class="">'.$rowComment['comment'].'</span>';
          //	echo '</span>';

      }
      //echo $ipusername;
      // if(!$more){

      ?>
      <!--	</span>   -->

      <br>

      <?php
      $moreC = 0;
      $sql_querya="SELECT * FROM interface_attach WHERE tktsid=".$row2['interfacedet_id']. " ORDER BY id DESC";
      $result_seta=mysql_query($sql_querya);
      while($rowa=mysql_fetch_assoc($result_seta))
      {
        /*  if(++$moreC > 5 ){
              $more = true;
              break;
          }*/
          ?>
          <?php echo $rowa["adate"].': '.$rowa['userName'].':  ' ?><a target="_blank" href="attachments/<?php echo $rowa["path"]; ?>" ><?php echo $rowa["path"].'<br>'; ?></a>




      <?php } //} ?>
      <br>
      <div><?php if($more) { ?><a target="_blank" href="03-InterfacePlan01-details01-PV1.php?interface_plan_id=<?php echo $expand_id; ?>&interface_detail_id=<?php echo $row2['interfacedet_id']; ?>">MORE</a>&nbsp;&nbsp;|&nbsp;&nbsp;<?php } ?><a href="#">TOP</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#archiveanchor">ARCHIVES</a></div>

      <!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////-->


 <br>
    <?php echo $row2['interfacedet_creationdate']; ?> :  <?php echo $row2['createdBy']; ?> - <?php echo $row2['interfacedet_remarks']; ?></td>
  </tr>
<?php $a++;} ?>  
  </tbody>
</table>
<p>
  <?php } ?>	
  <br>
  <br>
</p>
<hr>
<p>&nbsp; </p>
<a name="archiveanchor"></a>
<table width="100%" class="table2" align="center" border="0" cellpadding="0">
  <tbody>
    <tr bgcolor="#D8D8D8">
      <td colspan="16" align="left" valign="top" bgcolor="#E8E8E8"><strong>ARCHIVED INTERFACES</strong></td>
    </tr>
    <tr bgcolor="#D8D8D8">
      <td width="3%" align="left" valign="top" bgcolor="#E8E8E8"><strong>S<br>
        #</strong></td>
      <td width="10%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Description<br>
        (Constraint)</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Project<br>
        1</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Project<br>
        2</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>
        Discipline</strong></td>
      <td width="8%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>
        DWG</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>
        Location</strong></td>
      <td width="5%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Priority<br>
        Level</strong></td>
      <td width="10%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Time/<br>
        Dates</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Party<br>
        1</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Party<br>
        2</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Party<br>
        3</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Interface<br>
        Responsibility</strong></td>
      <td width="6%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Overall<br>
        Responsibility</strong></td>
      <td width="10%" align="left" valign="top" bgcolor="#E8E8E8"><strong>Proposed <br>
        Actions</strong></td>
      <td width="3%" align="center" valign="top" bgcolor="#E8E8E8"><strong>Actions<br>
        Status</strong></td>
    </tr>
    <?php
    $a = 1;
    $resultHide = mysql_query("SELECT * FROM interfacedetails WHERE interfacedet_plan_id='$expand_id' AND interfacedet_status='0'");
        while ($row2 = mysql_fetch_array($resultHide, MYSQL_ASSOC)) {
        ?>
            <tr>
                <td valign="top"><?php $a;//echo $row2['interfacedet_id']; ?></td>
                <td valign="top"><strong><?php echo $row2['interfacedet_descr']; ?></strong><br><br>(<?php echo $row2['interfacedet_constr']; ?>)</td>
                <td valign="top"><?php
                    $result = mysql_query("SELECT projectCode, projectName FROM projects where projectSerial='" . $row2['interfacedet_proj1'] . "'");
                    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        echo $row["projectCode"]/* . " - " . $row["projectName"]*/;
                    }
                    ?><br>
                    <?php
                    $result21 = mysql_query("SELECT  Phase_name FROM projectphases where Phase_id='" . $row2['interfacedet_phase1'] . "' ");
                    if ($row = mysql_fetch_array($result21, MYSQL_ASSOC)) {
                        echo $row['Phase_name'];
                    }
                    ?><br>
                    <?php
                    $result22 = mysql_query("SELECT  Zone_name FROM projectzones where   Zone_id='" . $row2['interfacedet_stage1'] . "'");
                    if ($row22 = mysql_fetch_array($result22, MYSQL_ASSOC)) {
                        echo $row22['Zone_name'];
                    }
                    ?></td>
                <td valign="top">
                    <?php
                    $result = mysql_query("SELECT projectCode, projectName FROM projects where projectSerial='" . $row2['interfacedet_proj2'] . "'");
                    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        echo $row["projectCode"]/* . " - " . $row["projectName"]*/;
                    }
                    ?><br>
                    <?php
                    $result21 = mysql_query("SELECT  Phase_name FROM projectphases where Phase_id='" . $row2['interfacedet_phase2'] . "' ");
                    if ($row = mysql_fetch_array($result21, MYSQL_ASSOC)) {
                        echo $row['Phase_name'];
                    }
                    ?><br>
                    <?php
                    $result22 = mysql_query("SELECT  Zone_name FROM projectzones where   Zone_id='" . $row2['interfacedet_stage2'] . "'");
                    if ($row22 = mysql_fetch_array($result22, MYSQL_ASSOC)) {
                        echo $row22['Zone_name'];
                    }
                    ?>
                </td>
                <td valign="top">
                    <?php
                    $result = mysql_query("SELECT discipline_name FROM discipline where discipline_id='".$row2['interfacedet_discipline']."'");
                    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        echo  $row["discipline_name"];
                    }
                    ?>
                </td>
                <td valign="top">
                    <?php
                    $QDWG = "SELECT dwgList_Title, dwg_suffix FROM scope_dwg WHERE dwgID='".$row2['interfacedet_dwg1']."'";
                    $resultdwg = mysql_query($QDWG);
                    if ($rowdwg = mysql_fetch_array($resultdwg, MYSQL_ASSOC)) {
                        echo $rowdwg['dwgList_Title'];
                    }
                    ?>
                    <br>
                    <?php
                    $query = "SELECT id, sheet_no, rev_no, dwg_title, dwg_title2, range_no FROM scope_dwg_revisions WHERE id ='".$row2['interfacedet_dwg11']."'";
                    $result = mysql_query($query);
                    if($rew = mysql_fetch_object($result)){
                        echo $rowdwg['dwg_suffix'] ." - ". $rew->range_no; ?> - <?php echo str_pad($rew->sheet_no, 3, '0', STR_PAD_LEFT) . " - " . str_pad($rew->rev_no, 3, '0', STR_PAD_LEFT); ?> - <?php echo $rew->dwg_title ?> - <?php echo $rew->dwg_title2;
                    }
                    ?> <br></td>
                <td valign="top"><?php echo $row2['interfacedet_loc']; ?></td>
                <td valign="top"><?php echo $row2['interfacedet_priority']; ?></td>
                <td valign="top"><?php echo $row2['interfacedet_timedesc']; ?><br><br>
                    <?php echo $row2['interfacedet_start']; ?><br><?php echo $row2['interfacedet_end']; ?></td>
                <td valign="top"><?php echo $row2['interfacedet_party1']; ?><br><?php echo getName($row2['interfacedet_party1'],$row2['interfacedet_party11']); ?></td>
                <td valign="top"><?php echo $row2['interfacedet_party2']; ?><br><?php echo getName($row2['interfacedet_party2'],$row2['interfacedet_party22']); ?></td>
                <td valign="top"><?php echo $row2['interfacedet_party3']; ?><br><?php echo getName($row2['interfacedet_party3'],$row2['interfacedet_party33']); ?></td>
                <td valign="top"><?php echo $row2['interfacedet_resp1']; ?><br><?php echo getName($row2['interfacedet_resp1'],$row2['interfacedet_resp11']); ?></td>
                <td valign="top"><?php //echo $row2['interfacedet_resp2']; ?><?php echo getName('Team',$row2['interfacedet_resp22']); ?></td>
                <td valign="top"><?php echo $row2['interfacedet_action']; ?><br></td>
                <td align="center" valign="top">
                    <a href="03-InterfacePlan01-details01DB.php?interface_plan_id=<?php echo $expand_id; ?>&Active=<?php echo $row2['interfacedet_id']; ?>"><img src="img/show.png" width="12" height="12" alt=""/></a>&nbsp;&nbsp;
                    <a onclick="return confirm('Are you sure to delete ? Press OK to Delete.');" href="03-InterfacePlan01-details01DB.php?interface_plan_id=<?php echo $expand_id; ?>&del=<?php echo $row2['interfacedet_id']; ?>"><img src="img/delete.png" width="12" height="12" alt=""/></a>&nbsp;&nbsp;
                </td>

            </tr>
            <tr>
                <td colspan="16" valign="top"><img src="img/information.png" width="12" height="12" alt=""/><br>
                    <?php echo $row2['interfacedet_creationdate']; ?> :  <?php echo $row2['createdBy']; ?> - <?php echo $row2['interfacedet_remarks']; ?></td>
            </tr>
    <?php $a++;} ?>
  </tbody>
</table>
<br>
<br>
<p>&nbsp; </p>


</body>
</html>
<script> // to show hide the forms and hidden tables

    $("textarea").each(function(){
        CKEDITOR.replace($(this).attr("name"),
            {
                extraPlugins: 'confighelper',
                width: "100%",
                height:"150px",
                toolbar: [
                    { name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] },	// Defines toolbar group with name (used to create voice label) and items in 3 subgroups.
                    [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo', 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat','NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'Styles', 'Format', 'Table' ],			// Defines toolbar group without name.

                ]
            });
    });

    function ReverseDisplay(d) {
        if(document.getElementById(d).style.display == "none")
        {
            document.getElementById(d).style.display = "block";
        }
        else
        {
            document.getElementById(d).style.display = "none";
        }
    }
</script>
<?php include('../includes/footer.php'); ?>
