Location: PHPKode > projects > Phpgw Time Tracking Add On App > timetrack/changeprofile.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: changeprofile.php,v 1.4 2001/01/15 15:24:10 rschader Exp $ */

  Header("Cache-Control: no-cache");
  Header("Pragma: no-cache");
  //Header("Expires: Sat, Jan 01 2000 01:01:01 GMT");

  $phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
  $phpgw_info["flags"]["currentapp"] = "timetrack";
  include("../header.inc.php");
  if ($phpgw_info["user"]["permissions"]["anonymous"]) {
     Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/"));
     $phpgw->common->phpgw_exit();
  }

  if ($submit) {
     // I have changed this code so that pictures must be submitted to one of the
	 // administrators, who can then put it in the hr/images directory. Convention
	 // is that each picture will be in gif format and will be named for the userid.
	 // This makes view_image.php obsolete fro now, and saves us the hassle involved
	 // with blobs (at least for me). Have to still devide a method where the blank_pic
	 // would replace anyone's missing picture, or just copy the blank_pic.gif multiple
	 // times to all loginid names.

        $phone_number = addslashes($phone_number);
        $comments     = addslashes($comments);
        $title        = addslashes($title);
		$mobilephn    = addslashes($mobilephn);
		$pager        = addslashes($pager);
        // Shouldn't need addslashes for the following:
		// $hired, $vacationtime, $vac_hours_used, $location
		// We do also need to get and update the user's "con" #,
		// as I have changed this field so that it always is the
		// same as the accounts.con field.

        $phpgw->db->query("update employee_profiles set title='$title',phone_number='$phone_number',"
		       . "mobilephn='$mobilephn',pager='$pager',comments='$comments'"
			   . "where owner='" . $phpgw_info["user"]["userid"] . "'");
     echo "<center>Your profile has been updated</center>";
  } // End of submit section

  $phpgw->db->query("select * from employee_profiles where owner='" . $phpgw_info["user"]["userid"] . "'");
  $phpgw->db->next_record();
  // Note: We need to store all these values in reference vars so other queries won't
  // screw things up
  $n_owner = $phpgw->db->f("owner");
  $n_title = $phpgw->db->f("title");
  $n_phone_number = $phpgw->db->f("phone_number");
  $n_comments = stripslashes($phpgw->db->f("comments"));
  $n_mobilephn = $phpgw->db->f("mobilephn");
  $n_pager = $phpgw->db->f("pager");
  $n_hire_date = $phpgw->db->f("hire_date");
  $n_yvac_hours = $phpgw->db->f("yearly_vacation_hours");
  $n_vhours_utd = $phpgw->db->f("vacation_hours_used_todate");
  $n_location_id = $phpgw->db->f("location_id");
  $n_inout = $phpgw->db->f("inout");
?>

  <form method="POST" action="<?php echo $phpgw->link();?>">

   <table border="0">
    <tr>
     <td colspan="2"><?php echo $phpgw->common->display_fullname($phpgw_info["user"]["userid"],
	$phpgw_info["user"]["firstname"],$phpgw_info["user"]["lastname"]); ?></td>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td>Title:</td>
     <td><input name="title" value="<?php echo $n_title; ?>"></td>
     <td rowspan="2">
	  <img src=
	  "<?php 
	   if (file_exists($phpgw_info["server"]["server_root"] . "/timetrack/images/" . $n_owner . ".gif"))
	    {
	     echo $phpgw_info["server"]["webserver_url"] . "/timetrack/images/" . $n_owner . ".gif"; 
		} else {
		 echo $phpgw_info["server"]["webserver_url"] . "/timetrack/images/blank_pic.jpg";
		}
	   ?>"
	   width="100" height="120" border="1">
     </td>
    </tr>

    <tr>
     <td>Phone number:</td>
     <td><input name="phone_number" value="<?php echo $n_phone_number; ?>"></td>
    </tr>

	<tr>
	 <td>Mobile number:</td>
	 <td><input name="mobilephn" value="<?php echo $n_mobilephn; ?>"></td>
	</tr>

    <tr>
     <td>Pager number:</td>
     <td><input name="pager" value="<?php echo $n_pager; ?>"></td>
    </tr>

    <!-- Probably shouldn't give the users access to the next thre items, but I should
	     be able to disable it easy enough later -->
    <tr>
	 <td colspan="2"><hr>The following info can only be updated by an Administrator.
	 </td>
	</tr> 
    <tr>
     <td>Hire Date:</td>
     <td><?php echo $n_hire_date; ?></td>
    </tr>

    <tr>
     <td>Yearly Vacation Hours:</td>
     <td><?php echo $n_yvac_hours; ?></td>
    </tr>

    <tr>
     <td>Vacation Hours Used:</td>
     <td><?php echo $n_vhours_utd; ?></td>
    </tr>

	<tr>
	 <td>Location:</td>
	 <td><?php
	  $phpgw->db->query("select * from locations where location_id='$n_location_id'");
	  $phpgw->db->next_record();
      echo $phpgw->db->f("location_name");
	  ?>
     </td>
	</tr>
	<tr>
	 <td colspan="2"><hr></td>
	</tr>

    <tr>
     <td>Comments:</td>
     <td><textarea cols="60" name="comments" rows="4" wrap="virtual"><?php echo $n_comments; ?></textarea></td>
    </tr>

    <tr>
     <td>Picture:</td>
     <td>Note: To update you picture, please submit a gif
	     <br>file to one of the managers via email.
	     <br>Pictures will be resized to 100x120.</td>
    </tr>

    <tr>
     <td colspan="3" align="center"><input type="submit" name="submit" value="Submit">
    </td></tr>
   </table>

  </form>

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