[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11414] bkbooking: stavanger added mail message to us
From: |
Kjell Arne Espedal |
Subject: |
[Fmsystem-commits] [11414] bkbooking: stavanger added mail message to users of building if a booking or application is canceled |
Date: |
Thu, 31 Oct 2013 13:30:41 +0000 |
Revision: 11414
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11414
Author: kjell
Date: 2013-10-31 13:30:38 +0000 (Thu, 31 Oct 2013)
Log Message:
-----------
bkbooking: stavanger added mail message to users of building if a booking or
application is canceled
Modified Paths:
--------------
branches/stavangerkommune/booking/inc/class.boallocation.inc.php
branches/stavangerkommune/booking/inc/class.bobooking.inc.php
branches/stavangerkommune/booking/inc/class.sobooking.inc.php
branches/stavangerkommune/booking/setup/phpgw_no.lang
branches/stavangerkommune/booking/templates/base/event_mail_settings.xsl
branches/stavangerkommune/booking/templates/base/mail_settings.xsl
branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php
branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php
branches/stavangerkommune/bookingfrontend/setup/phpgw_no.lang
Modified: branches/stavangerkommune/booking/inc/class.boallocation.inc.php
===================================================================
--- branches/stavangerkommune/booking/inc/class.boallocation.inc.php
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/booking/inc/class.boallocation.inc.php
2013-10-31 13:30:38 UTC (rev 11414)
@@ -10,6 +10,83 @@
}
/**
+ * @ Send message about cancelation to users of building.
+ */
+ function send_notification($allocation, $maildata,
$mailadresses)
+ {
+ if
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+ return;
+ $send = CreateObject('phpgwapi.send');
+
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+ echo "<pre>\n";
+ if($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on')
+ {
+ $res_names = '';
+ foreach ($allocation['resources'] as $res) {
+ $res_names =
$res_names.$this->so->get_resource($res)." ";
+ }
+ $info_deleted = ':<p>';
+ $info_deleted = $info_deleted."".$res_names." -
";
+ $info_deleted .= pretty_timestamp($allocation['from_'])." - ";
+ $info_deleted .= pretty_timestamp($allocation['to_']);
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
+ $link .=
urlencode($allocation['from_']).'&to_[]='.urlencode($allocation['to_']).'&resource='.$allocation['resources'][0];
+ $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>".$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />'.$allocation['organization_name'].' har
avbestilt tid i '.$allocation['building_name'];
+ $body .= $info_deleted.'</p>';
+
+ } else {
+ $res_names = '';
+ foreach ($allocation['resources'] as $res) {
+ $res_names =
$res_names.$this->so->get_resource($res)." ";
+ }
+ $info_deleted = ':<p>';
+ foreach ($maildata['delete'] as $valid_date) {
+ $info_deleted =
$info_deleted."".$res_names." - ";
+ $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
+ $info_deleted .= pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
+ $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$allocation['resources'][0];
+ $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ }
+
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>".$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />'.$allocation['organization_name'].' har
avbestilt tid i '.$allocation['building_name'];
+ $body .= $info_deleted.'</p>';
+
+ }
+
+
+ $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
+
+ foreach ($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject, $body,
'', '', '', $from, '', 'html');
+ }
+ catch (phpmailerException $e)
+ {
+ // TODO: Inform user if something goes wrong
+ }
+ }
+
+ }
+
+ /**
* @see bocommon_authorized
*/
protected function include_subject_parent_roles(array
$for_object = null)
Modified: branches/stavangerkommune/booking/inc/class.bobooking.inc.php
===================================================================
--- branches/stavangerkommune/booking/inc/class.bobooking.inc.php
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/booking/inc/class.bobooking.inc.php
2013-10-31 13:30:38 UTC (rev 11414)
@@ -29,8 +29,131 @@
$this->event_so = CreateObject('booking.soevent');
$this->season_bo = CreateObject('booking.boseason');
}
-
+
/**
+ * @ Send message about cancelation to users of building.
+ */
+ function send_notification($booking, $allocation, $maildata,
$mailadresses, $valid_dates=null)
+ {
+ if
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) &&
$GLOBALS['phpgw_info']['server']['smtp_server']))
+ return;
+ $send = CreateObject('phpgwapi.send');
+
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+
+ $from = isset($config->config_data['email_sender']) &&
$config->config_data['email_sender'] ? $config->config_data['email_sender'] :
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+ $external_site_address =
isset($config->config_data['external_site_address']) &&
$config->config_data['external_site_address'] ?
$config->config_data['external_site_address'] :
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+
+ if(($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on' && $maildata['delete_allocation'] != 'on') ||
+ ($maildata['outseason'] != 'on' && $maildata['recurring'] !=
'on' && $maildata['delete_allocation'] == 'on' &&
+ $maildata['allocation'] == 0))
+ {
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+ $link .=
urlencode($booking['from_']).'&to_[]='.urlencode($booking['to_']).'&resource='.$booking['resources'][0];
+
+ $subject =
$config->config_data['booking_canceled_mail_subject'];
+
+ $body = "<p>".$config->config_data['booking_canceled_mail'];
+ $body .= '</p><p>'.$booking['group_name'].' har avbestilt tid
i '.$booking['building_name'].':<br />';
+ $body .= $this->so->get_resource($booking['resources'][0]).'
den '.pretty_timestamp($booking['from_']);
+ $body .=' til '.pretty_timestamp($booking['to_']);
+ $body .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a></p>';
+
+ } elseif (($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on') {
+ $res_names = '';
+ foreach ($booking['resources'] as $res) {
+ $res_names =
$res_names.$this->so->get_resource($res)." ";
+ }
+ $info_deleted = ':<p>';
+ foreach ($valid_dates as $valid_date) {
+ $info_deleted = $info_deleted."".$res_names." -
";
+ $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
+ $info_deleted .= pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+ $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+ $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ }
+
+ $subject =
$config->config_data['booking_canceled_mail_subject'];
+
+ $body = "<p>".$config->config_data['booking_canceled_mail'];
+ $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
+ $body .= $info_deleted.'</p>';
+
+ } elseif (($maildata['outseason'] == 'on' ||
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on') {
+ $res_names = '';
+ foreach ($booking['resources'] as $res) {
+ $res_names =
$res_names.$this->so->get_resource($res)." ";
+ }
+ $info_deleted = ':<p>';
+ foreach ($valid_dates as $valid_date) {
+ if (!in_array($valid_date,$maildata['delete'])) {
+ $info_deleted =
$info_deleted."".$res_names." - ";
+ $info_deleted .=
pretty_timestamp($valid_date['from_'])." - ";
+ $info_deleted .= pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+ $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+ $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply
for time').'</a><br />';
+ }
+ }
+ foreach ($maildata['delete'] as $valid_date) {
+ $info_deleted =
$info_deleted."".$res_names." - ";
+ $info_deleted .= pretty_timestamp($valid_date['from_'])."
- ";
+ $info_deleted .= pretty_timestamp($valid_date['to_']);
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+ $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+ $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+ }
+
+
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>".$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
+ $body .= $info_deleted.'</p>';
+
+ } else {
+ $res_names = '';
+ foreach ($booking['resources'] as $res) {
+ $res_names =
$res_names.$this->so->get_resource($res)." ";
+ }
+ $info_deleted = ':<p>';
+ $info_deleted = $info_deleted."".$res_names." -
";
+ $info_deleted .= pretty_timestamp($allocation['from_'])." - ";
+ $info_deleted .= pretty_timestamp($allocation['to_']);
+ $link =
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+ $link .=
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+ $link .=
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+ $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for
time').'</a><br />';
+
+ $subject =
$config->config_data['allocation_canceled_mail_subject'];
+ $body = "<p>".$config->config_data['allocation_canceled_mail'];
+ $body .= '<br />'.$booking['group_name'].' har avbestilt tid i
'.$booking['building_name'];
+ $body .= $info_deleted.'</p>';
+ }
+
+ $body .=
"<p>".$config->config_data['application_mail_signature']."</p>";
+
+ foreach ($mailadresses as $adr)
+ {
+ try
+ {
+ $send->msg('email', $adr, $subject, $body,
'', '', '', $from, '', 'html');
+ }
+ catch (phpmailerException $e)
+ {
+ // TODO: Inform user if something goes wrong
+ }
+ }
+ }
+
+ /**
* @see bocommon_authorized
*/
protected function include_subject_parent_roles(array
$for_object = null)
Modified: branches/stavangerkommune/booking/inc/class.sobooking.inc.php
===================================================================
--- branches/stavangerkommune/booking/inc/class.sobooking.inc.php
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/booking/inc/class.sobooking.inc.php
2013-10-31 13:30:38 UTC (rev 11414)
@@ -444,6 +444,16 @@
return $this->db->f('name', false);
}
+ function get_groups_of_organization($grp_id)
+ {
+ $this->db->limit_query("select organization_id from
bb_group where id=($grp_id)", 0, __LINE__, __FILE__, 1);
+ if(!$this->db->next_record())
+ {
+ return False;
+ }
+ return $this->db->f('organization_id', false);
+ }
+
function get_resource($id)
{
$this->db->limit_query("SELECT name FROM bb_resource
where id=" . intval($id), 0, __LINE__, __FILE__, 1);
@@ -474,16 +484,32 @@
return $this->db->f('id', false);
}
- function get_group_of_organization($id)
+ public function get_group_contacts_of_organization($id)
{
$results = array();
- $this->db->query("SELECT id FROM bb_group WHERE active
= 1 and organization_id=". intval($id), __LINE__, __FILE__);
+ $sql = "SELECT
bb_group_contact.id,bb_group_contact.group_id,bb_group_contact.email FROM
bb_group,bb_group_contact WHERE bb_group.id=bb_group_contact.group_id AND
bb_group.active = 1 AND bb_group.organization_id=(".intval($id).")";
+ $this->db->query($sql, __LINE__, __FILE__);
while ($this->db->next_record())
{
- $results[] = $this->db->f('id', false);
+ $results[] = array('id' => $this->db->f('id',
false),
+ 'group_id' => $this->db->f('group_id',
false),
+ 'email' => $this->db->f('email', false));
}
return $results;
}
+ public function get_all_group_of_organization_from_groupid($id)
+ {
+ $results = array();
+ $sql = "SELECT
bb_group_contact.id,bb_group_contact.group_id,bb_group_contact.email FROM
bb_group,bb_group_contact WHERE bb_group.id=bb_group_contact.group_id AND
bb_group.active = 1 AND bb_group.organization_id=(select organization_id from
bb_group where id=(".intval($id)."))";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while ($this->db->next_record())
+ {
+ $results[] = array('id' => $this->db->f('id',
false),
+ 'group_id' => $this->db->f('group_id',
false),
+ 'email' => $this->db->f('email', false));
+ }
+ return $results;
+ }
function get_organizations()
{
Modified: branches/stavangerkommune/booking/setup/phpgw_no.lang
===================================================================
--- branches/stavangerkommune/booking/setup/phpgw_no.lang 2013-10-31
13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/booking/setup/phpgw_no.lang 2013-10-31
13:30:38 UTC (rev 11414)
@@ -632,4 +632,4 @@
Event Canceled Subject booking no E-post emne når arrangement avlyses
Mail for event canceled booking no E-post tekst når arrangement
avlyses
Extra kalendar for public opening times booking no Aktiver ekstra
kalender for publikumsbading
-
+Apply for time booking no Søk om tid
Modified:
branches/stavangerkommune/booking/templates/base/event_mail_settings.xsl
===================================================================
--- branches/stavangerkommune/booking/templates/base/event_mail_settings.xsl
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/booking/templates/base/event_mail_settings.xsl
2013-10-31 13:30:38 UTC (rev 11414)
@@ -57,7 +57,37 @@
<dd class="yui-skin-sam">
<textarea id="field_event_canceled_mail"
class="full-width settings" name="event_canceled_mail"
type="text"><xsl:value-of select="config_data/event_canceled_mail"/></textarea>
</dd>
+ </dl>
+ <div class="clr"/>
+ <dl class="form">
+ <dt class="heading"><xsl:value-of
select="php:function('lang', 'Cancel booking/allocation email settings')"/></dt>
+ </dl>
+ <dl class="form-col">
+ <dt><label for="field_booking_canceled_mail_subject"><xsl:value-of
select="php:function('lang', 'Booking Canceled Subject')"/></label></dt>
+ <dd>
+ <input id="field_booking_canceled_mail_subject"
name="booking_canceled_mail_subject" type="text" size="50">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/booking_canceled_mail_subject"/></xsl:attribute>
+ </input>
+ </dd>
+
+ <dt><label for="field_booking_canceled_mail"><xsl:value-of
select="php:function('lang', 'Mail for booking canceled')"/></label></dt>
+ <dd class="yui-skin-sam">
+ <textarea id="field_booking_canceled_mail"
class="full-width settings" name="booking_canceled_mail"
type="text"><xsl:value-of
select="config_data/booking_canceled_mail"/></textarea>
+ </dd>
+
+ <dt><label
for="field_allocation_canceled_mail_subject"><xsl:value-of
select="php:function('lang', 'Allocation Canceled Subject')"/></label></dt>
+ <dd>
+ <input
id="field_allocation_canceled_mail_subject"
name="allocation_canceled_mail_subject" type="text" size="50">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/allocation_canceled_mail_subject"/></xsl:attribute>
+ </input>
+ </dd>
+
+ <dt><label for="field_allocation_canceled_mail"><xsl:value-of
select="php:function('lang', 'Mail for allocation canceled')"/></label></dt>
+ <dd class="yui-skin-sam">
+ <textarea id="field_allocation_canceled_mail"
class="full-width settings" name="allocation_canceled_mail"
type="text"><xsl:value-of
select="config_data/allocation_canceled_mail"/></textarea>
+ </dd>
+
</dl>
<div class="form-buttons">
<input type="submit">
Modified: branches/stavangerkommune/booking/templates/base/mail_settings.xsl
===================================================================
--- branches/stavangerkommune/booking/templates/base/mail_settings.xsl
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/booking/templates/base/mail_settings.xsl
2013-10-31 13:30:38 UTC (rev 11414)
@@ -47,6 +47,7 @@
</dd>
</dl>
+
<div class="form-buttons">
<input type="submit">
<xsl:attribute name="value"><xsl:value-of
select="php:function('lang', 'Save')"/></xsl:attribute>
Modified:
branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php
===================================================================
--- branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php
2013-10-31 13:30:38 UTC (rev 11414)
@@ -16,7 +16,43 @@
$this->resource_bo = CreateObject('booking.boresource');
$this->building_bo = CreateObject('booking.bobuilding');
$this->system_message_bo =
CreateObject('booking.bosystem_message');
+ $this->organization_bo =
CreateObject('booking.boorganization');
+ $this->booking_bo = CreateObject('booking.bobooking');
+ }
+
+ public function building_users($building_id, $organization_id) {
+
+ $contacts = array();
+# $building = $this->building_bo->so->read_single($building_id);
+
+ $organizations =
$this->organization_bo->find_building_users($building_id);
+ foreach($organizations['results'] as $org)
+ {
+ if ($org['email'] != '' && strstr($org['email'], '@')) {
+ if (!in_array($org['email'], $contacts)) {
+ $contacts[] = $org['email'];
+ }
+ }
+ if ($org['contacts'][0]['email'] != '' &&
strstr($org['contacts'][0]['email'], '@')) {
+ if (!in_array($org['contacts'][0]['email'], $contacts)) {
+ $contacts[] = $org['contacts'][0]['email'];
+ }
+ }
+ if ($org['contacts'][1]['email'] != '' &&
strstr($org['contacts'][1]['email'], '@')) {
+ if (!in_array($org['contacts'][1]['email'], $contacts)) {
+ $contacts[] = $org['contacts'][1]['email'];
+ }
+ }
+ $grp_con =
$this->booking_bo->so->get_group_contacts_of_organization($org['id']);
+ foreach ($grp_con as $grp) {
+ if (!in_array($grp['email'], $contacts) &&
strstr($grp['email'], '@')) {
+ $contacts[] = $grp['email'];
+ }
+ }
+ }
+ return $contacts;
}
+
public function cancel()
{
$config = CreateObject('phpgwapi.config','booking');
@@ -81,6 +117,14 @@
$invalid_dates = array();
$valid_dates = array();
+ $mailadresses =
$this->building_users($allocation['building_id'],$allocation['organization_id']);
+
+ $maildata = array();
+ $maildata['outseason'] = $outseason;
+ $maildata['recurring'] = $recurring;
+ $maildata['repeat_until'] = $field_until;
+ $maildata['field_interval'] = $field_interval;
+
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$from_date = $_POST['from_'];
@@ -116,6 +160,7 @@
$system_message['message'] =
$system_message['message']."<br />".$info_deleted;
$receipt =
$this->system_message_bo->add($system_message);
+ $this->bo->send_notification($allocation,
$maildata, $mailadresses);
$err = $this->bo->so->delete_allocation($id);
$this->redirect(array('menuaction' =>
'bookingfrontend.uibuilding.schedule', 'id'=>$allocation['building_id']));
}
@@ -174,6 +219,12 @@
}
if ($step == 3)
{
+ $maildata = array();
+ $maildata['outseason'] =
phpgw::get_var('outseason','GET');
+ $maildata['recurring'] =
phpgw::get_var('recurring', 'GET');
+ $maildata['repeat_until'] =
phpgw::get_var('repeat_until', 'GET');
+ $maildata['delete'] =
$valid_dates;
+
$res_names = '';
date_default_timezone_set("Europe/Oslo");
$date = new
DateTime(phpgw::get_var('date'));
@@ -196,6 +247,7 @@
$info_deleted =
$info_deleted."<br />".$res_names." -
".pretty_timestamp($valid_date['from_'])." -
".pretty_timestamp($valid_date['to_']);
}
$system_message['message'] =
$system_message['message']."<br />".$info_deleted;
+ $this->bo->send_notification($allocation,
$maildata, $mailadresses);
$receipt =
$this->system_message_bo->add($system_message);
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
'id'=>$allocation['building_id']));
Modified: branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php
===================================================================
--- branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php
2013-10-31 13:30:38 UTC (rev 11414)
@@ -26,6 +26,7 @@
$this->season_bo = CreateObject('booking.boseason');
$this->building_bo = CreateObject('booking.bobuilding');
$this->system_message_bo =
CreateObject('booking.bosystem_message');
+ $this->organization_bo =
CreateObject('booking.boorganization');
}
private function item_link(&$item, $key)
@@ -582,15 +583,62 @@
);
}
+ public function building_users($building_id, $group_id,
$delete_allocation) {
+
+ $contacts = array();
+# $building = $this->building_bo->so->read_single($building_id);
+
+ $organizations =
$this->organization_bo->find_building_users($building_id);
+ foreach($organizations['results'] as $org)
+ {
+ if ($org['email'] != '' && strstr($org['email'], '@')) {
+ if (!in_array($org['email'], $contacts)) {
+ $contacts[] = $org['email'];
+ }
+ }
+ if ($org['contacts'][0]['email'] != '' &&
strstr($org['contacts'][0]['email'], '@')) {
+ if (!in_array($org['contacts'][0]['email'], $contacts)) {
+ $contacts[] = $org['contacts'][0]['email'];
+ }
+ }
+ if ($org['contacts'][1]['email'] != '' &&
strstr($org['contacts'][1]['email'], '@')) {
+ if (!in_array($org['contacts'][1]['email'], $contacts)) {
+ $contacts[] = $org['contacts'][1]['email'];
+ }
+ }
+ $grp_con =
$this->bo->so->get_group_contacts_of_organization($org['id']);
+ foreach ($grp_con as $grp) {
+ if ($grp['email'] != '' && strstr($grp['email'], '@') &&
$grp['group_id'] != $group_id ) {
+ if (!in_array($grp['email'], $contacts)) {
+ $contacts[] = $grp['email'];
+ }
+ }
+ }
+ }
+ return $contacts;
+ }
+
+ public function organization_users($group_id) {
+
+ $contacts = array();
+ $groups =
$this->bo->so->get_all_group_of_organization_from_groupid($group_id);
+ foreach($groups as $grp) {
+ if ($grp['email'] != '' && strstr($grp['email'], '@') &&
$grp['group_id'] != $group_id ) {
+ if (!in_array($grp['email'], $contacts)) {
+ $contacts[] = $grp['email'];
+ }
+ }
+ }
+ return $contacts;
+ }
public function cancel()
{
$config = CreateObject('phpgwapi.config','booking');
$config->read();
-
+
if ($config->config_data['user_can_delete'] != 'yes') {
$booking =
$this->bo->read_single(intval(phpgw::get_var('id', 'GET')));
-
$errors = array();
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
@@ -636,7 +684,7 @@
$id = intval(phpgw::get_var('id', 'GET'));
$outseason = phpgw::get_var('outseason', 'GET');
$recurring = phpgw::get_var('recurring', 'GET');
- $repeat_untild = phpgw::get_var('repeat_until',
'GET');
+ $repeat_until = phpgw::get_var('repeat_until',
'GET');
$field_interval =
intval(phpgw::get_var('field_interval', 'GET'));
$delete_allocation =
phpgw::get_var('delete_allocation', 'GET');
$booking = $this->bo->read_single($id);
@@ -649,7 +697,16 @@
$valid_dates = array();
$allocation_delete = array();
$allocation_keep = array();
-
+
+ $mailadresses =
$this->building_users($booking['building_id'],$booking['group_id'],
$delete_allocation);
+# $grp = $this->organization_users($booking['group_id']);
+
+ $maildata = array();
+ $maildata['outseason'] = $outseason;
+ $maildata['recurring'] = $recurring;
+ $maildata['repeat_until'] = $field_until;
+ $maildata['delete_allocation'] = $delete_allocation;
+
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$from_date = $_POST['from_'];
@@ -663,24 +720,27 @@
if ($_POST['delete_allocation'] != 'on') {
$inf_del = "Booking";
+ $maildata['allocation'] = 0;
$this->bo->so->delete_booking($id);
}
else
{
$allocation_id = $booking['allocation_id'];
-
$this->bo->so->delete_booking($id);
$err =
$this->allocation_bo->so->check_for_booking($allocation_id);
if ($err)
{
$inf_del = "Booking";
+ $maildata['allocation'] = 0;
$errors['booking'] = lang('Could not delete
allocation due to a booking still use it');
}
else
{
$inf_del = "Booking and allocation";
+ $maildata['allocation'] = 1;
$err =
$this->allocation_bo->so->delete_allocation($allocation_id);
}
+
}
$res_names = '';
@@ -702,6 +762,8 @@
}
$info_deleted = lang($inf_del."
deleted on")." ".$system_message['building_name'].":<br />".$res_names." -
".pretty_timestamp($booking['from_'])." - ".pretty_timestamp($booking['to_']);
+ $this->bo->send_notification($booking, $allocation,
$maildata, $mailadresses);
+
$system_message['message'] =
$system_message['message']."<br />".$info_deleted;
$receipt =
$this->system_message_bo->add($system_message);
@@ -772,7 +834,15 @@
}
if ($step == 3)
{
- $res_names = '';
+ $maildata = array();
+ $maildata['outseason'] =
phpgw::get_var('outseason','GET');
+ $maildata['recurring'] =
phpgw::get_var('recurring', 'GET');
+ $maildata['repeat_until'] =
phpgw::get_var('repeat_until', 'GET');
+ $maildata['delete_allocation'] =
phpgw::get_var('delete_allocation', 'GET');
+ $maildata['keep'] =
$allocation_keep;
+ $maildata['delete'] =
$allocation_delete;
+
+ $res_names = '';
date_default_timezone_set("Europe/Oslo");
$date = new
DateTime(phpgw::get_var('date'));
$system_message =
array();
@@ -794,6 +864,9 @@
$info_deleted =
$info_deleted."<br />".$res_names." -
".pretty_timestamp($valid_date['from_'])." -
".pretty_timestamp($valid_date['to_']);
}
$system_message['message'] =
$system_message['message']."<br />".$info_deleted;
+
+ $this->bo->send_notification($booking,
$allocation, $maildata, $mailadresses, $valid_dates);
+
$receipt =
$this->system_message_bo->add($system_message);
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
'id'=>$allocation['building_id']));
}
@@ -814,7 +887,7 @@
'outseason' => $outseason,
'interval' => $field_interval,
'repeat_until' => $repeat_until,
- 'delete_allocation' => $delete_allocation,
+ 'delete_allocation' => $delete_allocation
));
}
elseif ($step == 2)
Modified: branches/stavangerkommune/bookingfrontend/setup/phpgw_no.lang
===================================================================
--- branches/stavangerkommune/bookingfrontend/setup/phpgw_no.lang
2013-10-31 13:26:47 UTC (rev 11413)
+++ branches/stavangerkommune/bookingfrontend/setup/phpgw_no.lang
2013-10-31 13:30:38 UTC (rev 11414)
@@ -366,3 +366,4 @@
Tilsynsvakt email bookingfrontend no Tilsynsvakt epost
Tilsynsvakt telephone bookingfrontend no Tilsynsvakt telefon
Public schedule bookingfrontend no Publikumsbading
+Apply for time bookingfrontend no Søk om tid
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11414] bkbooking: stavanger added mail message to users of building if a booking or application is canceled,
Kjell Arne Espedal <=