forked from opendream/hotri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmbr_edit.php
106 lines (94 loc) · 3.79 KB
/
mbr_edit.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?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";
$restrictToMbrAuth = TRUE;
$nav = "edit";
$restrictInDemo = true;
require_once("../shared/logincheck.php");
require_once("../classes/Member.php");
require_once("../classes/MemberQuery.php");
require_once("../classes/DmQuery.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();
}
#****************************************************************************
#* Validate data
#****************************************************************************
$mbrid = $_POST["mbrid"];
$mbr = new Member();
$mbr->setMbrid($_POST["mbrid"]);
$mbr->setBarcodeNmbr($_POST["barcodeNmbr"]);
$_POST["barcodeNmbr"] = $mbr->getBarcodeNmbr();
$mbr->setLastChangeUserid($_SESSION["userid"]);
$mbr->setLastName($_POST["lastName"]);
$_POST["lastName"] = $mbr->getLastName();
$mbr->setFirstName($_POST["firstName"]);
$_POST["firstName"] = $mbr->getFirstName();
$mbr->setAddress($_POST["address"]);
$_POST["address"] = $mbr->getAddress();
$mbr->setHomePhone($_POST["homePhone"]);
$_POST["homePhone"] = $mbr->getHomePhone();
$mbr->setWorkPhone($_POST["workPhone"]);
$_POST["workPhone"] = $mbr->getWorkPhone();
$mbr->setEmail($_POST["email"]);
$_POST["email"] = $mbr->getEmail();
$mbr->setClassification($_POST["classification"]);
$mbr->setStatus($_POST["status"]);
$dmQ = new DmQuery();
$dmQ->connect();
$customFields = $dmQ->getAssoc('member_fields_dm');
$dmQ->close();
foreach ($customFields as $name => $title) {
if (isset($_REQUEST['custom_'.$name])) {
$mbr->setCustom($name, $_REQUEST['custom_'.$name]);
}
}
$validData = $mbr->validateData();
if (!$validData) {
$pageErrors["barcodeNmbr"] = $mbr->getBarcodeNmbrError();
$pageErrors["lastName"] = $mbr->getLastNameError();
$pageErrors["firstName"] = $mbr->getFirstNameError();
$pageErrors["status"] = $mbr->getStatusError();
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../circ/mbr_edit_form.php");
exit();
}
#**************************************************************************
#* Check for duplicate barcode number
#**************************************************************************
$mbrQ = new MemberQuery();
$mbrQ->connect();
$dupBarcode = $mbrQ->DupBarcode($mbr->getBarcodeNmbr(),$mbr->getMbrid());
if ($dupBarcode) {
$pageErrors["barcodeNmbr"] = $loc->getText("mbrDupBarcode",array("barcode"=>$mbr->getBarcodeNmbr()));
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../circ/mbr_edit_form.php");
exit();
}
#**************************************************************************
#* Update library member
#**************************************************************************
$mbrQ->update($mbr);
$mbrQ->updateActivity($mbrid);
$mbrQ->close();
#**************************************************************************
#* Destroy form values and errors
#**************************************************************************
unset($_SESSION["postVars"]);
unset($_SESSION["pageErrors"]);
$msg = $loc->getText("mbrEditSuccess");
header("Location: ../circ/mbr_view.php?mbrid=".U($mbr->getMbrid())."&reset=Y&msg=".U($msg));
exit();
?>