fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11451] bkbooking: stavanger bugfix


From: Kjell Arne Espedal
Subject: [Fmsystem-commits] [11451] bkbooking: stavanger bugfix
Date: Wed, 13 Nov 2013 10:12:03 +0000

Revision: 11451
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11451
Author:   kjell
Date:     2013-11-13 10:12:02 +0000 (Wed, 13 Nov 2013)
Log Message:
-----------
bkbooking: stavanger bugfix

Modified Paths:
--------------
    branches/stavangerkommune/booking/templates/base/settings.xsl
    branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php
    branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php
    
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_cancel.xsl
    
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_info.xsl
    
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_delete.xsl
    
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_info.xsl

Modified: branches/stavangerkommune/booking/templates/base/settings.xsl
===================================================================
--- branches/stavangerkommune/booking/templates/base/settings.xsl       
2013-11-12 14:02:03 UTC (rev 11450)
+++ branches/stavangerkommune/booking/templates/base/settings.xsl       
2013-11-13 10:12:02 UTC (rev 11451)
@@ -11,23 +11,40 @@
     <form action="" method="POST">
 
        <dl class="form">
-            <dt><label for="field_user_can_delete"><xsl:value-of 
select="php:function('lang', 'Frontend users can delete bookings and 
allocations')"/></label></dt>
+            <dt><label for="field_user_can_delete_bookings"><xsl:value-of 
select="php:function('lang', 'Frontend users can delete 
bookings')"/></label></dt>
                        <dd>
-                               <select id="field_user_can_delete" 
name="config_data[user_can_delete]">
+                               <select id="field_user_can_delete_bookings" 
name="config_data[user_can_delete_bookings]">
                     <option value="no">
-                        <xsl:if test="config_data/user_can_delete='no'">
+                        <xsl:if 
test="config_data/user_can_delete_bookings='no'">
                             <xsl:attribute 
name="selected">checked</xsl:attribute>
                         </xsl:if>
                         <xsl:value-of select="php:function('lang', 'No')" />
                     </option>
                     <option value="yes">
-                        <xsl:if test="config_data/user_can_delete='yes'">
+                        <xsl:if 
test="config_data/user_can_delete_bookings='yes'">
                             <xsl:attribute 
name="selected">checked</xsl:attribute>
                         </xsl:if>
                         <xsl:value-of select="php:function('lang', 'Yes')" />
                           </option>
                        </select>
                        </dd>
+            <dt><label for="field_user_can_delete_allocations"><xsl:value-of 
select="php:function('lang', 'Frontend users can delete 
allocations')"/></label></dt>
+                       <dd>
+                               <select id="field_user_can_delete_allocations" 
name="config_data[user_can_delete_allocations]">
+                    <option value="no">
+                        <xsl:if 
test="config_data/user_can_delete_allocations='no'">
+                            <xsl:attribute 
name="selected">checked</xsl:attribute>
+                        </xsl:if>
+                        <xsl:value-of select="php:function('lang', 'No')" />
+                    </option>
+                    <option value="yes">
+                        <xsl:if 
test="config_data/user_can_delete_allocations='yes'">
+                            <xsl:attribute 
name="selected">checked</xsl:attribute>
+                        </xsl:if>
+                        <xsl:value-of select="php:function('lang', 'Yes')" />
+                          </option>
+                       </select>
+                       </dd>
             <dt><label for="field_extra_schedule"><xsl:value-of 
select="php:function('lang', 'Activate extra kalendar field on 
building')"/></label></dt>
                        <dd>
                                <select id="field_extra_schedule" 
name="config_data[extra_schedule]">

Modified: 
branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php
===================================================================
--- branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php    
2013-11-12 14:02:03 UTC (rev 11450)
+++ branches/stavangerkommune/bookingfrontend/inc/class.uiallocation.inc.php    
2013-11-13 10:12:02 UTC (rev 11451)
@@ -20,7 +20,7 @@
                        $this->booking_bo = CreateObject('booking.bobooking');
        }
 
