<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../../includes/topmenunewest.php');
$companyID = $_SESSION['id'];
$company_id = $_SESSION['id'];
$TMembers = mysql_query("SELECT internal_personnel_id FROM internal_personnel where internal_personnel_company_id='$id' AND internal_personnel_status= '1'");
$TMembers = mysql_num_rows($TMembers)+1;

$result = mysql_query("SELECT sum(members_number) as total FROM subscriptions where `user_id` = '" . $companyID . "' AND `subscr_status` = 'payed' AND DATEDIFF( `subscr_end_date` ,  '" . date("Y-m-d") . "' ) >=0");
$allowed_team_members = 0;
if (mysql_num_rows($result) > 0) {//If some record is found
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($row['total'] != '') {
        $allowed_team_members = $row['total'];
    }
}
/*
if ($allowed_team_members == 0) {//If no record is found
    echo '<script>window.location="../01-home/01-15Subscribe01.php?msg= Subscription is necessary to build a team of more than three members";</script>';	
}
*/
include('04-10MyTeam-ListDB.php');
?>

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

</head>

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

<div><br></div>

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

   <form align="center" name="entryformform" method="post" action="04-10MyTeam-List.php" onSubmit="return validatemyteam();">
       <input type="hidden" name="edit_id" id="edit_id" value="<?php echo $internal_personnel['internal_personnel_id']?>" />
           <fieldset>
               <legend align="center">
               <button id="hideformdiv" class="button1">&nbsp;&nbsp;&nbsp;MY CURRENT TEAM&nbsp;&nbsp;&nbsp;</button></legend>
               <table name="entryformtable" align="center" class="table1" width="80%" border="0" cellpadding="0">
                <tr>
                  <td width="10%" align="left" valign="middle"><strong>First Name*</strong></td>
                  <td width="22%" align="left" valign="middle">
                    <input type="text" name="fname" placeholder="First Name" value="<?php echo $internal_personnel['internal_personnel_firstName']?>" required id="fname">
                  </td>
                      
                  <td width="10%" align="left" valign="middle"><strong>Last Name*</strong></td>
                  <td width="22%" align="left" valign="middle">
                    <input type="text" name="lname" placeholder="Last Name" value="<?php echo $internal_personnel['internal_personnel_lastName']?>" required id="lname">
                  </td>
                  
                  <td width="10%" align="left" valign="middle"><strong>Designation</strong></td>
                  <td width="22%" align="right" valign="middle">
                    <input type="text" name="desig" placeholder="Designation" value="<?php echo $internal_personnel['internal_personnel_desig']?>" id="desig">
                  </td>
                  <td width="4%" align="left" valign="middle">&nbsp;</td>
                  </tr>
                <tr>
                  <td align="left" valign="middle"><strong>Email Address*</strong></td>
                  <td align="left" valign="middle">
                    <input type="text" name="email1" placeholder="Email" value="<?php echo $internal_personnel['internal_personnel_email']?>" required id="email1">
                  </td>
                  
                  <td align="left" valign="middle"><strong>Retype Email Address*</strong></td>
                  <td align="left" valign="middle">
                    <input type="text" name="email2" placeholder="Retype Email" value="<?php echo $internal_personnel['internal_personnel_email']?>" required id="email2">
                  </td>
                  
                  <td align="left" valign="middle"><strong>Discipline</strong></td>
                  <td align="right" valign="middle">
                    <select name="discipline" id="discipline">
                      <option value="">Select</option>
                      <?php
						$company_id = $_SESSION['id'];
						$result1 = mysql_query("SELECT * FROM discipline where (discipline_company_id = '$id' OR discipline_name = 'All') AND discipline_status= '1' ORDER BY discipline_name ASC");
						while ($row1 = mysql_fetch_array($result1, MYSQL_ASSOC)) {
                      ?>
                      		<option value="<?php echo $row1['discipline_id']; ?>" <?php echo (($internal_personnel['internal_personnel_discipline_id'] == $row1['discipline_id']) ? "selected" : "");?>><?php echo $row1['discipline_name']; ?></option>
                      <?php } ?>
                    </select>
                  </td>
                  <td align="left" valign="middle">&nbsp;</td>
                </tr>
                <tr>
                  <td align="left" valign="middle"><strong>Land Line</strong></td>
                  <td align="left" valign="middle"><strong>
                    <input type="text" name="phone" placeholder="Phone" value="<?php echo $internal_personnel['internal_personnel_phone']?>" id="phone">
                  </strong></td>
                  <td align="left" valign="middle"><strong>Mobile</strong></td>
                  <td align="left" valign="middle"><strong>
                    <input type="text" name="mobile" placeholder="Mobile" value="<?php echo $internal_personnel['internal_personnel_mobile']?>" id="mobile" >
                  </strong></td>
                  <td align="left" valign="middle"><strong>Access Type*</strong></td>
                  <td align="right" valign="middle" ><strong>
                     <select name="accesstype" id="accesstype" required>
                      <option value="">Select</option>
                      <option value="Comment" <?php echo (($internal_personnel['internal_personnel_access'] == "Comment") ? "selected" : "");?>>Comment</option>
                      <option value="Consolidate" <?php echo (($internal_personnel['internal_personnel_access'] == "Consolidate") ? "selected" : "");?>>Consolidate</option>
                      <option value="Contractor" <?php echo (($internal_personnel['internal_personnel_access'] == "Contractor") ? "selected" : "");?>>Contractor</option>
                      <option value="Drafting" <?php echo (($internal_personnel['internal_personnel_access'] == "Drafting") ? "selected" : "");?>>Drafting</option>
                      <option value="Finance" <?php echo (($internal_personnel['internal_personnel_access'] == "Finance") ? "selected" : "");?>>Finance</option>
                      <option value="Full Control" <?php echo (($internal_personnel['internal_personnel_access'] == "Full Control") ? "selected" : "");?>>Full Control</option>
                      <option value="Plan" <?php echo (($internal_personnel['internal_personnel_access'] == "Plan") ? "selected" : "");?>>Plan</option>
                      <option value="Progress" <?php echo (($internal_personnel['internal_personnel_access'] == "Progress") ? "selected" : "");?>>Progress</option>
                      <option value="View" <?php echo (($internal_personnel['internal_personnel_access'] == "View") ? "selected" : "");?>>View</option>
                    </select>
                  </span></strong></td>
                  <td  align="left" valign="middle">&nbsp;</td>
                </tr>
                <tr>
                  <td align="left" valign="middle"><strong>Username*</strong></td>
                  <td align="left" valign="middle">
                    <input type="text" name="username" placeholder="UserName" value="<?php echo $internal_personnel['internal_personnel_username']?>" required id="username">
                  </td>
                  <td align="left" valign="middle"><strong>Initials*</strong></td>
                  <td align="left" valign="middle">
                    <input type="text" name="initials" placeholder="Initials" value="<?php echo $internal_personnel['internal_personnel_userinit']?>" required id="initials" maxlength="3">
                  </td>
                  <td align="left" valign="middle"><strong>Password*</strong></td>
                  <td align="right" valign="middle" >
                    <input type="password" name="ps1" placeholder="Password" value="<?php echo $internal_personnel['internal_personnel_password']?>" required id="ps1">
                  </td>
                  <td align="left" valign="middle">
                    <button style="vertical-align: bottom" class="button1" title="Save">&#x25ba;</button>
                    
                    </td>
                </tr>
                </table>
          </fieldset>
    </form>
	<br></div></div>


