<?php
/* $Id: [sahana_home]/mod/hw/process_hello.inc,v 1.0 2006/10/02  */
/**
 *
 * Hello World Module --  processes the say_hello form.
 *
 * @package    Trinity_College_hw_demo
 * @copyright  Copyright {@link http://www.opensource.lk Lanka Software Foundation} 2006
 * @license    http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) 
 * @author     R. Morelli <ralph.morelli@trincoll.edu>
 */

error_reporting(E_ALL);

/**
 * Processes the say_hello form.
 *
 * @access public
 * @return void
 */
function shn_hw_process_hello() { 
    
    global $global;
//    include_once $global['approot']."/mod/vr/utility_functions.inc";   // Local Library: Contains dbgpost()
//    dbgpost($_POST);                                                   // Uncomment to display post values

    $name = $_POST['name'];
    if (!shn_validate_field($name, 'Name', $max_len=30, $check_null=true)){
        $error=true;
    } 
    $gender = $_POST['opt_gender'];
    $gender_str = "male";
    if ($gender != "mal") {
	$gender_str = "female";
    }

    $dob_entered = $_POST['dobY'] . $_POST['dobM'] . $_POST['dobD'];
    if (!shn_valid_date($dob_entered, $check_null=false, $pattern='/^\d{4}\d{2}\d{2}$/')){
        $error=true;
        add_error(SHN_ERR_DOB_INCORRECT);
    } else if (shn_is_null($dob_entered)) {
	$dob_formatted = "unknown";
    } else {
       $dob_formatted = $_POST['dobM']  . "-" . $_POST['dobD'] . "-" . $_POST['dobY'];
    }

    if ($error) {
        display_errors();
        $hellostring = "Sorry. Please try again.";
    } else {
        $hellostring = "Hello " . $name . ". <BR>You are a  " . $gender_str . " and your birthday is " . $dob_formatted;
   }
?>
<div id="hello">
    <?=_("<center><h2> $hellostring </h2></center>")?>
</div>
<br />
<?php
} // process_hello()
