Location: PHPKode > projects > Phpgw Time Tracking Add On App > timetrack/hr-profiles.php
<?php
  /**************************************************************************\
  * phpgwtimetrack - phpGroupWare addon application                          *
  * http://phpgwtimetrack.sourceforge.net                                    *
  * Written by Robert Schader <hide@address.com>                         *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: hr-profiles.php,v 1.4 2001/01/08 21:30:09 rschader Exp $ */

  $phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
  $phpgw_info["flags"]["currentapp"] = "timetrack";

  include("../header.inc.php");?>
<p>
<table border="0" width="100%">
 <tr>
  <td align="left" width="50%" valign="top">
   <?php
    echo '<table border="0" width="80%">';
    echo '<tr><td bgcolor="' . $phpgw_info["theme"]["th_bg"] . '" align="center">Users</td>'
       . '</tr>';

     $phpgw->db->query("select account_id,account_lid,account_lastname,account_firstname "
		. "from accounts where account_status !="
		. " 'L' order by account_lastname, account_firstname, account_lid");
     while ($phpgw->db->next_record()) {
       $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
       echo '<tr><td bgcolor="' . $tr_color . '"><a href="'
	  . $phpgw->link("hr-profiles.php","user=" . $phpgw->db->f("account_id")) . '">&nbsp;'
	  . $phpgw->common->display_fullname($phpgw->db->f("account_lid"),
		 $phpgw->db->f("account_firstname"),
		 $phpgw->db->f("account_lastname")) . '</a></td></tr>';
     }
     echo "</table>";

     echo '<p><table border="0" width="80%">';
     echo '<tr><td bgcolor="' . $phpgw_info["theme"]["th_bg"] . '" align="center">Groups</td>'
        . '</tr>';

     $phpgw->db->query("select group_id,group_name from groups");
     while ($phpgw->db->next_record()) {
       $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
       echo '<tr><td bgcolor="' . $tr_color . '">&nbsp;<a href="'
	  . $phpgw->link("hr-profiles.php","group=" . $phpgw->db->f("group_id")) . '">'
	  . $phpgw->db->f("group_name") . '</a></td></tr>';
     }
     echo "</table>";
   ?>
  </td>
  <td align="right" width="50%" valign="top">
   <?php
     if ($group && ! $user) {
        $phpgw->db->query("select group_name from groups where group_id='$group'");
        $phpgw->db->next_record();

        $current_groupname = $phpgw->db->f("group_name");
        echo '<table border="0" width="80%">';
        echo '<tr><td bgcolor="' . $phpgw_info["theme"]["th_bg"] . '" align="center">Users '
	   . 'apart of ' . $current_groupname . '</td></tr>';

        $phpgw->db->query("select account_id,account_lid,account_firstname,account_lastname "
			. "from accounts where account_groups "
			. "like '%$group%' order by account_lastname, account_firstname, account_lid");
        while ($phpgw->db->next_record()) {
          $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
          echo '<tr><td bgcolor="' . $tr_color . '"><a href="'
	     . $phpgw->link("hr-profiles.php","user=" . $phpgw->db->f("account_id")) . '">&nbsp;'
	     . $phpgw->common->display_fullname($phpgw->db->f("account_lid"),
		$phpgw->db->f("account_firstname"),
   		$phpgw->db->f("account_lastname")) . '</a></td></tr>';
        }
        echo "</table>";
     }

     if (! $group && $user) {
        $phpgw->db->query("select account_lid from accounts where account_id='$user'");
        $phpgw->db->next_record();
	$loginid = $phpgw->db->f("account_lid");
	$phpgw->db->query("select * from employee_profiles where owner='"
		       . $loginid . "'");
        $phpgw->db->next_record();

        $profile_comments     = htmlentities($phpgw->db->f("comments"));
        $profile_phone_number = htmlentities($phpgw->db->f("phone_number"));
        $profile_title        = htmlentities($phpgw->db->f("title"));
        $profile_mobilephn    = htmlentities($phpgw->db->f("mobilephn"));
        $profile_pager        = htmlentities($phpgw->db->f("pager"));
		$hired 	              = $phpgw->db->f("hire_date");
		$vacationtime         = $phpgw->db->f("yearly_vacation_hours");
		$vac_hours_used       = $phpgw->db->f("vacation_hours_used_todate");
		$location             = $phpgw->db->f("location_id");

		$n_owner              = $phpgw->db->f("owner");

        if (! $phpgw->db->f("comments"))
           $profile_comments = "&nbsp;";

        if (! $phpgw->db->f("phone_number"))
           $profile_phone_number = "&nbsp;";

        if (! $phpgw->db->f("title"))
	   $profile_title = "&nbsp;";

	if (! $phpgw->db->f("mobilephn"))
	   $profile_mobilephn = "&nbsp;";

	if (! $phpgw->db->f("pager"))
	   $profile_pager = "&nbsp;";

        $phpgw->db->query("select * from accounts where account_id='$user'");
        $phpgw->db->next_record();

        echo '<table border="0" width="80%">';
        echo '<tr><td colspan="2" bgcolor="' . $phpgw_info["theme"]["th_bg"]
	   . '">&nbsp;</td></tr>';

        // Note: I am using the alternate_row_color to make it easier to add or delete fields.
        //       Make a local function to handle display the rows better.

        $firstname = $phpgw->db->f("account_firstname");
        $lastname  = $phpgw->db->f("account_lastname");

        if (! $firstname) $firstname = "&nbsp;";
        if (! $lastname)  $lastname = "&nbsp;";

        $phpgw->db->query("SELECT location_name from locations where location_id='$location'");
        $phpgw->db->next_record();
        $location_str = $phpgw->db->f("location_name");
        // Should not need checking either^

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Firstname:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $firstname. '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Lastname:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $lastname . '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Title:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $profile_title . '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Phone number:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $profile_phone_number . '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Mobile number:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $profile_mobilephn . '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Pager number:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $profile_pager . '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Comments:</td>'
	   . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
	   . $profile_comments . '</td></tr>';

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
		if (file_exists($phpgw_info["server"]["server_root"] . "/timetrack/images/" . $n_owner . ".gif"))
		 {
          echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">&nbsp;</td>'
	     . '<td width="50%" align="right" bgcolor="' . $tr_color . '">'
	     . '<img src="' . $phpgw_info["server"]["webserver_url"] . "/timetrack/images/" . $n_owner . ".gif"
	     . '" width="100" height="120"></td></tr>';
		 }
		 else
		 {
		  echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">&nbsp;</td>'
		  . '<td width="50%" align="right" bgcolor="' . $tr_color . '">'
		  . '<img src="' . $phpgw_info["server"]["webserver_url"] . "/timetrack/images/blank_pic.jpg"
          . '" width="100" height="120"></td></tr>';
		 }
        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Dated Hired:</td>'
           . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
           . $hired . '</td></tr>';

        if($phpgw_info["apps"]["timetrack"]["ismanager"]) {
          $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
          echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Yearly Vacation Hours:</td>'
             . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
             . $vacationtime . '</td></tr>';

          $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
          echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Vacation Hours Used:</td>'
             . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
             . $vac_hours_used . '</td></tr>';
        }

        $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
        echo '<tr><td align="left" bgcolor="' . $tr_color . '" width="50%">Work Location:</td>'
           . '<td align="right" width="50%" bgcolor="' . $tr_color . '">'
           . $location_str . '</td></tr>';

        echo '<tr><td colspan="2">&nbsp;</td></tr>';
        echo '<tr><td colspan="2" align="left" bgcolor="' . $phpgw_info["theme"]["th_bg"]
	   . '">Member of the following groups</td></tr>';

        $user_groups = $phpgw->accounts->read_group_names($loginid);
	for ($i=0;$i<count($user_groups); $i++) {
           $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
           echo "<tr bgcolor=\"$tr_color\"><td colspan=\"2\"><a href=\""
	      . $phpgw->link("hr-profiles.php","group=" . $user_groups[$i][0]) . "\">"
	      . $user_groups[$i][1] . "</a></td></tr>";
        }
        echo "</table>";
     }

   ?>
  </td>
 </tr>
</table>
<?php
  $phpgw->common->phpgw_footer();
Return current item: Phpgw Time Tracking Add On App