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

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

<?php
$BID =isset($_GET['BID'])?$_GET['BID']:0;
$cid  = $_SESSION['id'];
$scope ='specs-brief';


$result = mysql_query("SELECT specs_scope.*,projects.*,client.* FROM projects,client,specs_scope where specs_scope.companyID='$id' AND specs_scope.SPECID='$BID' AND specs_scope.spec_status='1' AND projects.projectSerial=specs_scope.spec_project AND client.clientSerial=specs_scope.spec_client ");
$row = mysql_fetch_array($result , MYSQL_ASSOC);
$PreparedBy = "";
if($row["spec_preparedby"]==$row["companyID"]){
$resultPre = mysql_query("SELECT firstName, lastName FROM login where loginId='".$row["spec_preparedby"]."'");
$PreparedBy .= mysql_result($resultPre,0,0);
$PreparedBy .=" ". mysql_result($resultPre,0,1);
}
else{
$resultPre = mysql_query("SELECT internal_personnel_firstName, internal_personnel_lastName FROM internal_personnel where internal_personnel_id='".$row["spec_preparedby"]."'");
$PreparedBy .= mysql_result($resultPre,0,0);
$PreparedBy .=" ". mysql_result($resultPre,0,1);
}

?>

<div style="overflow-x:auto;">
<div id="formdiv" style="margin-top:20px" >
 
     <fieldset>
        <legend align="center">SPECIFICATIONS PACKAGE</legend>
        <table name="entryform" align="center" class="table1" width="80%" border="0" cellpadding="0"  >
            <tr>
                <td width="10%" align="left" valign="top"><strong>Project</strong>:</td>
                <td width="23%" align="left" valign="top"><?php echo $row["projectCode"]; ?> - <?php echo $row["projectName"]; ?></td>
                <td  width="10%" align="left" valign="top"><strong>Client</strong>:</td>
                <td  width="24%" align="left" valign="top"><?php echo $row["clientCode"]; ?> - <?php echo $row["clientName"]; ?> </td>
                <td width="10%" align="left" valign="top"><strong>Consultant</strong></td>
                <td width="23%" align="left" valign="top">
                <?php $resultC = mysql_query("SELECT * FROM consultants WHERE conSerial = '".$row['spec_consultant']."'");
					  $consaltant = mysql_fetch_array($resultC, MYSQL_ASSOC);
					  echo $consaltant["conCode"]." - ".$consaltant['conName']."";
				?>
                </td>
            </tr>
            <tr>
              <td align="left" valign="top"><strong>GWBS/ Title</strong></td>
              <td align="left" valign="top"><?php
                    $GWBSID = $row['WBSID'];
                    $resultw = mysql_query("SELECT wbslist.WBSList_code, WBSList_title FROM wbslist where WBSList_id = '$GWBSID' and WBSList_companyid = '$id' and wbslist.WBSList_status=1");// order by WBSList_code, description");


                    if( $row2 = mysql_fetch_array($resultw, MYSQL_ASSOC))
                        echo $row2['WBSList_code']. "-". $row2['WBSList_title'];
                    ?></td>
              <td align="left" valign="top"><strong>Package Title</strong></td>
              <td align="left" valign="top"><?php echo $row["title"]; ?></td>
              <td align="left" valign="top"><strong>Created</strong></td>
              <td align="left" valign="top"><?php echo $PreparedBy;?>/ <?php echo $row['dateCreated']; ?></td>
            </tr>
        </table>
    </fieldset>
</div>
	
	
<table width="100%" align="center">
	  <tbody>
	    <tr>
	       <td align="right">
		<a href="03-05Scope-01Specifications03-DetailsPVall.php?sid=<?php echo $BID; ?>"><img src="img/printall.png" width="13" height="12" alt=""/></a>&nbsp;<a href="03-05Scope-01Specifications01.php"><img src="img/deletecb.png" width="12" height="12" alt=""/></a></td>
        </tr>
      </tbody>
  </table>
	
	

