Location: PHPKode > projects > Work project > workproject/add_qualification.php
<?
include ("include_config.inc");
include ("include_profile_name.inc");
include ("include_project_name.inc");
include ("include_log_file.inc");
include ("include_delete_task.inc");
include ("include_delete_project.inc");
include ("include_delete_profile.inc");
include ("include_update_user.inc"); 
include ("include_delete_user.inc");
include ("include_list_user.inc");
include ("include_state_name.inc");
include ("include_user_name.inc");
include ("include_workload_project.inc");
include ("include_dates_project.inc");
include ("include_display_comment.inc");
include ("include_button.inc");

if ( isset( $HTTP_COOKIE_VARS[$g_string_cookie] ) ) {
	$g_string_cookie_val         = $HTTP_COOKIE_VARS[$g_string_cookie];
	write_log_user ($filename_log, "Cookie created 1.1: ".$g_string_cookie." -- ".$g_string_cookie_val);
}
if ( isset( $HTTP_COOKIE_VARS[$g_project_cookie] ) ) {
	$g_project_cookie_val        = $HTTP_COOKIE_VARS[$g_project_cookie];
	write_log_user ($filename_log, "Cookie created 2.1: ".$g_project_cookie." -- ".$g_project_cookie_val);
}

/* check the login for user */
login_cookie_check();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Your tasks - Add qualification</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<? include("include_css.inc");?>
<script src="main.js" type="text/javascript"></script>
<script src="tasks.js" type="text/javascript"></script>
<script src="nav.js" type="text/javascript"></script>

</head>
<BODY onload="init()">

<?
include ("include_main.inc");
?>

<?php
write_log_user ($filename_log, "Beginning of Adding qualification.");

/* database connection */
$link= mysql_connect($g_hostname, $g_db_username, $g_db_password) or die("could not connect");
$result = mysql_select_db($g_database_name);

/* read of the user connected */
$connected_user = user_connected();
$profile_connected_user = user_profile($connected_user);
$name_connected_user = user_name($connected_user,$g_database_name);
$name_profile_connected_user = profile_name($profile_connected_user);
display_connected_user($name_connected_user,$name_profile_connected_user);

# verify the data
if( $qualif != "") {
	#verify if the qualification does already exist
	$query_test = "SELECT DESCRIPTION_QUALIF from QUALIFICATION where DESCRIPTION_QUALIF='$qualif'";
	write_log_user ($filename_log, $query_test );
	$result_test = mysql_query($query_test);
	$total_rows = mysql_numrows($result_test);
	if ( $total_rows != 0 ) {
		display_comment("Qualification not added: this qualification does already exist.");
	} else {
		if ( $currency != "") {
			/* seek for the highest qualifid */
			$result = mysql_query("SELECT ID_QUALIF FROM QUALIFICATION order by ID_QUALIF ASC");
			$total_rows = mysql_numrows($result);
			$qualifid = mysql_result($result,$total_rows-1,ID_QUALIF);
			$qualifid = $qualifid + 1;
			mysql_free_result($result);
			/* add user */
			if ($cost == "") $cost = 'NULL';
			if ($sold == "") $sold = 'NULL';	
			if ($currency == "") $currency = 'NULL';
			
			$query_add= "INSERT INTO QUALIFICATION (ID_QUALIF,DESCRIPTION_QUALIF,STANDARD_COST,STANDARD_SOLD,ID_CURRENCY) 
			VALUES ($qualifid,'$qualif','$cost','$sold','$currency')" ;
			mysql_query($query_add) or $mysql_eval_error_add = mysql_error();
			if ($mysql_eval_error_add) {
				write_log_user ($filename_log, "Add Error: ". mysql_error() );
				$is_comment= "Qualification not added: ". mysql_error();
				display_comment($is_comment);				
			} else {
				mysql_query("COMMIT");
			}
		} else {
			$is_comment= "Qualification currency is mandatory.";
			display_comment($is_comment);				
		}
	}
} else {
	if ($add == 1 ) {
		$is_comment= "Qualification description is mandatory.";
		display_comment($is_comment);
	}
}

if ( $DESCRIPTION_QUALIF == "" ) 	$DESCRIPTION_QUALIF=$qualif;
if ( $STANDARD_COST == "" ) 		$STANDARD_COST=$cost;
if ( $STANDARD_SOLD == "" ) 		$STANDARD_SOLD=$sold;

?>

<form name="addqualification" method="post">
<input type="hidden" name="add" value="1">

<table class="around" border=0 align="center" cellspacing="2" cellpadding="4"> 
<tr><td class="title" colspan="6">Add Qualification</td></tr>
<tr><td class="input">Qualification</td><td><input type="text" name="qualif" value="<? echo $DESCRIPTION_QUALIF; ?>"></input></td></tr>
<tr><td class="input">Standard Cost</td><td><input type="text" name="cost" value="<? echo $STANDARD_COST; ?>"></input></td>
<td class="input">Standard Sold</td><td><input type="text" name="sold" value="<? echo $STANDARD_SOLD; ?>"></input></td>

<td class="input">Currency</td>
<td><select name="currency">
<option value=""></option>
<?
$result_currency = mysql_query("SELECT ID_CURRENCY,DESCRIPTION_CURRENCY  FROM CURRENCY ORDER BY DESCRIPTION_CURRENCY");
$total_rows = mysql_numrows($result_currency);
$counter = 0;
while($counter < $total_rows) {
	$currency_code = mysql_result($result_currency,$counter,ID_CURRENCY);
	$currency_description = mysql_result($result_currency,$counter,DESCRIPTION_CURRENCY);
	if ( $currency == $currency_code ){
		echo "<option value=".$currency_code." selected>".$currency_description."</option>";
	} else {
		echo "<option value=".$currency_code.">".$currency_description."</option>";
	}
	$counter = $counter + 1;
}
?>
</select>
</td>
</tr>

</table>

<br>
<table align="center">
<? if ( right_user($connected_user,30) ){ ?>
<tr><td>
<? button("Add","Add a new qualification","submit();"); ?>
</td>
<td><a href="<? echo $g_path; ?>qualification.php"><? button("List Qualif","List of Qualifications"); ?></a></td>
<? } 
if ( right_user($connected_user,13) ){ ?>
<td>
<a href=<? echo $g_file_log_directory; ?>  title="Log data" > <img src="<? echo $g_icon_path;?>see.gif" border="0"> </a>
</td>
<? } ?>
<td>
<img src="<? echo $g_path;?>images/question.gif" ALT="Help"  onClick="show_comment_screen('Help','Add qualifications',63);">
</td>
</tr>
</table>
</form>

<?
include ("include_bottom.inc");
?>

</BODY>
</HTML>
Return current item: Work project