<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../../includes/topmenunewest.php');
$company_id = $_SESSION['id'];
$companyID = $company_id;
include('03-05Scope-01Specifications01DB.php');
/*error_reporting(0);*/
/*$order_type = "ASC";
$order_par = "projectCode";
if (isset($_REQUEST['otype'])) {
    $order_type = $_REQUEST['otype'];
}

if (isset($_REQUEST['opar'])) {
    $order_par = $_REQUEST['opar'];
}*/
?>

<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>
    <script src="03-05Scope-01Specifications01.js"></script>
    <link href="03-00Scope-Styles0.css" rel="stylesheet" type="text/css" />
</head>

<style>
    .actionTD a{text-decoration:none;}
</style>
<body style="backgrond-color:#E8E8E8">
<!----------------------- Div For errors and warnings--------------------------------->

<!----------------------- Div For errors and warnings--------------------------------->

<!----------------------- Div For errors and warnings--------------------------------->
<div><h5 class="msg">
        <?php if (isset($_REQUEST["msg"])) { ?>
            <?php echo $_REQUEST["msg"]; ?>
        <?php } ?>
    </h5></div>
<div style="overflow-x:auto;">
    <br>
    <div id="formdiv" > <!--div for the form (style="display:none;")-->
       
        <?php //if ($uacc == "Full Control") { ?>
        <form align="center" action="03-05Scope-01Specifications01.php" method="post" >
			<input type="hidden" value="<?php echo $specs_scope['SPECID']?>" name="edit_id" id="edit_id" />
            <fieldset>
              <legend align="center">
                    <button id="hideformdiv" class="button1" title="Click to Hide">
                        &nbsp;&nbsp;&nbsp;SPECIFICATIONS&nbsp;&nbsp;&nbsp;</button></legend>

                <table name="entryform" align="center" class="table1" width="80%" border="0" cellpadding="0">
                    <tr>
                        <td width="15%" align="left" valign="middle"><strong>Project Name*</strong></td>
                        <td align="left" valign="middle">
                            <select name="projname" id="projname" class="single-select">
                                <?php
                                $result = mysql_query("SELECT projectSerial,projectCode, projectName FROM projects where companySerial = '$id' AND projStatus=1 order by projectCode, projectName asc");


                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                    $projectSerial = $row['projectSerial'];
                                    echo "<option value='$projectSerial' ".(($projectSerial == $specs_scope['spec_project']) ? "selected" : "").">" . $row["projectCode"] . " - " . $row["projectName"] . "</option>";
                                   
                                }
                                ?>
                            </select>
                            <a href="../02-options/02-03Options-01Projects01.php"><img src="img/Adding.png" width="7" height="7" alt=""/></a></td>
                        <td align="left" valign="middle"><strong>Client*</strong></td>
                        <td align="left" valign="middle"><select name="clientname"  id="clientname" class="single-select">
                          <?php
                                $result = mysql_query("SELECT clientSerial, clientName, clientContactName, clientCode FROM client where companySerial = '$id' AND clientStatus=1 order by clientCode,clientContactName asc");
                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                    $clientSerial = $row["clientSerial"];
                                    echo "<option value='$clientSerial' ".(($clientSerial == $specs_scope['spec_client']) ? "selected" : "").">" . $row["clientCode"] . " - " . $row["clientContactName"] . "</option>";
                                }
                                ?>
                        </select>
                          <a href="../02-options/02-04Options-01Clients01.php"><img src="img/Adding.png" width="7" height="7" alt=""/></a></td>
                        <td align="left" valign="middle"><strong>Consultant</strong></td>
                        <td align="right" valign="middle"><select name="consname"  id="consname" class="single-select">
                          <?php
                               $resultC = mysql_query("SELECT * FROM consultants WHERE companySerial = '$id' AND conStatus=1 ORDER BY conCode, conName");
                               while ($rowC = mysql_fetch_array($resultC, MYSQL_ASSOC)) {
	                             $consultant = $rowC['conSerial'];
                        ?>
                          <option value='<?php echo $consultant ?>' <?php echo (($consultant == $specs_scope['spec_consultant']) ? "selected" : "");?> ><?php echo $rowC["conCode"]." - ".$rowC['conName'].""; ?></option>
                          <?php } ?>
                        </select>
                          <a href="../02-options/02-06Options-01Consultants01.php"></a></td>
                        <td align="left" valign="top"><a href="../02-options/02-06Options-01Consultants01.php"><img src="img/Adding.png" width="7" height="7" alt=""/></a></td>
                    </tr>
                    <tr>
                        <td align="left" valign="middle"><strong>GWBS/ Master Format* <a href="../01-home/help.php#specs" target="new"><img src="img/question2b.png" width="11" height="11" alt=""/></a></strong></td>
                        <td align="left" valign="middle">
                            <select name="wbs" id="wbs" class="single-select" required <?php echo (($specs_scope['WBSID']) ? 'disabled' : 'onChange="setWBS(this.value)"')?>>
                                <option value="">Select a GWBS or Master Format</option>
						          <?php
									$result = mysql_query("SELECT WBSList_id,WBSList_code,WBSList_title FROM wbslist where WBSList_companyid = '$id' and WBSList_status='1'");
									while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$gwbs = $row['WBSList_id'];
										echo "<option value='$gwbs' ".(($gwbs == $specs_scope['WBSID']) ? "selected" : "").">" . $row["WBSList_code"] . " - ".  $row["WBSList_title"] ."</option>";
									}
                                  ?>
                            </select>
                            <a href="03-04Scope-01WBS01.php"><img src="img/Adding.png" width="7" height="7" alt=""/></a>
                        </td>
                        <td align="left" valign="middle"><strong>Dated</strong></td>
                        <td align="left" valign="middle"><input name="date" type="date" disabled="disabled" id="date"></td>
                        <td align="left" valign="middle"><strong>Title of Package*</strong></td>
                        <td align="right" valign="middle"><input name="briefname" required type="text"  id="briefname" value="<?php echo $specs_scope['title']; ?>" size="40" /></td>
                        <td align="left" valign="middle"><button style="vertical-align: bottom" type="Submit" class="button1" title="Save">&#x25ba;</button></td>
                    </tr>
                </table>

            </fieldset></form><?php //} ?>
  <br></div></div>

	<a name="activeanchor"></a>
