316 lines
10 KiB
PHP
316 lines
10 KiB
PHP
|
<?php
|
||
|
|
||
|
|
||
|
/*
|
||
|
|
||
|
Copyright 2018 Murray Hayes
|
||
|
|
||
|
Redistribution and use in source and binary forms, with or without
|
||
|
modification, are permitted provided that the following conditions
|
||
|
are met:
|
||
|
|
||
|
1. Redistributions of source code must retain the above copyright
|
||
|
notice, this list of conditions and the following disclaimer.
|
||
|
|
||
|
2. Redistributions in binary form must reproduce the above copyright
|
||
|
notice, this list of conditions and the following disclaimer in the
|
||
|
documentation and/or other materials provided with the distribution.
|
||
|
|
||
|
3. Neither the name of the copyright holder nor the names of its
|
||
|
contributors may be used to endorse or promote products derived from
|
||
|
this software without specific prior written permission.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||
|
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||
|
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||
|
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
|
POSSIBILITY OF SUCH DAMAGE.
|
||
|
|
||
|
*/
|
||
|
|
||
|
|
||
|
session_start();
|
||
|
|
||
|
include_once "utils.php";
|
||
|
include_once "DOMUtils.php";
|
||
|
include_once "consts.php";
|
||
|
include_once "database.php";
|
||
|
include_once "adminUtils.php";
|
||
|
include_once "formUtils.php";
|
||
|
|
||
|
$doc = returnDoc();
|
||
|
$root = returnRoot($doc);
|
||
|
|
||
|
$transactionInsite = null;
|
||
|
|
||
|
//if (!isset($_SESSION['login']) || !isset($_SESSION['MemberID']))
|
||
|
if (!validateSession())
|
||
|
if (!isset($_SESSION['cookieMonster']))
|
||
|
generateCookieMonster();
|
||
|
else
|
||
|
generateLoginRedirect();
|
||
|
else
|
||
|
if (($_SESSION['login'] === TRUE) && returnAdminStatus($_SESSION['MemberID']))
|
||
|
{
|
||
|
$targetMemberID = 0;
|
||
|
$targetTransactionID = NULL;
|
||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST')
|
||
|
{
|
||
|
/*
|
||
|
* Process form data.
|
||
|
*/
|
||
|
//print_r ($_POST);
|
||
|
|
||
|
if (isset($_POST['selectedmember']))
|
||
|
{
|
||
|
$targetMemberID = $_POST['selectedmember'];
|
||
|
}
|
||
|
else
|
||
|
if (isset($_POST['id']))
|
||
|
{
|
||
|
if ($_POST['id'] === '0')
|
||
|
{
|
||
|
/*
|
||
|
* Insert
|
||
|
*/
|
||
|
insertIntoTransactionTable();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
updateTransactionTable();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ($_SERVER['REQUEST_METHOD'] == 'GET')
|
||
|
{
|
||
|
if (isset($_GET['member']))
|
||
|
{
|
||
|
$targetMemberID = $_GET['member'];
|
||
|
$targetTransactionID = $_GET['id'];
|
||
|
}
|
||
|
}
|
||
|
$root = $doc->appendChild($root);
|
||
|
$root->appendChild(generateHead($doc));
|
||
|
|
||
|
$body = $doc->createElement('body');
|
||
|
$root->appendChild($body);
|
||
|
|
||
|
$body->appendChild(generateMastHead($doc, $baseDir));
|
||
|
|
||
|
//$body->appendChild($doc->createElement('hr'));
|
||
|
/*
|
||
|
$body->appendChild(generateMemberNavigationBar($doc));
|
||
|
$body->appendChild(generateAdminNavigationBar($doc));
|
||
|
*/
|
||
|
|
||
|
$_SESSION['subNav'] = 1;
|
||
|
$body->appendChild(generateSelectedMenuBar($doc, 1));
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
* Insert content here.
|
||
|
*/
|
||
|
|
||
|
if (isset($_GET['id']))
|
||
|
{
|
||
|
$id = cleanInput($_GET['id']);
|
||
|
if (is_numeric($id))
|
||
|
{
|
||
|
$id = (int) $id;
|
||
|
$body->appendChild(generateTransactionDetail($doc, $id));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$body->appendChild(generateTransactionEditorForm($doc, $targetMemberID, $targetTransactionID));
|
||
|
|
||
|
$bodyDiv = $doc->createElement('div');
|
||
|
$tableDiv = $doc->createElement('div');
|
||
|
|
||
|
$tableDiv->appendChild(generateMemberLookupForm($doc, 'transactionEditor.php'));
|
||
|
|
||
|
/* if (!isset($_SESSION['TargetMemberID']))
|
||
|
$_SESSION['TargetMemberID'] = 0;*/
|
||
|
|
||
|
$tableDiv->appendChild(generateTransactionTable($doc, $targetMemberID));
|
||
|
|
||
|
$bodyDiv->appendChild($tableDiv);
|
||
|
/*
|
||
|
$editorDiv = $doc->createElement('div');
|
||
|
$editorDiv->setAttribute('id', 'MemberEditorDiv');
|
||
|
$form = $doc->createElement('form');
|
||
|
$form->setAttribute('action', 'transactionEditor.php');
|
||
|
$form->setAttribute('method', 'post');
|
||
|
$label = $doc->createElement('H3');
|
||
|
$label->appendChild($doc->createTextNode("Transaction Editor"));
|
||
|
$form->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('input');
|
||
|
$label->setAttribute('type', 'hidden');
|
||
|
$label->setAttribute('name', 'id');
|
||
|
$label->setAttribute('readonly', 'readonly');
|
||
|
$form->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('input');
|
||
|
$label->setAttribute('type', 'hidden');
|
||
|
$label->setAttribute('name', 'first_name');
|
||
|
$label->setAttribute('readonly', 'readonly');
|
||
|
$form->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('input');
|
||
|
$label->setAttribute('type', 'hidden');
|
||
|
$label->setAttribute('name', 'last_name');
|
||
|
$label->setAttribute('readonly', 'readonly');
|
||
|
$form->appendChild($label);
|
||
|
|
||
|
$fieldSet = $doc->createElement('fieldset');
|
||
|
//$fieldSet->setAttribute('style', 'width:200px; max-width:300px;'); //margin-top:0.5em;');
|
||
|
$fieldSetDiv = $doc->createElement('div');
|
||
|
|
||
|
$label = $doc->createElement('label', 'Member ID:');
|
||
|
$label->setAttribute('for', 'member_id');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'number');
|
||
|
$input->setAttribute('name', 'member_id');
|
||
|
if ($targetMemberID > 0)
|
||
|
{
|
||
|
$input->setAttribute('value', "$targetMemberID");
|
||
|
$input->setAttribute('readonly', 'readonly');
|
||
|
}
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Price:');
|
||
|
$label->setAttribute('for', 'total_price');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'number');
|
||
|
$input->setAttribute('name', 'total_price');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Reference:');
|
||
|
$label->setAttribute('for', 'reference_number');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'number');
|
||
|
$input->setAttribute('name', 'reference_number');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Quantity:');
|
||
|
$label->setAttribute('for', 'quantity');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'number');
|
||
|
$input->setAttribute('name', 'quantity');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Category:');
|
||
|
$label->setAttribute('for', 'category');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'text');
|
||
|
$input->setAttribute('name', 'category');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Account Type:');
|
||
|
$label->setAttribute('for', 'account_type');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'text');
|
||
|
$input->setAttribute('name', 'account_type');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Info-Source:');
|
||
|
$label->setAttribute('for', 'info_source');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'text');
|
||
|
$input->setAttribute('name', 'info_source');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Months Added:');
|
||
|
$label->setAttribute('for', 'months_added');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'number');
|
||
|
$input->setAttribute('name', 'months_added');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$label = $doc->createElement('label', 'Memo:');
|
||
|
$label->setAttribute('for', 'memo');
|
||
|
$label->setAttribute('class', 'MemberEditorInputLabel');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'text');
|
||
|
$input->setAttribute('name', 'memo');
|
||
|
$input->setAttribute('autocomplete', 'off');
|
||
|
$fieldSetDiv->appendChild($input);
|
||
|
$label = $doc->createElement('br');
|
||
|
$fieldSetDiv->appendChild($label);
|
||
|
|
||
|
$fieldSet->appendChild($fieldSetDiv);
|
||
|
|
||
|
$form->appendChild($fieldSet);
|
||
|
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'reset');
|
||
|
$form->appendChild($input);
|
||
|
|
||
|
$input = $doc->createElement('input');
|
||
|
$input->setAttribute('type', 'submit');
|
||
|
$form->appendChild($input);
|
||
|
$editorDiv->appendChild($form);
|
||
|
|
||
|
*/
|
||
|
|
||
|
|
||
|
$body->appendChild($bodyDiv);
|
||
|
|
||
|
$body->appendChild(generateFooter($doc));
|
||
|
|
||
|
outputDoc($doc);
|
||
|
}
|
||
|
else
|
||
|
generateIndexRedirect();
|
||
|
|
||
|
?>
|