Revision: 1255
http://mrbs.svn.sourceforge.net/mrbs/?rev=1255&view=rev
Author: cimorrison
Date: 2009-11-11 13:15:13 +0000 (Wed, 11 Nov 2009)
Log Message:
-----------
Email notifications implemented on provisional booking rejection
Modified Paths:
--------------
mrbs/branches/provisional_bookings/web/del_entry.php
mrbs/branches/provisional_bookings/web/functions_mail.inc
mrbs/branches/provisional_bookings/web/lang.en
mrbs/branches/provisional_bookings/web/systemdefaults.inc.php
Modified: mrbs/branches/provisional_bookings/web/del_entry.php
===================================================================
--- mrbs/branches/provisional_bookings/web/del_entry.php 2009-11-11
12:20:17 UTC (rev 1254)
+++ mrbs/branches/provisional_bookings/web/del_entry.php 2009-11-11
13:15:13 UTC (rev 1255)
@@ -13,7 +13,14 @@
$id = get_form_var('id', 'int');
$series = get_form_var('series', 'int');
$returl = get_form_var('returl', 'string');
+$action = get_form_var('action', 'string');
+$note = get_form_var('note', 'string');
+if (!isset($note))
+{
+ $note = "";
+}
+
if (empty($returl))
{
switch ($default_view)
@@ -32,27 +39,52 @@
if (getAuthorised(1) && ($info = mrbsGetBookingInfo($id, FALSE, TRUE)))
{
- $day = strftime("%d", $info["start_time"]);
- $month = strftime("%m", $info["start_time"]);
- $year = strftime("%Y", $info["start_time"]);
- $area = mrbsGetRoomArea($info["room_id"]);
-
- if ($mail_settings['admin_on_delete'])
+ $user = getUserName();
+ // check that the user is allowed to delete this entry
+ if (isset($action) && ($action="reject"))
{
- require_once "functions_mail.inc";
- // Gather all fields values for use in emails.
- $mail_previous = getPreviousEntryData($id, $series);
+ $authorised = auth_can_confirm($user, $info['room_id']);
}
- sql_begin();
- $result = mrbsDelEntry(getUserName(), $id, $series, 1);
- sql_commit();
- if ($result)
+ else
{
- // Send a mail to the Administrator
- ($mail_settings['admin_on_delete']) ? $result =
notifyAdminOnDelete($mail_previous) : '';
- Header("Location: $returl");
- exit();
+ $authorised = getWritable($info['create_by'], $user);
}
+ if ($authorised)
+ {
+ $day = strftime("%d", $info["start_time"]);
+ $month = strftime("%m", $info["start_time"]);
+ $year = strftime("%Y", $info["start_time"]);
+ $area = mrbsGetRoomArea($info["room_id"]);
+
+ $notify_by_email = $mail_settings['admin_on_delete'] ||
$mail_settings['book_admin_on_provisional'];
+
+ if ($notify_by_email)
+ {
+ require_once "functions_mail.inc";
+ // Gather all fields values for use in emails.
+ $mail_previous = getPreviousEntryData($id, $series);
+ }
+ sql_begin();
+ $result = mrbsDelEntry(getUserName(), $id, $series, 1);
+ sql_commit();
+ if ($result)
+ {
+ // Send a mail to the Administrator
+ if ($notify_by_email)
+ {
+ if (isset($action) && ($action == "reject"))
+ {
+ $result = notifyAdminOnDelete($mail_previous, $action, $note);
+ }
+ else
+ {
+ $result = notifyAdminOnDelete($mail_previous);
+ }
+ }
+ Header("Location: $returl");
+ exit();
+ }
+ }
}
// If you got this far then we got an access denied.
Modified: mrbs/branches/provisional_bookings/web/functions_mail.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/functions_mail.inc 2009-11-11
12:20:17 UTC (rev 1254)
+++ mrbs/branches/provisional_bookings/web/functions_mail.inc 2009-11-11
13:15:13 UTC (rev 1255)
@@ -187,6 +187,9 @@
}
$recipients = array();
+ $cc = array();
+ $cc[] = $mail_settings['cc'];
+
$id_table = ($rep_type > 0) ? "rep" : "e";
($mail_settings['admin_on_bookings']) ? $recipients[] =
$mail_settings['recipients'] : '';
if ($mail_settings['area_admin_on_bookings'])
@@ -250,6 +253,13 @@
if ($mail_settings['booker'])
{
+ if ($action == "accept")
+ {
+ // Put the recipients on the cc line and the booker will go
+ // on the to line
+ $cc = array_merge($cc, $recipients);
+ $recipients = array();
+ }
if ('db' == $auth['type'])
{
/* It would be possible to move this query within the query in
@@ -297,6 +307,7 @@
return FALSE;
}
$recipient_list = get_address_list($recipients);
+ $cc_list = get_address_list($cc);
// set up the subject and body
switch ($action)
@@ -512,7 +523,7 @@
$subject,
$body,
get_mail_charset(),
- $mail_settings['cc']);
+ $cc_list);
return $result;
}
@@ -529,8 +540,15 @@
{
global $typel, $enable_periods, $auth, $tbl_users;
global $mail_settings;
- //
+
+ // Get any extra arguments
+ $action = (func_num_args() > 1) ? func_get_arg(1) : "delete";
+ $note = (func_num_args() > 2) ? func_get_arg(2) : "";
+
$recipients = array();
+ $cc = array();
+ $cc[] = $mail_settings['cc'];
+
($mail_settings['admin_on_bookings']) ? $recipients[] =
$mail_settings['recipients'] : '';
if ($mail_settings['area_admin_on_bookings'] &&
!empty($mail_previous['area_admin_email']))
{
@@ -542,6 +560,13 @@
}
if ($mail_settings['booker'])
{
+ if ($action == "reject")
+ {
+ // Put the recipients on the cc line and the booker will go
+ // on the to line
+ $cc = array_merge($cc, $recipients);
+ $recipients = array();
+ }
if ('db' == $auth['type'])
{
/* It would be possible to move this query within the query in
@@ -574,9 +599,22 @@
return FALSE;
}
$recipient_list = get_address_list($recipients);
- //
- $subject = get_mail_vocab("mail_subject_delete");
- $body = get_mail_vocab("mail_body_del_entry") . "\n\n";
+ $cc_list = get_address_list($cc);
+
+ // Set the subject and body
+ if ($action == "reject")
+ {
+ $subject = get_mail_vocab("mail_subject_rejected");
+ $body = get_mail_vocab("mail_body_rej_entry") . "\n\n";
+ $body .= get_mail_vocab("reason") . ': ';
+ $body .= convertToMailCharset($note) . "\n\n";
+ }
+ else
+ {
+ $subject = get_mail_vocab("mail_subject_delete");
+ $body = get_mail_vocab("mail_body_del_entry") . "\n\n";
+ }
+
// Displays deleted entry details
$body .= "\n" . get_mail_vocab("namebooker") . ': ';
$body .= convertToMailCharset($mail_previous['namebooker']) . "\n";
@@ -635,7 +673,7 @@
}
$body .= "\n";
// End of mail details
- $result = sendMail($recipient_list, $subject, $body, get_mail_charset(),
$mail_settings['cc']);
+ $result = sendMail($recipient_list, $subject, $body, get_mail_charset(),
$cc_list);
return $result;
}
Modified: mrbs/branches/provisional_bookings/web/lang.en
===================================================================
--- mrbs/branches/provisional_bookings/web/lang.en 2009-11-11 12:20:17 UTC
(rev 1254)
+++ mrbs/branches/provisional_bookings/web/lang.en 2009-11-11 13:15:13 UTC
(rev 1255)
@@ -139,6 +139,7 @@
$vocab["mail_body_del_entry"] = "An entry has been deleted, here are the
details:";
$vocab["mail_body_changed_entry"] = "An entry has been modified, here are the
details:";
$vocab["mail_subject_delete"] = "Entry deleted for $mrbs_company MRBS";
+$vocab["reason"] = "Reason";
// Authentication stuff
$vocab["accessdenied"] = "Access Denied";
Modified: mrbs/branches/provisional_bookings/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/provisional_bookings/web/systemdefaults.inc.php
2009-11-11 12:20:17 UTC (rev 1254)
+++ mrbs/branches/provisional_bookings/web/systemdefaults.inc.php
2009-11-11 13:15:13 UTC (rev 1255)
@@ -557,7 +557,7 @@
$mail_settings['room_admin_on_bookings'] = FALSE;
// Set to TRUE if you want the appropriate booking administrators to be emailed
-// when a provisional booking is created
+// when a provisional booking is created, accepted or rejected
$mail_settings['book_admin_on_provisional'] = FALSE;
// Set to TRUE if you want ADMIN to be notified when entries are deleted. Email
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits