<?
session_start();
header("Cache-control: private"); // IE6 fix
include ($DOCUMENT_ROOT."/mySQL_config.php");
include ($DOCUMENT_ROOT."/functions.php");
include ($DOCUMENT_ROOT."/config.php");
check_admin();
$FilePath = $_SERVER['DOCUMENT_ROOT']."/employee/sites/materials/";
if (isset($Submit)) {
// form has been submitted, process data
if (!empty($siteID)) {
// update the database
//if any of these fields are empty, then we cannot continue
if(empty($site_name) || empty($address1) || empty($city) || empty($state) || empty($zip) || empty($phone) || empty($directions) || empty($metro)) {
$Msg = 'One or more fields were left blank. Please review the information you have entered and resubmit.';
} else {
$site_name = mysql_escape_string($site_name);
$city = mysql_escape_string($city);
$query = "UPDATE client_sites
SET site_name = '".$site_name."',
company_name = '".$company_name."',
type = '".$type."',
address1 = '".$address1."',
address2 = '".$address2."',
city = '".$city."',
state = '".$state."',
zip = '".$zip."',
phone_number = '".$phone."',
contact = '".$contact."',
parking = '".$parking."',
dress_code = '".$dress_code."',
start_time = '".$start_time."',
additional_info = '".$additional_info."',
alt_phone = '".$alt_phone."',
directions = '".$directions."',
metro_ID = '".$metro."',
phone_note = '".$phone_note."',
alt_phone_note = '".$alt_phone_note."'
WHERE site_ID = ".$siteID;
//everything seems to have worked so we try to insert our record.
// $result = mysql_query($query, $connection) or ($Msg = sqlErrOut(mysql_errno($connection)));
$result = mysql_query($query, $connection) or ($Msg = mysql_error());
// respond to the user letting them know the db was updated
if (empty($Msg)) {
$Msg = "The database was updated successfully.";
}
// move the uploaded site materials
$MaterialsSiteID = $siteID;
if ( !empty($materials) ) {
$filename = $MaterialsSiteID.'_'.date('mdy')."_".str_replace(' ','_',$_FILES['materials'] ['name']);
move_uploaded_file ($_FILES['materials'] ['tmp_name'],$FilePath.$filename);
$materials_query = "INSERT INTO client_site_materials VALUES(NULL,'$filename','$materials_desc',$siteID)";
$materials_result = mysql_query($materials_query, $connection) or ($Msg = sqlErrOut(mysql_errno($connection)));
// respond to the user letting them know the db was updated
if (empty($Msg)) {
$Msg = "The database was updated successfully.";
}
$materials_id = mysql_insert_id();
}
}
} else {
// insert new data
//if any of these fields are empty, then we cannot continue
if(empty($site_name) || empty($address1) || empty($city) || empty($state) || empty($zip) || empty($phone) || empty($directions) || empty($metro)) {
$Msg = 'One or more fields were left blank. Please review the information you have entered and resubmit.';
} else {
$site_name = mysql_escape_string($site_name);
$city = mysql_escape_string($city);
$query = "INSERT INTO client_sites (site_name, company_name, type, address1, address2,";
$query .= "city, state, zip, phone_number, contact, parking, dress_code, start_time, additional_info, alt_phone, directions, metro_ID, phone_note, alt_phone_note)";
$query .= " values ('".$site_name."','".$company_name."','".$type."','".$address1."','".$address2."','";
$query .= $city."','".$state."','".$zip."','".$phone."','".$contact."','".$parking."','".$dress_code."','".$start_time."','".$additional_info."','".$alt_phone."','".$directions."','".$metro."','".$phone_note."','".$alt_phone_note."' )";
//everything seems to have worked so we try to insert our record.
$result = mysql_query($query, $connection) or ($Msg = sqlErrOut(mysql_errno($connection)));
// respond to the user letting them know the db was updated
if (empty($Msg)) {
$Msg = "The database was updated successfully.";
}
$site_ID = mysql_insert_id();
// move the uploaded site materials
$MaterialsSiteID = mysql_insert_id();
if ( !empty($materials) ) {
$filename = $MaterialsSiteID.'_'.date('mdy')."_".str_replace(' ','_',$_FILES['materials'] ['name']);
move_uploaded_file ($_FILES['materials'] ['tmp_name'],$FilePath.$filename);
$materials_query = "INSERT INTO client_site_materials VALUES(NULL,'$filename','$materials_desc',$site_ID)";
$materials_result = mysql_query($materials_query, $connection) or ($Msg = sqlErrOut(mysql_errno($connection)));
// respond to the user letting them know the db was updated
if (empty($Msg)) {
$Msg = "The database was updated successfully.";
}
$materials_id = mysql_insert_id();
}
}
}
}
if (!empty($siteID)) {
$query = "SELECT * FROM client_sites WHERE site_ID = ".$siteID;
$result = mysql_query($query) or die(mysql_error());
$result_ar = mysql_fetch_assoc($result);
}
?>
<HTML>
<HEAD>
<? include($DOCUMENT_ROOT."/meta.php"); ?>
<link href="/quantum.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY background="http://www.quantumhp.com/images/pattern_leaves_tan.gif" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<table width="95%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="page_border">
<tr>
<td height="91" align="right" bgcolor="#64211f"><img src="/images/splash_logo.gif" width="734" height="91"></td>
</tr>
<tr>
<td class="top_menu_shell" height="26" align="left" valign="middle" nowrap bgcolor="#000000"><? include($_SERVER['DOCUMENT_ROOT'].'/top_menu.php'); ?></td>
</tr>
<tr>
<td height="88" bgcolor="#000000" class="photo_border"><img src="/images/sample-photo02.gif" alt="" width="740" height="88"></td>
</tr>
<tr>
<td valign="top">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="231" valign="top" background="/images/pattern_leaves_brown.gif"><? include("include_Menu_Sites.php"); ?></td>
<td valign="top"><br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26" class="title-bold">ADD <span class="title-italic">facility</span> </td>
</tr>
<tr>