forked from opendream/hotri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mbr_transaction.php
84 lines (75 loc) · 2.99 KB
/
mbr_transaction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/* This file is part of a copyrighted work; it is distributed with NO WARRANTY.
* See the file COPYRIGHT.html for more details.
*/
require_once("../shared/common.php");
$tab = "circulation";
$nav = "account";
$restrictInDemo = true;
require_once("../shared/logincheck.php");
require_once("../classes/MemberAccountTransaction.php");
require_once("../classes/MemberAccountQuery.php");
require_once("../functions/errorFuncs.php");
require_once("../classes/Localize.php");
$loc = new Localize(OBIB_LOCALE,$tab);
#****************************************************************************
#* Checking for post vars. Go back to form if none found.
#****************************************************************************
if (count($_POST) == 0) {
header("Location: ../circ/index.php");
exit();
}
#****************************************************************************
#* Retrieving get var
#****************************************************************************
$mbrid = $_POST["mbrid"];
#****************************************************************************
#* Validate data
#****************************************************************************
$trans = new MemberAccountTransaction();
$trans->setMbrid($mbrid);
$trans->setCreateUserid($_SESSION["userid"]);
$trans->setTransactionTypeCd($_POST["transactionTypeCd"]);
$_POST["transactionTypeCd"] = $trans->getTransactionTypeCd();
$trans->setAmount($_POST["amount"]);
$_POST["amount"] = $trans->getAmount();
$trans->setDescription($_POST["description"]);
$_POST["description"] = $trans->getDescription();
$validData = $trans->validateData();
if (!$validData) {
$pageErrors["amount"] = $trans->getAmountError();
$pageErrors["description"] = $trans->getDescriptionError();
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../circ/mbr_account.php?mbrid=".U($mbrid));
exit();
}
#**************************************************************************
#* Insert new member transaction
#**************************************************************************
$transQ = new MemberAccountQuery();
$transQ->connect();
if ($transQ->errorOccurred()) {
$transQ->close();
displayErrorPage($transQ);
}
$trans = $transQ->insert($trans);
if ($transQ->errorOccurred()) {
$transQ->close();
displayErrorPage($transQ);
}
$transQ->close();
require_once('../classes/MemberQuery.php');
$mbrQ = new MemberQuery;
$mbrQ->connect();
$mbrQ->updateActivity($mbrid);
$mbrQ->close();
#**************************************************************************
#* Destroy form values and errors
#**************************************************************************
unset($_SESSION["postVars"]);
unset($_SESSION["pageErrors"]);
$msg = $loc->getText("mbrTransactionSuccess");
header("Location: ../circ/mbr_account.php?mbrid=".U($mbrid)."&reset=Y&msg=".U($msg));
exit();
?>