<div style="overflow-x:auto;">
<div>
<?php
$result = mysql_query("SELECT * FROM internal_personnel where internal_personnel_company_id='$id' AND internal_personnel_status= '1' order by internal_personnel_firstName ASC");
?>
<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>&nbsp;Active Team Members (<strong><?php echo $TMembers; ?></strong>)</div>
<div style='float: right; text-align: right'>
  <select style="width:30%" id="findType">
      <option value="">Select Access</option> 
      <?php
        $result2 = mysql_query("SELECT * FROM internal_personnel where internal_personnel_company_id='$id' AND internal_personnel_status= '1' group by `internal_personnel_access` order by internal_personnel_userinit ASC");
        
        while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
            ?>
            <option value='<?php echo $row2["internal_personnel_access"]; ?>' ><?php echo $row2["internal_personnel_access"];?></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="SearchMeasure" type="search" placeholder="Type to Search">
</div>
</th>
</tr>
</table>
</div>
</div>
<div style="overflow-x:auto;">
<?php
	$resultc = mysql_query("SELECT * FROM login where loginId='$company_id'" );
	while ($rowc = mysql_fetch_array($resultc, MYSQL_ASSOC)) {
?>
<table align="center" class="table2 tableActive" name="datatable" border="0" width="80%" cellpadding="1">
  <thead>
   <tr>
     <th align="left" bgcolor="#AAAAAA">Dated Created<br>(yyyy.mm.dd)</th>
     <th align="left" bgcolor="#AAAAAA">First Name, Last name<br />
     Username </th>
     <th align="left" bgcolor="#AAAAAA">User<br>
       Initials</th>
     <th align="left" bgcolor="#AAAAAA">Access<br />Type <br></th>
     <th align="left" bgcolor="#AAAAAA">Contact<br />Information </span></th>
     <th align="left" bgcolor="#AAAAAA">Designation/<br />Discipline </span></th>
     <th width="9%" align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
  </tr>
   <tr>
     <td><?php echo $rowc['registrationDate']; ?></td>
     <td> <br>
       Name/ Initials: <?php echo $rowc['firstName'] . " " . $rowc['lastName'] . "/"; ?> RR <br />
       Username: <?php echo $rowc['UserName']; ?> <br /></td>
     <td>RR</td>
     <td> Full Control </td>
     <td> Email: <?php echo $rowc['emailAddressOne']; ?> <br />
       PH/ MOB: <?php echo $rowc['user_phone'] . "/"; ?> <?php echo $rowc['user_mobile']; ?> <br /></td>
     <td> Admin <br />Registrar </td>
     <td>Can not be edited<br />or deleted </td>
   </tr>
   </thead>
   <tbody>
	<?php
    }
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    ?>
   
      <tr class="tableData" trid="<?php echo $row['internal_personnel_id']?>">
        <td class="tdData srtDate"><?php echo $row['internal_personnel_creation_date']; ?></td>
        <td class="tdData srtName">Name:<strong> <?php echo $row['internal_personnel_firstName'] . " " . $row['internal_personnel_lastName']; ?></strong><br />
          Username: <?php echo $row['internal_personnel_username']; ?><br /></td>
        <td class="tdData srtName"><span style="text-transform:uppercase;"><?php echo $row['internal_personnel_userinit']; ?></span></td>
        <td class="tdData srtAccess"><?php echo $row['internal_personnel_access']; ?></td>
        <td class="tdData srtEmail">Email:<?php echo $row['internal_personnel_email']; ?><br />
          PH/ MOB: <?php echo $row['internal_personnel_phone'] . "/"; ?> <?php echo $row['internal_personnel_mobile']; ?><br />
        </td>
        <td class="tdData srtDesg"><?php echo $row['internal_personnel_desig']; ?><br />
          <?php
			$did = $row['internal_personnel_discipline_id'];
			$result12 = mysql_query("SELECT * FROM discipline where discipline_id='$did' ");

			$row12 = mysql_fetch_array($result12, MYSQL_ASSOC);
			echo $row12['discipline_code'];
			?>
        </td>
        <td align="center" class="table2 sortable">
          <button id="addformdiv" class="button3"><img src="img/add.png" width="13" height="13" alt="" title="Add"/></button>&nbsp;&nbsp;&nbsp;
          <a href="04-10MyTeam-List.php?update=<?php echo $row['internal_personnel_id']; ?>"><img src="img/edit.png" width="13" height="13" alt="" title="Edit"/></a>&nbsp;&nbsp;&nbsp;
          <a href="04-10MyTeam-List.php?del=<?php echo $row['internal_personnel_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>
          
          <?php if($row['internal_personnel_email_status'] == "1"){?>
		           <a href="04-10MyTeam-List.php?send=<?php echo $row['internal_personnel_id']; ?>"><img src="img/send_grey.png" width="13" height="13" alt="Sent" title="Sent"/></a>&nbsp;&nbsp;&nbsp;
          <?php }else{?>
          		   <a href="04-10MyTeam-List.php?send=<?php echo $row['internal_personnel_id']; ?>"><img src="img/send_black.png" width="13" height="13" alt="Sent" title="Send"/></a>&nbsp;&nbsp;&nbsp;
          <?php } ?>           
          <a href="04-10MyTeam-List.php?expand_id=<?php echo $row['internal_personnel_id']; ?>"> <img src="img/print.png" width="13" height="13" alt="" title="Print"/></a> &nbsp;&nbsp;&nbsp; 
          <a href="04-10MyTeam-List.php?statusId=<?php echo $row['internal_personnel_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"/></button>&nbsp;&nbsp;&nbsp;
          <button id="shownotesdiv" class="button3"><img src="img/notes.png" width="13" height="13" alt="" title="Add Notes"/></button>&nbsp;&nbsp;&nbsp;
          <button id="showfilesdiv" class="button3"><img src="img/attach.png" width="13" height="13" alt="" title="Attach" /></button>
        </td>
      </tr>
    <tr class="trid<?php echo $row2['internal_personnel_id']; ?> notetr">
      <td colspan="7" align="left">
    <!--   <div id="div2"></div>        <br> --><em><img src="img/information.png" width="12" height="12" alt=""/></em></td>
    </tr>
   <?php } ?>
     </tbody>
  </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></td>
    </tr>
  </tbody>