<div style="overflow-x:auto;">
    <div>
    <?php
    $result = mysql_query("SELECT specs_scope.*,projects.projectName,projects.projectCode
							   FROM projects,specs_scope
							   WHERE specs_scope.spec_project = projects.projectSerial
							   AND specs_scope.companyID = '$id' AND specs_scope.spec_status=1 ORDER BY `dateCreated` DESC");

	?>
        <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 Archived">&#x25bc;</button>-->
		<a href="#archiveanchor"><button class="button1" title="View Archived">&#x25bc;</button></a><button id="showformdiv" class="button1" title="Show/ Hide the Form">&#x25b2;&#x25bc;</button>
                        Active Specifications (<?php echo mysql_num_rows($result);?>)</div>
                    <div style='float: right; text-align: right'>
                        <select id="findproject" style="width:30%" >
                            <option value="">Select a Project</option>
                            <?php
                            $result2 = mysql_query("SELECT specs_scope.*,projects.projectName,projects.projectCode,client.*
												   FROM projects,client,specs_scope
												   WHERE specs_scope.spec_project = projects.projectSerial
												   AND specs_scope.spec_client = client.clientSerial
												   AND specs_scope.companyID = '$id' AND specs_scope.spec_status=1 GROUP BY projects.projectName ORDER BY `projectCode` ASC");
                            while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
                                ?>
                                <option value='<?php echo $row2["projectName"]; ?>' ><?php echo $row2["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="50" selected> Show 50 Rows</option>     
                            <option 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="85%" cellpadding="1">
        <tr>
            <th align="left" bgcolor="#AAAAAA">Project<br />Code</th>
            <th align="left" bgcolor="#AAAAAA">Date Created<br>(yyyy.mm.dd)</th>
            <th align="left" bgcolor="#AAAAAA">Package ID/ Title/ <br>GWBS</th>
            <th align="left" bgcolor="#AAAAAA">Project Name/Client Name/<br>Consultant Name</th>
           <?php /*?> <th align="left" class="" sorting="DateLoction2" bgcolor="#AAAAAA"> Work Flow/<br />Assignments&nbsp;&#x21c5;</th>
            <th align="left" class="" sorting="DateLoction3" bgcolor="#AAAAAA"> Work Flow/<br />Status&nbsp;&#x21c5;</th><?php */?>
            <th align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
        </tr>
        <?php
        while ($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);
            }
            ?>

            <tr class="tableData" trid="<?php echo $row['SPECID']; ?>">
                <td align="left" class="tdData projectCode"><?php echo $row['projectCode']; ?></td>
                <td align="left" class="tdData hazardID"><?php echo $row['dateCreated']; ?></td>
                <td align="left" class="tdData DateLoction1">SPEC-<?php echo $row['SPECID']; ?><br>                  <?php echo $row['title']; ?><br>
                  GWBS: <?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'];
                    ?>
                    <br /></td>
                <td align="left" class="tdData srtProject">Project:&nbsp;<?php echo $row["projectCode"]; ?> - <?php echo $row["projectName"]; ?><br>
                    Clinet:&nbsp;<?php $resultww = mysql_query("SELECT * from client where clientSerial='".$row['spec_client']."' and client.clientStatus=1");// order by WBSList_code, description");
                    if( $row22 = mysql_fetch_array($resultww, MYSQL_ASSOC))
                    echo $row22['clientCode']. "-". $row22['clientName'];
                    ?><br>
                  Consultant:&nbsp;<?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>
                <?php /*?><td align="left" class="tdData DateLoction2">RR&nbsp;</td>
                <td align="left" class="tdData DateLoction3">Listing Created</td><?php */?>
                <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 ($uacc == "Full Control") { ?>
                    &nbsp;&nbsp;&nbsp; -->
<a href="03-05Scope-01Specifications01.php?update=<?php echo $row['SPECID']; ?>"><img src="img/edit.png" width="13" height="13" alt="" title="Edit"/></a> &nbsp;&nbsp;&nbsp;
<?php //} else { ?>
                    <?php /*?>&nbsp;&nbsp;&nbsp; <img src="img/edit.png" width="13" height="13" alt="" title="Edit"/>&nbsp;&nbsp;&nbsp;<?php */?>
<?php //} ?>

                  <?php /*?> <img src="img/delete.png" width="13" height="13" alt="" title="Delete" /><?php */?>
                    <?php //} ?>


                  <a href="03-05Scope-01Specifications02-Pack.php?BID=<?php echo $row["SPECID"]; ?>"><img src="img/expand.png" width="13" height="13" alt="" title="Expand"/></a>&nbsp;&nbsp;&nbsp;

             <!--       <a href="#"> <img src="img/print.png" width="13" height="13" alt="" title="Print"/></a>&nbsp;&nbsp;&nbsp;-->
					
                  <?php //if ($uacc == "Full Control") { ?>
                    <a href="03-05Scope-01Specifications01.php?statusId=<?php echo $row['SPECID']; ?>&status=0">

                        <img src="img/hide.png" width="13" height="13" alt="" title="Archive"/></a>
                    <?php //} else { ?>
                   <?php /*?> <img src="img/hide.png" width="13" height="13" alt="" title="Archive"/></a><?php */?>
                    <?php //} ?>
                 

              </td>

            </tr>

            <tr class="trid<?php echo $row['SPECID']; ?> notetr">

                <td colspan="9" align="left"><img src="img/information.png" width="12" height="12" alt=""/></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-->

<a name="archiveanchor"></a><br>

<hr class="hrstyle1">

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

    <div id="hiddendiv" > <!--- style="display:none" ------>
         <?php
		$result = mysql_query("SELECT specs_scope.*,projects.projectName,projects.projectCode
								   FROM projects,specs_scope
								   WHERE specs_scope.spec_project = projects.projectSerial
								
								   AND specs_scope.companyID = '$id' AND specs_scope.spec_status=0 ORDER BY `projectCode` ASC");
	
		?>
        <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 Specifications (<?php echo mysql_num_rows($result);?>)
                </div>
              <div style='float: right; text-align: right'> 
                <select id="findprojectHide" style="width:30%" >
                    <option value="">Select a Project</option>
                    <?php
                    $result2 = mysql_query("SELECT specs_scope.*,projects.projectName,projects.projectCode,client.*
                                           FROM projects,client,specs_scope
                                           WHERE specs_scope.spec_project = projects.projectSerial
                                           AND specs_scope.spec_client = client.clientSerial
                                           AND specs_scope.companyID = '$id' AND specs_scope.spec_status=0 GROUP BY projects.projectName ORDER BY `projectCode` ASC");
                    while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
                        ?>
                        <option value='<?php echo $row2["projectName"]; ?>' ><?php echo $row2["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="50" selected> Show 50 Rows</option> 
                  <option value="100"> Show 100 Rows</option>
                  <option value="all"> Show All Rows</option>
                </select>
                <input style="width:30%" id="SearchMeasureHide" type="search" placeholder="Type to Search">
              </div>
            </th>
          </tr>
        </table>
       
        <table align="center" class="table2 tableInActive" name="datatable" border="0" width="80%" cellpadding="1">
            <tr>
                <th align="left" bgcolor="#AAAAAA">Project<br />Code</th>
                <th align="left" bgcolor="#AAAAAA">Date Created<br>(yyyy.mm.dd)</th>
                <th align="left" bgcolor="#AAAAAA">Package ID/ Title/ <br>GWBS</th>
                <th align="left" bgcolor="#AAAAAA">Project Name/Client Name/<br>Consultant Name</th>
               <?php /*?> <th align="left" class="" sorting="DateLoction2" bgcolor="#AAAAAA"> Work Flow/<br />Assignments&nbsp;&#x21c5;</th>
                <th align="left" class="" sorting="DateLoction3" bgcolor="#AAAAAA"> Work Flow/<br />Status&nbsp;&#x21c5;</th><?php */?>
                <th align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
            </tr>
            <?php
            while ($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);
                }
                ?>

                <tr class="tableDataHide" trid="<?php echo $row['SPECID']; ?>">

                    <td align="left" class="tdDataHide projectCode"><?php echo $row['projectCode']; ?></td>

                    <td align="left" class="tdDataHide hazardID"><?php echo $row['dateCreated']; ?></td>

                    <td align="left" class="tdDataHide DateLoction1"><span class="tdData DateLoction1">SPEC-<?php echo $row['SPECID']; ?><br>
                        <?php echo $row['title']; ?><br>
GWBS:
<?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'];
                    ?>
                  </span><br /></td>
                    <td align="left" class="tdDataHide srtProject"><?php echo $row["projectCode"]; ?> - <?php echo $row["projectName"]; ?><br>
					   <?php $resultww = mysql_query("SELECT * from client where clientSerial='".$row['spec_client']."' and client.clientStatus=1");// order by WBSList_code, description");
                    if( $row22 = mysql_fetch_array($resultww, MYSQL_ASSOC))
                    echo $row22['clientCode']. "-". $row22['clientName'];?><br>
                      <?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>

                   <?php /*?> <td align="left" class="tdDataHide DateLoction2">RR&nbsp;</td>

                    <td align="left" class="tdDataHide DateLoction3">Listing Created</td><?php */?>
                    <td width="9%" align="center">
						
                        <?php //if ($uacc == "Full Control") { ?>
                        <a href="03-05Scope-01Specifications01.php?statusId=<?php echo $row['SPECID']; ?>&status=1">
                            <img src="img/show.png" width="13" height="13" alt="" title="Unhide"/></a><?php ///} else { ?>
                        &nbsp;&nbsp;&nbsp;
						
					<?php //if ($uacc == "Full Control") { ?>
                    <a href="03-05Scope-01Specifications01.php?del=<?php echo $row['SPECID']; ?>" onClick="return confirm('Are you sure you want to delete the record?');">

                        <img src="img/delete.png" width="13" height="13" alt="" title="Delete" />

                    </a>

                    <?php //} else { ?>
						
                  </td>

                </tr>

                <tr class="trid<?php echo $row['SPECID']; ?> notetr">

                    <td colspan="9" align="left">

                        <em>

                            <!--   <div id="div2"></div>        <br> --><img src="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'); ?>