-               public function building_users($building_id, $organization_id) {
+               public function building_users($building_id) {
 
             $contacts = array();
 #            $building = $this->building_bo->so->read_single($building_id);
@@ -58,17 +58,13 @@
                        $config = CreateObject('phpgwapi.config','booking');
                        $config->read();
 
-                       if ($config->config_data['user_can_delete'] != 'yes') {
+                       if ($config->config_data['user_can_delete_allocations'] 
!= 'yes') {
                
                        $allocation = 
$this->bo->read_single(intval(phpgw::get_var('allocation_id', 'GET')));
-
                                $errors = array();
                                if($_SERVER['REQUEST_METHOD'] == 'POST')
                    {
-            
-                       $from = $_POST['from_'];
-                       $to =  $_POST['to_'];
-                       $organization_id = $_POST['organization_id'];
+                   
                        $outseason = $_POST['outseason'];
                        $recurring = $_POST['recurring'];
                        $repeat_until = $_POST['repeat_until'];
@@ -91,7 +87,7 @@
                        $link = mb_strcut($link,16,strlen($link));
                        $system_message['message'] = 
$system_message['message']."\n\n".lang('To cancel allocation use this link')." 
- <a href='".$link."'>".lang('Delete')."</a>";
 
-                                       $receipt = 
$this->system_message_bo->add($system_message);
+                                       
$this->system_message_bo->add($system_message);
                                        $this->redirect(array('menuaction' =>  
'bookingfrontend.uibuilding.schedule', 'id' => $system_message['building_id']));
 
                    }
@@ -103,8 +99,10 @@
                                self::render_template('allocation_cancel', 
array('allocation'=>$allocation));
 
                        } else {
-       
+
                                $id = intval(phpgw::get_var('allocation_id', 
'GET'));
+                $from_date = phpgw::get_var('from_', 'GET');
+                $to_date = phpgw::get_var('to_', 'GET');
                                $outseason = phpgw::get_var('outseason', 'GET');
                                $recurring = phpgw::get_var('recurring', 'GET');
                                $repeat_until = phpgw::get_var('repeat_until', 
'GET');
@@ -122,7 +120,7 @@
                 $maildata = array();
                 $maildata['outseason'] = $outseason;           
                 $maildata['recurring'] = $recurring;           
-                $maildata['repeat_until'] = $field_until;              
+                $maildata['repeat_until'] = $repeat_until;
                 $maildata['field_interval'] = $field_interval;         
 
                                if($_SERVER['REQUEST_METHOD'] == 'POST')
@@ -158,10 +156,10 @@
                                                        }
                                                        $info_deleted = 
lang("Allocation deleted on")." ".$system_message['building_name'].":<br 
/>".$res_names." - ".pretty_timestamp($allocation['from_'])." - 
".pretty_timestamp($allocation['to_']);
                                        $system_message['message'] = 
$system_message['message']."<br />".$info_deleted;
-                                                       $receipt = 
$this->system_message_bo->add($system_message);
+                                                       
$this->system_message_bo->add($system_message);
 
                             $this->bo->send_notification($allocation, 
$maildata, $mailadresses);
-                               $err = $this->bo->so->delete_allocation($id);
+                               $this->bo->so->delete_allocation($id);
                                $this->redirect(array('menuaction' => 
'bookingfrontend.uibuilding.schedule', 'id'=>$allocation['building_id']));
                            }
                        } 
@@ -212,7 +210,7 @@
                                                                if ($step == 3)
                                                                {
                                                                        
-                                       $stat = 
$this->bo->so->delete_allocation($id);
+                                       $this->bo->so->delete_allocation($id);
                                    }                            
                                }
                                                        $i++;
@@ -248,7 +246,7 @@
                                                        }
                                        $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->system_message_bo->add($system_message);
 
                                                        
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 
'id'=>$allocation['building_id']));
                                                }
@@ -291,6 +289,17 @@
 
                public function info()
                {
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+                       if ($config->config_data['user_can_delete_allocations'] 
!= 'yes')
+                       {
+                               $user_can_delete_allocations = 0;
+                       
+                       } else {
+                               $user_can_delete_allocations = 1;
+                       }
+                       
+
                        $allocation = 
$this->bo->read_single(intval(phpgw::get_var('id', 'GET')));
                        $resources = 
$this->resource_bo->so->read(array('filters'=>array('id'=>$allocation['resources']),
 'sort'=>'name'));
                        $allocation['resources'] = $resources['results'];
@@ -309,7 +318,7 @@
                                $allocation['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uiallocation.cancel', 
'allocation_id'=>$allocation['id'], 'from_'=>$allocation['from_'], 
'to_'=>$allocation['to_'], 'resource'=>$allocation['resource']));
             }
                        $allocation['when'] = 