</table>
<!-- HIDDEN TABLE (style="display:none")-->
<br>
<hr class="hrstyle1">
<br>



<div style="overflow-x:auto;">
<div id="hiddendiv">
<?php
$result = mysql_query("SELECT * FROM internal_personnel where internal_personnel_company_id='$id' AND internal_personnel_status= '0' order by internal_personnel_userinit 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 Team Members (<?php echo mysql_num_rows($result);?>)</div>
<div style='float: right; text-align: right'>
  <select style="width:30%" id="findTypeHide">
      <option value="">Select Access</option> 
	  <?php
        $result2 = mysql_query("SELECT * FROM internal_personnel where internal_personnel_company_id='$id' AND internal_personnel_status= '0' group by `internal_personnel_access` order by internal_personnel_firstName ASC");
        
        while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
            ?>
            <option value='<?php echo $row2["internal_personnel_access"]; ?>' ><?php echo $row2["internal_personnel_access"];?></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">
   <thead>
     <tr>
         <th align="left" bgcolor="#AAAAAA">Dated Created<br>(yyyy.mm.dd)</th>
         <th align="left" bgcolor="#AAAAAA">First Name, Last name<br />
         Username </th>
         <th align="left" bgcolor="#AAAAAA">User<br>
Initials</th>
         <th align="left" bgcolor="#AAAAAA">Access<br />Type <br></th>
         <th align="left" bgcolor="#AAAAAA">Contact<br />Information </span></th>
         <th align="left" bgcolor="#AAAAAA">Designation/<br />Discipline </span></th>
         <th width="9%" align="center" bgcolor="#AAAAAA">Actions<br>Status</th>
      </tr>
   </thead>
   <tbody>
   <?php
    	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
	?>
    <tr class="tableDataHide" trid="<?php echo $row['internal_personnel_id']; ?>">
      	<td class="tdDataHide srtDate"><?php echo $row['internal_personnel_creation_date']; ?></td>
        <td class="tdDataHide srtName">Name:<strong> <?php echo $row['internal_personnel_firstName'] . " " . $row['internal_personnel_lastName']; ?></strong><br />
          Username: <?php echo $row['internal_personnel_username']; ?><br /></td>
        <td class="tdDataHide srtAccess"><span style="text-transform:uppercase;"><?php echo $row['internal_personnel_userinit']; ?></span></td>
        <td class="tdDataHide srtAccess"><?php echo $row['internal_personnel_access']; ?></td>
        <td class="tdDataHide srtEmail">Email:<?php echo $row['internal_personnel_email']; ?><br />
          PH/ MOB: <?php echo $row['internal_personnel_phone'] . "/"; ?> <?php echo $row['internal_personnel_mobile']; ?><br />
        </td>
        <td class="tdDataHide srtDesg"><?php echo $row['internal_personnel_desig']; ?><br />
          <?php
			$did = $row['internal_personnel_discipline_id'];
			$result12 = mysql_query("SELECT * FROM discipline where discipline_id='$did' ");

			$row12 = mysql_fetch_array($result12, MYSQL_ASSOC);
			echo $row12['discipline_code'];
			?>
        </td>
        <td width="9%" align="center" class="table2 sortable">
	        <a href="04-10MyTeam-List.php?statusId=<?php echo $row['internal_personnel_id']; ?>&status=1"><img src="img/show.png" width="13" height="13" alt="" title="Unhide"/></a>
        </td>
    </tr>
    <tr class="trid<?php echo $row['internal_personnel_id']?> notetr">
      <td colspan="7" align="left">
    <!--   <div id="div2"></div>        <br> --><em><img src="img/information.png" width="13" height="13" alt=""/></em></td>
    </tr>
<?php
		}
?>
      </tbody>
    </table>
</div>
</div>
<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>
<br><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>