<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../../includes/topmenunewest.php');

$company_id = $_SESSION['id'];
$companyID = $company_id;
include('04a-02procure01-tier01DB.php');
?>

<html><head><meta charset="utf-8">
<title>pmAnywhere - Procurement Module</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="04a-02procure01-tier01.js"></script>
<link href="02-00simple01.css" rel="stylesheet" type="text/css" />
</head>

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

<div style="overflow-x:auto;">
  <div id="formdiv">     
    <form align="center" id="form1" method="post" action="04a-02procure01-tier01.php" style="margin-top:20px">
      <input type="hidden" value="<?php echo $tierone['tierone_id'];?>" name="edit_id" id="edit_id" />
      <fieldset>
        <legend align="center">
        <button id="hideformdiv" class="button1" title="Click to hide">&nbsp;TIER 1 CLASSIFICATION OF CATEGORIES&nbsp;</button>
        </legend>
        <table name="entryform" align="center" class="table1" width="80%" border="0" cellpadding="0">
          <tr>
            <td width="13%" align="left" valign="top"><strong>Category*:</strong></td>
            <td align="left" valign="top">
            <select name="input_category" id="input_category" required>
            <?php
            	$result = mysql_query("SELECT Cat.*, subCat.* FROM resourcesubcategory AS subCat,resourcecategory AS Cat WHERE subCat.companyID='$companyID' AND subCat.`resSubCatStatus` = '1' AND Cat.resCatStatus = '1' AND subCat.resCatID=Cat.resCatSerial ORDER BY resCatCode, resSubCatCode DESC");
				while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			?>
            		<option value="<?php echo $row['resCatSerial']."_".$row['resSubCatSerial']?>" <?php echo (($row['resCatSerial'] == $tierone['tierone_categoryID'] && $row['resSubCatSerial'] == $tierone['tierone_subcategoryID']) ? "selected" : "")?> ><?php echo $row['resCatCode']."-".$row['resSubCatCode']?> (<?php echo $row['resSubCatName']?>)</option>
            <?php		
				}
			?>
            </select>
            </td>
          </tr>
          <tr>
            <td align="left" valign="top"><strong>Tier 1 Name*:</strong></td>
            <td align="left" valign="top"><input type="text" required value="<?php echo $tierone['tierone_name'];?>" name="input_tier1name" id="input_tier1name"></td>
          </tr>
          <tr>
            <td align="left" valign="top"><strong>Tier1 Code*:</strong></td>
            <td align="left" valign="top"><input type="text" required value="<?php echo $tierone['tierone_code'];?>" name="input_tier1code" id="input_tier1code">
              <button style="vertical-align: bottom" class="button1 btn-success" title="Save">&#x25ba;</button>
              <a href="04a-02procure01-tier01-IV01.php" class="button1" title="Import Suggestions from  pmAnywhere">
              &#x25bc;</a></td>
          </tr>
        </table>
      </fieldset>
    </form>
    <br>
  </div>
</div>
<div style="overflow-x:auto;">
  <div>
    <?php
    $result = mysql_query("SELECT tierone.*, cat.resCatCode, subCat.resSubCatName, subCat.resSubCatCode FROM tierone, resourcecategory AS cat, resourcesubcategory AS subCat
						   WHERE tierone.tierone_company_id = '$company_id' AND tierone.tierone_status= '1' AND tierone.tierone_categoryID = cat.resCatSerial AND tierone.tierone_subcategoryID = subCat.resSubCatSerial ORDER BY `resCatCode` ASC, `resSubCatCode` ASC, `tierone_code` ASC") or die (mysql_error());
	?>
    <table align="center" name="tabletitle" class="table1 tableActiveFilter" width="80%" border="0" cellpadding="0">
      <tr>
        <th> <div style='float: left; text-align: left'>
            <button id="showhiddendiv" class="button1" title="Show Hidden">&#x25bc;</button>
            <button id="showformdiv" class="button1" title="Add">&#x25b2;</button>
            Active Tiers (<?php echo mysql_num_rows($result);?>)
            </div>
          <div style='float: right; text-align: right'> 
            <select style="width:45%" 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:50%" id="SearchMeasure" type="search" placeholder="Type to Search">
          </div>
        </th>
      </tr>
    </table>
  </div>
</div>
<div style="overflow-x:auto;">
  <table align="center" class="table2 tableActive" name="datatable" border="0" width="80%" cellpadding="1">
    <thead>
      <tr>
        <th width="15%" align="left" class="sorting" sorting="srtDate" bgcolor="#AAAAAA">Date<br>Created&nbsp;&#x21c5;</th>
        <th width="30%" align="left" class="sorting" sorting="srtCat" bgcolor="#AAAAAA">Resource Category/<br>Sub-Sategory&nbsp;&#x21c5;</th>
        <th width="30%" align="left" class="sorting" sorting="srtCode" bgcolor="#AAAAAA">Tier 1 Classification Code/ <br>
        Tier 1 Classification Name</th>
        <th width="15%" align="left" class="sorting" sorting="srtName" bgcolor="#AAAAAA">Full Resource<br>Code</th>
        <th width="10%" align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
      </tr>
    </thead>
    <tbody>
    <?php
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    ?>
      <tr class="tableData" trid="<?php echo $row['tierone_id']?>">
        <td align="left" class="tdData srtDate"><?php echo $row['tierone_creation_date']; ?></td>        
        <td align="left" class="tdData srtCat"><?php echo $row['resCatCode']?>-<?php echo $row['resSubCatCode']?> (<?php echo $row['resSubCatName']?>)</td>        
        <td align="left" class="tdData srtCode"><strong><?php echo $row['tierone_code']; ?></strong> - <span class="tdData srtName"><?php echo $row['tierone_name']; ?></span></td>
        <td align="left" class="tdData srtName"><span class="tdData srtCat"><?php echo $row['resCatCode']?>-<?php echo $row['resSubCatCode']?></span>-<?php echo $row['tierone_code']; ?></td>
        <td align="center">
          <button id="addformdiv" class="button3"> <img src="img/add.png" width="13" height="13" alt="" title="Add"/></button>&nbsp;&nbsp;&nbsp; 
          <a href="04a-02procure01-tier01.php?update=<?php echo $row['tierone_id']; ?>"> <img src="img/edit.png" width="13" height="13" alt="" title="Edit"/></a> &nbsp;&nbsp;&nbsp;
          <a href="04a-02procure01-tier01.php?del=<?php echo $row['tierone_id'];?>" onClick="return confirm('Are you sure you want to delete the record?');"><img src="img/delete.png" width="12" height="12" alt=""/></a><br>
          <a href="04a-02procure01-tier01.php"><img src="img/expand.png" width="13" height="13" alt="" title="Import Suggestions from pmAnywhere"/></a>&nbsp;&nbsp;&nbsp;
          <a href="04a-02procure01-tier01.php"><img src="img/print.png" width="13" height="13" alt="" title="Print"/></a>&nbsp;&nbsp;&nbsp;
          <a href="04a-02procure01-tier01.php?statusId=<?php echo $row['tierone_id']; ?>&status=0"><img src="img/hide.png" width="13" height="13" alt="" title="Archive"/></a> <br>
          <!--  <button id="showremsdiv" class="button3">--> 
          <img src="img/mymentos.png" width="13" height="13" alt="" title="Add a Reminder"/> &nbsp;&nbsp;&nbsp; 
          <!--  <button id="shownotesdiv" class="button3">--> 
          <img src="img/notes.png" width="13" height="13" alt="" title="Add Notes"/> &nbsp;&nbsp;&nbsp; 
          <!-- <button id="showfilesdiv" class="button3"> --> 
          <img src="img/attach.png" width="13" height="13" alt="" title="Attach" />
        </td>
      </tr>
      <?php } ?>
    </tbody>
  </table>