pretty_timestamp($allocation['from_']).' - 
'.pretty_timestamp($allocation['to_']);
-                       self::render_template('allocation_info', 
array('allocation'=>$allocation));
+                       self::render_template('allocation_info', 
array('allocation'=>$allocation, 'user_can_delete_allocations' => 
$user_can_delete_allocations));
                        $GLOBALS['phpgw']->xslttpl->set_output('wml'); // Evil 
hack to disable page chrome
                }
        }

Modified: branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php
===================================================================
--- branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php       
2013-11-12 14:02:03 UTC (rev 11450)
+++ branches/stavangerkommune/bookingfrontend/inc/class.uibooking.inc.php       
2013-11-13 10:12:02 UTC (rev 11451)
@@ -636,7 +636,7 @@
                        $config = CreateObject('phpgwapi.config','booking');
                        $config->read();
             
-                       if ($config->config_data['user_can_delete'] != 'yes') {
+                       if ($config->config_data['user_can_delete_bookings'] != 
'yes') {
 
                        $booking = 
$this->bo->read_single(intval(phpgw::get_var('id', 'GET')));
                                $errors = array();
@@ -874,12 +874,18 @@
                                }
        
                                $this->flash_form_errors($errors);
+                               if 
($config->config_data['user_can_delete_allocations'] != 'yes')
+                               {
+                                       $user_can_delete_allocations = 0;
+                               
+                               } else {
+                                       $user_can_delete_allocations = 1;
+                               }
                                self::add_javascript('booking', 'booking', 
'booking.js');
                                $booking['resources_json'] = 
json_encode(array_map('intval', $booking['resources']));
 #                              $booking['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibooking.show', 'id' => 
$booking['id']));
                 $booking['cancel_link'] = self::link(array('menuaction' => 
'bookingfrontend.uibuilding.schedule', 'id' => $booking['building_id'], 'date' 
=> $booking['from_']));
                                $booking['booking_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibooking.show', 'id' => 
$booking['id']));
-       
                                if ($step < 2) 
                    {
                                self::render_template('booking_delete', 
array('booking' => $booking,
@@ -887,7 +893,8 @@
                                                'outseason' => $outseason,
                                                'interval' => $field_interval,
                                                'repeat_until' => $repeat_until,
-                           'delete_allocation' => $delete_allocation
+                           'delete_allocation' => $delete_allocation,
+                                               'user_can_delete_allocations' 
=> $user_can_delete_allocations
                        ));
                    }
                                elseif ($step == 2) 
@@ -901,6 +908,7 @@
                                                'from_date' => $from_date,
                                                'to_date' => $to_date,
                            'delete_allocation' => $_POST['delete_allocation'],
+                                               'user_can_delete_allocations' 
=> $user_can_delete_allocations,
                                                'allocation_keep' => 
$allocation_keep,
                                                'allocation_delete' => 
$allocation_delete,
                                                'message' => $_POST['message'],
@@ -915,6 +923,15 @@
 
                public function info()
                {
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+                       if ($config->config_data['user_can_delete_bookings'] != 
'yes')
+                       {
+                               $user_can_delete_bookings = 0;
+                       
+                       } else {
+                               $user_can_delete_bookings = 1;
+                       }
                        $booking = 
$this->bo->read_single(intval(phpgw::get_var('id', 'GET')));
                        $booking['group'] = 
$this->group_bo->read_single($booking['group_id']);
                        $resources = 
$this->resource_bo->so->read(array('filters'=>array('id'=>$booking['resources']),
 'sort'=>'name'));
@@ -936,7 +953,7 @@
                                $booking['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibooking.cancel', 'id' => 
$booking['id']));
             }
                        $booking['when'] = 
pretty_timestamp($booking['from_']).' - '.pretty_timestamp($booking['to_']);
-                       self::render_template('booking_info', 
array('booking'=>$booking));
+                       self::render_template('booking_info', 
array('booking'=>$booking, 'user_can_delete_bookings' => 
$user_can_delete_bookings));
                        $GLOBALS['phpgw']->xslttpl->set_output('wml'); // Evil 
hack to disable page chrome
                }
        }

Modified: 
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_cancel.xsl
===================================================================
--- 
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_cancel.xsl
 2013-11-12 14:02:03 UTC (rev 11450)