<table width="90%" border="0" cellpadding="0" class="table5" align="center">
      <tbody>
        <tr CLASS="subTitleBG">
          <td><SPAN CLASS="subTitleBG">#</SPAN></td>
          <td><SPAN CLASS="subTitleBG">Code</SPAN></td>
          <td><SPAN CLASS="subTitleBG">DESCRIPTION OF GWBS/ MWBS/ WBS/ ITEMS/ SITEMS</SPAN></td>
          <td><SPAN CLASS="subTitleBG">STATUS</SPAN></td>
          <td align="right"><SPAN CLASS="subTitleBG">ACTIONS</SPAN></td>
        </tr>
        
        <?php
		$number = 1;
		$WID=isset($GWBSID)?$GWBSID:0;
			  
			  $result1 = mysql_query("SELECT * FROM globalwbs where gwbslist_id ='$WID' && companyID = '$id'  ORDER BY WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
		while($row1 = mysql_fetch_array($result1 , MYSQL_ASSOC))
  		{
  		
			$WBSIDA = $row1["WBSIDA"];
	  		$WBSIDB = $row1["WBSIDB"];
	  		$WBSIDC = $row1["WBSIDC"];
	  		$WBSIDD = $row1["WBSIDD"];
	  		$WBSIDE = $row1["WBSIDE"];
			$WBSID1 = $row1["WBSID"];
			$parent = $row1["parent"];
			
?>
        <tr class="<?php echo (($row1["sortCode"] == "WBS") ? "bold_row_2" : "bold_row_1" ); ?>">
          <td><?php echo $number;?></td>
          <td><?php echo $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE; ?></td>
          <td><?php echo $row1["sortCode"]; ?> - <?php echo $row1["description"]; ?></td>
          <td>
			<?php
                $status = false;
                $resultchkstatus = mysql_query("SELECT * FROM specs_scope_brief_description where pack_id = '$WBSID1'");
                if(mysql_num_rows($resultchkstatus) > 0){
                    $status = true;
                }else{
                    $resultchkstatus = mysql_query("SELECT * FROM specs_scope_brief where pack_id = '$WBSID1'");
                    if(mysql_num_rows($resultchkstatus) > 0){
                        $status = true;
                    }
                }
                echo (($status) ? "Started" : "");
            ?>	
          </td>
          <td align="right"><a href="03-05Scope-01Specifications03-Details.php?sid=<?php echo $BID; ?>&WID=<?php echo $WBSID1; ?>"><img src="img/expand.png" width="16" height="15" alt=""/></a> <a href="03-05Scope-01Specifications03-DetailsPV.php?sid=<?php echo $BID; ?>&WID=<?php echo $WBSID1; ?>"><img src="img/print.png" width="15" height="15" alt=""/></a></td>
        </tr>
        
        
          <!--    ///////////////////////// WBS END Item Start ///////////////////////////////-->
		 <?php 
         $queryItem="SELECT * FROM globalitems where WBSID = '$WBSID1' && itemParent = '0' ORDER BY itemID ASC";
         $resultItem = mysql_query($queryItem);
		$number2=0;
   		while($rowItem = mysql_fetch_array($resultItem , MYSQL_ASSOC))
  		{
			?>
             <tr class="bold_row_3">
              <td><?php echo $number.".".$number2++;?></td>
              <td><?php $items = $rowItem["itemID"]; echo  $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE.".".$rowItem["itemID"]; ?></td>
              <td><?php echo $rowItem["sortCode"]; ?> - <?php echo $rowItem["description"]; ?></td>
              <td>
              	<?php
					$status = false;
                	$resultchkstatus = mysql_query("SELECT * FROM specs_scope_brief_description where pack_id = '$items'");
					if(mysql_num_rows($resultchkstatus) > 0){
						$status = true;
					}else{
						$resultchkstatus = mysql_query("SELECT * FROM specs_scope_brief where pack_id = '$items'");
						if(mysql_num_rows($resultchkstatus) > 0){
							$status = true;
						}
					}
					echo (($status) ? "Started" : "");
				?>	
              </td>
              <td align="right"><a href="03-05Scope-01Specifications03-Details.php?sid=<?php echo $BID; ?>&WID=<?php echo $WBSID1; ?>&iid=<?php echo $items?>"><img src="img/expand.png" width="16" height="15" alt=""/></a> <a href="03-05Scope-01Specifications03-DetailsPV.php?sid=<?php echo $BID; ?>&WID=<?php echo $WBSID1; ?>&iid=<?php echo $items?>"><img src="img/print.png" width="15" height="15" alt=""/></a></td>
        	</tr>
            
             <?php
           //////////////////////////////////////////////////// Sub item Start
		   $result123 = mysql_query("SELECT * FROM globalitems where WBSID = '$WBSID1' && itemParent = '$items' ORDER BY itemID ASC");
		
   		while($row1 = mysql_fetch_array($result123 , MYSQL_ASSOC))
  		{
		
  		?>
        	<tr class="bold_row_4">
              <td><?php echo $number.".".$number2++;?></td>
              <td><?php echo  $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE.".".$row1["itemID"];?></td>
              <td><?php echo $row1["sortCode"]; ?> - <?php echo $row1["description"]; ?></td>
              <td>
              	<?php
					$status = false;
                	$resultchkstatus = mysql_query("SELECT * FROM specs_scope_brief_description where pack_id = '".$row1['itemID']."'");
					if(mysql_num_rows($resultchkstatus) > 0){
						$status = true;
					}else{
						$resultchkstatus = mysql_query("SELECT * FROM specs_scope_brief where pack_id = '".$row1['itemID']."'");
						if(mysql_num_rows($resultchkstatus) > 0){
							$status = true;
						}
					}
					echo (($status) ? "Started" : "");
				?>	
              </td>
              <td align="right"><a href="03-05Scope-01Specifications03-Details.php?sid=<?php echo $BID; ?>&WID=<?php echo $WBSID1; ?>&iid=<?php echo $row1['itemID']?>"><img src="img/expand.png" width="16" height="15" alt=""/></a> <a href="03-05Scope-01Specifications03-DetailsPV.php?sid=<?php echo $BID; ?>&WID=<?php echo $WBSID1; ?>&iid=<?php echo $row1['itemID']?>"><img src="img/print.png" width="15" height="15" alt=""/></a></td>
        	</tr>
            
            <?php 
		 } //////////sub item end
		}////// item end
		?>
                <!--///////////////////////// Item End ////////////////////////////////////////-->  
  
  <?php ++$number; } /// wbs end ?>
      </tbody>
</table>

</body>
</html>

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