This repository was archived by the owner on Nov 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulkaction.php
More file actions
executable file
·154 lines (141 loc) · 8.63 KB
/
bulkaction.php
File metadata and controls
executable file
·154 lines (141 loc) · 8.63 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
//actions codes
//1 cancel (sends email)
//2 renew (sends email)
//3 received
//4 fill (sends email)
//5 not fill (send email)
//6 check item back in
$illsystemhost = $_SERVER["SERVER_NAME"];
// Connect to database
require '/var/www/seal_script/seal_db.inc';
require '/var/www/seal_script/seal_function.php';
$db = mysqli_connect($dbhost, $dbuser, $dbpass);
mysqli_select_db($db, $dbname);
$timestamp = date("Y-m-d H:i:s");
$todaydate = date("Y-m-d");
//only process if data was posted
if (isset($_POST['bulkaction'])) {
//set action variable
$action = $_POST['bulkaction'];
//pull the array of illids
$ids = array();
foreach ((array) $_POST['check_list'] as $id) {
echo "Processing ILL #" . $id . "<br>";
// Get title and request email and destination library
$sqlselect = "select requesterEMAIL,Title,Destination from `$sealSTAT` where illNUB='$id' LIMIT 1 ";
$result = mysqli_query($db, $sqlselect);
$row = mysqli_fetch_array($result);
$title = $row['Title'];
$requesterEMAIL = $row['requesterEMAIL'];
$destlib = $row['Destination'];
// Get the Destination Name
$GETLISTSQLDEST = "SELECT`Name`, `ill_email` FROM `$sealLIB` where loc like '$destlib' limit 1";
$resultdest = mysqli_query($db, $GETLISTSQLDEST);
while ($rowdest = mysqli_fetch_assoc($resultdest)) {
$destlib = $rowdest["Name"];
$destemail = $rowdest["ill_email"];
}
// In case the ill_email for the destination library is more than one, break it down to a comma for PHP mail
$destemailarray = explode(';', $destemail);
$destemail_to = implode(',', $destemailarray);
if ($action == 1) {
$sqlupdate = "UPDATE `$sealSTAT` SET `Fill` = '6' WHERE `illNUB` = '$id'";
if (mysqli_query($db, $sqlupdate)) {
echo "ILL #" . $id . " has been canceled<br>";
$headers = "From: Southeastern SEAL <donotreply@senylrc.org>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
// Setting up email notification
$message = "ILL request $id for $title has been canceled ";
// $to="spalding@senylrc.org";
$subject = "ILL Request Canceled ILL# $id ";
// SEND request an email to let them know the request will be filled
$message = preg_replace('/(?<!\r)\n/', "\r\n", $message);
$headers = preg_replace('/(?<!\r)\n/', "\r\n", $headers);
// mail has been sent to meg at seal for development
//$destemail_to="spalding@senylrc.org";
mail($destemail_to, $subject, $message, $headers, "-f donotreply@senylrc.org");
} else {
echo "<div style='color: red;>Bulk System error, request was not updated</div><br>";
} //end if checking mysql
} elseif ($action == 2) {
$sqlupdate = "UPDATE `$sealSTAT` SET `renewTimeStamp` = '" . $timestamp . "', `renewAccountRequester` = '" . $wholename . "' WHERE `illNUB` = '$id'";
if (mysqli_query($db, $sqlupdate)) {
echo "ILL #" . $id . " renewal request sent<br>";
// Message for the destination library
$messagedest = $field_your_institution . " has requested a renewal for ILL# " . $id . "<br>Title: " . $title . "<br><br>
<br>
How do you wish to answer the renewal? <a href='http://$illsystemhost/renew?num=$id&a=1' >Approved</a> <a href='http://$illsystemhost/renew?num=$id&a=2' >Deny</a>
<Br>
<hr style='width:200px;text-align:left;margin-left:0'>
<br> This is an automated message from the SEAL. Responses to this email will be sent back to Southeastern New York Library Resources Council staff. If you would like to contact the other library in this ILL transaction, email " . $reqemail . ".";
// Set email subject for renewal
$subject = "SEAL Renew Request: from " . $field_your_institution . " ILL# $id";
$subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
// SEND EMAIL to Detestation Library
$email_to = implode(',', $destemailarray);
$headers = "From: Southeastern SEAL <donotreply@senylrc.org>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$messagedest = preg_replace('/(?<!\r)\n/', "\r\n", $messagedest);
$headers = preg_replace('/(?<!\r)\n/', "\r\n", $headers);
// mail has been sent to meg at seal for development
//$destemail_to="spalding@senylrc.org";
mail($destemail_to, $subject, $messagedest, $headers, "-f donotreply@senylrc.org");
} else {
echo "<div style='color: red;>Bulk System error, request was not updated</div><br>";
} //end if checking mysql
} elseif ($action == 3) {
$sqlupdate = "UPDATE `$sealSTAT` SET `receiveTimeStamp` = '$timestamp', `receiveAccount` = '" . $wholename . "', `receiveDate` = '$todaydate' WHERE `illNUB` = '$id'";
if (mysqli_query($db, $sqlupdate)) {
echo "ILL #" . $id . " has been marked received<br>";
} else {
echo "<div style='color: red;>Bulk System error, request was not updated</div><br>";
} //end if checking mysql
} elseif ($action == 4) {
// this this is to retun an item
$sqlupdate = "UPDATE `$sealSTAT` SET `returnTimeStamp` = '$timestamp',`returnMethod` = '$returnmethod',`returnNote` = '$returnnote', `returnAccount` = '" . $wholename . "', `returnDate` = '$todaydate', `patronnote` = '' WHERE `illNUB` = '$id'";
if (mysqli_query($db, $sqlupdate)) {
echo "The requests has been marked return <br>";
} else {
echo "<div style='color: red;>Bulk System error, request was not updated</div><br>";
} //end if checking mysql
} elseif ($action == 5) {
$sqlupdate = "UPDATE `$sealSTAT` SET `emailsent` = '1', `Fill` = '0' WHERE `illNUB` = '$reqnumb'";
if (mysqli_query($db, $sqlupdate)) {
echo "ILL #" . $id . " has been marked not filled<br>";
$headers = "From: Southeastern SEAL <donotreply@senylrc.org>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$messagedest = preg_replace('/(?<!\r)\n/', "\r\n", $messagedest);
$headers = preg_replace('/(?<!\r)\n/', "\r\n", $headers);
$message = "Your ILL request $id for $title can not be filled by $destlib.<br>" .
"<br><br>$respnote<br><br> <a href='http://" . $illsystemhost . "'>Would you like to try a different library</a>?";
// Setup php email headers
$to = $requesterEMAIL;
$subject = "ILL Request Not Filled ILL# $id ";
// SEND requester an email to let them know the request will be filled
$message = preg_replace('/(?<!\r)\n/', "\r\n", $message);
$headers = preg_replace('/(?<!\r)\n/', "\r\n", $headers);
// mail has been sent to meg at seal for development
//$to="spalding@senylrc.org";
mail($to, $subject, $message, $headers, "-f donotreply@senylrc.org");
} else {
echo "<div style='color: red;'>Bulk System error, request was not updated</div><br>";
} //end if checking mysql
} elseif ($action == 6) {
$sqlupdate = "UPDATE `$sealSTAT` SET `checkinTimeStamp` = '$timestamp', `checkinAccount` = '" . $wholename . "' WHERE `illNUB` = '$reqnumb'";
if (mysqli_query($db, $sqlupdate)) {
echo "ILL #" . $id . " has been marked checked in<br>";
} else {
echo "<div style='color: red;'>Bulk System error, request was not updated</div><br>";
} //end if checking mysql
} else {
echo "<div style='color: red;'>Unknown action, please report this error to system admin</div><br>";
echo "<div style='color: red;'>Action was " . $action . "</div><br>";
} //end if checking for actions
} //end foreach loop
} else {
echo "<div style='color: red;'>Please go back to your profile and submit a bulk action through the interface</div><br>";
}//end if check if action was posted