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

<html><head><meta charset="utf-8"><title>pmAnywhere - Scope 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>
    <style>
        thead { display: table-header-group; }
        tfoot { display: table-footer-group; }
    </style>
</head>
<body>
<table width="100%">
    <thead><tr><td>
            <?php
            $BID =isset($_GET['sid'])?$_GET['sid']:0;
            $WID = $_GET['WID'];
            $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 id="fixedDiv">
                <br>
                <fieldset>
                    <legend align="center">SPECIFICATIONS<?php //echo $row["title"]; ?></legend>
                    <table name="entryform" align="center" class="table1" width="80%" border="0" cellpadding="0">
                        <tr>
                            <td colspan="6" align="center" valign="top"><span class="projectTitle">
				<?php
                if(!isset($_GET['iid'])){
                $WID = isset($_GET['WID'])?$_GET['WID']:0;

                $result1 = mysql_query("SELECT * FROM globalwbs where WBSID ='$WID' && companyID = '$cid'  ORDER BY WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
                $row1wbs = mysql_fetch_array($result1 , MYSQL_ASSOC);
                $WBSIDA = $row1wbs["WBSIDA"];
                $WBSIDB = $row1wbs["WBSIDB"];
                $WBSIDC = $row1wbs["WBSIDC"];
                $WBSIDD = $row1wbs["WBSIDD"];
                $WBSIDE = $row1wbs["WBSIDE"];
                $WBSID1 = $row1wbs["WBSID"];
                $parent = $row1wbs["parent"];
                $wbs_code = $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE;
                ?>
                </span>
                            </td>
                        </tr>
                        <tr>
                            <td width="9%" align="left" valign="top"><strong>Project</strong>:</td>
                            <td width="28%" align="left" valign="top"><?php echo $row["projectCode"]; ?> - <?php echo $row["projectName"]; ?></td>
                            <td align="left" valign="top"><strong>Client</strong>:</td>
                            <td align="left" valign="top"><?php echo $row["clientCode"]; ?> - <?php echo $row["clientName"]; ?></td>
                            <td width="7%" 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>Title</strong></td>
                            <td align="left" valign="top"><?php echo $row["title"]; ?></td>
                            <td align="left" valign="top"><strong>Section No</strong></td>
                            <td align="left" valign="top"><?php echo $wbs_code;?></td>
                            <td align="left" valign="top"><strong>Section Title</strong></td>
                            <td align="left" valign="top">
                                <?php /*?><?php echo $row["title"]; ?> - <?php echo $row1wbs["sortCode"]; ?> - <?php */?>
                                <?php echo $row1wbs["description"];
                                }
                                else
                                {
                                    $WID = isset($_GET['WID'])?$_GET['WID']:0;
                                    $iid = isset($_GET['iid'])?$_GET['iid']:0;
                                    $result123 = mysql_query("SELECT * FROM globalitems where WBSID = '$WID' && itemID='$iid' ORDER BY itemID ASC");

                                    $row1item = mysql_fetch_array($result123 , MYSQL_ASSOC);
                                    echo $row1item["description"];
                                    $WID = $iid;
                                    $result1 = mysql_query("SELECT * FROM globalwbs where WBSID ='".$row1item['WBSID']."' && companyID = '$cid' ");
                                    $row1wbs = mysql_fetch_array($result1 , MYSQL_ASSOC);
                                    $WBSIDA = $row1wbs["WBSIDA"];
                                    $WBSIDB = $row1wbs["WBSIDB"];
                                    $WBSIDC = $row1wbs["WBSIDC"];
                                    $WBSIDD = $row1wbs["WBSIDD"];
                                    $WBSIDE = $row1wbs["WBSIDE"];
                                    $WBSID1 = $row1wbs["WBSID"];
                                    $parent = $row1wbs["parent"];
                                    $wbs_code = $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE.".".$row1item["itemID"];
                                }
                                ?></td>
                        </tr>
                    </table>
                </fieldset>
                <br />
            </div>
        </td></tr></thead>
    <tbody>
    <tr><td>



            <table width="95%" border="0" align="center" cellpadding="0" class="table3">
                <tbody>
                <tr>
                    <td ><span class="subTitle">START OF SECTION <?php echo $wbs_code;?></span></td>
                </tr>
                </tbody>
            </table>
            <br>
            <br />
            <table align="center" width="95%" class="table1" border="0">
                <tbody>
                <tr>
                    <td  width="95%"><span class="subTitle">1.0 GENERAL</span></td>
                </tr>
                </tbody>
            </table>
            <br />
            <?php
            $query ="SELECT * from specs_scope_brief WHERE scope_type='$scope' AND (company_id= 0 OR company_id = '$cid') AND (brief_id= 0 OR brief_id = '$BID') AND brief_type ='General' AND (pack_id = 0 OR pack_id = '".$WID."')";
            $result = mysql_query($query);
            $k=1;

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

                $query2 ="SELECT * from specs_scope_brief_description WHERE `heading_id` = '".$row['id']."' AND `brief_id` ='".$BID."' AND company_id= '$cid' AND pack_id = '".$WID."'";
                $results = mysql_query($query2);
                $row2 = mysql_fetch_object($results);
                ?>
                <table align="center" width="95%" class="table1" border="0">
                    <tbody>
                    <tr>
                        <td width="95%"><strong><em><?php  echo '1.'.$k.'. '.$row['heading']; ?></em></strong></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table1" align="center" width="95%" border="0">
                    <tbody>
                    <tr>
                        <td width="3%">&nbsp;</td>
                        <td width="97%"><?php  echo ((@$row2->description) ? @$row2->description : ''); ?></td>
                    </tr>
                    </tbody>
                </table>
                <br />
                <br />

                <?php $k=$k+1;
            } ?>

            <table align="center" width="95%" class="table1" border="0">
                <tbody>
                <tr>
                    <td width="95%"><span class="subTitle" >2.0 PRODUCTS </span></td>
                </tr>
                </tbody>
            </table>
            <br />
            <?php
            $query ="SELECT * from specs_scope_brief WHERE scope_type='$scope' AND (company_id= 0 OR company_id = '$cid') AND (brief_id= 0 OR brief_id = '$BID') AND brief_type='Products' AND (pack_id = 0 OR pack_id = '".$WID."')";
            $result = mysql_query($query);
            $k = 1;

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

                $query2 ="SELECT * from specs_scope_brief_description WHERE `heading_id` = '".$row['id']."' AND `brief_id` ='".$BID."' AND company_id= '$cid' AND pack_id = '".$WID."'";
                $results = mysql_query($query2);
                $row2 = mysql_fetch_object($results);
                ?>
                <table align="center" width="95%" class="table1" border="0">
                    <tbody>
                    <tr>
                        <td width="95%"><strong><em><?php  echo '2.'.$k.'. '.$row['heading']; ?></em></strong></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table1" align="center" width="95%" border="0">
                    <tbody>
                    <tr>
                        <td width="3%">&nbsp;</td>
                        <td width="97%"><?php  echo ((@$row2->description) ? @$row2->description : ''); ?></td>
                    </tr>
                    </tbody>
                </table>
                <br />
                <br />
                <?php
                $k=$k+1;
            }
            ?>
            <table align="center" width="95%" class="table1" border="0">
                <tbody>
                <tr>
                    <td width="95%"><span class="subTitle" >3.0 EXECUTION</span> </td>
                </tr>
                </tbody>
            </table>
            <br />
            <?php
            $query ="SELECT * from specs_scope_brief WHERE scope_type='$scope' AND (company_id= 0 OR company_id = '$cid') AND (brief_id= 0 OR brief_id = '$BID') AND brief_type='Execution' AND (pack_id = 0 OR pack_id = '".$WID."')";
            $result = mysql_query($query);
            $k=1;

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

                $query2 ="SELECT * from specs_scope_brief_description WHERE `heading_id` = '".$row['id']."' AND `brief_id` ='".$BID."' AND company_id= '$cid' AND pack_id = '".$WID."'";
                $results = mysql_query($query2);
                $row2 = mysql_fetch_object($results);

                ?>
                <table class="table1" align="center" width="95%" class="table1" border="0">
                    <tbody>
                    <tr>
                        <td width="95%"><strong><em><?php  echo '3.'.$k.'. '.$row['heading']; ?></em></strong></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table1" align="center" width="95%" border="0">
                    <tbody>
                    <tr>
                        <td width="3%">&nbsp;</td>
                        <td width="97%"><?php  echo ((@$row2->description) ? @$row2->description : ''); ?></td>
                    </tr>
                    </tbody>
                </table>
                <br />
                <br />



                <?php
                $k=$k+1;
            }
            ?>

            <table width="95%" border="0" align="center" cellpadding="0" class="table3">
                <tbody>
                <tr>
                    <td ><span class="subTitle">END OF SECTION <?php echo $wbs_code;?></span></td>
                </tr>
                </tbody>
            </table>

            <table align="center" width="95%" class="table2" border="0">
                <tbody>
                <tr>
                    <td width="25%"><strong></strong></td>
                    <td width="25%">&nbsp;</td>
                    <td width="25%">&nbsp;</td>
                    <td width="25%">&nbsp;</td>
                </tr>
                <tr>
                    <td><em>Signatures</em></td>
                    <td><em>Signatures</em></td>
                    <td><em>Signatures</em></td>
                    <td><em>Signatures</em></td>
                </tr>
                <tr>
                    <td><em>Prepared By</em></td>
                    <td><em>Reviewed By</em></td>
                    <td><em>Approved By</em></td>
                    <td><em>Received By</em></td>
                </tr>
                <tr>
                    <td><em>Name: </em><?php echo $_SESSION['UserName']; ?></td>
                    <td><em>Name</em></td>
                    <td><em>Name</em></td>
                    <td><em>Name</em></td>
                </tr>
                <tr>
                    <td><em>Date: </em><?php echo $row['obs_creation_date'];?></td>
                    <td><em>Date</em></td>
                    <td><em>Date</em></td>
                    <td><em>Date</em></td>
                </tr>
                </tbody>
            </table>

        </td></tr>
    </tbody>
    <tfoot><tr><td><!--Your footer goes here--></td></tr></tfoot>
</table>
</body>

</html>

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