</div>

<!-- Table to show the pagination for active table --> 

<!-- Table to show the pagination  --> 

<!-- Table to show the pagination  -->

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

<!-- HIDDEN TABLE--> 

<br>
<hr class="hrstyle1">
<br>
<div style="overflow-x:auto;">
  <div id="hiddendiv" ><!--  style="display:none" -->    
  <?php
    $result = mysql_query("SELECT tierone.*, cat.resCatCode, subCat.resSubCatName, subCat.resSubCatCode FROM tierone, resourcecategory AS cat, resourcesubcategory AS subCat
						   WHERE tierone_company_id = '$company_id' AND tierone_status= '0' AND tierone.tierone_categoryID = cat.resCatSerial AND tierone.tierone_subcategoryID = subCat.resSubCatSerial ORDER BY `tierone_name` 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>
            Archived Tiers (<?php echo mysql_num_rows($result);?>)
            </div>
          <div style='float: right; text-align: right'> 
            
            <select style="width:45%" 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:50%" id="SearchMeasureHide" type="search" placeholder="Type to Search">
          </div>
        </th>
      </tr>
    </table>
    <table align="center" class="table2 sortable tableInActive" name="datatable" border="0" width="80%" cellpadding="1">
      <thead>
      <tr>
        <th width="15%" align="left" class="sorting" sorting="srtDate" bgcolor="#AAAAAA">Date<br>Created&nbsp;&#x21c5;</th>
        <th width="30%" align="left" class="sorting" sorting="srtCat" bgcolor="#AAAAAA">Resource Category/<br>Sub-Sategory&nbsp;&#x21c5;</th>
        <th width="30%" align="left" class="sorting" sorting="srtCode" bgcolor="#AAAAAA">Tier 1 Classification Code/ <br>
Tier 1 Classification Name</th>
        <th width="15%" align="left" class="sorting" sorting="srtName" bgcolor="#AAAAAA">Full Resource<br>Code</th>
        <th width="10%" align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
      </tr>
    </thead>
      <tbody>       
        <?php
		 while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
	    ?>       
        <tr class="tableDataHide">
          <td align="left" class="tdData srtDate"><?php echo $row['tierone_creation_date']; ?></td>        
          <td align="left" class="tdDataHide srtCat"><?php echo $row['resCatCode']?>-<?php echo $row['resSubCatCode']?> (<span class="tdData srtCat"><?php echo $row['resSubCatName']?></span>)</td>        
          <td align="left" class="tdDataHide srtCode"><strong><?php echo $row['tierone_code']; ?></strong> - <span class="tdDataHide srtName"><?php echo $row['tierone_name']; ?></span></td>
          <td align="left" class="tdDataHide srtName"><span class="tdData srtName"><span class="tdData srtCat"><?php echo $row['resCatCode']?>-<?php echo $row['resSubCatCode']?></span>-<strong><?php echo $row['tierone_code']; ?></strong></span></td>
          <td align="center">
          	<a  href="04a-02procure01-tier01.php?statusId=<?php echo $row['tierone_id']; ?>&status=1"> <img src="img/show.png" width="13" height="13" alt="" title="Unhide"/></a>
          </td>          
        </tr>
        <?php } ?>
      </tbody>
    </table>
    
    <!-- Table to show the pagination for hidden table --> 
    
    <!-- Table to show the pagination  --> 
    
    <!-- Table to show the pagination  -->
    
    <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>
    
    <!-- Table to show the pagination  ends--> 
    
    <!-- Table to show the pagination  ends--> 
    
    <!-- Table to show the pagination ends --> 
    
  </div>
</div>
<br>
<br>
</body>
</html>
<SCRIPT>
$(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();

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