All pastes #465384 Raw Edit

Unnamed

public text v1 · immutable
#465384 ·published 2007-04-30 03:31 UTC
rendered paste body
<?
if (!isset($_GET['year'])) {
	$_GET['year'] = "2007";
}
include "dbconnect.php";
function convert_date($n0) {
	$o1 = strtotime($n0);
	$o2 = date("Y-m-d", $o1);
	return $o2;
}
$months0 = array(Jan, Feb, Mar, Apr);
$months1 = array(May, Jun, Jul, Aug);
$months2 = array(Sep, Oct, Nov, Dec);
$post_date = $_POST['appointment_date'];
$new_date = convert_date("$post_date");
$add_unit = "INSERT INTO service 
						(customer_name, phone_number, vehicle_type, appointment_date, appointment_time, tech, job_type, tech_hours, service_writer, inspection_service) VALUES 
						('$customer_name', '$phone_number', '$vehicle_type', '$new_date', '$appointment_time', '$tech', '$job_type', '$tech_hours', '$service_writer', '$inspection_service')";
#$add_unit_backuptable = "INSERT INTO service_backup (
#						(id, customer_name, phone_number, vehicle_type, appointment_date, appointment_time, tech, job_type, tech_hours, service_writer, inspection_service) VALUES
#						('NULL', '$customer_name', '$phone_number', '$vehicle_type', '$new_date', '$appointment_time', '$tech', '$job_type', '$tech_hours', '$service_writer', '$inspection_service')";
if (isset($_POST["editSubmit"])) {
	$id = $_POST['id'];
	$customerName = $_POST["customer_name"];
	$phoneNumber = $_POST["phone_number"];
	$vehicleType = $_POST["vehicle_type"];
	$appointmentDate = $_POST["appointment_date"];
	$appointmentTime = $_POST["appointment_time"];
	$tech = $_POST["tech"];
	$jobType = $_POST["job_type"];
	$techHours = $_POST["tech_hours"];
	$serviceWriter = $_POST["service_writer"];
	$inspectionService = $_POST["inspection_service"];
	$unitUpdate = "UPDATE service SET customer_name='$customerName', phone_number='$phoneNumber', vehicle_type='$vehicleType', appointment_date='$appointmentDate', appointment_time='$appointmentTime', tech='$tech', job_type='$jobType', tech_hours='$techHours', service_writer='$serviceWriter', inspection_service='$inspectionService' WHERE id='$id'";
	echo $unitUpdate;
	mysql_query($unitUpdate) or die(mysql_error());
	# takes the input from the appointment_date field in the form and assigns it to the $link_url variable
	$link_url = $_POST['appointment_date'];
	# converts the inputted day into a unix timestamp
	$newlink_url = strtotime($link_url);
	# I want to extract the year from the date input
	$url_year = date('Y', $newlink_url);
	# I want to extract the month from the new unix timestamp and make it lowercase so it fits in my link
	$url_month = strtolower(date('M', $newlink_url));
	# I want to do the same for the day so that it fits into my link as well
	$url_day = date('j', $newlink_url);
#	echo "COMPLETED QUERY $customerName" . "$id";
	header("Location:service_display.php?year=$url_year&month=$url_month&day=$url_day");
}
if($_GET["cmd"]=="delete") {
	$id = $_GET["id"];
	$url_year = $_GET['year'];
	$url_month = $_GET['month'];
	$url_day = $_GET['day'];
	mysql_query("DELETE FROM service WHERE id=$id") or die(msyql_error());
#	echo "Unit Deleted!<br><a href=" . $return_user . ">Return to Service Display</a>";
	header("Location:service_display.php?year=$url_year&month=$url_month&day=$url_day");
}
if (isset($_POST['appointment_date'])) {
	# takes the input from the appointment_date field in the form and assigns it to the $link_url variable
	$link_url = $_POST['appointment_date'];
	# converts the inputted day into a unix timestamp
	$newlink_url = strtotime($link_url);
	# I want to extract the year from the date input
	$url_year = date('Y', $newlink_url);
	# I want to extract the month from the new unix timestamp and make it lowercase so it fits in my link
	$url_month = strtolower(date('M', $newlink_url));
	# I want to do the same for the day so that it fits into my link as well
	$url_day = date('j', $newlink_url);
	if (isset($submit)) {
		if (empty($customer_name)) {
			die("The Customer Name field is empty, please correct.");
		} elseif (empty($vehicle_type)) {
			die("The Vehicle Type field is empty, please correct.");
		} elseif (empty($appointment_date)) {
			die("The Appointment Date field is empty, please correct.");
		} elseif (empty($tech_hours)) {
			die("The Tech Hours field is empty, please correct.");
		} elseif (empty($job_type)) {
			die("The Job Type field is empty, please correct.");
		} elseif (empty($service_writer)) {
			die("The Service Writer field is empty, please correct.");
		} elseif (empty($inspection_service)) {
			die ("The Inspection/Service field is empty, please correct.");
		} else {
		mysql_query($add_unit) or die("Cannot query the databse.<br>" . mysql_error());
		header("Location: service_display.php?year=$url_year&month=$url_month&day=$url_day");
		}
	}
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PCP Motorsports - Service Appointment Display</title>
<link href="service_style.css" type="text/css" rel="stylesheet" />
</head>
<?
$url_year = $_GET['year'];
$url_month = $_GET['month'];
$url_day = $_GET['day'];
?>
<body onLoad=window.setTimeout("location.href='<?php echo "service_display.php?year=" . $url_year . "&month=" . $url_month . "&day=" . $url_day; ?>'",10000)>
<?
#convert the link jan, to Jan for display
$str = $_GET['month'];
$a = substr($str, 0, 1);
$c = substr($str, 1);
$b = strtoupper($a);
?>
<table width="100%">
	<tr>
		<td valign="top" width="70%">
		<table width="100%">
			<tr><td align="center" width="100%" colspan="12" class="header">
			<? 
			
			echo $b.$c." ".$_GET['day']." ".$_GET['year']; ?></td></tr>
			<tr class="header">
				<td>Customer Name</td><td>Phone Number</td><td>Vehicle Type</td><td>Appt Date</td><td>Appt Time</td><td>Technician</td><td>Job Type</td><td>Tech Hours</td><td>Service Writer</td><td>Inspection / Service</td><td>Delete / Edit</td><td><a href="service_control.php">Add Unit</a></td>
			</tr>
			<tr>
				<td>
				<?
				switch ($_GET['month']) {
					default: $Current_Month = date("01"); break;
					case 'feb': $Current_Month = date("02"); break;
					case 'mar': $Current_Month = date("03"); break;
					case 'apr': $Current_Month = date("04"); break;
					case 'may': $Current_Month = date("05"); break;
					case 'jun': $Current_Month = date("06"); break;
					case 'jul': $Current_Month = date("07"); break;
					case 'aug': $Current_Month = date("08"); break;
					case 'sep': $Current_Month = date("09"); break;
					case 'oct': $Current_Month = date("10"); break;
					case 'nov': $Current_Month = date("11"); break;
					case 'dec': $Current_Month = date("12"); break;
				}
				include "query.php";
				?>
				</td>
			</tr>
		</table>			
		</td>	
		<?
		// How many days are in the current month 
$Days_In_Month = cal_days_in_month(CAL_GREGORIAN, date("m"), $_GET['year']); 

// Gets the Current day, day with 1st 2nd etc, day name, year (2004), month, 
// month name 
$Current_Day = date("d"); 
$Current_Day_S = date("dS"); 
$Current_Day_Name = date("l"); 
$Current_Year = $_GET['year'];
#$Current_Year = date("Y"); 
$Current_Month_Name = date("F");

// Set the day names 
$Days_Array = array(); 
$Days_Array[] = "S"; 
$Days_Array[] = "M"; 
$Days_Array[] = "T"; 
$Days_Array[] = "W"; 
$Days_Array[] = "T"; 
$Days_Array[] = "F"; 
$Days_Array[] = "S"; 


// Get the offset of the first day of the month 
$First_Day_Of_Month = date("w", mktime(0, 0, 0, $Current_Month, 1, $Current_Year)); 

// For each of the Day Names, print em out 
$Day_Names = ""; 
foreach ($Days_Array as $x => $y) { 
    $Day_Names .= '<td align="center" width="14.28%">' . $y . '</td>'; 
} 

// Spacers for the offset of the first day of the month 
$Cal_Weeks_Days = ""; 
$i = $First_Day_Of_Month + 1; 
if ($First_Day_Of_Month != "0") { 
    $Cal_Weeks_Days .= '<td colspan="' . $First_Day_Of_Month . '"> </td>'; 
} 
// Cal Days - The first day is 1, default with PHP is 0, so lets set it to 1 
$Day_i = "1"; 
$ii = $i; 
for ($i; $i <= ($Days_In_Month + $First_Day_Of_Month) ;$i++) { 

    // If the current day is sunday, make sure a new row gets set 
    if ($ii == 8) { 
        $Cal_Weeks_Days .= "</tr><tr>"; 
        $ii = 1; 
    } 
    // Show the days. 
    $Cal_Weeks_Days .= "<td><a href=\"?year=$url_year&month=$url_month&day=$Day_i\">" . $Day_i . "</a></td>"; 

    // Increment the day number and the week day number (ii) 
    $Day_i++; 
    $ii++; 
} 

// Add end month spacers 
if ((8 - $ii) >= "1") { 
    $Cal_Weeks_Days .= '<td colspan="' . (8 - $ii) . '"> </td>'; 
} ?>	
		<td width="30%" valign="top">		
		<table align="center" cols="4">
			<tr>
				<td align="center"><a href="service_display.php?year=<? echo $_GET['year'] - 1; ?>">&laquo;</a></td><td align="center" colspan="2"><? echo $Current_Year; ?></td><td align="center"><a href="service_display.php?year=<? echo $_GET['year'] + 1; ?>">&raquo;</a></td>
			</tr>
			<tr>
				<?
				foreach ($months0 as $value) {
					$lowercase = strtolower($value);
					echo "<td><a href=\"service_display.php?year=". $_GET['year'] ."&month=$lowercase&day=".$_GET['day']."\">$value</a></td>";
				}
				?>				
			</tr>
			<tr>
				<?
				foreach ($months1 as $value) {
					$lowercase = strtolower($value);
					echo "<td><a href=\"service_display.php?year=". $_GET['year'] ."&month=$lowercase&day=".$_GET['day']."\">$value</a></td>";
				}
				?>
			</tr>
			<tr>
				<?
				foreach ($months2 as $value) {
					$lowercase = strtolower($value);
					echo "<td><a href=\"service_display.php?year=". $_GET['year'] ."&month=$lowercase&day=".$_GET['day']."\">$value</a></td>";
				}
				?>
			</tr>
		</table>		
		</td>
	</tr>
	<tr>
		<td width="70%" valign="top">
<!--
		<table width="100%">
			<tr class="header">
			<?
			/* 
			foreach ($techs as $value) {
				echo "<td>$value</td>";
			}
			*/
			?>
			</tr>
			<tr>
				<? #echo "<td>$hours_tech1[0]</td><td>$hours_tech2[0]</td><td>$hours_tech3[0]</td><td>$hours_tech4[0]</td><td>$hours_tech5[0]</td><td>$hours_tech6[0]</td><td>$hours_tech7[0]</td><td>$hours_tech8[0]</td><td>$hours_tech9[0]</td><td>$hours_tech10[0]</td>"; ?>
			</tr>
		</table>
-->
		</td>
		<td align="center" width="30%" valign="top">
<?
// Echo the HTML 
echo '
<table align=\"center\"> 
    <tr> 
        '.$Day_Names.' 
    </tr> 
	<tr> 
		'.$Cal_Weeks_Days.' 
	</tr> 
</table> 
';
?>
		</td>
	</tr>
</table>

	

</body>
</html>
<?
} //end else Line 54
?>