mirror of
https://github.com/fspc/biketree.git
synced 2026-09-16 14:31:36 -04:00
First commit of biketree to github!
This commit is contained in:
Executable
+101
@@ -0,0 +1,101 @@
|
||||
<?php session_start(); ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
||||
include ("../../settings.php");
|
||||
include ("../../language/$cfg_language");
|
||||
include ("../../classes/db_functions.php");
|
||||
include ("../../classes/security_functions.php");
|
||||
include ("../../classes/form.php");
|
||||
include ("../../classes/display.php");
|
||||
|
||||
$lang=new language();
|
||||
$dbf=new db_functions($cfg_server,$cfg_username,$cfg_password,$cfg_database,$cfg_tableprefix,$cfg_theme,$lang);
|
||||
$sec=new security_functions($dbf,'Admin',$lang);
|
||||
$display= new display($dbf->conn,$cfg_theme,$cfg_currency_symbol,$lang);
|
||||
|
||||
if(!$sec->isLoggedIn())
|
||||
{
|
||||
header ("location: ../../login.php");
|
||||
exit();
|
||||
}
|
||||
//set default values, these will change if $action==update.
|
||||
$item_id_value='';
|
||||
$percent_off_value='';
|
||||
$comment_value='';
|
||||
$id=-1;
|
||||
|
||||
//decides if the form will be used to update or add a user.
|
||||
if(isset($_GET['action']))
|
||||
{
|
||||
$action=$_GET['action'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$action="insert";
|
||||
}
|
||||
|
||||
//if action is update, sets variables to what the current users data is.
|
||||
if($action=="update")
|
||||
{
|
||||
$display->displayTitle("$lang->updateDiscount");
|
||||
|
||||
if(isset($_GET['id']))
|
||||
{
|
||||
$id=$_GET['id'];
|
||||
$tablename = "$cfg_tableprefix".'discounts';
|
||||
$result = mysql_query("SELECT * FROM $tablename WHERE id=\"$id\"",$dbf->conn);
|
||||
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$item_id_value=$row['item_id'];
|
||||
$percent_off_value=$row['percent_off'];
|
||||
$comment_value=$row['comment'];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$display->displayTitle("$lang->addDiscount");
|
||||
|
||||
}
|
||||
//creates a form object
|
||||
$f1=new form('process_form_discounts.php','POST','discounts','300',$cfg_theme,$lang);
|
||||
|
||||
//creates form parts.
|
||||
$itemtable = "$cfg_tableprefix".'items';
|
||||
|
||||
$item_option_titles=$dbf->getAllElements("$itemtable",'item_name','item_name');
|
||||
$item_option_titles[0] = $dbf->idToField("$itemtable",'item_name',"$item_id_value");
|
||||
$item_option_values=$dbf->getAllElements("$itemtable",'id','item_name');
|
||||
$item_option_values[0] = $item_id_value;
|
||||
|
||||
$f1->createSelectField("<b>$lang->itemName:</b>",'item_id',$item_option_values,$item_option_titles,'160');
|
||||
|
||||
$f1->createInputField("<b>$lang->percentOff: (%)</b> ",'text','percent_off',"$percent_off_value",'24','150');
|
||||
$f1->createInputField("$lang->comment: ",'text','comment',"$comment_value",'24','150');
|
||||
|
||||
|
||||
|
||||
//sends 2 hidden varibles needed for process_form_discounts.php.
|
||||
echo "
|
||||
<input type='hidden' name='action' value='$action'>
|
||||
<input type='hidden' name='id' value='$id'>";
|
||||
$f1->endForm();
|
||||
|
||||
$dbf->closeDBlink();
|
||||
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
<?php session_start(); ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<SCRIPT LANGUAGE="Javascript">
|
||||
<!---
|
||||
function decision(message, url)
|
||||
{
|
||||
if(confirm(message) )
|
||||
{
|
||||
location.href = url;
|
||||
}
|
||||
}
|
||||
// --->
|
||||
</SCRIPT>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
||||
include ("../../settings.php");
|
||||
include ("../../language/$cfg_language");
|
||||
include ("../../classes/db_functions.php");
|
||||
include ("../../classes/security_functions.php");
|
||||
include ("../../classes/display.php");
|
||||
include ("../../classes/form.php");
|
||||
|
||||
$lang=new language();
|
||||
$dbf=new db_functions($cfg_server,$cfg_username,$cfg_password,$cfg_database,$cfg_tableprefix,$cfg_theme,$lang);
|
||||
$sec=new security_functions($dbf,'Admin',$lang);
|
||||
|
||||
if(!$sec->isLoggedIn())
|
||||
{
|
||||
header ("location: ../../login.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
$display=new display($dbf->conn,$cfg_theme,$cfg_currency_symbol,$lang);
|
||||
$display->displayTitle("$lang->manageDiscounts");
|
||||
|
||||
$f1=new form('manage_discounts.php','POST','discounts','475',$cfg_theme,$lang);
|
||||
$f1->createInputField("<b>$lang->searchForDiscount</b>",'text','search','','24','375');
|
||||
$f1->endForm();
|
||||
|
||||
$tableheaders=array("$lang->rowID","$lang->itemName","$lang->percentOff","$lang->comment","$lang->updateDiscount","$lang->deleteDiscount");
|
||||
$tablefields=array('id','item_id','percent_off','comment');
|
||||
|
||||
if(isset($_POST['search']))
|
||||
{
|
||||
$search=$_POST['search'];
|
||||
echo "<center>$lang->searchedForDiscount: <b>$search</b></center>";
|
||||
$display->displayManageTable("$cfg_tableprefix",'discounts',$tableheaders,$tablefields,'percent_off',"$search",'percent_off');
|
||||
}
|
||||
else
|
||||
{
|
||||
$display->displayManageTable("$cfg_tableprefix",'discounts',$tableheaders,$tablefields,'','','percent_off');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dbf->closeDBlink();
|
||||
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+108
@@ -0,0 +1,108 @@
|
||||
<?php session_start(); ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
||||
include ("../../settings.php");
|
||||
include ("../../language/$cfg_language");
|
||||
include ("../../classes/db_functions.php");
|
||||
include ("../../classes/security_functions.php");
|
||||
|
||||
//creates 2 objects needed for this script.
|
||||
$lang=new language();
|
||||
$dbf=new db_functions($cfg_server,$cfg_username,$cfg_password,$cfg_database,$cfg_tableprefix,$cfg_theme,$lang);
|
||||
$sec=new security_functions($dbf,'Admin',$lang);
|
||||
|
||||
//checks if user is logged in.
|
||||
if(!$sec->isLoggedIn())
|
||||
{
|
||||
header ("location: ../../login.php");
|
||||
exit ();
|
||||
}
|
||||
|
||||
//variables needed globably in this file.
|
||||
$tablename="$cfg_tableprefix".'discounts';
|
||||
$field_names=null;
|
||||
$field_data=null;
|
||||
$id=-1;
|
||||
|
||||
|
||||
|
||||
//checks to see if action is delete and an ID is specified. (only delete uses $_GET.)
|
||||
if(isset($_GET['action']) and isset($_GET['id']))
|
||||
{
|
||||
$action=$_GET['action'];
|
||||
$id=$_GET['id'];
|
||||
}
|
||||
//checks to make sure data is comming from form ($action is either delete or update)
|
||||
elseif(isset($_POST['item_id']) and isset($_POST['percent_off']) and isset($_POST['comment']) and isset($_POST['id']) and isset($_POST['action']) )
|
||||
{
|
||||
|
||||
$action=$_POST['action'];
|
||||
$id = $_POST['id'];
|
||||
|
||||
//gets variables entered by user.
|
||||
$item_id=$_POST['item_id'];
|
||||
$percent_off=$_POST['percent_off'];
|
||||
$comment=$_POST['comment'];
|
||||
|
||||
|
||||
//insure all fields are filled in.
|
||||
if($item_id=='' or $percent_off=='')
|
||||
{
|
||||
echo "$lang->forgottenFields";
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$field_names=array('item_id','percent_off','comment');
|
||||
$field_data=array("$item_id","$percent_off","$comment");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//outputs error message because user did not use form to fill out data.
|
||||
echo "$lang->mustUseForm";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
//finds out what action needs to be taken and preforms it by calling methods from dbf class.
|
||||
case $action=="insert":
|
||||
$dbf->insert($field_names,$field_data,$tablename,true);
|
||||
|
||||
break;
|
||||
|
||||
case $action=="update":
|
||||
$dbf->update($field_names,$field_data,$tablename,$id,true);
|
||||
|
||||
break;
|
||||
|
||||
case $action=="delete":
|
||||
$dbf->deleteRow($tablename,$id);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "$lang->noActionSpecified";
|
||||
break;
|
||||
}
|
||||
$dbf->closeDBlink();
|
||||
|
||||
?>
|
||||
<br>
|
||||
<a href="manage_discounts.php"><?php echo $lang->manageDiscounts ?>--></a>
|
||||
<br>
|
||||
<a href="form_discounts.php?action=insert"><?php echo $lang->discountAnItem ?>--></a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user