+++ 
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_cancel.xsl
 2013-11-13 10:12:02 UTC (rev 11451)
@@ -37,7 +37,7 @@
                        <dd>
                 <div> </div>
                        </dd>
-                       <dt><label for="field_repeat_until"><xsl:value-of 
select="php:function('lang', 'Recurring allocation deletion')" /></label></dt>
+                       <dt><label for="field_repeat_until"><xsl:value-of 
select="php:function('lang', 'Recurring allocation cancelation')" 
/></label></dt>
                        <dd>
                                <label>
                                        <input type="checkbox" name="outseason" 
id="outseason">
@@ -55,7 +55,7 @@
                                                        <xsl:attribute 
name="checked">checked</xsl:attribute>
                                                </xsl:if>
                                        </input>
-                                       <xsl:value-of 
select="php:function('lang', 'Delete until')" />
+                                       <xsl:value-of 
select="php:function('lang', 'Cancel until')" />
                                </label>
                        </dd>
                        <dd class="date-picker">

Modified: 
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_info.xsl
===================================================================
--- 
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_info.xsl
   2013-11-12 14:02:03 UTC (rev 11450)
+++ 
branches/stavangerkommune/bookingfrontend/templates/stavanger/allocation_info.xsl
   2013-11-13 10:12:02 UTC (rev 11451)
@@ -17,7 +17,12 @@
        <xsl:if test="allocation/add_link">
                <div class="actions">
                        <button 
onclick="location.href='{allocation/add_link}'"><xsl:value-of 
select="php:function('lang', 'Create new booking')"/></button>
+                       <xsl:if test="user_can_delete_allocations != 1">
                        <button 
onclick="location.href='{allocation/cancel_link}'"><xsl:value-of 
select="php:function('lang', 'Cancel allocation')"/></button>
+                       </xsl:if>
+                       <xsl:if test="user_can_delete_allocations != 0">
+                       <button 
onclick="location.href='{allocation/cancel_link}'"><xsl:value-of 
select="php:function('lang', 'Delete allocation')"/></button>
+                       </xsl:if>
                </div>
        </xsl:if>
 </xsl:template>

Modified: 
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_delete.xsl
===================================================================
--- 
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_delete.xsl
    2013-11-12 14:02:03 UTC (rev 11450)
+++ 
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_delete.xsl
    2013-11-13 10:12:02 UTC (rev 11451)
@@ -104,6 +104,7 @@
             <dd>
                         <xsl:value-of select="booking/season_name"/>
             </dd>
+                       <xsl:if test="user_can_delete_allocations != 0">        
                                        
                        <dt><label for="field_repeat_until"><xsl:value-of 
select="php:function('lang', 'Delete allocation also')" /></label></dt>
                        <dd>
                                <label>
@@ -115,7 +116,9 @@
                                        <xsl:value-of 
select="php:function('lang', 'Delete allocations')" />
                                </label>
                        </dd>
+                       </xsl:if>
         </dl>
+       
                <div style='clear:left; padding:0; margin:0'/>
 
         <dl class="form-col">

Modified: 
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_info.xsl
===================================================================
--- 
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_info.xsl  
    2013-11-12 14:02:03 UTC (rev 11450)
+++ 
branches/stavangerkommune/bookingfrontend/templates/stavanger/booking_info.xsl  
    2013-11-13 10:12:02 UTC (rev 11451)
@@ -20,7 +20,12 @@
        <xsl:if test="booking/edit_link">
                <div class="actions">
                        <button 
onclick="location.href='{booking/edit_link}'"><xsl:value-of 
select="php:function('lang', 'Edit booking')"/></button>
-                       <button 
onclick="location.href='{booking/cancel_link}'"><xsl:value-of 
select="php:function('lang', 'Cancel booking')"/></button>
+                       <xsl:if test="user_can_delete_bookings != 1">
+                               <button 
onclick="location.href='{booking/cancel_link}'"><xsl:value-of 
select="php:function('lang', 'Cancel booking')"/></button>
+                       </xsl:if>
+                       <xsl:if test="user_can_delete_bookings != 0">
+                               <button 
onclick="location.href='{booking/cancel_link}'"><xsl:value-of 
select="php:function('lang', 'Delete booking')"/></button>
+                       </xsl:if>
                </div>
        </xsl:if>
 </xsl:template>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]