<?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: newprofile.php,v 1.4 2001/01/12 22:14:47 rschader Exp $ */
if($submit) {
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
}
$phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
$phpgw_info["flags"]["currentapp"] = "timetrack";
include("../header.inc.php");
if ($submit) {
if (! $n_loginid)
$error = "<br>" . lang("You must enter a loginid");
$phpgw->db->query("select account_id,account_lid from accounts where account_lid='$n_loginid'");
$phpgw->db->next_record();
$uid = $phpgw->db->f("account_id");
$uname = $phpgw->db->f("account_lid");
$phpgw->db->query("select owner from employee_profiles where owner='$uname'");
$phpgw->db->next_record();
$uname2 = $phpgw->db->f("owner");
if (($uid) && (! $uname2))
{
$loc = implode(",",$n_location);
if (! $n_vhours) $n_vhours = 0;
if (! $n_vhours_used) $n_vhours_used = 0;
$table_locks = array('employee_profiles');
$phpgw->db->lock($table_locks);
$sql = "INSERT INTO employee_profiles (con,owner,title,phone_number,comments,mobilephn,pager,"
. "hire_date,yearly_vacation_hours,vacation_hours_used_todate,location_id,inout)"
. " values ($uid,'$n_loginid','" . addslashes($n_title) . "','"
. addslashes($n_phone) . "','" . addslashes($n_comments) . "','"
. addslashes($n_mobilephn) ."','" . addslashes($n_pager) . "','"
. addslashes($n_hiredate) . "',$n_vhours,$n_vhours_used,$loc,'Out')";
//echo "sql statement 1 is <br>" . $sql . "<br>";
$phpgw->db->query($sql);
$phpgw->db->unlock();
Header("Location: " . $phpgw->link("profiles.php"));
} else {
if (! $uid)
{
echo "The user account for " . $n_loginid . " has to be created before<br>";
echo "adding their profile entries<br>";
}
if ($uname2)
{
echo "The user " . $uname2 . " already has an entry in the profiles table, please<br>";
echo "use the update method instead<br>";
}
}
}
else
{
// END of submit form code, start of form code
// NOTE: We are going to assume and use the convention that a user's email address
// equals his loginid + "@domainname.com
?>
<form method="POST" action="<?php echo $phpgw->link();?>">
<?php
if ($error) {
echo "<center>" . lang("Error") . ":$error</center>";
}
?>
<center>
<table border=0 width=65%>
<tr>
<td><?php echo lang("LoginID"); ?></td>
<td><input name="n_loginid" value="<?php echo $n_loginid; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Title"); ?></td>
<td><input name="n_title" value="<?php echo $n_title; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Phone Number"); ?></td>
<td><input name="n_phone" value="<?php echo $n_phone; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Mobile Phone"); ?></td>
<td><input name="n_mobilephn" value="<?php echo $n_mobilephn; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Pager"); ?></td>
<td><input name="n_pager" value="<?php echo $n_pager; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Hire Date"); ?></td>
<td><input name="n_hiredate" value="<?php echo $n_hiredate; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Vacation Hours"); ?></td>
<td><input name="n_vhours" value="<?php echo $n_vhours; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Vacation Hours Used"); ?></td>
<td><input name="n_vhours_used" value="<?php echo $n_vhours_used; ?>"></td>
</tr>
<tr>
<td><?php echo lang("Location"); ?></td>
<td><select name="n_location[]"><?php
$phpgw->db->query("select * from locations");
while ($phpgw->db->next_record()) {
$locid = $phpgw->db->f("location_id");
echo "<option value=\"" . $locid . "\"";
if ($ $locid == $n_location_id ) {
echo " selected";
}
echo ">" . $phpgw->db->f("location_name") . "</option>";
}
?>
</select></tr>
</tr>
<tr>
<td><?php echo lang("Comments"); ?></td>
<td><textarea cols="30" rows="4" name="n_comments"
wrap="virtual"><?php echo $n_comments; ?></textarea></td>
</tr>
<tr>
<td colspan=2>
<input type="submit" name="submit" value="<?php echo lang("submit"); ?>">
</td>
</tr>
</table>
</center>
</form>
<?php
$phpgw->common->phpgw_footer();
}
?>