Current File : /home/inlingua/public_html/noida/icentex/admin/admin_super/admin_user.main.php |
<?php
// Copyright, Panalink Infotech Limited. Created on: 22-05-2010
// Include the database connection details
require('../dbConnection.php');
// Include common functions
require('../commonFunc.php');
// Include common functions
require('../globalVars.php');
// Setup table name, configuration and data entry form
$tableName = "timesheet_user";
$tableConf = "admin_user.conf.php";
$dataForm = "admin_user.form.php";
$viewForm = "admin_user.view.php";
// Include table configuration details
require($tableConf);
// Include the table handler class
require('../dbHandler.class.php');
$dbObject = new dbHandler();
$dbObject->setTableName($tableName);
$dbObject->setDbFieldList($dbFieldList);
$dbObject->setKeyFieldName("recNo");
$dbObject->connect();
// Retrieve parameters from request
$dbObject->getDbFieldsFromRequest();
$currentMode = "";
$formPrompt = "";
$succFailMesg = "";
$showResult = "N";
$action = $_REQUEST['aC'];
if (($action == "") || ($action == "sA"))
{ // Set 'Add' mode in dataform
$currentMode = "Add"; $succFailMesg = "<b>Add details</b> [<a href='javascript:history.back()'>Back</a>]<br>";
}
else if ($action == "Add")
{ $currentMode = "Add";
$reqFields = array("name|Name","username| UserName","password|Password",);
$blankFields = "";
foreach ($reqFields as $reqField)
{ list($field,$prompt) = explode('|',$reqField);
if ($_REQUEST[$field] == "") { $blankFields .= "'". $prompt . "', ";}
}
// Perform check for duplicate entry
if($dbObject->Exists("recNo", $_REQUEST["recNo"]))
{ $succFailMesg = "<b>Could not add details, record with this key exists.</b><br>";
$showResult = "N"; // Show dataentry form again
}
elseif ($blankFields != "")
{
$succFailMesg = "<font color='#da0000'><b>No values entered for $blankFields please enter or select value</b><br></font>";
$showResult = "N"; // Show dataentry form again
}
else if($dbObject->Exists("username", $_REQUEST["username"]))
{ $succFailMesg = "<font color='#da0000'><b>Could not add details, 'User-Name' already exists.</b><br></font>";
$showResult = "N"; // Show dataentry form again
}
else
{ //$today = date("Y-m-d");
$dbObject->Save();
require("../../class.phpmailer.php");
$message="Welcome ".$_REQUEST[name].",<br>Your Account has been created on <Name of the application to be decided><br><br>Your account details are as follows:
<br> Login ID:".$_REQUEST[username]."<br>Password:".$_REQUEST[password]."(Password is case sensitive)<br>Contact No.:".$_REQUEST[contact_no]."<br>Primary Center:".$_REQUEST[primarycenter]."<br>Pay Type:".$_REQUEST[pay_type]."<br>If any of the information above is incorrect, please contact the Administrator at hrd@inlinguanewdelhi.com<br><br>
*Please do not delete this email. You may need it to retrieve your password and login ID .";
$message.="<br><br>";
$message.="-Administrator<br>Inlingua New Delhi";
$fromEmail= "hrd@inlinguanewdelhi.com";
$fromName="Inlingua";
$to=$_REQUEST[email];
$subject="Welcome On Inlingua Online System";
$mail = new PHPMailer();
//$mail->IsSMTP(); // set mailer to use SMTP
$mail->IsMail();
//$mail->Host = $smtpHost; // specify main and backup server
//$mail->SMTPAuth = true; // turn on SMTP authentication
//$mail->Username = $smtpUser; // SMTP username
//$mail->Password = $smtpPassword; // SMTP password
$mail->From = $fromEmail;
$mail->FromName = $fromName;
//foreach ($to as $toAddress)
//{
$toAddress;
$mail->AddAddress($to, "");
//}
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $subject;
$mail->Body = $message;
//$mail->AddReplyTo("umraovikas@gmail.com","");
$mail->AddAttachment($path);
/*if(!$mail->Send())
{
echo "Message could not be sent on mailid: <font color='red'>'".$to."'</font><br>";
echo "Please check the emailId.<br>";
//echo "Mailer Error: " . $mail->ErrorInfo;
//exit;
}
*/
$succFailMesg = "<b>Details added successfully</b><br>";
$showResult = "Y"; // Goto result part in dataform
}
}
else if ($action == "sM")
{ // Set 'Update' mode in dataform
$currentMode = "Update"; $succFailMesg = "<b>Modify details</b> [<a href='javascript:history.back()'>Back</a>]<br>";
// Retrieve record first
if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
{ ; }
else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }
}
else if ($action == "Update")
{ $currentMode = "Update";
$showResult = "Y"; // Goto result part in dataform
$reqFields = array("name|Name","username| UserName","password|Password",);
$blankFields = "";
foreach ($reqFields as $reqField)
{ list($field,$prompt) = explode('|',$reqField);
if ($_REQUEST[$field] == "") { $blankFields .= "'". $prompt . "', ";}
}
if ($blankFields != "")
{
$succFailMesg = "<font color='#da0000'><b>No values entered for $blankFields please enter or select value</b><br></font>";
$showResult = "N"; // Show dataentry form again
}
/*else if($dbObject->Exists_update("username", $_REQUEST["username"],"recNo",$_REQUEST["recNo"]))
{ $succFailMesg = "<font color='#da0000'><b>Could not modify details, 'User-name' already exists.</b><br></font>";
$showResult = "N"; // Show dataentry form again
}*/
else if ($dbObject->Update("recNo",$_REQUEST["kV"]))
{ $succFailMesg = "<b>Details modified successfully</b><br>"; }
else
{ $succFailMesg = "<b>Could not modify details. Contact system administrator</b><br>" ; }
}
else if ($action == "sD")
{ $currentMode = "Delete"; $succFailMesg = "<b>Delete details</b> [<a href='javascript:history.back()'>Back</a>]<br>";
// Retrieve record first
if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
{ ; }
else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }
}
else if ($action == "Delete")
{ $showResult = "Y"; // Goto result part in dataform
if ($dbObject->Delete("recNo",$_REQUEST["kV"]))
{ $succFailMesg = "<b>Details deleted successfully</b><br>"; }
else
{ $succFailMesg = "<b>Could not delete details. Contact System administrator</b><br>" ; }
}
else if ($action == "sV")
{ // Set 'View' mode
$currentMode = "View"; $succFailMesg = "<b>View details</b><br>";
$dataForm = $viewForm;
// Retrieve record first
if ($dbObject->Retrieve("recNo",$_REQUEST["kV"]))
{ ; }
else { $succFailMesg = "<b>Could not retrieve details. Contact system administrator</b><br>"; }
}
else
{ echo "Nothing to do !";
return;
}
// Load the data entry or view entry form
require($dataForm);
$dbObject->CloseConnection();
return;
?>